import { CommunicationEventType , IoSource } from ".." ; import { TopicEvent , TopicEventData } from "./communication-event" ; /**
 * IoValue event.
 */ export class IoValueEvent extends TopicEvent < IoValueEventData > { get eventType ( ) { return CommunicationEventType . IoValue ; } /**
     * The IoSource on which to publish the IO value.
     */ readonly ioSource : IoSource ; internal param ioSource param eventData param options throws constructor ( ioSource , eventData , options ? ) { super ( undefined , eventData , options ) ; const isValueRaw = eventData . payload instanceof Uint8Array ; if ( isValueRaw && ! ioSource . useRawIoValues || ! isValueRaw && ioSource . useRawIoValues ) { throw new Error ( "IO value data format of given IO source is not compatible with given IO value" ) ; } this . ioSource = ioSource ; } param ioSource param value param options throws static with ( ioSource , value , options ? ) { return new IoValueEvent ( ioSource , new IoValueEventData ( value ) , options ) ; } } /**
 * Defines event data format for IoValue events.
 */ export class IoValueEventData extends TopicEventData { /**
     * The payload JSON data or raw Uint8Array (or Buffer in Node.js, a subclass
     * thereof).
     */ readonly payload : any | Uint8Array ; param payload constructor ( payload ) { super ( ) ; this . payload = payload ; } internal static createFrom ( eventData ) { return new IoValueEventData ( eventData ) ; } toJsonObject ( ) { if ( this . payload instanceof Uint8Array ) { return undefined ; } return this . payload ; } }