private void InitLib()
        {
            configLib = new Config();
            aConfig   = configLib.getConfigObj();

            atsLib = new ATSSend(aConfig.switchBetweenChineseAndEnglis);
            atsLib.initATSLib(aConfig.sendIP, aConfig.sendPort, 30, aConfig.pisServerIP1, aConfig.pisServerPort1);

            logicLib         = new Logic(aConfig.confgStationList.Count);
            communicationLib = new communication();
            if (!communicationLib.StarSevice(aConfig.atsServerPort1, aConfig.atsServerIP1, 4096 * 2, 0))
            {
                // 如果备也连接失败开户定时器每隔2秒重连
                // 实例化Timer类,设置间隔时间为10000毫秒;
                if (connectTimer == null)
                {
                    connectTimer = new System.Timers.Timer(5000);
                    // 到达时间的时候执行事件 获取中央ATS-列车状态;
                    connectTimer.Elapsed += new System.Timers.ElapsedEventHandler(reConnectServer);
                    // 设置是执行一次(false)还是一直执行(true);
                    connectTimer.AutoReset = true;
                    // 是否执行System.Timers.Timer.Elapsed事件;
                    connectTimer.Enabled = true;
                }
            }
            communicationLib.recvCommChanged   += CommunicationLib_recvCommChanged;
            communicationLib.disConnectChanged += CommunicationLib_disConnectChanged;

            // 处理数据线程
            Thread dataThread = new Thread(new ParameterizedThreadStart(logicDataThread));

            dataThread.Start((Object)this);
        }
 /// <summary>
 /// Creates a Connection Translator.
 /// </summary>
 /// <param name="connection">The Connection instance to use</param>
 public ConnectionManager(IComm connection, Parser parser)
 {
     _parser = parser;
     _parser.PayloadCallback   = PayloadCallback;
     _parser.ExceptionCallback = ExceptionCallback;
     Connection  = connection ?? throw new ArgumentNullException(nameof(connection));
     Destination = connection.Socket.GetDestination();
 }
        //----< register communicator for routing messages >-------

        public void Register(IComm communicator)
        {
            if (communicator.Name == this.Name) // don't allow MessageDispatcher to register itself
            {
                return;
            }
            CommunicatorLookup[communicator.Name] = communicator;
        }
Exemplo n.º 4
0
        public void CreateChannel(string address)
        {
            EndpointAddress baseaddress = new EndpointAddress(address);
            WSHttpBinding   binding     = new WSHttpBinding();

            factory = new ChannelFactory <IComm>(binding, address);
            channel = factory.CreateChannel();
        }
Exemplo n.º 5
0
 public CameraCommsTests()
 {
     _camera = new Camera
     {
         Name = "Test Camera"
     };
     _comm = new CameraCommChannel(_camera);
 }
Exemplo n.º 6
0
        public void CreateSendChannel(string address)
        {
            EndpointAddress        baseAddress = new EndpointAddress(address);
            WSHttpBinding          binding     = new WSHttpBinding();
            ChannelFactory <IComm> factory     = new ChannelFactory <IComm>(binding, address);

            channel = factory.CreateChannel();
            Console.Write("\n  service proxy created for {0}", address);
        }
Exemplo n.º 7
0
 public CameraPowerTests()
 {
     _camera = new Camera
     {
         Name = "Test Camera"
     };
     _comm = new CameraCommChannel(_camera);
     _operations = new CameraOperations(_comm, _camera);
 }
Exemplo n.º 8
0
        public void CreateChannel(string url)
        {
            EndpointAddress        baseAddress = new EndpointAddress(url);
            WSHttpBinding          binding     = new WSHttpBinding();
            ChannelFactory <IComm> factory     = new ChannelFactory <IComm>(binding, url);

            channel = factory.CreateChannel();
            Console.WriteLine("Proxy Created for : " + url);
        }
Exemplo n.º 9
0
 public CameraOperationTests()
 {
     _camera = new Camera
     {
         Name    = "Test Camera",
         MaxZoom = 4
     };
     _comm       = new CameraCommChannel(_camera);
     _operations = new CameraOperations(_comm, _camera);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a Connection Translator.
 /// </summary>
 /// <param name="connection">The Connection instance to use</param>
 /// <param name="onMsgRecieved">Called when a Msg instance is created from incoming byte arrays</param>
 /// <param name="generalExceptionAction">Called when an exception is thrown</param>
 /// <param name="onParseError">Called when a Msg cannot be parsed</param>
 /// <param name="connectionClosed">Called when the Connection closes</param>
 /// <param name="byteMsgRecieved">Called when bytes are received</param>
 public ConnectionManager(IComm connection, IReceiver onMsgRecieved, Action <ConnectionManager, Exception> generalExceptionAction, Action <ConnectionManager, Msg.DecodeResult, string> onParseError = null, Action <ConnectionManager> connectionClosed = null, Action <ConnectionManager, byte[]> byteMsgRecieved = null)
 {
     if (connection == null)
     {
         throw new ArgumentNullException();
     }
     Connection              = connection;
     Destination             = connection.Socket.RemoteEndPoint.ToString();
     _parser                 = new ByteMessageParser(PayloadCallback, ExceptionCallback);
     _onMsgRecieved          = onMsgRecieved;
     _generalExceptionAction = generalExceptionAction;
     _onParseError           = onParseError;
     _onMsgBytesRecieved     = byteMsgRecieved;
     _connectionClosed       = connectionClosed;
     Connection.Bind(ConnectionRecieve, OnConnectionClosed);
 }
 public EncryptionCommDecorator(IComm wrappee) : base(wrappee)
 {
 }
Exemplo n.º 12
0
 public void Register(IComm communicator)
 {
     dispatcher.Register(communicator);
 }
Exemplo n.º 13
0
 public ACamera(IComm comm)
 {
     this.channel = comm;
     Init();
 }
Exemplo n.º 14
0
 public CommDecorator(IComm wrappee)
 {
     _wrappee = wrappee;
 }
 public static CommOpenResult Open(IComm comm)
 {
     return(new CommOpenResult {
         IsValid = true, IsOpen = true, Comm = comm
     });
 }
Exemplo n.º 16
0
 public Camera(IComm comm) : base(comm)
 {
 }
    //----< register communicator for routing messages >-------

    public void Register(IComm communicator)
    {
      if (communicator.Name == this.Name)  // don't allow MessageDispatcher to register itself
        return;
      CommunicatorLookup[communicator.Name] = communicator;
    }
Exemplo n.º 18
0
 public CameraOperations(IComm comm, Camera camera) : base(camera)
 {
     _comm   = comm;
     _camera = camera;
 }
 public CompressionCommDecorator(IComm wrappee) : base(wrappee)
 {
 }
Exemplo n.º 20
0
 public void Register(IComm communicator)
 {
     dispatcher.Register(communicator);
 }