Esempio n. 1
0
 public void _discovery_DeviceFound(Object sender, CameraDeviceInfoEventArgs e)
 {
     Console.WriteLine("found device");
     Console.WriteLine(e.CameraDevice.Name);
     _discovery.Stop();
     _camera.Connect(e.CameraDevice);
 }
Esempio n. 2
0
 private void buttonConnect_Click(object sender, EventArgs e)
 {
     buttonConnectCamera.Enabled = false;
     if (flirConnectStatus == false)
     {
         bool deviceFound = false;
         List <CameraDeviceInfo> deviceList = new List <CameraDeviceInfo>();
         deviceList = discovery.Start(5);
         foreach (var _device in deviceList)
         {
             if (_device.IsFlirCamera == true && (_device.CameraDeviceType == Interface.Usb || _device.CameraDeviceType == Interface.Usb3 || _device.CameraDeviceType == Interface.Network))
             {
                 device      = _device;
                 deviceFound = true;
                 break;
             }
         }
         discovery.Stop();
         if (!deviceFound)
         {
             connectionStatus.Text       = "No Device";
             buttonConnectCamera.Enabled = true;
             return;
         }
         cam.GetImage().Changed += cam_ImageChanged;
         cam.ConnectionStatusChanged += cam_ConnectionStatusChanged;
         cam.Connect(device);
     }
     else
     {
         if (cam.Recorder.Status == RecorderState.Recording || cam.Recorder.Status == RecorderState.Stopped)
         {
             cam.Recorder.Stop();
         }
         cam.Disconnect();
         while (cam.ConnectionStatus != ConnectionStatus.Disconnected)
         {
             ;
         }
         cam.GetImage().Changed -= cam_ImageChanged;
         cam.ConnectionStatusChanged -= cam_ConnectionStatusChanged;
     }
     buttonConnectCamera.Enabled = true;
 }
Esempio n. 3
0
        private async void connectCamera()
        {
            buttonConnectCamera.Enabled = false;
            if (flirConnectStatus == false)
            {
                bool deviceFound = false;
                List <CameraDeviceInfo> deviceList = new List <CameraDeviceInfo>();
                deviceList = discovery.Start(5);
                foreach (var _device in deviceList)
                {
                    if (_device.IsFlirCamera == true && (_device.CameraDeviceType == Interface.Usb || _device.CameraDeviceType == Interface.Usb3 || _device.CameraDeviceType == Interface.Network))
                    {
                        device      = _device;
                        deviceFound = true;
                        break;
                    }
                }
                discovery.Stop();
                if (!deviceFound)
                {
                    connectionStatus.Text       = "No Device";
                    buttonConnectCamera.Enabled = true;
                    return;
                }
                cam.ThermalImage.Changed           += cam_ImageChanged;
                cam.Recorder.RecorderStatusChanged += cam_RecorderStatusChanged;
                cam.ConnectionStatusChanged        += cam_ConnectionStatusChanged;
                cam.RemoteControl.CommandExecuted  += cam_CommandExecuted;
                cam.Connect(device);
            }
            else
            {
                await camLock.WaitAsync();

                RecorderState status = cam.Recorder.Status;
                if (camLock.CurrentCount == 0)
                {
                    camLock.Release();
                }
                if (status == RecorderState.Recording || status == RecorderState.Paused)
                {
                    Command(() => cam.Recorder.Stop(), true);
                    await camLock.WaitAsync();

                    if (camLock.CurrentCount == 0)
                    {
                        camLock.Release();
                    }
                }
                cam.Disconnect();
                while (flirConnectStatus)
                {
                    await Task.Delay(100);
                }
                cam.ThermalImage.Changed           -= cam_ImageChanged;
                cam.Recorder.RecorderStatusChanged -= cam_RecorderStatusChanged;
                cam.ConnectionStatusChanged        -= cam_ConnectionStatusChanged;
                cam.RemoteControl.CommandExecuted  -= cam_CommandExecuted;
            }
            buttonConnectCamera.Enabled = true;
        }