I have a class called Communicator which has an interface to an ElectronicDevice, and ElectronicDevice has an interface to a SerialPortWrapper class (which in turn has a SerialPort object)
Communicator sends messages to the ElectronicDevice via the SerialPort.
Communicator needs to modify its behaviour in some cases based on the response from SerialPort. SerialPort would normally raise SerialDataReceivedEvent when its receives data, but Communicator doesn’t have access to this.
What’s the best way for me to deal with the communication between my objects and SerialPort? I’m open to any and all suggestions! (I’m completely new to communicating with the SerialPort, so if you can steer me correct, I really appreciate it!)
Your
SerialPortWrappercould expose and raise an event when theSerialPortraises its event. YourElectronicDevicecould handle that event, and raise its own event. This will create a chain of events back toCommunicator. At each stage along the way, you might choose to re-shape the event as appropriate – for example,ElectronicDevicemight raise aMessageReceivedevent instead of aSerialDataReceivedEvent.