I am having some difficulty evaluating my current design which involves persistent communication over RS-485 with a PID controller. The serial commands are fairly simplistic and are always expressed as integers and always received as ASCII encoded values. Receiving data is contingent on first transmitting the appropriate command sequence.
The issue I am having so properly evaluating whether my design approach is the most efficient given the simplicity of the application. At the moment, upon successful connection with the device I initiate a Thread which constantly checks the status of a TransmitQueue (which is filled by higher level callers) - I'd also like to mention the SerialPort is declared in a static class that is representative of the device mentioned earlier. Each subsequent removal from the transmission queue and write to the serial buffer can result in few/no returned bytes.
My issues deciding on how to properly implement a receiver as Threading would require knowledge of the last packet sent. Ideally, I would like to be able to farm out messages to transmit and fire an event (to update GUI) on device response. Are there are design patterns that would be applicable for such a purpose?
Aucun commentaire:
Enregistrer un commentaire