| Monitor

Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
monitor.CommandManager Class Reference

Command Manager. Use for timeout managment during reception of data Used as intermediate layer between TCP client class (Client) and application level managment of command and answers More...

Collaboration diagram for monitor.CommandManager:
[legend]

## Public Types
enum | CommandManagerStatus { CommandManagerStatus.AnswerReceived, CommandManagerStatus.Timeout, CommandManagerStatus.Busy }
| Available status when sending command More...

## Public Member Functions
delegate void | CommandReceivedEvent (string msg, byte[] buffer)
| Callback for sending received data to upper level More...
| CommandManager (CommandReceivedEvent callback)
| Initializes a new instance of the T:monitor.CommandManager class. More...
bool | Open (string hostname)
| Open the specified hostname server, using default port number. More...
bool | Open (string hostname, int port)
| Open connection to server "host", with port number "port" More...
void | Close ()
| Close connection to server More...
CommandManagerStatus | SendCommand (string cmd, out string answer, double timeout)
| Sends a command to TCP server More...

## Public Attributes
CommandReceivedEvent | commandReceivedEvent = null

## Private Member Functions
| ~CommandManager ()
| Releases unmanaged resources and performs other cleanup operations before the T:monitor.CommandManager is reclaimed by garbage collection. More...
void | OnMessageReception (string message, byte[] buffer)
| Callback called by Client class after reception of new message More...
void | OnMessageTimeout (object sender, System.Timers.ElapsedEventArgs e)
| Callback called by stopwatch on timeout More...

## Private Attributes
System.Timers.Timer | waitTimer = new System.Timers.Timer()
| Timer for managing timeout More...
ManualResetEvent | waitEvent = new ManualResetEvent(false)
bool | waitForAcknowledge = false
| Flag to tell rogram to wait for an acknowledge from server More...
string | messageReceived = null
| received message More...
bool | isBusy = false
| flag indicating command manager is currently busy waiting an acknowledge More...

## Detailed Description

Command Manager. Use for timeout managment during reception of data Used as intermediate layer between TCP client class (Client) and application level managment of command and answers

Definition at line 31 of file CommandManager.cs.

## Member Enumeration Documentation

## ◆ CommandManagerStatus

enum monitor.CommandManager.CommandManagerStatus
| strong

Available status when sending command

Enumerator
AnswerReceived |
Timeout |
Busy |

Definition at line 63 of file CommandManager.cs.

## Constructor & Destructor Documentation

## ◆ CommandManager()

monitor.CommandManager.CommandManager | ( | CommandReceivedEvent | callback | ) |

Initializes a new instance of the T:monitor.CommandManager class.

Parameters

  callback | Callback used when new message are received

Definition at line 74 of file CommandManager.cs.

## ◆ ~CommandManager()

monitor.CommandManager.~CommandManager | ( |  | ) |
| private

Releases unmanaged resources and performs other cleanup operations before the T:monitor.CommandManager is reclaimed by garbage collection.

Definition at line 86 of file CommandManager.cs.

## Member Function Documentation

## ◆ Close()

void monitor.CommandManager.Close | ( |  | ) |

Close connection to server

Definition at line 115 of file CommandManager.cs.

## ◆ CommandReceivedEvent()

delegate void monitor.CommandManager.CommandReceivedEvent | ( | string | msg,
|  | byte [] | buffer
| ) |  |

Callback for sending received data to upper level

## ◆ OnMessageReception()

void monitor.CommandManager.OnMessageReception | ( | string | message,
|  | byte [] | buffer
| ) |  |
| private

Callback called by Client class after reception of new message

Parameters

  message | Message received from server
  buffer | Raw buffer reived from server

Definition at line 125 of file CommandManager.cs.

## ◆ OnMessageTimeout()

void monitor.CommandManager.OnMessageTimeout | ( | object | sender,
|  | System.Timers.ElapsedEventArgs | e
| ) |  |
| private

Callback called by stopwatch on timeout

Parameters

  sender | Sender object
  e | Information on elapsed condition

Definition at line 156 of file CommandManager.cs.

## ◆ Open() [1/2]

bool monitor.CommandManager.Open | ( | string | hostname | ) |

Open the specified hostname server, using default port number.

Returns
  true if connection succeded, false otherwise

Parameters

  hostname | Hostname to connect to

Definition at line 96 of file CommandManager.cs.

## ◆ Open() [2/2]

bool monitor.CommandManager.Open | ( | string | hostname,
|  | int | port
| ) |  |

Open connection to server "host", with port number "port"

Returns
  true if connection succeded, false otherwise

Parameters

  hostname | Hostname to connect to
  port | Port number for connection

Definition at line 107 of file CommandManager.cs.

## ◆ SendCommand()

CommandManagerStatus monitor.CommandManager.SendCommand | ( | string | cmd,
|  | out string | answer,
|  | double | timeout
| ) |  |

Sends a command to TCP server

Returns
  status that is part of CommandManagerStatus enumerate

Parameters

  cmd | Command message to send to server
  answer | Answer from server, in case of acknowledge
  timeout | Timeout (ms) waiting an acknowledge, 0 if no acknowledge needed

Definition at line 171 of file CommandManager.cs.

## Member Data Documentation

## ◆ commandReceivedEvent

CommandReceivedEvent monitor.CommandManager.commandReceivedEvent = null

Definition at line 37 of file CommandManager.cs.

## ◆ isBusy

bool monitor.CommandManager.isBusy = false
| private

flag indicating command manager is currently busy waiting an acknowledge

Definition at line 58 of file CommandManager.cs.

## ◆ messageReceived

string monitor.CommandManager.messageReceived = null
| private

received message

Definition at line 53 of file CommandManager.cs.

## ◆ waitEvent

ManualResetEvent monitor.CommandManager.waitEvent = new ManualResetEvent(false)
| private

Definition at line 43 of file CommandManager.cs.

## ◆ waitForAcknowledge

bool monitor.CommandManager.waitForAcknowledge = false
| private

Flag to tell rogram to wait for an acknowledge from server

Definition at line 48 of file CommandManager.cs.

## ◆ waitTimer

System.Timers.Timer monitor.CommandManager.waitTimer = new System.Timers.Timer()
| private

Timer for managing timeout

Definition at line 42 of file CommandManager.cs.

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

- CommandManager.cs