61 public const string RobotPing =
"p";
62 public const string RobotReset =
"r";
63 public const string RobotStartWithoutWatchdog =
"u";
64 public const string RobotStartWithWatchdog =
"W";
65 public const string RobotGetBattery =
"v";
66 public const string RobotGetBusyState =
"b";
67 public const string RobotMove =
"M";
68 public const string RobotTurn =
"T";
69 public const string RobotGetVersion =
"V";
70 public const string RobotPowerOff =
"z";
86 private string receivedHeader = null;
91 private string receivedData = null;
96 public delegate
void CommandReceivedEvent(
string header,
string data, byte[] buffer);
97 public CommandReceivedEvent commandReceivedEvent = null;
102 public double timeout = 100;
113 CommunicationLostWithRobot,
114 CommunicationLostWithServer
124 this.commandReceivedEvent += callback;
133 if (commandManager != null) commandManager.
Close();
144 string[] msgs = msg.Split(
':');
147 if (msgs.Length >= 1) receivedHeader = msgs[0];
148 else receivedHeader = null;
151 if (msgs.Length >= 2) receivedData = msgs[1];
152 else receivedData = null;
155 this.commandReceivedEvent?.Invoke(receivedHeader, receivedData, buffer);
163 public bool Open(
string hostname)
174 public bool Open(
string hostname,
int port)
176 if (commandManager != null)
return commandManager.
Open(hostname, port);
185 if (commandManager != null) commandManager.
Close();
196 return header +
":" + data;
222 else if (answer.Length == 0) status =
CommandStatus.CommunicationLostWithServer;
244 return DecodeStatus(localStatus, answer);
261 return DecodeStatus(localStatus, answer);
278 return DecodeStatus(localStatus, answer);
295 return DecodeStatus(localStatus, answer);
312 return DecodeStatus(localStatus, answer);
329 return DecodeStatus(localStatus, answer);
347 return DecodeStatus(localStatus, answer);
365 return DecodeStatus(localStatus, answer);
382 return DecodeStatus(localStatus, answer);
405 string[] msg = answer.Split(
':');
434 return DecodeStatus(localStatus, answer);
451 return DecodeStatus(localStatus, answer);
468 return DecodeStatus(localStatus, answer);
485 return DecodeStatus(localStatus, answer);
502 return DecodeStatus(localStatus, answer);
519 return DecodeStatus(localStatus, answer);
536 return DecodeStatus(localStatus, answer);
553 return DecodeStatus(localStatus, answer);
const string HeaderMtsDmbOrder
const string HeaderStmImage
CommandStatus RobotGetVersion(out string version)
Request robot firmware version
CommandStatus RobotStartWithoutWatchdog()
Start robot, without enabling watchdog
const int defaultPort
Default server port number
CommandStatus CameraArenaInfirm()
Reject arena detected (after requesting image of detected arena, using CameraAskArena ...
bool Open(string hostname)
Open the specified hostname server, using default port number.
const string RobotGetBattery
Command Manager. Use for timeout managment during reception of data Used as intermediate layer betwee...
void Close()
Close connection to server
const string HeaderStmBat
const string RobotGetVersion
const string DataCamComputePosition
void OnCommandReceived(string msg, byte[] buffer)
Callback used for receiving data from lower layer (CommandManager class)
const string RobotPowerOff
CommandStatus RobotGetBattery()
Request robot battery level
CommandStatus RobotStartWithWatchdog()
Start robot, enabling watchdog
CommandManagerStatus SendCommand(string cmd, out string answer, double timeout)
Sends a command to TCP server
bool Open(string hostname, int port)
Open connection to server "host", with port number "port"
const string HeaderStmAck
Commands used for robot messages
const string RobotStartWithoutWatchdog
Specialization class for command manager, which implemnent destijl protocol between monitor and serve...
const string HeaderStmMes
CommandStatus RobotPing()
Ping the robot.
const string DataCamInfirm
CommandStatus CameraComputePosition()
Request robot position computing
CommandStatus CameraStopComputePosition()
Stop robot position computing
CommandStatus CameraArenaConfirm()
Confirm arena detection (after requesting image of detected arena, using CameraAskArena ...
CommandStatus
List of available return status
const string DataComClose
CommandStatus CameraAskArena()
Request still image of detected arena
const string HeaderStmNoAck
CommandStatus RobotReset()
Reset robot and let it in idle mode
CommandStatus CameraClose()
Close camera on remote device
const string HeaderStmPos
DestijlCommandManager(CommandReceivedEvent callback)
Initializes a new instance of the monitor.DestijlCommandManager class.
const string DataCamArenaConfirm
CommandStatus RobotTurn(int angle)
Make robot turn left or right, for a given angle
string CreateCommand(string header, string data)
Creates the command to send to server, based on header and data provided
CommandStatus CameraOpen()
Open camera on remote device
const string HeaderMtsCamera
CommandStatus RobotPowerOff()
Power off robot
const string DataCamClose
const string DataCamAskArena
const string HeaderMtsMessage
const string HeaderMtsComDmb
Static class for TCP client
~DestijlCommandManager()
Releases unmanaged resources and performs other cleanup operations before the monitor.DestijlCommandManager is reclaimed by garbage collection.
CommandStatus RobotCloseCom()
Close communication with robot and wait acknowledge
CommandStatus RobotMove(int distance)
Move robot forward or backward, for a distance expressed in millimeter
CommandManagerStatus
Available status when sending command
const string DataCamStopComputePosition
CommandStatus RobotOpenCom()
Open communication with robot and wait acknowledge
CommandStatus DecodeStatus(CommandManager.CommandManagerStatus localStatus, string answer)
Provide DestijlCommandManager.CommandStatus based on status received by CommandManager.SendCommand and answer string
Commands and options parameters used in Destijl project when communicating with server ...
bool Open(string hostname)
Open the specified hostname server, using default port number.
const string HeaderStmLostDmb
const string RobotStartWithWatchdog
void Close()
Close connection to server