No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MonitorUI.cs 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. //
  2. // MonitorUI.cs
  3. //
  4. // Author:
  5. // Di MERCURIO Sébastien <dimercur@insa-toulouse.fr>
  6. //
  7. // Copyright (c) 2018 INSA - DGEI
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation, either version 3 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. using System;
  22. using Gtk;
  23. using Gdk;
  24. using monitor;
  25. /// <summary>
  26. /// Main part of the program, behavior of main window
  27. /// </summary>
  28. public partial class MainWindow : Gtk.Window
  29. {
  30. /// <summary>
  31. /// Destijl command manager reference
  32. /// </summary>
  33. private DestijlCommandManager cmdManager;
  34. /// <summary>
  35. /// Pixbuffer used for displaying image
  36. /// </summary>
  37. private Pixbuf drawingareaCameraPixbuf;
  38. /// <summary>
  39. /// List of availble state for the application
  40. /// </summary>
  41. enum SystemState
  42. {
  43. NotConnected,
  44. ServerConnected,
  45. RobotConnected
  46. };
  47. /// <summary>
  48. /// The state of the system. Can take a value from SystemState
  49. /// </summary>
  50. private SystemState systemState = SystemState.NotConnected;
  51. /// <summary>
  52. /// Timer for battery request
  53. /// </summary>
  54. private System.Timers.Timer batteryTimer;
  55. private int imageReceivedCounter = 0;
  56. private int badImageReceivedCounter = 0;
  57. /// <summary>
  58. /// Initializes a new instance of the <see cref="MainWindow"/> class.
  59. /// </summary>
  60. public MainWindow() : base(Gtk.WindowType.Toplevel)
  61. {
  62. Build();
  63. cmdManager = new DestijlCommandManager(OnCommandReceivedEvent);
  64. // create new timer for battery request, every 10s
  65. batteryTimer = new System.Timers.Timer(10000.0);
  66. batteryTimer.Elapsed += OnBatteryTimerElapsed;
  67. // Customize controls
  68. AdjustControls();
  69. }
  70. /// <summary>
  71. /// Make some adjustement to controls, like disabling some controls
  72. /// </summary>
  73. public void AdjustControls()
  74. {
  75. // Change state of system, and grey every controls not needed
  76. ChangeState(SystemState.NotConnected);
  77. // Load "no picture" image from disque
  78. drawingareaCameraPixbuf = Pixbuf.LoadFromResource("monitor.ressources.missing_picture.png");
  79. // setup server controls
  80. entryServerName.Text = Client.defaultIP;
  81. entryServerPort.Text = Client.defaultPort.ToString();
  82. entryTimeout.Text = "1000";
  83. }
  84. /// <summary>
  85. /// Method used to change controls visibility (greyed or not) depending on current state
  86. /// </summary>
  87. /// <param name="newState">New state</param>
  88. private void ChangeState(SystemState newState)
  89. {
  90. switch (newState)
  91. {
  92. case SystemState.NotConnected:
  93. labelRobot.Sensitive = false;
  94. gtkAlignmentRobot.Sensitive = false;
  95. labelRobotControl.Sensitive = false;
  96. gtkAlignmentRobotControl.Sensitive = false;
  97. boxCamera.Sensitive = false;
  98. buttonServerConnection.Label = "Connect";
  99. buttonRobotActivation.Label = "Activate";
  100. labelBatteryLevel.Text = "Unknown";
  101. checkButtonCameraOn.Active = false;
  102. checkButtonRobotPosition.Active = false;
  103. if (cmdManager != null) cmdManager.Close();
  104. batteryTimer.Stop();
  105. break;
  106. case SystemState.ServerConnected:
  107. buttonServerConnection.Label = "Disconnect";
  108. buttonRobotActivation.Label = "Activate";
  109. labelBatteryLevel.Text = "Unknown";
  110. labelRobot.Sensitive = true;
  111. gtkAlignmentRobot.Sensitive = true;
  112. boxCamera.Sensitive = true;
  113. labelRobotControl.Sensitive = false;
  114. gtkAlignmentRobotControl.Sensitive = false;
  115. batteryTimer.Stop();
  116. break;
  117. case SystemState.RobotConnected:
  118. buttonRobotActivation.Label = "Reset";
  119. labelRobotControl.Sensitive = true;
  120. gtkAlignmentRobotControl.Sensitive = true;
  121. batteryTimer.Start();
  122. break;
  123. default:
  124. labelRobot.Sensitive = false;
  125. gtkAlignmentRobot.Sensitive = false;
  126. labelRobotControl.Sensitive = false;
  127. gtkAlignmentRobotControl.Sensitive = false;
  128. boxCamera.Sensitive = false;
  129. buttonServerConnection.Label = "Connect";
  130. buttonRobotActivation.Label = "Activate";
  131. labelBatteryLevel.Text = "Unknown";
  132. checkButtonCameraOn.Active = false;
  133. checkButtonRobotPosition.Active = false;
  134. systemState = SystemState.NotConnected;
  135. return;
  136. }
  137. systemState = newState;
  138. }
  139. /// <summary>
  140. /// Display a popup message window
  141. /// </summary>
  142. /// <param name="type">Type of popup window (question, error, information,...)</param>
  143. /// <param name="buttons">Buttons available on popup window</param>
  144. /// <param name="title">Title of window</param>
  145. /// <param name="message">Message</param>
  146. private void MessagePopup(MessageType type, ButtonsType buttons, string title, string message)
  147. {
  148. MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, type, buttons, message)
  149. {
  150. Title = title
  151. };
  152. md.Run();
  153. md.Destroy();
  154. }
  155. /// <summary>
  156. /// Callback called when delete event is sent by window
  157. /// </summary>
  158. /// <param name="sender">Sender object</param>
  159. /// <param name="a">Not really sure of what it is...</param>
  160. protected void OnDeleteEvent(object sender, DeleteEventArgs a)
  161. {
  162. Console.WriteLine("Bye bye");
  163. if (cmdManager != null) cmdManager.Close();
  164. Application.Quit();
  165. a.RetVal = true;
  166. }
  167. private byte[] imageComplete;
  168. private byte[] imageInProgress;
  169. /// <summary>
  170. /// Callback called when new message is received from server
  171. /// </summary>
  172. /// <param name="header">Header of message</param>
  173. /// <param name="data">Data of message</param>
  174. /// <param name="buffer">Raw buffer corresponding of received message</param>
  175. public void OnCommandReceivedEvent(string header, string data, byte[] buffer)
  176. {
  177. if (buffer==null)
  178. {
  179. // we have lost server
  180. ChangeState(SystemState.NotConnected);
  181. MessagePopup(MessageType.Error,
  182. ButtonsType.Ok, "Server lost",
  183. "Server is down: disconnecting");
  184. cmdManager.Close();
  185. }
  186. // if we have received a valid message
  187. if (header != null)
  188. {
  189. #if DEBUG
  190. // print message content
  191. if (header.Length > 4)
  192. Console.WriteLine("Bad header(" + buffer.Length + ")");
  193. else
  194. Console.WriteLine("Received header (" + header.Length + "): " + header);
  195. //if (header.ToUpper() != DestijlCommandList.HeaderStmImage)
  196. //{
  197. // if (data != null) Console.WriteLine("Received data (" + data.Length + "): " + data);
  198. //}
  199. #endif
  200. // Image management
  201. if (header == DestijlCommandList.HeaderStmImage)
  202. {
  203. imageComplete = imageInProgress;
  204. imageInProgress = buffer;
  205. }
  206. else
  207. {
  208. if (imageInProgress == null) imageInProgress = buffer;
  209. else
  210. {
  211. Array.Resize<byte>(ref imageInProgress, imageInProgress.Length + buffer.Length);
  212. System.Buffer.BlockCopy(buffer, 0, imageInProgress, imageInProgress.Length - buffer.Length, buffer.Length);
  213. }
  214. }
  215. // depending on message received (based on header)
  216. // launch correponding action
  217. if (header.ToUpper() == DestijlCommandList.HeaderStmBat)
  218. {
  219. switch (data[0])
  220. {
  221. case '2':
  222. labelBatteryLevel.Text = "High";
  223. break;
  224. case '1':
  225. labelBatteryLevel.Text = "Low";
  226. break;
  227. case '0':
  228. labelBatteryLevel.Text = "Empty";
  229. break;
  230. default:
  231. labelBatteryLevel.Text = "Invalid value";
  232. break;
  233. }
  234. }
  235. else if (header.ToUpper() == DestijlCommandList.HeaderStmImage)
  236. {
  237. // if message is an image, convert it to a pixbuf
  238. // that can be displayed
  239. if (imageComplete != null)
  240. {
  241. byte[] image = new byte[imageComplete.Length - 4];
  242. System.Buffer.BlockCopy(imageComplete, 4, image, 0, image.Length);
  243. imageReceivedCounter++;
  244. try
  245. {
  246. drawingareaCameraPixbuf = new Pixbuf(image);
  247. drawingAreaCamera.QueueDraw();
  248. }
  249. catch (GLib.GException)
  250. {
  251. badImageReceivedCounter++;
  252. #if DEBUG
  253. Console.WriteLine("Bad Image: " + badImageReceivedCounter +
  254. " / " + imageReceivedCounter +
  255. " (" + badImageReceivedCounter * 100 / imageReceivedCounter + "%)");
  256. #endif
  257. }
  258. }
  259. }
  260. }
  261. }
  262. /// <summary>
  263. /// Callback called by "quit" menu
  264. /// </summary>
  265. /// <param name="sender">Sender object</param>
  266. /// <param name="e">Event</param>
  267. protected void OnQuitActionActivated(object sender, EventArgs e)
  268. {
  269. Console.WriteLine("Bye bye 2");
  270. if (cmdManager != null) cmdManager.Close();
  271. this.Destroy();
  272. Application.Quit();
  273. }
  274. /// <summary>
  275. /// Callback called by "show log" menu
  276. /// </summary>
  277. /// <param name="sender">Sender object</param>
  278. /// <param name="e">Event</param>
  279. protected void OnShowLogWindowActionActivated(object sender, EventArgs e)
  280. {
  281. MessagePopup(MessageType.Info,
  282. ButtonsType.Ok, "Info",
  283. "Logger not yet implemented");
  284. }
  285. /// <summary>
  286. /// Callback called by "buttonServerConnection" button
  287. /// </summary>
  288. /// <param name="sender">Sender object</param>
  289. /// <param name="e">Event</param>
  290. protected void OnButtonServerConnectionClicked(object sender, EventArgs e)
  291. {
  292. DestijlCommandManager.CommandStatus statusCmd;
  293. // if we are currently connected
  294. if (buttonServerConnection.Label == "Disconnect")
  295. {
  296. // Change state to disconnect and close connection
  297. ChangeState(SystemState.NotConnected);
  298. }
  299. else // we are not currently connected to server
  300. {
  301. // if information about hostname or port are invalid, show a popup error
  302. if ((entryServerName.Text == "") || (entryServerPort.Text == ""))
  303. {
  304. MessagePopup(MessageType.Error,
  305. ButtonsType.Ok, "Error",
  306. "Server name or port is invalid");
  307. }
  308. else
  309. {
  310. Console.WriteLine("Connecting to " + entryServerName.Text + ":" + entryServerPort.Text);
  311. bool status = false;
  312. // try to convert timout string value to double. If that failed, default to 100 ms
  313. try
  314. {
  315. cmdManager.timeout = Convert.ToDouble(entryTimeout.Text);
  316. }
  317. catch (Exception)
  318. {
  319. cmdManager.timeout = 100;
  320. entryTimeout.Text = cmdManager.timeout.ToString();
  321. }
  322. // try to connect to givn server.
  323. try
  324. {
  325. status = cmdManager.Open(entryServerName.Text, Convert.ToInt32(entryServerPort.Text));
  326. }
  327. catch (Exception)
  328. {
  329. Console.WriteLine("Something went wrong during connection");
  330. return;
  331. }
  332. //if connection status is not ok, show an error popup
  333. if (status != true)
  334. {
  335. MessagePopup(MessageType.Error,
  336. ButtonsType.Ok, "Error",
  337. "Unable to connect to server " + entryServerName.Text + ":" + Convert.ToInt32(entryServerPort.Text));
  338. }
  339. else // if we succed in connecting, open communication with robot
  340. {
  341. Console.Write("Send command RobotOpenCom: ");
  342. statusCmd = cmdManager.RobotOpenCom();
  343. Console.WriteLine(statusCmd.ToString());
  344. if (statusCmd == DestijlCommandManager.CommandStatus.Success)
  345. {
  346. ChangeState(SystemState.ServerConnected);
  347. }
  348. else // if communication with robot is not possible, show error
  349. {
  350. MessagePopup(MessageType.Error,
  351. ButtonsType.Ok, "Error",
  352. "Unable to open communication with robot.\nCheck that supervisor is accepting OPEN_COM_DMB command");
  353. cmdManager.Close();
  354. }
  355. }
  356. }
  357. }
  358. }
  359. /// <summary>
  360. /// Callback called when "buttonRobotactivation" is clicked
  361. /// </summary>
  362. /// <param name="sender">Sender object</param>
  363. /// <param name="e">Event</param>
  364. protected void OnButtonRobotActivationClicked(object sender, EventArgs e)
  365. {
  366. DestijlCommandManager.CommandStatus status;
  367. //if robot is not activated
  368. if (buttonRobotActivation.Label == "Activate")
  369. {
  370. // if a startup with watchdog is requested
  371. if (radioButtonWithWatchdog.Active)
  372. {
  373. status = cmdManager.RobotStartWithWatchdog();
  374. }
  375. else // startup without watchdog
  376. {
  377. status = cmdManager.RobotStartWithoutWatchdog();
  378. }
  379. // if status of command is ok, change state of system, enabling robot control
  380. if (status == DestijlCommandManager.CommandStatus.Success)
  381. {
  382. ChangeState(SystemState.RobotConnected);
  383. }
  384. else // if status is not ok, depending of error, show appropriate error
  385. {
  386. if (status == DestijlCommandManager.CommandStatus.CommunicationLostWithServer)
  387. {
  388. MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Connection lost with server");
  389. ChangeState(SystemState.NotConnected);
  390. }
  391. else
  392. {
  393. MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Command rejected\nCheck that supervisor accept \nDMB_START_WITH_WD and/or DMB_START_WITHOUT_WD");
  394. }
  395. }
  396. }
  397. else // If robot is already activated, request reset of robot
  398. {
  399. status = cmdManager.RobotReset();
  400. // if status of command is ok, change state of system, disabling robot control
  401. if (status == DestijlCommandManager.CommandStatus.Success)
  402. {
  403. ChangeState(SystemState.ServerConnected);
  404. }
  405. else // if status is not ok, depending of error, show appropriate error
  406. {
  407. if (status == DestijlCommandManager.CommandStatus.CommunicationLostWithServer)
  408. {
  409. MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Connection lost with server");
  410. ChangeState(SystemState.NotConnected);
  411. }
  412. else
  413. {
  414. MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Unknown error");
  415. }
  416. }
  417. }
  418. }
  419. /// <summary>
  420. /// Callback called when user click on direction button
  421. /// </summary>
  422. /// <param name="sender">Sender button</param>
  423. /// <param name="e">Event</param>
  424. protected void OnButtonMouvClicked(object sender, EventArgs e)
  425. {
  426. // depending on button clicked, launch appropriate action
  427. if (sender == buttonRight)
  428. {
  429. cmdManager.RobotTurn(90);
  430. }
  431. else if (sender == buttonLeft)
  432. {
  433. cmdManager.RobotTurn(-90);
  434. }
  435. else if (sender == buttonForward)
  436. {
  437. cmdManager.RobotMove(100);
  438. }
  439. else if (sender == buttonDown)
  440. {
  441. cmdManager.RobotMove(-100);
  442. }
  443. else
  444. {
  445. MessagePopup(MessageType.Warning, ButtonsType.Ok, "Abnormal behavior", "Callback OnButtonMouvClicked called by unknown sender");
  446. }
  447. }
  448. /// <summary>
  449. /// Callback called when battery timer expired
  450. /// </summary>
  451. /// <param name="sender">Sender object</param>
  452. /// <param name="e">Event</param>
  453. void OnBatteryTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
  454. {
  455. DestijlCommandManager.CommandStatus status;
  456. batteryTimer.Stop();
  457. // if battery checkbox is checked, a request for battery level is done
  458. if (checkButtonGetBattery.Active)
  459. {
  460. status = cmdManager.RobotGetBattery();
  461. // if status is not ok, show appropriate message and print "Unknown" for battery level
  462. switch (status)
  463. {
  464. case DestijlCommandManager.CommandStatus.Success:
  465. batteryTimer.Start();
  466. break;
  467. case DestijlCommandManager.CommandStatus.CommunicationLostWithServer:
  468. Console.WriteLine("Error: Connection lost with server");
  469. batteryTimer.Stop();
  470. labelBatteryLevel.Text = "Unknown";
  471. ChangeState(SystemState.NotConnected);
  472. break;
  473. case DestijlCommandManager.CommandStatus.CommunicationLostWithRobot:
  474. Console.WriteLine("Error: Connection lost with robot");
  475. batteryTimer.Stop();
  476. labelBatteryLevel.Text = "Unknown";
  477. ChangeState(SystemState.ServerConnected);
  478. break;
  479. default:
  480. labelBatteryLevel.Text = "Unknown";
  481. batteryTimer.Start();
  482. break;
  483. }
  484. }
  485. else batteryTimer.Start();
  486. }
  487. /// <summary>
  488. /// Callback called when checkbutton for camera is clicked
  489. /// </summary>
  490. /// <param name="sender">Sender object</param>
  491. /// <param name="e">Event</param>
  492. protected void OnCheckButtonCameraOnClicked(object sender, EventArgs e)
  493. {
  494. // if camera is already active, switch it off
  495. if (!checkButtonCameraOn.Active)
  496. {
  497. if (cmdManager.CameraClose() != DestijlCommandManager.CommandStatus.Success)
  498. {
  499. MessagePopup(MessageType.Error,
  500. ButtonsType.Ok, "Error",
  501. "Error when closing camera: bad answer for supervisor or timeout");
  502. }
  503. }
  504. else // camera is not active, switch it on
  505. {
  506. badImageReceivedCounter = 0;
  507. imageReceivedCounter = 0;
  508. if (cmdManager.CameraOpen() != DestijlCommandManager.CommandStatus.Success)
  509. {
  510. MessagePopup(MessageType.Error,
  511. ButtonsType.Ok, "Error",
  512. "Error when opening camera: bad answer for supervisor or timeout");
  513. checkButtonCameraOn.Active = false;
  514. }
  515. }
  516. }
  517. /// <summary>
  518. /// Callback called when checkbutton robot position is clicked
  519. /// </summary>
  520. /// <param name="sender">Sender object</param>
  521. /// <param name="e">Event</param>
  522. protected void OnCheckButtonRobotPositionClicked(object sender, EventArgs e)
  523. {
  524. // if server already send robot position, stop it
  525. if (!checkButtonRobotPosition.Active)
  526. {
  527. if (cmdManager.CameraStopComputePosition() != DestijlCommandManager.CommandStatus.Success)
  528. {
  529. MessagePopup(MessageType.Error,
  530. ButtonsType.Ok, "Error",
  531. "Error when stopping position reception: bad answer for supervisor or timeout");
  532. }
  533. }
  534. else // start reception of robot position
  535. {
  536. if (cmdManager.CameraComputePosition() != DestijlCommandManager.CommandStatus.Success)
  537. {
  538. MessagePopup(MessageType.Error,
  539. ButtonsType.Ok, "Error",
  540. "Error when starting getting robot position: bad answer for supervisor or timeout");
  541. checkButtonRobotPosition.Active = false;
  542. }
  543. }
  544. }
  545. /// <summary>
  546. /// Callback called when drawingarea need refresh
  547. /// </summary>
  548. /// <param name="o">Sender object</param>
  549. /// <param name="args">Expose arguments</param>
  550. protected void OnDrawingAreaCameraExposeEvent(object o, ExposeEventArgs args)
  551. {
  552. //Console.WriteLine("Event expose. Args = " + args.ToString());
  553. DrawingArea area = (DrawingArea)o;
  554. Gdk.Pixbuf displayPixbuf;
  555. int areaWidth, areaHeight;
  556. // Get graphic context for background
  557. Gdk.GC gc = area.Style.BackgroundGC(Gtk.StateType.Normal);
  558. // get size of drawingarea widget
  559. area.GdkWindow.GetSize(out areaWidth, out areaHeight);
  560. int width = drawingareaCameraPixbuf.Width;
  561. int height = drawingareaCameraPixbuf.Height;
  562. float ratio = (float)width / (float)height;
  563. // if widget is smaller than image, reduce it
  564. if (areaWidth <= width)
  565. {
  566. width = areaWidth;
  567. height = (int)(width / ratio);
  568. }
  569. // if image is smaller than widget, enlarge it
  570. if (width > areaWidth)
  571. {
  572. width = areaWidth;
  573. }
  574. if (height > areaHeight)
  575. {
  576. height = areaHeight;
  577. }
  578. //scale original picture and copy result in local pixbuf
  579. displayPixbuf = drawingareaCameraPixbuf.ScaleSimple(width, height, InterpType.Bilinear);
  580. // draw local pixbuff centered on drawingarea
  581. area.GdkWindow.DrawPixbuf(gc, displayPixbuf,
  582. 0, 0,
  583. (areaWidth - displayPixbuf.Width) / 2,
  584. (areaHeight - displayPixbuf.Height) / 2,
  585. displayPixbuf.Width, displayPixbuf.Height,
  586. RgbDither.Normal, 0, 0);
  587. }
  588. /// <summary>
  589. /// Show a popup asking user to tell if arena is correct or not
  590. /// </summary>
  591. protected void DetectArena()
  592. {
  593. DestijlCommandManager.CommandStatus status;
  594. MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent,
  595. MessageType.Question, ButtonsType.YesNo, "Arena is correct ?");
  596. {
  597. Title = "Check arena";
  598. };
  599. ResponseType result = (ResponseType)md.Run();
  600. md.Destroy();
  601. if (result == ResponseType.Yes)
  602. {
  603. status = cmdManager.CameraArenaConfirm();
  604. }
  605. else
  606. {
  607. status = cmdManager.CameraArenaInfirm();
  608. }
  609. if (status != DestijlCommandManager.CommandStatus.Success)
  610. {
  611. MessagePopup(MessageType.Error,
  612. ButtonsType.Ok, "Error",
  613. "Unable to send Confirm or Infirm arena command to supervisor");
  614. }
  615. }
  616. /// <summary>
  617. /// Callback called when "detect Arena " button is clicked
  618. /// </summary>
  619. /// <param name="sender">Sender object</param>
  620. /// <param name="e">Event</param>
  621. protected void OnButtonAskArenaClicked(object sender, EventArgs e)
  622. {
  623. // Send command to server for arean rendering
  624. if (cmdManager.CameraAskArena() != DestijlCommandManager.CommandStatus.Success)
  625. {
  626. MessagePopup(MessageType.Error,
  627. ButtonsType.Ok, "Error",
  628. "Error when asking for arena rendering");
  629. return;
  630. }
  631. // show popup and wait for user to say if arena is ok or not
  632. DetectArena();
  633. }
  634. }