Пример #1
0
        public void Close(int millisecondsWait = 0)
        {
            bool isAnyCommunicatorActive = Publishers.Count > 0 || Subscribers.Count > 0 || ServiceProviders.Count > 0;

            while (Publishers.Count > 0)
            {
                Unadvertise(Publishers.First().Key);
            }

            while (Subscribers.Count > 0)
            {
                Unsubscribe(Subscribers.First().Key);
            }

            while (ServiceProviders.Count > 0)
            {
                UnadvertiseService(ServiceProviders.First().Key);
            }

            // Service consumers do not stay on. So nothing to unsubscribe/unadvertise

            if (isAnyCommunicatorActive)
            {
                Thread.Sleep(millisecondsWait);
            }

            protocol.Close();
        }
Пример #2
0
        private void FinalizePsdkApplicationBlocks()
        {
            if (confServiceContract != null)
            {
                ConfServiceFactory.ReleaseConfService(confServiceContract);
            }
            // Cleanup code
            eventBrokerService.Deactivate();

            eventBrokerService.Dispose();

            // Close Connection if opened (check status of protocol object)
            IProtocol protocol = protocolManagementService[configServerId];

            if (protocol.State == ChannelState.Opened) // Close only if the protocol state is opened
            {
                try
                {
                    protocol.Close();
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message + "\n" + ex.StackTrace + "\n");
                }
            }

            protocolManagementService.Unregister(configServerId);
        }
Пример #3
0
        private static void FinalizePSDKApplicationBlocks()
        {
            ConfServiceFactory.ReleaseConfService(confService);

            // Cleanup code
            eventBrokerService.Deactivate();

            eventBrokerService.Dispose();

            // Close Connection if opened (check status of protocol object)
            IProtocol protocol = protocolManagementService[CONFIGSERVER_IDENTIFIER];

            if (protocol.State == ChannelState.Opened) // Close only if the protocol state is opened
            {
                try
                {
                    protocol.Close();
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);
                }
            }
            protocolManagementService.Unregister(CONFIGSERVER_IDENTIFIER);
        }
Пример #4
0
 public bool Close()
 {
     if (device == null)
     {
         return(false);
     }
     return(device.Close());
 }
Пример #5
0
        public void Stop()
        {
            try
            {
                isRunning = false;
                processGate.Set(); // make sure we aren't proccessing anything
                if (transport != null && ((messageProcessor != null && !messageProcessor.Join(1500)) ||
                                          (dataListener != null && !dataListener.Join(1500))))
                {
                    transport.Close();
                    if (messageProcessor.ThreadState == ThreadState.Running && Thread.CurrentThread != messageProcessor)
                    {
                        messageProcessor.Abort();
                    }
                    if (dataListener.ThreadState == ThreadState.Running && Thread.CurrentThread != dataListener)
                    {
                        dataListener.Abort();
                    }
                }

                System.Console.WriteLine("Killing protocol");

                if (tcpProtocol != null)
                {
                    tcpProtocol.Close();
                }
            }
            catch (Exception e)
            {
                isRunning = false;
                if (transport != null)
                {
                    transport.Close();
                }
                if (tcpProtocol != null)
                {
                    tcpProtocol.Close();
                }
                throw new Exception("Disconnect exception", e);
            }
        }
Пример #6
0
        public void Dispose()
        {
            clientRun = false;
            netProtocol.Close();
            heartTimer.Dispose();
            timeoutTimer.Dispose();

            lock (sessionToCallback)
            {
                sessionToCallback.Clear();
                netProtocol.WaitRecive = 0;
            }
        }
Пример #7
0
        public void Close()
        {
            while (Publishers.Count > 0)
            {
                Unadvertise(Publishers.First().Key);
            }

            while (Subscribers.Count > 0)
            {
                Unsubscribe(Subscribers.First().Key);
            }

            while (ServiceProviders.Count > 0)
            {
                UnadvertiseService(ServiceProviders.First().Key);
            }

            protocol.Close();
        }
Пример #8
0
        public void Disconnect()
        {
            try
            {
                // Get the protocol associated with this configuration
                IProtocol protocol = protocolManagementService[OCS_IDENTIFIER];

                // Close if protocol not already closed
                if (protocol.State == ChannelState.Opened)
                {
                    // Close the connection asynchronously
                    protocol.Close();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
Пример #9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            switch (b.Content)
            {
            case "Connect": {
                device = new SCPI();
                device.Open(txt_visaaddress.Text);

                b.Background = device.IsConnected() ? Brushes.Lime : Brushes.Red;
                break;
            }

            case "Send": {
                rtb_result.Document.Blocks.Clear();
                device = new SCPI();
                device.Open(txt_visaaddress.Text);

                foreach (var x in commands)
                {
                    if (!x.Contains("?"))
                    {
                        device.Write(x);
                    }
                    else
                    {
                        string data = device.Query(x).Replace("\r", "").Replace("\n", "").Trim();
                        data = data + "\n";
                        rtb_result.AppendText(data);
                    }
                }

                device.Close();

                break;
            }
            }
        }
Пример #10
0
        public void FinalizePSDKApplicationBlocks()
        {
            // Cleanup code
            eventBrokerService.Deactivate();

            eventBrokerService.Dispose();

            // Close Connection if opened (check status of protocol object)
            IProtocol protocol = protocolManagementService[ISERVER_IDENTIFIER];

            if (protocol.State == ChannelState.Opened) // Close only if the protocol state is opened
            {
                try
                {
                    protocol.Close();
                }
                catch (Exception ex)
                {
                    LogException(ex);
                }
            }

            protocolManagementService.Unregister(ISERVER_IDENTIFIER);
        }
Пример #11
0
        private void FinalizePSDKApplicationBlocks()
        {
            // Cleanup code
            eventBrokerService.Deactivate();

            eventBrokerService.Dispose();

            // Close Connection if opened (check status of protocol object)
            IProtocol protocol = protocolManagementService[OCS_IDENTIFIER];

            if (protocol.State == ChannelState.Opened) // Close only if the protocol state is opened
            {
                try
                {
                    protocol.Close();
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message + "\n" + ex.StackTrace + "\n");
                }
            }

            protocolManagementService.Unregister(OCS_IDENTIFIER);
        }