CmdMessenger  3.0
CmdMessenger is a serial port messaging library for the Arduino
Public Member Functions | Properties | List of all members
CommandMessenger.ReceivedCommand Class Reference

A command received from CmdMessenger More...

Public Member Functions

 ReceivedCommand ()
 Default constructor. More...
 
 ReceivedCommand (string[] arguments)
 Constructor. More...
 
bool Next ()
 Fetches the next argument. More...
 
bool Available ()
 returns if a next command is available More...
 
Int16 ReadInt16Arg ()
 Reads the current argument as short value. More...
 
UInt16 ReadUInt16Arg ()
 Reads the current argument as unsigned short value. More...
 
bool ReadBoolArg ()
 Reads the current argument as boolean value. More...
 
Int32 ReadInt32Arg ()
 Reads the current argument as int value. More...
 
UInt32 ReadUInt32Arg ()
 Reads the current argument as unsigned int value. More...
 
Single ReadFloatArg ()
 Reads the current argument as a float value. More...
 
Single ReadDoubleArg ()
 Reads the current argument as a double value. More...
 
String ReadStringArg ()
 Reads the current argument as a string value. More...
 
Single ReadBinFloatArg ()
 Reads the current binary argument as a float value. More...
 
Double ReadBinDoubleArg ()
 Reads the current binary argument as a double value. More...
 
Int16 ReadBinInt16Arg ()
 Reads the current binary argument as a short value. More...
 
UInt16 ReadBinUInt16Arg ()
 Reads the current binary argument as a unsigned short value. More...
 
Int32 ReadBinInt32Arg ()
 Reads the current binary argument as a int value. More...
 
UInt32 ReadBinUInt32Arg ()
 Reads the current binary argument as a unsigned int value. More...
 
String ReadBinStringArg ()
 Reads the current binary argument as a string value. More...
 
bool ReadBinBoolArg ()
 Reads the current binary argument as a boolean value. More...
 

Properties

long TimeStamp [get, set]
 Gets or sets the time stamp. More...
 
bool Ok [get]
 Returns whether this is a valid & filled command. More...
 
string this[int index] [get]
 Indexer to get arguments directly. More...
 
int CommandId [get]
 Gets the command ID. More...
 

Detailed Description

A command received from CmdMessenger

Constructor & Destructor Documentation

CommandMessenger.ReceivedCommand.ReceivedCommand ( )
inline

Default constructor.

39  {
40  }
CommandMessenger.ReceivedCommand.ReceivedCommand ( string[]  arguments)
inline

Constructor.

Parameters
argumentsAll command arguments, first one is command ID
45  {
46  _arguments = arguments;
47  }

Member Function Documentation

bool CommandMessenger.ReceivedCommand.Available ( )
inline

returns if a next command is available

Returns
true if it succeeds, false if it fails.

References CommandMessenger.ReceivedCommand.Next().

103  {
104  return Next();
105  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
bool CommandMessenger.ReceivedCommand.Next ( )
inline
bool CommandMessenger.ReceivedCommand.ReadBinBoolArg ( )
inline

Reads the current binary argument as a boolean value.

Returns
The boolean value.

References CommandMessenger.ReceivedCommand.Next().

343  {
344  if (Next())
345  {
346  var current = BinaryConverter.ToByte(_arguments[_parameter]);
347  if (current != null)
348  {
349  _dumped = true;
350  return (current != 0);
351  }
352  }
353  return false;
354  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
Double CommandMessenger.ReceivedCommand.ReadBinDoubleArg ( )
inline

Reads the current binary argument as a double value.

Returns
The double value.

References CommandMessenger.ReceivedCommand.Next().

248  {
249  if (Next())
250  {
251  var current = BinaryConverter.ToDouble(_arguments[_parameter]);
252  if (current != null)
253  {
254  _dumped = true;
255  return (double) current;
256  }
257  }
258  return 0;
259  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
Single CommandMessenger.ReceivedCommand.ReadBinFloatArg ( )
inline

Reads the current binary argument as a float value.

Returns
The float value.

References CommandMessenger.ReceivedCommand.Next().

232  {
233  if (Next())
234  {
235  var current = BinaryConverter.ToFloat(_arguments[_parameter]);
236  if (current != null)
237  {
238  _dumped = true;
239  return (float) current;
240  }
241  }
242  return 0;
243  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
Int16 CommandMessenger.ReceivedCommand.ReadBinInt16Arg ( )
inline

Reads the current binary argument as a short value.

Returns
The short value.

References CommandMessenger.ReceivedCommand.Next().

264  {
265  if (Next())
266  {
267  var current = BinaryConverter.ToInt16(_arguments[_parameter]);
268  if (current != null)
269  {
270  _dumped = true;
271  return (Int16) current;
272  }
273  }
274  return 0;
275  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
Int32 CommandMessenger.ReceivedCommand.ReadBinInt32Arg ( )
inline

Reads the current binary argument as a int value.

Returns
The int value.

References CommandMessenger.ReceivedCommand.Next().

296  {
297  if (Next())
298  {
299  var current = BinaryConverter.ToInt32(_arguments[_parameter]);
300  if (current != null)
301  {
302  _dumped = true;
303  return (Int32) current;
304  }
305  }
306  return 0;
307  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
String CommandMessenger.ReceivedCommand.ReadBinStringArg ( )
inline

Reads the current binary argument as a string value.

Returns
The string value.

References CommandMessenger.ReceivedCommand.Next().

328  {
329  if (Next())
330  {
331  if (_arguments[_parameter] != null)
332  {
333  _dumped = true;
334  return Escaping.Unescape(_arguments[_parameter]);
335  }
336  }
337  return "";
338  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
UInt16 CommandMessenger.ReceivedCommand.ReadBinUInt16Arg ( )
inline

Reads the current binary argument as a unsigned short value.

Returns
The unsigned short value.

References CommandMessenger.ReceivedCommand.Next().

280  {
281  if (Next())
282  {
283  var current = BinaryConverter.ToUInt16(_arguments[_parameter]);
284  if (current != null)
285  {
286  _dumped = true;
287  return (UInt16) current;
288  }
289  }
290  return 0;
291  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
UInt32 CommandMessenger.ReceivedCommand.ReadBinUInt32Arg ( )
inline

Reads the current binary argument as a unsigned int value.

Returns
The unsigned int value.

References CommandMessenger.ReceivedCommand.Next().

312  {
313  if (Next())
314  {
315  var current = BinaryConverter.ToUInt32(_arguments[_parameter]);
316  if (current != null)
317  {
318  _dumped = true;
319  return (UInt32) current;
320  }
321  }
322  return 0;
323  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
bool CommandMessenger.ReceivedCommand.ReadBoolArg ( )
inline

Reads the current argument as boolean value.

Returns
The boolean value.

References CommandMessenger.ReceivedCommand.ReadInt32Arg().

144  {
145  return (ReadInt32Arg() != 0);
146  }
Int32 ReadInt32Arg()
Reads the current argument as int value.
Definition: ReceivedCommand.cs:150
Single CommandMessenger.ReceivedCommand.ReadDoubleArg ( )
inline

Reads the current argument as a double value.

Returns
The unsigned double value.

References CommandMessenger.ReceivedCommand.Next().

199  {
200  if (Next())
201  {
202  Single current;
203  if (Single.TryParse(_arguments[_parameter], out current))
204  {
205  _dumped = true;
206  return current;
207  }
208  }
209  return 0;
210  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
Single CommandMessenger.ReceivedCommand.ReadFloatArg ( )
inline

Reads the current argument as a float value.

Returns
The float value.

References CommandMessenger.ReceivedCommand.Next().

183  {
184  if (Next())
185  {
186  Single current;
187  if (Single.TryParse(_arguments[_parameter], out current))
188  {
189  _dumped = true;
190  return current;
191  }
192  }
193  return 0;
194  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
Int16 CommandMessenger.ReceivedCommand.ReadInt16Arg ( )
inline

Reads the current argument as short value.

Returns
The short value.

References CommandMessenger.ReceivedCommand.Next().

112  {
113  if (Next())
114  {
115  Int16 current;
116  if (Int16.TryParse(_arguments[_parameter], out current))
117  {
118  _dumped = true;
119  return current;
120  }
121  }
122  return 0;
123  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
Int32 CommandMessenger.ReceivedCommand.ReadInt32Arg ( )
inline

Reads the current argument as int value.

Returns
The int value.

References CommandMessenger.ReceivedCommand.Next().

Referenced by CommandMessenger.ReceivedCommand.ReadBoolArg().

151  {
152  if (Next())
153  {
154  Int32 current;
155  if (Int32.TryParse(_arguments[_parameter], out current))
156  {
157  _dumped = true;
158  return current;
159  }
160  }
161  return 0;
162  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
String CommandMessenger.ReceivedCommand.ReadStringArg ( )
inline

Reads the current argument as a string value.

Returns
The string value.

References CommandMessenger.ReceivedCommand.Next().

215  {
216  if (Next())
217  {
218  if (_arguments[_parameter] != null)
219  {
220  _dumped = true;
221  return _arguments[_parameter];
222  }
223  }
224  return "";
225  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
UInt16 CommandMessenger.ReceivedCommand.ReadUInt16Arg ( )
inline

Reads the current argument as unsigned short value.

Returns
The unsigned short value.

References CommandMessenger.ReceivedCommand.Next().

128  {
129  if (Next())
130  {
131  UInt16 current;
132  if (UInt16.TryParse(_arguments[_parameter], out current))
133  {
134  _dumped = true;
135  return current;
136  }
137  }
138  return 0;
139  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81
UInt32 CommandMessenger.ReceivedCommand.ReadUInt32Arg ( )
inline

Reads the current argument as unsigned int value.

Returns
The unsigned int value.

References CommandMessenger.ReceivedCommand.Next().

167  {
168  if (Next())
169  {
170  UInt32 current;
171  if (UInt32.TryParse(_arguments[_parameter], out current))
172  {
173  _dumped = true;
174  return current;
175  }
176  }
177  return 0;
178  }
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81

Property Documentation

int CommandMessenger.ReceivedCommand.CommandId
get

Gets the command ID.

The command ID.

Referenced by CommandMessenger.CmdMessenger.HandleMessage().

bool CommandMessenger.ReceivedCommand.Ok
get

Returns whether this is a valid & filled command.

true if ok, false if not.

Referenced by CommandMessenger.CmdMessenger.HandleMessage().

string CommandMessenger.ReceivedCommand.this[int index]
get

Indexer to get arguments directly.

The indexed item.

long CommandMessenger.ReceivedCommand.TimeStamp
getset

Gets or sets the time stamp.

The time stamp.


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