123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816 |
- //
- // MonitorUI.cs
- //
- // Author:
- // Di MERCURIO Sébastien <dimercur@insa-toulouse.fr>
- //
- // Copyright (c) 2018 INSA - DGEI
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
- using System;
- using Gtk;
- using Gdk;
- using Cairo;
-
- using monitor;
- using System.Timers;
-
- /// <summary>
- /// Main part of the program, behavior of main window
- /// </summary>
- public partial class MainWindow : Gtk.Window
- {
- /// <summary>
- /// Destijl command manager reference
- /// </summary>
- private DestijlCommandManager cmdManager;
-
- /// <summary>
- /// Pixbuffer used for displaying image
- /// </summary>
- private Pixbuf drawingareaCameraPixbuf;
-
- /// <summary>
- /// Position used for displaying position
- /// </summary>
- private DestijlCommandManager.Position position=new DestijlCommandManager.Position();
-
- /// <summary>
- /// List of availble state for the application
- /// </summary>
- enum SystemState
- {
- NotConnected,
- ServerConnected,
- RobotConnected
- };
-
- /// <summary>
- /// The state of the system. Can take a value from SystemState
- /// </summary>
- private SystemState systemState = SystemState.NotConnected;
-
- /// <summary>
- /// Timer for battery request
- /// </summary>
- private System.Timers.Timer batteryTimer;
-
- private int imageReceivedCounter = 0;
- private int badImageReceivedCounter = 0;
- private int imageFPS = 0;
- private int imageFPScounter = 0;
-
- /// <summary>
- /// Timer for FPS request
- /// </summary>
- private System.Timers.Timer fpsTimer;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="MainWindow"/> class.
- /// </summary>
- public MainWindow() : base(Gtk.WindowType.Toplevel)
- {
- Build();
-
- cmdManager = new DestijlCommandManager(OnCommandReceivedEvent);
-
- // create new timer for battery request, every 10s
- batteryTimer = new System.Timers.Timer(10000.0);
- batteryTimer.Elapsed += OnBatteryTimerElapsed;
-
- // create new timer for FPS , every 1s
- fpsTimer = new System.Timers.Timer(1000.0);
- fpsTimer.Elapsed += OnFpsTimerElapsed;
-
- // Customize controls
- AdjustControls();
- }
-
- /// <summary>
- /// Make some adjustement to controls, like disabling some controls
- /// </summary>
- public void AdjustControls()
- {
- // Change state of system, and grey every controls not needed
- ChangeState(SystemState.NotConnected);
-
- // Load "no picture" image from disque
- drawingareaCameraPixbuf = Pixbuf.LoadFromResource("monitor.ressources.missing_picture.png");
-
- // setup server controls
- entryServerName.Text = Client.defaultIP;
- entryServerPort.Text = Client.defaultPort.ToString();
- entryTimeout.Text = "1000";
- }
-
- /// <summary>
- /// Method used to change controls visibility (greyed or not) depending on current state
- /// </summary>
- /// <param name="newState">New state</param>
- private void ChangeState(SystemState newState)
- {
- switch (newState)
- {
- case SystemState.NotConnected:
- labelRobot.Sensitive = false;
- gtkAlignmentRobot.Sensitive = false;
-
- labelRobotControl.Sensitive = false;
- gtkAlignmentRobotControl.Sensitive = false;
- boxCamera.Sensitive = false;
-
- buttonServerConnection.Label = "Connect";
- buttonRobotActivation.Label = "Activate";
- labelBatteryLevel.Text = "Unknown";
-
- checkButtonCameraOn.Active = false;
- checkButtonRobotPosition.Active = false;
- checkButtonFPS.Active = false;
-
- if (cmdManager != null) cmdManager.Close();
-
- batteryTimer.Stop();
- break;
- case SystemState.ServerConnected:
- buttonServerConnection.Label = "Disconnect";
- buttonRobotActivation.Label = "Activate";
- labelBatteryLevel.Text = "Unknown";
-
- labelRobot.Sensitive = true;
- gtkAlignmentRobot.Sensitive = true;
- boxCamera.Sensitive = true;
-
- labelRobotControl.Sensitive = false;
- gtkAlignmentRobotControl.Sensitive = false;
-
- batteryTimer.Stop();
- break;
- case SystemState.RobotConnected:
- buttonRobotActivation.Label = "Reset";
- labelRobotControl.Sensitive = true;
- gtkAlignmentRobotControl.Sensitive = true;
-
- batteryTimer.Start();
- break;
- default:
- labelRobot.Sensitive = false;
- gtkAlignmentRobot.Sensitive = false;
-
- labelRobotControl.Sensitive = false;
- gtkAlignmentRobotControl.Sensitive = false;
- boxCamera.Sensitive = false;
-
- buttonServerConnection.Label = "Connect";
- buttonRobotActivation.Label = "Activate";
- labelBatteryLevel.Text = "Unknown";
-
- checkButtonCameraOn.Active = false;
- checkButtonRobotPosition.Active = false;
- checkButtonFPS.Active = false;
-
- systemState = SystemState.NotConnected;
-
- return;
- }
-
- systemState = newState;
- }
-
- /// <summary>
- /// Display a popup message window
- /// </summary>
- /// <param name="type">Type of popup window (question, error, information,...)</param>
- /// <param name="buttons">Buttons available on popup window</param>
- /// <param name="title">Title of window</param>
- /// <param name="message">Message</param>
- private void MessagePopup(MessageType type, ButtonsType buttons, string title, string message)
- {
- MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, type, buttons, message);
-
- md.Title = title;
- md.Run();
- md.Destroy();
- }
-
- /// <summary>
- /// Callback called when delete event is sent by window
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="a">Not really sure of what it is...</param>
- protected void OnDeleteEvent(object sender, DeleteEventArgs a)
- {
- Console.WriteLine("Bye bye");
-
- if (cmdManager != null) cmdManager.Close();
- Application.Quit();
- a.RetVal = true;
- }
-
- /// <summary>
- /// Callback called when new message is received from server
- /// </summary>
- /// <param name="header">Header of message</param>
- /// <param name="data">Data of message</param>
- public void OnCommandReceivedEvent(string header, string data)
- {
- if (header == null)
- {
- // we have lost server
- ChangeState(SystemState.NotConnected);
-
- Gtk.Application.Invoke(delegate
- {
- MessagePopup(MessageType.Error,
- ButtonsType.Ok, "Server lost",
- "Server is down: disconnecting");
- cmdManager.Close();
- });
- }
-
- // if we have received a valid message
- if (header != null)
- {
- #if DEBUG
- // print message content
- if (header.Length > 4)
- {
- Console.WriteLine("Bad header(" + header.Length + ")");
- }
- #endif
- // Depending on message received (based on header), launch correponding action
- header = header.ToUpper();
-
- if (header == DestijlCommandList.ROBOT_BATTERY_LEVEL)
- {
- string batLevel = "";
-
- switch (data[0])
- {
- case '2':
- batLevel = "High";
- break;
- case '1':
- batLevel = "Low";
- break;
- case '0':
- batLevel = "Empty";
- break;
- default:
- batLevel = "Invalid value";
- break;
- }
-
- Gtk.Application.Invoke(delegate
- {
- labelBatteryLevel.Text = batLevel;
- });
- }
- else if (header == DestijlCommandList.CAMERA_IMAGE)
- {
- imageReceivedCounter++;
-
- byte[] image = new byte[2];
- try
- {
- image = Convert.FromBase64String(data);
- }
- catch (FormatException)
- {
- badImageReceivedCounter++;
- Console.WriteLine("Unable to convert from base64 ");
- }
-
- try
- {
- drawingareaCameraPixbuf = new Pixbuf(image);
- imageFPScounter++;
-
- Gtk.Application.Invoke(delegate
- {
- drawingAreaCamera.QueueDraw();
- });
- }
- catch (GLib.GException)
- {
- badImageReceivedCounter++;
- #if DEBUG
- Console.WriteLine("Bad Image: " + badImageReceivedCounter +
- " / " + imageReceivedCounter +
- " (" + badImageReceivedCounter * 100 / imageReceivedCounter + "%)");
- #endif
- }
- //}
- }
- else if (header == DestijlCommandList.CAMERA_POSITION)
- {
- position = DestijlCommandManager.DecodePosition(data);
-
- Gtk.Application.Invoke(delegate
- {
- drawingAreaCamera.QueueDraw();
- });
- }
- }
- }
-
- /// <summary>
- /// Callback called by "quit" menu
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- protected void OnQuitActionActivated(object sender, EventArgs e)
- {
- Console.WriteLine("Bye bye 2");
- if (cmdManager != null) cmdManager.Close();
- this.Destroy();
- Application.Quit();
- }
-
- /// <summary>
- /// Callback called by "show log" menu
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- protected void OnShowLogWindowActionActivated(object sender, EventArgs e)
- {
- MessagePopup(MessageType.Info,
- ButtonsType.Ok, "Info",
- "Logger not yet implemented");
- }
-
- /// <summary>
- /// Callback called by "buttonServerConnection" button
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- protected void OnButtonServerConnectionClicked(object sender, EventArgs e)
- {
- DestijlCommandManager.CommandStatus statusCmd;
-
- // if we are currently connected
- if (buttonServerConnection.Label == "Disconnect")
- {
- // Change state to disconnect and close connection
- ChangeState(SystemState.NotConnected);
- }
- else // we are not currently connected to server
- {
- // if information about hostname or port are invalid, show a popup error
- if ((entryServerName.Text == "") || (entryServerPort.Text == ""))
- {
- MessagePopup(MessageType.Error,
- ButtonsType.Ok, "Error",
- "Server name or port is invalid");
- }
- else
- {
- Console.WriteLine("Connecting to " + entryServerName.Text + ":" + entryServerPort.Text);
- bool status = false;
-
- // try to convert timout string value to double. If that failed, default to 100 ms
- try
- {
- cmdManager.timeout = Convert.ToDouble(entryTimeout.Text);
- }
- catch (Exception)
- {
- cmdManager.timeout = 100;
- entryTimeout.Text = cmdManager.timeout.ToString();
- }
-
- // try to connect to givn server.
- try
- {
- status = cmdManager.Open(entryServerName.Text, Convert.ToInt32(entryServerPort.Text));
- }
- catch (Exception)
- {
- Console.WriteLine("Something went wrong during connection");
- return;
- }
-
- //if connection status is not ok, show an error popup
- if (status != true)
- {
- MessagePopup(MessageType.Error,
- ButtonsType.Ok, "Error",
- "Unable to connect to server " + entryServerName.Text + ":" + Convert.ToInt32(entryServerPort.Text));
- }
- else // if we succed in connecting, open communication with robot
- {
- Console.Write("Send command RobotOpenCom: ");
- statusCmd = cmdManager.RobotOpenCom();
- Console.WriteLine(statusCmd.ToString());
-
- if (statusCmd == DestijlCommandManager.CommandStatus.Success)
- {
- ChangeState(SystemState.ServerConnected);
- }
- else // if communication with robot is not possible, show error
- {
- MessagePopup(MessageType.Error,
- ButtonsType.Ok, "Error",
- "Unable to open communication with robot.\nCheck that supervisor is accepting OPEN_COM_DMB command");
-
- cmdManager.Close();
- }
- }
- }
- }
- }
-
- /// <summary>
- /// Callback called when "buttonRobotactivation" is clicked
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- protected void OnButtonRobotActivationClicked(object sender, EventArgs e)
- {
- DestijlCommandManager.CommandStatus status;
-
- //if robot is not activated
- if (buttonRobotActivation.Label == "Activate")
- {
- // if a startup with watchdog is requested
- if (radioButtonWithWatchdog.Active)
- {
- status = cmdManager.RobotStartWithWatchdog();
- }
- else // startup without watchdog
- {
- status = cmdManager.RobotStartWithoutWatchdog();
- }
-
- // if status of command is ok, change state of system, enabling robot control
- if (status == DestijlCommandManager.CommandStatus.Success)
- {
- ChangeState(SystemState.RobotConnected);
- }
- else // if status is not ok, depending of error, show appropriate error
- {
- if (status == DestijlCommandManager.CommandStatus.CommunicationLostWithServer)
- {
- MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Connection lost with server");
- ChangeState(SystemState.NotConnected);
- }
- else
- {
- MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Command rejected\nCheck that supervisor accept \nDMB_START_WITH_WD and/or DMB_START_WITHOUT_WD");
- }
- }
- }
- else // If robot is already activated, request reset of robot
- {
- status = cmdManager.RobotReset();
-
- // if status of command is ok, change state of system, disabling robot control
- if (status == DestijlCommandManager.CommandStatus.Success)
- {
- ChangeState(SystemState.ServerConnected);
- }
- else // if status is not ok, depending of error, show appropriate error
- {
- if (status == DestijlCommandManager.CommandStatus.CommunicationLostWithServer)
- {
- MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Connection lost with server");
- ChangeState(SystemState.NotConnected);
- }
- else
- {
- MessagePopup(MessageType.Error, ButtonsType.Ok, "Error", "Unknown error");
- }
- }
- }
- }
-
- /// <summary>
- /// Callback called when user click on direction button
- /// </summary>
- /// <param name="sender">Sender button</param>
- /// <param name="e">Event</param>
- protected void OnButtonMouvClicked(object sender, EventArgs e)
- {
- // depending on button clicked, launch appropriate action
- if (sender == buttonRight)
- {
- cmdManager.RobotTurn(90);
- }
- else if (sender == buttonLeft)
- {
- cmdManager.RobotTurn(-90);
- }
- else if (sender == buttonForward)
- {
- cmdManager.RobotMove(100);
- }
- else if (sender == buttonDown)
- {
- cmdManager.RobotMove(-100);
- }
- else
- {
- MessagePopup(MessageType.Warning, ButtonsType.Ok, "Abnormal behavior", "Callback OnButtonMouvClicked called by unknown sender");
- }
- }
-
- /// <summary>
- /// Callback called when battery timer expired
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- void OnBatteryTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
- {
- DestijlCommandManager.CommandStatus status;
- batteryTimer.Stop();
-
- // if battery checkbox is checked, a request for battery level is done
- if (checkButtonGetBattery.Active)
- {
- status = cmdManager.RobotGetBattery();
-
- // if status is not ok, show appropriate message and print "Unknown" for battery level
- switch (status)
- {
- case DestijlCommandManager.CommandStatus.Success:
- batteryTimer.Start();
- break;
- case DestijlCommandManager.CommandStatus.CommunicationLostWithServer:
- Console.WriteLine("Error: Connection lost with server");
- batteryTimer.Stop();
- labelBatteryLevel.Text = "Unknown";
-
- ChangeState(SystemState.NotConnected);
- break;
- case DestijlCommandManager.CommandStatus.CommunicationLostWithRobot:
- Console.WriteLine("Error: Connection lost with robot");
- batteryTimer.Stop();
- labelBatteryLevel.Text = "Unknown";
-
- ChangeState(SystemState.ServerConnected);
- break;
- default:
- labelBatteryLevel.Text = "Unknown";
- batteryTimer.Start();
- break;
- }
- }
- else batteryTimer.Start();
- }
-
- /// <summary>
- /// Callback called when checkbutton for camera is clicked
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- protected void OnCheckButtonCameraOnClicked(object sender, EventArgs e)
- {
- // if camera is already active, switch it off
- if (!checkButtonCameraOn.Active)
- {
- if (cmdManager.CameraClose() != DestijlCommandManager.CommandStatus.Success)
- {
- Console.WriteLine("Error when closing camera: bad answer for supervisor or timeout");
- }
- }
- else // camera is not active, switch it on
- {
- badImageReceivedCounter = 0;
- imageReceivedCounter = 0;
-
- if (cmdManager.CameraOpen() != DestijlCommandManager.CommandStatus.Success)
- {
- Console.WriteLine("Error when opening camera: bad answer for supervisor or timeout");
- //checkButtonCameraOn.Active = false;
- }
- }
- }
-
- /// <summary>
- /// Callback called when checkbutton robot position is clicked
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- protected void OnCheckButtonRobotPositionClicked(object sender, EventArgs e)
- {
- // if server already send robot position, stop it
- if (!checkButtonRobotPosition.Active)
- {
- if (cmdManager.CameraStopComputePosition() != DestijlCommandManager.CommandStatus.Success)
- {
- Console.WriteLine("Error when stopping position reception: bad answer for supervisor or timeout");
- }
- }
- else // start reception of robot position
- {
- if (cmdManager.CameraComputePosition() != DestijlCommandManager.CommandStatus.Success)
- {
- Console.WriteLine("Error when starting getting robot position: bad answer for supervisor or timeout");
-
- //checkButtonRobotPosition.Active = false;
- }
- }
- }
-
- /// <summary>
- /// Callback called when drawingarea need refresh
- /// </summary>
- /// <param name="o">Sender object</param>
- /// <param name="args">Expose arguments</param>
- protected void OnDrawingAreaCameraExposeEvent(object o, ExposeEventArgs args)
- {
- //Console.WriteLine("Event expose. Args = " + args.ToString());
-
- DrawingArea area = (DrawingArea)o;
- Gdk.Pixbuf displayPixbuf;
- int areaWidth, areaHeight;
-
- // Get graphic context for background
- Gdk.GC gc = area.Style.BackgroundGC(Gtk.StateType.Normal);
-
- // get size of drawingarea widget
- area.GdkWindow.GetSize(out areaWidth, out areaHeight);
- int width = drawingareaCameraPixbuf.Width;
- int height = drawingareaCameraPixbuf.Height;
- float ratio = (float)width / (float)height;
-
- // if widget is smaller than image, reduce it
- if (areaWidth <= width)
- {
- width = areaWidth;
- height = (int)(width / ratio);
- }
-
- // if image is smaller than widget, enlarge it
- if (width > areaWidth)
- {
- width = areaWidth;
- }
-
- if (height > areaHeight)
- {
- height = areaHeight;
- }
-
- //scale original picture and copy result in local pixbuf
- displayPixbuf = drawingareaCameraPixbuf.ScaleSimple(width, height, InterpType.Bilinear);
-
- // draw local pixbuff centered on drawingarea
- area.GdkWindow.DrawPixbuf(gc, displayPixbuf,
- 0, 0,
- (areaWidth - displayPixbuf.Width) / 2,
- (areaHeight - displayPixbuf.Height) / 2,
- displayPixbuf.Width, displayPixbuf.Height,
- RgbDither.Normal, 0, 0);
-
- if (checkButtonRobotPosition.Active) {
- Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
- Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
-
- cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
- cr.SetSourceColor(textFontColor);
- cr.SetFontSize(16);
-
- double space = 0.0;
- string text = "Direction (" + position.direction.x.ToString("0.##") + " ; " + position.direction.y.ToString("0.##") +")";
- TextExtents te = cr.TextExtents(text);
- cr.MoveTo(areaWidth - te.Width-5,
- areaHeight - te.Height -5);
- space = te.Height;
- cr.ShowText(text);
-
- text = "Centre (" + position.centre.x.ToString("0.##") + " ; " + position.centre.y.ToString("0.##") + ")";
- te = cr.TextExtents(text);
- cr.MoveTo(areaWidth - te.Width - 5,
- areaHeight - te.Height - 5 - space-5);
- space = space+ te.Height+5;
- cr.ShowText(text);
-
- text = "Angle: " + position.angle.ToString("0.##");
- te = cr.TextExtents(text);
- cr.MoveTo(areaWidth - te.Width - 5,
- areaHeight - te.Height - 5 - space - 5);
- space = space+ te.Height+5;
- cr.ShowText(text);
-
- text = "ID: " + position.robotID;
- te = cr.TextExtents(text);
- cr.MoveTo(areaWidth - te.Width - 5,
- areaHeight - te.Height - 5 - space-5);
-
- cr.ShowText(text);
-
- ((IDisposable)cr.GetTarget()).Dispose();
- ((IDisposable)cr).Dispose();
- }
-
- if (checkButtonFPS.Active) {
- Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
- Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
-
- cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
- cr.SetSourceColor(textFontColor);
- cr.SetFontSize(16);
-
- string text = "FPS= " + imageFPS.ToString() ;
- TextExtents te = cr.TextExtents(text);
- cr.MoveTo( 10,10 + te.Height);
- cr.ShowText(text);
-
- ((IDisposable)cr.GetTarget()).Dispose();
- ((IDisposable)cr).Dispose();
- }
- }
-
- /// <summary>
- /// Show a popup asking user to tell if arena is correct or not
- /// </summary>
- protected void DetectArena()
- {
- DestijlCommandManager.CommandStatus status;
- MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent,
- MessageType.Question, ButtonsType.YesNo, "Arena is correct ?");
-
- md.Title = "Check arena";
-
- ResponseType result = (ResponseType)md.Run();
- md.Destroy();
-
- if (result == ResponseType.Yes)
- {
- status = cmdManager.CameraArenaConfirm();
- }
- else
- {
- status = cmdManager.CameraArenaInfirm();
- }
-
- if (status != DestijlCommandManager.CommandStatus.Success)
- {
- MessagePopup(MessageType.Error,
- ButtonsType.Ok, "Error",
- "Unable to send Confirm or Infirm arena command to supervisor");
- }
- }
-
- /// <summary>
- /// Callback called when "detect Arena " button is clicked
- /// </summary>
- /// <param name="sender">Sender object</param>
- /// <param name="e">Event</param>
- protected void OnButtonAskArenaClicked(object sender, EventArgs e)
- {
- // Send command to server for arean rendering
- if (cmdManager.CameraAskArena() != DestijlCommandManager.CommandStatus.Success)
- {
- MessagePopup(MessageType.Error,
- ButtonsType.Ok, "Error",
- "Error when asking for arena rendering");
- return;
- }
-
- // show popup and wait for user to say if arena is ok or not
- DetectArena();
- }
-
- protected void OnCheckButtonFPSToggled(object sender, EventArgs e)
- {
- if (checkButtonFPS.Active) { // User ask for FPS
- imageFPS = 0;
- imageFPScounter = 0;
-
- fpsTimer.Start();
- }
- else { // stop computing FPS
- fpsTimer.Stop();
-
- Gtk.Application.Invoke(delegate
- {
- drawingAreaCamera.QueueDraw();
- });
- }
- }
-
- private void OnFpsTimerElapsed(object sender, ElapsedEventArgs e)
- {
- imageFPS = imageFPScounter;
- imageFPScounter = 0;
-
- Gtk.Application.Invoke(delegate
- {
- drawingAreaCamera.QueueDraw();
- });
- }
- }
|