CmdMessenger
3.0
CmdMessenger is a serial port messaging library for the .Net / Mono Platform.
|
Command messenger main class. More...
Public Member Functions | |
delegate void | MessengerCallbackFunction (ReceivedCommand receivedCommand) |
Definition of the messenger callback function. | |
CmdMessenger (ITransport transport) | |
Constructor. | |
CmdMessenger (ITransport transport, char fieldSeparator) | |
Constructor. | |
CmdMessenger (ITransport transport, char fieldSeparator, char commandSeparator) | |
Constructor. | |
CmdMessenger (ITransport transport, char fieldSeparator, char commandSeparator, char escapeCharacter) | |
Constructor. | |
void | SetSingleCore () |
void | SetControlToInvokeOn (Control controlToInvokeOn) |
Sets a control to invoke on. | |
bool | StopListening () |
Stop listening and end serial port connection. | |
bool | StartListening () |
Starts serial port connection and start listening. | |
void | Attach (MessengerCallbackFunction newFunction) |
Attaches default callback for unsupported commands. | |
void | Attach (int messageId, MessengerCallbackFunction newFunction) |
Attaches default callback for certain Message ID. | |
void | HandleMessage (ReceivedCommand receivedCommand) |
Handle message. | |
ReceivedCommand | SendCommand (SendCommand sendCommand) |
Sends a command. If no command acknowledge is requested, the command will be send asynchronously: it will be put on the top of the send queue If a command acknowledge is requested, the command will be send synchronously: the program will block until the acknowledge command has been received or the timeout has expired. | |
ReceivedCommand | SendCommand (SendCommand sendCommand, ClearQueue clearQueueState) |
Sends a command. If no command acknowledge is requested, the command will be send asynchronously: it will be put on the top of the send queue If a command acknowledge is requested, the command will be send synchronously: the program will block until the acknowledge command has been received or the timeout has expired. Based on ClearQueueState, the send- and receive-queues are left intact or are cleared. | |
ReceivedCommand | ExecuteSendCommand (SendCommand sendCommand, ClearQueue clearQueueState) |
Directly executes the send command operation. | |
void | QueueCommand (SendCommand sendCommand) |
Put the command at the back of the sent queue. | |
void | QueueCommand (CommandStrategy commandStrategy) |
Put a command wrapped in a strategy at the back of the sent queue. | |
void | AddReceiveCommandStrategy (GeneralStrategy generalStrategy) |
Adds a general command strategy to the receive queue. This will be executed on every enqueued and dequeued command. | |
void | AddSendCommandStrategy (GeneralStrategy generalStrategy) |
Adds a general command strategy to the send queue. This will be executed on every enqueued and dequeued command. | |
void | ClearReceiveQueue () |
Clears the receive queue. | |
void | ClearSendQueue () |
Clears the send queue. | |
Public Attributes | |
EventHandler | NewLinesReceived |
EventHandler | NewLineReceived |
EventHandler | NewLineSent |
Protected Member Functions | |
override void | Dispose (bool disposing) |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. | |
Properties | |
bool | PrintLfCr [get, set] |
Gets or sets a whether to print a line feed carriage return after each command. | |
String | CurrentReceivedLine [get, set] |
Gets or sets the current received command line. | |
ReceivedCommand | CurrentReceivedCommand [get, set] |
Gets or sets the current received command. | |
String | CurrentSentLine [get, set] |
Gets or sets the currently sent line. | |
String | LogFileReceiveCommands [get, set] |
Gets or sets the log file of send commands. | |
long | LastLineTimeStamp [get, set] |
Gets or sets the time stamp of the last command line received. |
Command messenger main class.
CommandMessenger.CmdMessenger.CmdMessenger | ( | ITransport | transport | ) |
Constructor.
transport | The transport layer. |
CommandMessenger.CmdMessenger.CmdMessenger | ( | ITransport | transport, |
char | fieldSeparator | ||
) |
Constructor.
transport | The transport layer. |
fieldSeparator | The field separator. |
CommandMessenger.CmdMessenger.CmdMessenger | ( | ITransport | transport, |
char | fieldSeparator, | ||
char | commandSeparator | ||
) |
Constructor.
transport | The transport layer. |
fieldSeparator | The field separator. |
commandSeparator | The command separator. |
CommandMessenger.CmdMessenger.CmdMessenger | ( | ITransport | transport, |
char | fieldSeparator, | ||
char | commandSeparator, | ||
char | escapeCharacter | ||
) |
Constructor.
transport | The transport layer. |
fieldSeparator | The field separator. |
commandSeparator | The command separator. |
escapeCharacter | The escape character. |
void CommandMessenger.CmdMessenger.AddReceiveCommandStrategy | ( | GeneralStrategy | generalStrategy | ) |
Adds a general command strategy to the receive queue. This will be executed on every enqueued and dequeued command.
generalStrategy | The general strategy for the receive queue. |
void CommandMessenger.CmdMessenger.AddSendCommandStrategy | ( | GeneralStrategy | generalStrategy | ) |
Adds a general command strategy to the send queue. This will be executed on every enqueued and dequeued command.
generalStrategy | The general strategy for the send queue. |
void CommandMessenger.CmdMessenger.Attach | ( | MessengerCallbackFunction | newFunction | ) |
Attaches default callback for unsupported commands.
newFunction | The callback function. |
void CommandMessenger.CmdMessenger.Attach | ( | int | messageId, |
MessengerCallbackFunction | newFunction | ||
) |
Attaches default callback for certain Message ID.
messageId | Command ID. |
newFunction | The callback function. |
Clears the receive queue.
Clears the send queue.
override void CommandMessenger.CmdMessenger.Dispose | ( | bool | disposing | ) | [protected, virtual] |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
disposing | true if resources should be disposed, false if not. |
Reimplemented from CommandMessenger.DisposableObject.
ReceivedCommand CommandMessenger.CmdMessenger.ExecuteSendCommand | ( | SendCommand | sendCommand, |
ClearQueue | clearQueueState | ||
) |
Directly executes the send command operation.
sendCommand | The command to sent. |
clearQueueState | Property to optionally clear the send and receive queues. |
void CommandMessenger.CmdMessenger.HandleMessage | ( | ReceivedCommand | receivedCommand | ) |
Handle message.
receivedCommand | The received command. |
delegate void CommandMessenger.CmdMessenger.MessengerCallbackFunction | ( | ReceivedCommand | receivedCommand | ) |
Definition of the messenger callback function.
receivedCommand | The received command. |
void CommandMessenger.CmdMessenger.QueueCommand | ( | SendCommand | sendCommand | ) |
Put the command at the back of the sent queue.
sendCommand | The command to sent. |
void CommandMessenger.CmdMessenger.QueueCommand | ( | CommandStrategy | commandStrategy | ) |
Put a command wrapped in a strategy at the back of the sent queue.
commandStrategy | The command strategy. |
ReceivedCommand CommandMessenger.CmdMessenger.SendCommand | ( | SendCommand | sendCommand | ) |
Sends a command. If no command acknowledge is requested, the command will be send asynchronously: it will be put on the top of the send queue If a command acknowledge is requested, the command will be send synchronously: the program will block until the acknowledge command has been received or the timeout has expired.
sendCommand | The command to sent. |
ReceivedCommand CommandMessenger.CmdMessenger.SendCommand | ( | SendCommand | sendCommand, |
ClearQueue | clearQueueState | ||
) |
Sends a command. If no command acknowledge is requested, the command will be send asynchronously: it will be put on the top of the send queue If a command acknowledge is requested, the command will be send synchronously: the program will block until the acknowledge command has been received or the timeout has expired. Based on ClearQueueState, the send- and receive-queues are left intact or are cleared.
sendCommand | The command to sent. |
clearQueueState | Property to optionally clear the send and receive queues |
void CommandMessenger.CmdMessenger.SetControlToInvokeOn | ( | Control | controlToInvokeOn | ) |
Sets a control to invoke on.
controlToInvokeOn | The control to invoke on. |
Starts serial port connection and start listening.
Stop listening and end serial port connection.
Gets or sets the current received command.
The current received command.
String CommandMessenger.CmdMessenger.CurrentReceivedLine [get, set] |
Gets or sets the current received command line.
The current received line.
String CommandMessenger.CmdMessenger.CurrentSentLine [get, set] |
Gets or sets the currently sent line.
The currently sent line.
long CommandMessenger.CmdMessenger.LastLineTimeStamp [get, set] |
Gets or sets the time stamp of the last command line received.
The last line time stamp.
String CommandMessenger.CmdMessenger.LogFileReceiveCommands [get, set] |
Gets or sets the log file of send commands.
The logfile name for send commands.
Gets or sets the log file of receive commands.
The logfile name for receive commands.
bool CommandMessenger.CmdMessenger.PrintLfCr [get, set] |
Gets or sets a whether to print a line feed carriage return after each command.
true if print line feed carriage return, false if not.