Example #1
0
 private void updateGraph(USBdevice USB)
 {
     if (USB.frameList.Count > 0)
     {
         var point = USB.frameList.Last();
         ForceOuptut.Text = point.SensorData[0] + "";
     }
 }
Example #2
0
 public void WatchDeviceCancel(USBdevice selectedDeviceUSB, ApplicationContext baseUSB)
 {
     if (selectedDeviceUSB != null)
     {
         baseUSB.USBdevices.Remove(selectedDeviceUSB);
         baseUSB.SaveChanges();
     }
     else
     {
         MessageBox.Show("Выберите USB для снятия наблюдения!");
     }
 }
Example #3
0
 public void WatchDevice(USBdevice selectedDeviceUSB, ApplicationContext baseUSB)
 {
     if (selectedDeviceUSB != null)
     {
         baseUSB.USBdevices.Add(new USBdevice()
         {
             DeviceID    = selectedDeviceUSB.DeviceID,
             Description = selectedDeviceUSB.Description
         });
         baseUSB.SaveChanges();
     }
     else
     {
         MessageBox.Show("Выберите USB под наблюдение!");
     }
 }
Example #4
0
        private delegate void CloseMainFormDelegate(); //Used to close the program if hardware is not connected

        public Form1()
        {
            string exceptionMessage = null;

            InitializeComponent();
            var finder = new ComPortFinder();

            // Get available serial ports.
            comPortList = finder.findSingleTact();
            if (comPortList.Count == 0)
            {
                MessageBox.Show(
                    "Failed to start sensor: no serial ports found.\n\nPlease ensure Arduino drivers are installed.\nThis can be checked by looking if the Arduino is identified in Device Manager.\n\nPlease connect the device then restart this application.",
                    "Hardware initialisation failed",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                // There's no point showing the GUI.  Force the app to auto-close.
                Environment.Exit(-1);
            }
            else
            {
                for (int i = 0; i < 1; i++)
                {
                    USBdevice USB = new USBdevice();
                    USB.Initialise(finder.prettyToComPort(comPortList[i]));
                    USBdevices.Add(USB);
                    this.Text = comPortList[i];
                }
            }
            activeSingleTact = USBdevices[0].singleTact;
            try
            {
                //PopulateGUIFields();
                foreach (USBdevice USB in USBdevices)
                {
                    USB.singleTact.PushSettingsToHardware();
                    RefreshFlashSettings_Click(this, null); //Get the settings from flash
                }
                //CreateStripChart();
                AcquisitionWorker.RunWorkerAsync(); //Start the acquisition thread

                guiTimer_.Start();
            }
            catch
            {
                string summary = "Failed to start sensor";

                if (comPortList.Count == 0)
                {
                    summary += ": no serial ports detected.";
                }
                else
                {
                    summary += " on " + comPortList[0] + ".";
                }

                summary += "\n\n";

                if (exceptionMessage != null)
                {
                    summary += exceptionMessage;
                }
                else
                {
                    summary += "Please connect the device then restart this application.";
                }

                MessageBox.Show(
                    summary,
                    "Hardware initialisation failed",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);

                // There's no point showing the GUI.  Force the app to auto-close.
                Environment.Exit(-1);
            }
        }