CmdMessenger  4.0.0
CmdMessenger is a serial port messaging library for the .Net / Mono Platform.
Public Member Functions | Protected Member Functions | Properties | Events
CommandMessenger.CmdMessenger Class Reference

Command messenger main class. More...

List of all members.

Public Member Functions

delegate void MessengerCallbackFunction (ReceivedCommand receivedCommand)
 Definition of the messenger callback function.
 CmdMessenger (ITransport transport, BoardType boardType=BoardType.Bit16)
 Constructor.
 CmdMessenger (ITransport transport, int sendBufferMaxLength, BoardType boardType=BoardType.Bit16)
 Constructor.
 CmdMessenger (ITransport transport, BoardType boardType, char fieldSeparator)
 Constructor.
 CmdMessenger (ITransport transport, BoardType boardType, char fieldSeparator, int sendBufferMaxLength)
 Constructor.
 CmdMessenger (ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator)
 Constructor.
 CmdMessenger (ITransport transport, BoardType boardType, char fieldSeparator, char commandSeparator, char escapeCharacter, int sendBufferMaxLength)
 Constructor.
void Dispose ()
 Disposal of CmdMessenger.
void SetControlToInvokeOn (Control controlToInvokeOn)
 Sets a control to invoke on.
bool Disconnect ()
 Stop listening and end serial port connection.
bool Connect ()
 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.
ReceivedCommand SendCommand (SendCommand sendCommand, SendQueue sendQueueState=SendQueue.InFrontQueue, ReceiveQueue receiveQueueState=ReceiveQueue.Default)
 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 SendCommand (SendCommand sendCommand, SendQueue sendQueueState, ReceiveQueue receiveQueueState, UseQueue useQueue)
 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 SendCommandSync (SendCommand sendCommand, SendQueue sendQueueState)
 Synchronized send a command.
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.

Protected Member Functions

virtual void Dispose (bool disposing)

Properties

bool PrintLfCr [get, set]
 Gets or sets a whether to print a line feed carriage return after each command.
Control ControlToInvokeOn [get, set]
 The control to invoke the callback on.
long LastReceivedCommandTimeStamp [get]
 Gets or sets the time stamp of the last command line received.

Events

EventHandler< CommandEventArgsNewLineReceived
 Event handler for one or more lines received.
EventHandler< CommandEventArgsNewLineSent
 Event handler for a new line sent.

Detailed Description

Command messenger main class.


Constructor & Destructor Documentation

CommandMessenger.CmdMessenger.CmdMessenger ( ITransport  transport,
BoardType  boardType = BoardType.Bit16 
)

Constructor.

Parameters:
transportThe transport layer.
boardTypeEmbedded Processor type. Needed to translate variables between sides.
CommandMessenger.CmdMessenger.CmdMessenger ( ITransport  transport,
int  sendBufferMaxLength,
BoardType  boardType = BoardType.Bit16 
)

Constructor.

Parameters:
transportThe transport layer.
sendBufferMaxLengthThe maximum size of the send buffer
boardTypeEmbedded Processor type. Needed to translate variables between sides.
CommandMessenger.CmdMessenger.CmdMessenger ( ITransport  transport,
BoardType  boardType,
char  fieldSeparator 
)

Constructor.

Parameters:
transportThe transport layer.
boardTypeEmbedded Processor type. Needed to translate variables between sides.
fieldSeparatorThe field separator.
CommandMessenger.CmdMessenger.CmdMessenger ( ITransport  transport,
BoardType  boardType,
char  fieldSeparator,
int  sendBufferMaxLength 
)

Constructor.

Parameters:
transportThe transport layer.
boardTypeEmbedded Processor type. Needed to translate variables between sides.
fieldSeparatorThe field separator.
sendBufferMaxLengthThe maximum size of the send buffer
CommandMessenger.CmdMessenger.CmdMessenger ( ITransport  transport,
BoardType  boardType,
char  fieldSeparator,
char  commandSeparator 
)

Constructor.

Parameters:
transportThe transport layer.
boardTypeEmbedded Processor type. Needed to translate variables between sides.
fieldSeparatorThe field separator.
commandSeparatorThe command separator.
CommandMessenger.CmdMessenger.CmdMessenger ( ITransport  transport,
BoardType  boardType,
char  fieldSeparator,
char  commandSeparator,
char  escapeCharacter,
int  sendBufferMaxLength 
)

Constructor.

Parameters:
transportThe transport layer.
boardTypeEmbedded Processor type. Needed to translate variables between sides.
fieldSeparatorThe field separator.
commandSeparatorThe command separator.
escapeCharacterThe escape character.
sendBufferMaxLengthThe maximum size of the send buffer

Member Function Documentation

Adds a general command strategy to the receive queue. This will be executed on every enqueued and dequeued command.

Parameters:
generalStrategyThe general strategy for the receive queue.

Adds a general command strategy to the send queue. This will be executed on every enqueued and dequeued command.

Parameters:
generalStrategyThe general strategy for the send queue.

Attaches default callback for unsupported commands.

Parameters:
newFunctionThe callback function.
void CommandMessenger.CmdMessenger.Attach ( int  messageId,
MessengerCallbackFunction  newFunction 
)

Attaches default callback for certain Message ID.

Parameters:
messageIdCommand ID.
newFunctionThe callback function.

Clears the receive queue.

Clears the send queue.

Starts serial port connection and start listening.

Returns:
true if it succeeds, false if it fails.

Stop listening and end serial port connection.

Returns:
true if it succeeds, false if it fails.

Disposal of CmdMessenger.

Definition of the messenger callback function.

Parameters:
receivedCommandThe received command.

Put the command at the back of the sent queue.

Parameters:
sendCommandThe command to sent.

Put a command wrapped in a strategy at the back of the sent queue.

Parameters:
commandStrategyThe command strategy.
ReceivedCommand CommandMessenger.CmdMessenger.SendCommand ( SendCommand  sendCommand,
SendQueue  sendQueueState = SendQueue.InFrontQueue,
ReceiveQueue  receiveQueueState = ReceiveQueue.Default 
)

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.

Parameters:
sendCommandThe command to sent.
sendQueueStateProperty to optionally clear/wait the send queue
receiveQueueStateProperty to optionally clear/wait the send queue
Returns:
A received command. The received command will only be valid if the ReqAc of the command is true.
ReceivedCommand CommandMessenger.CmdMessenger.SendCommand ( SendCommand  sendCommand,
SendQueue  sendQueueState,
ReceiveQueue  receiveQueueState,
UseQueue  useQueue 
)

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.

Parameters:
sendCommandThe command to sent.
sendQueueStateProperty to optionally clear/wait the send queue
receiveQueueStateProperty to optionally clear/wait the send queue
useQueueProperty to optionally bypass the queue
Returns:
A received command. The received command will only be valid if the ReqAc of the command is true.
ReceivedCommand CommandMessenger.CmdMessenger.SendCommandSync ( SendCommand  sendCommand,
SendQueue  sendQueueState 
)

Synchronized send a command.

Parameters:
sendCommandThe command to sent.
sendQueueStateProperty to optionally clear/wait the send queue.
Returns:
.
void CommandMessenger.CmdMessenger.SetControlToInvokeOn ( Control  controlToInvokeOn)

Sets a control to invoke on.

Parameters:
controlToInvokeOnThe control to invoke on.

Property Documentation

The control to invoke the callback on.

Gets or sets the time stamp of the last command line received.

The last line time stamp.

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.


Event Documentation

Event handler for one or more lines received.

Event handler for a new line sent.


The documentation for this class was generated from the following file: