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.

{
}

CommandMessenger.ReceivedCommand.ReceivedCommand | ( | string[] | arguments | ) |

inline

Constructor.

Parameters

  arguments | All command arguments, first one is command ID

{
_arguments = arguments;
}

## 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().

{
return Next();
}
CommandMessenger.ReceivedCommand.Next
bool Next()
Fetches the next argument.
Definition: ReceivedCommand.cs:81

bool CommandMessenger.ReceivedCommand.Next | ( |  | ) |

inline

Fetches the next argument.

Returns
  true if it succeeds, false if it fails.

Referenced by CommandMessenger.ReceivedCommand.Available(), CommandMessenger.ReceivedCommand.ReadBinBoolArg(), CommandMessenger.ReceivedCommand.ReadBinDoubleArg(), CommandMessenger.ReceivedCommand.ReadBinFloatArg(), CommandMessenger.ReceivedCommand.ReadBinInt16Arg(), CommandMessenger.ReceivedCommand.ReadBinInt32Arg(), CommandMessenger.ReceivedCommand.ReadBinStringArg(), CommandMessenger.ReceivedCommand.ReadBinUInt16Arg(), CommandMessenger.ReceivedCommand.ReadBinUInt32Arg(), CommandMessenger.ReceivedCommand.ReadDoubleArg(), CommandMessenger.ReceivedCommand.ReadFloatArg(), CommandMessenger.ReceivedCommand.ReadInt16Arg(), CommandMessenger.ReceivedCommand.ReadInt32Arg(), CommandMessenger.ReceivedCommand.ReadStringArg(), CommandMessenger.ReceivedCommand.ReadUInt16Arg(), and CommandMessenger.ReceivedCommand.ReadUInt32Arg().

{
// If this parameter has already been read, see if there is another one
if (_dumped)
{
if (_parameter < _arguments.Length - 1)
{
_parameter++;
_dumped = false;
return true;
}
else
{
return false;
}
}
return true;
}

bool CommandMessenger.ReceivedCommand.ReadBinBoolArg | ( |  | ) |

inline

Reads the current binary argument as a boolean value.

Returns
  The boolean value.

References CommandMessenger.ReceivedCommand.Next().

{
if (Next())
{
var current = BinaryConverter.ToByte(_arguments[_parameter]);
if (current != null)
{
_dumped = true;
return (current != 0);
}
}
return false;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
var current = BinaryConverter.ToDouble(_arguments[_parameter]);
if (current != null)
{
_dumped = true;
return (double) current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
var current = BinaryConverter.ToFloat(_arguments[_parameter]);
if (current != null)
{
_dumped = true;
return (float) current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
var current = BinaryConverter.ToInt16(_arguments[_parameter]);
if (current != null)
{
_dumped = true;
return (Int16) current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
var current = BinaryConverter.ToInt32(_arguments[_parameter]);
if (current != null)
{
_dumped = true;
return (Int32) current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
if (_arguments[_parameter] != null)
{
_dumped = true;
return Escaping.Unescape(_arguments[_parameter]);
}
}
return "";
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
var current = BinaryConverter.ToUInt16(_arguments[_parameter]);
if (current != null)
{
_dumped = true;
return (UInt16) current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
var current = BinaryConverter.ToUInt32(_arguments[_parameter]);
if (current != null)
{
_dumped = true;
return (UInt32) current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
return (ReadInt32Arg() != 0);
}
CommandMessenger.ReceivedCommand.ReadInt32Arg
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().

{
if (Next())
{
Single current;
if (Single.TryParse(_arguments[_parameter], out current))
{
_dumped = true;
return current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
Single current;
if (Single.TryParse(_arguments[_parameter], out current))
{
_dumped = true;
return current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
Int16 current;
if (Int16.TryParse(_arguments[_parameter], out current))
{
_dumped = true;
return current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
Int32 current;
if (Int32.TryParse(_arguments[_parameter], out current))
{
_dumped = true;
return current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
if (_arguments[_parameter] != null)
{
_dumped = true;
return _arguments[_parameter];
}
}
return "";
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
UInt16 current;
if (UInt16.TryParse(_arguments[_parameter], out current))
{
_dumped = true;
return current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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().

{
if (Next())
{
UInt32 current;
if (UInt32.TryParse(_arguments[_parameter], out current))
{
_dumped = true;
return current;
}
}
return 0;
}
CommandMessenger.ReceivedCommand.Next
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:

- D:/My Documents/Github/Arduino-Code-and-Libraries/Libraries/CmdMessenger/CSharp/CommandMessenger/ReceivedCommand.cs