Esempio n. 1
0
        public void Stop()
        {
            this.listening = false;
            this.inConnector.Cancel();
            this.listenThread.Join();
            this.inConnector.Dispose();
            this.inConnector = null;

            this.convertor.Dispose();
            this.convertor = null;

            this.shutdownEvent.Set();
            foreach (IConverterStream converterStream in this.converterStreamList.ToArray())
            {
                converterStream.Cancel();
                converterStream.Dispose();
            }

            while (Interlocked.CompareExchange(ref this.numberReadingThread, 0, 0) != 0)
            {
                Thread.Sleep(50);
            }

            this.shutdownEvent.Reset();
        }
Esempio n. 2
0
        public bool Listen(int port, int subscriberID, int handshakeTimeout, bool enableKeepAlive,
                           int keepAliveInterval, int keepAliveTimeOut, bool useExternalIdAsSerialNumber)
        {
            if (this.listening)
            {
                throw new System.Exception("StorageSystemSimulatorCore already Listening");
            }

            List <ConfigurationValue> configurationForTcpInConnector = this.GetConfigurationForTcpInConnector(port);

            this.inConnector = new TcpInConnector();

            if (!this.inConnector.Initialize(1, configurationForTcpInConnector))
            {
                return(false);
            }

            List <ConfigurationValue> configurationForWwksConverter = this.GetConfigurationForWwksConverter(
                subscriberID, handshakeTimeout, enableKeepAlive, keepAliveInterval, keepAliveTimeOut, useExternalIdAsSerialNumber);

            this.convertor = new WwksConverter();
            this.convertor.Initialize(2, configurationForWwksConverter);

            this.inputCore.SetSubscriberID(subscriberID);
            _simulatorArticleInfoCore.SetSubscriberID(subscriberID);
            this.listening = true;

            this.listenThread      = new Thread(this.ExecuteListen);
            this.listenThread.Name = "StorageSystemSimulator Listen thread";
            this.listenThread.Start();

            StorageSystemSerializer storageSystemSerializer = new StorageSystemSerializer();

            storageSystemSerializer.SaveConnectionInformation("Connection.xml",
                                                              configurationForTcpInConnector, configurationForWwksConverter);

            return(true);
        }