Beispiel #1
0
 public void ShutdownInstrument()
 {
     if (myInstrument != null)
     {
         myInstrument.Halt();
         myInstrument = null;
     }
 }
Beispiel #2
0
        public void Initialise()
        {
            // Create a proxy to IInstrumentControl
            myInstrument = InstrumentControlProxy.GetInstance();

            // Reference the Quadrant Manager
            myQuadrantManager = QuadrantManager.GetInstance();
        }
Beispiel #3
0
        private SeparatorImpl()
        {
            try
            {
                // -------------------
                // Set the fully-qualified machine name for the server (optionally supplied in
                // the application configuration file).
                NameValueCollection nvc = (NameValueCollection)System.Configuration.ConfigurationManager.GetSection("Separator/InstrumentControlConnection");

                string serverAddress = string.Empty;
                try
                {
                    serverAddress = nvc.Get("ServerAddress");
                }
                finally
                {
                    // Ignore any exceptions -- if we can't read the IP address configuration
                    // setting then we act as if it were not specified.
                }

                RemotingInfo.ConfigureInstance(serverAddress);

                string configuredAddress = (serverAddress == null || serverAddress == string.Empty) ?
                                           "<Not specified>" : serverAddress;
                LogFile.AddMessage(TraceLevel.Verbose, "Configured address = " + configuredAddress);

                // -------------------
                // Register an event handler for IInstrumentControlEvents
                RemotingConfiguration.Configure("Separator.exe.config", false);

                // -------------------
                // Setup TCP Server channel
                BinaryClientFormatterSinkProvider tcpClientSinkProvider = new BinaryClientFormatterSinkProvider();

                BinaryServerFormatterSinkProvider tcpServerSinkProvider = new BinaryServerFormatterSinkProvider();
                tcpServerSinkProvider.TypeFilterLevel = TypeFilterLevel.Full;

                ListDictionary tcpChannelProperties = new ListDictionary();
                tcpChannelProperties.Add("name", "SeparatorAPI");
                tcpChannelProperties.Add("port", 3149);

                TcpChannel tcpChannel = new TcpChannel(tcpChannelProperties, tcpClientSinkProvider, tcpServerSinkProvider);

                ChannelServices.RegisterChannel(tcpChannel, false);

                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(InstrumentControlEventSink),
                    RemotingInfo.GetInstance().IcsEventSinkURI,
                    WellKnownObjectMode.Singleton);

                myTCPSvr         = OrcaTCPServer.GetInstance();
                myTCPSvr.TCPPort = myTCP_Port;
                // -------------------
                // Create the InstrumentControlEventSink
                try
                {
                    theInstrumentControlEventSink =
                        (IInstrumentControlEvents)Activator.GetObject(
                            typeof(InstrumentControlEventSink),
                            RemotingInfo.GetInstance().IcsEventSinkURL);
                    theInstrumentControlEventSink.ping();                        // Call a method to trigger the server
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            catch (Exception ex)
            {
                myInstrument = null;

                Console.WriteLine(ex.GetType());
                Console.WriteLine(ex.Message + "\n" + ex.InnerException);
                Console.WriteLine(ex.StackTrace);

                throw new ApplicationException();
            }
        }