import { CommunicationEventType , Uuid } from ".." ; import { CommunicationEvent , CommunicationEventData } from "./communication-event" ; /**
 * Associate event.
 */ export class AssociateEvent extends CommunicationEvent < AssociateEventData > { get eventTypeFilter ( ) { return this . _ioContextName ; } private _ioContextName : string ; internal param ioContextName param eventData constructor ( ioContextName , eventData ) { super ( eventData ) ; this . _ioContextName = ioContextName ; } param ioContextName param ioSourceId param ioActorId param associatingRoute param isExternalRoute param updateRate static with ( ioContextName , ioSourceId , ioActorId , associatingRoute , isExternalRoute ? , updateRate ? ) { return new AssociateEvent ( ioContextName , new AssociateEventData ( ioSourceId , ioActorId , associatingRoute , isExternalRoute , updateRate ) ) ; } get eventType ( ) { return CommunicationEventType . Associate ; } } /**
 * Defines event data format to associate or disassociate an IO source with an IO actor.
 */ export class AssociateEventData extends CommunicationEventData { private _ioSourceId : Uuid ; private _ioActorId : Uuid ; private _associatingRoute : string ; private _isExternalRoute ? : boolean ; private _updateRate ? : number ; param ioSourceId param ioActorId param associatingRoute param isExternalRoute param updateRate constructor ( ioSourceId , ioActorId , associatingRoute , isExternalRoute ? , updateRate ? ) { super ( ) ; this . _ioSourceId = ioSourceId ; this . _ioActorId = ioActorId ; this . _associatingRoute = associatingRoute ; this . _isExternalRoute = isExternalRoute ; this . _updateRate = updateRate ; if ( ! this . _hasValidParameters ( ) ) { throw new TypeError ( "in AssociateEventData: arguments not valid" ) ; } } internal static createFrom ( eventData ) { return new AssociateEventData ( eventData . ioSourceId , eventData . ioActorId , eventData . associatingRoute , eventData . isExternalRoute , eventData . updateRate ) ; } /**
     * The object Id of the IO source object.
     */ get ioSourceId ( ) { return this . _ioSourceId ; } /**
     * The object Id of the IO actor object.
     */ get ioActorId ( ) { return this . _ioActorId ; } /**
     * The IO route associating the given IO source and IO actor, or undefined if
     * the association between IO source and actor should be dissolved.
     */ get associatingRoute ( ) { return this . _associatingRoute ; } /**
     * Indicates whether the associating route represents an external topic, as
     * specified by `IoPoint.externalRoute` (optional).
     *
     * Only used for association, not for disassociation.
     */ get isExternalRoute ( ) { return this . _isExternalRoute ; } /**
     * The recommended update rate (in millis) for publishing IO source values
     * (optional).
     *
     * Only used for association, not for disassociation.
     */ get updateRate ( ) { return this . _updateRate ; } toJsonObject ( ) { return { ioSourceId : this . _ioSourceId , ioActorId : this . _ioActorId , associatingRoute : this . _associatingRoute , updateRate : this . _updateRate , } ; } private _hasValidParameters ( ) { return this . _ioSourceId && typeof this . ioSourceId === "string" && this . ioSourceId . length > 0 && typeof this . ioActorId === "string" && this . ioActorId . length > 0 && ( this . _associatingRoute === undefined || ( typeof this . _associatingRoute === "string" && this . _associatingRoute . length > 0 ) ) && ( this . _updateRate === undefined || typeof this . _updateRate === "number" ) ; } }