protected SoapMessage <WSD.ProbeMatchesType> ProbeDevice(
            bool multicast,
            DiscoveryUtils.DiscoveryType[][] types,
            string[] scopes,
            string matchRule,
            Discovery.ProcessMessage processMessageMethod)
        {
            System.Diagnostics.Trace.WriteLine(string.Format("ProbeDevice: entry point"));
            System.Diagnostics.Trace.Flush();

            SoapMessage <WSD.ProbeMatchesType> response = null;
            Discovery discovery = new Discovery(_nic.IP, processMessageMethod);

            discovery.Discovered        += OnDiscovered;
            discovery.DiscoveryFinished += OnDiscoveryFinished;
            discovery.SoapFaultReceived += OnSoapFault;
            discovery.ReceiveError      += OnDiscoveryError;

            discovery.MessageSent += OnMessageSent;

            _eventProbeMatchReceived = new AutoResetEvent(false);
            _eventTimeout            = new AutoResetEvent(false);
            _eventFaultReceived      = new AutoResetEvent(false);
            _eventDiscoveryError     = new AutoResetEvent(false);
            int res = -1;

            try
            {
                discovery.Probe(multicast, _cameraIp, null, _messageTimeout, types, scopes, matchRule);
                res = WaitForResponse(new WaitHandle[] { _eventProbeMatchReceived, _eventTimeout, _eventFaultReceived, _eventDiscoveryError });
                if (res == 0)
                {
                    response = _message.ToSoapMessage <WSD.ProbeMatchesType>();
                }
                else if (res == 2)
                {
                    throw new SoapFaultException(_soapFault);
                }
                else if (res == 3)
                {
                    string message = _error.Message + _error.InnerException ?? " " + _error.InnerException.Message;
                    throw new AssertException(message);
                }
            }
            finally
            {
                System.Diagnostics.Trace.WriteLine(string.Format("ProbeDevice: discovery.Dispose, res = {0}", res));
                System.Diagnostics.Trace.Flush();
                discovery.Dispose();
            }
            return(response);
        }
Example #2
0
        private async void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            _updateGuiTimer.Stop();
            if (cam == null)
            {
                return;
            }
            if (flirConnectStatus == true)
            {
                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();
                cam.ConnectionStatusChanged -= cam_ConnectionStatusChanged;
                cam.GetImage().Changed -= cam_ImageChanged;
                cam.Recorder.RecorderStatusChanged -= cam_RecorderStatusChanged;
                cam.RemoteControl.CommandExecuted  -= cam_CommandExecuted;
            }
            cam.Dispose();
            if (discovery == null)
            {
                return;
            }
            discovery.Dispose();
        }
Example #3
0
        /// <summary>
        /// Stops the UPnP discovery.
        /// </summary>
        protected void Stop()
        {
            // If the discovery is available
            if (mdDiscovery != null)
            {
                // Stop it if its searching
                if (mdDiscovery.Searching)
                {
                    mdDiscovery.Stop();
                }

                // Remove events
                mdDiscovery.DeviceAdded    -= new DeviceAddedEventHandler(mdDiscovery_DeviceAdded);
                mdDiscovery.DeviceRemoved  -= new DeviceRemovedEventHandler(mdDiscovery_DeviceRemoved);
                mdDiscovery.SearchComplete -= new SearchCompleteEventHandler(mdDiscovery_SearchComplete);

                // Dispose of the discover and clear it
                mdDiscovery.Dispose();
                mdDiscovery = null;

                // Raise the SearchEnded event
                OnSearchEnded(new EventArgs());
            }
        }
Example #4
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     _updateGuiTimer.Stop();
     if (cam == null)
     {
         return;
     }
     if (flirConnectStatus == true)
     {
         if (cam.Recorder.Status == RecorderState.Recording || cam.Recorder.Status == RecorderState.Stopped)
         {
             cam.Recorder.Stop();
         }
         cam.Disconnect();
         cam.ConnectionStatusChanged -= cam_ConnectionStatusChanged;
         cam.GetImage().Changed -= cam_ImageChanged;
     }
     cam.Dispose();
     if (discovery == null)
     {
         return;
     }
     discovery.Dispose();
 }