github.com/bluenviron/gomavlib/v3@v3.0.0/events.go (about) 1 package gomavlib 2 3 import ( 4 "github.com/bluenviron/gomavlib/v3/pkg/frame" 5 "github.com/bluenviron/gomavlib/v3/pkg/message" 6 ) 7 8 // Event is the interface implemented by all events received with node.Events(). 9 type Event interface { 10 isEventOut() 11 } 12 13 // EventChannelOpen is the event fired when a channel gets opened. 14 type EventChannelOpen struct { 15 Channel *Channel 16 } 17 18 func (*EventChannelOpen) isEventOut() {} 19 20 // EventChannelClose is the event fired when a channel gets closed. 21 type EventChannelClose struct { 22 Channel *Channel 23 } 24 25 func (*EventChannelClose) isEventOut() {} 26 27 // EventFrame is the event fired when a frame is received. 28 type EventFrame struct { 29 // the frame 30 Frame frame.Frame 31 32 // the channel from which the frame was received 33 Channel *Channel 34 } 35 36 func (*EventFrame) isEventOut() {} 37 38 // SystemID returns the frame system id. 39 func (res *EventFrame) SystemID() byte { 40 return res.Frame.GetSystemID() 41 } 42 43 // ComponentID returns the frame component id. 44 func (res *EventFrame) ComponentID() byte { 45 return res.Frame.GetComponentID() 46 } 47 48 // Message returns the message inside the frame. 49 func (res *EventFrame) Message() message.Message { 50 return res.Frame.GetMessage() 51 } 52 53 // EventParseError is the event fired when a parse error occurs. 54 type EventParseError struct { 55 // the error 56 Error error 57 58 // the channel used to send the frame 59 Channel *Channel 60 } 61 62 func (*EventParseError) isEventOut() {} 63 64 // EventStreamRequested is the event fired when an automatic stream request is sent. 65 type EventStreamRequested struct { 66 // the channel to which the stream request is addressed 67 Channel *Channel 68 // the system id to which the stream requests is addressed 69 SystemID byte 70 // the component id to which the stream requests is addressed 71 ComponentID byte 72 } 73 74 func (*EventStreamRequested) isEventOut() {}