Exemplo n.º 1
0
        protected volatile bool terminated;                 // necessary to stop receiving data


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public UdpChannelLogic(ILineContext lineContext, ChannelConfig channelConfig)
            : base(lineContext, channelConfig)
        {
            options     = new UdpChannelOptions(channelConfig.CustomOptions);
            requestArgs = new IncomingRequestArgs();
            deviceLock  = new object();

            masterConn = null;
            slaveConn  = null;
            deviceDict = null;
            terminated = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Makes the communication channel ready for operating.
        /// </summary>
        public override void MakeReady()
        {
            CheckBehaviorSupport();
            tcpListener = new TcpListener(IPAddress.Any, options.TcpPort);

            if (options.DeviceMapping == DeviceMapping.ByIPAddress ||
                options.DeviceMapping == DeviceMapping.ByHelloPacket)
            {
                deviceDict = new DeviceDictionary();
                deviceDict.AddRange(LineContext.SelectDevices());
            }
        }
Exemplo n.º 3
0
        protected volatile bool terminated;                 // necessary to stop the thread


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public TcpServerChannel(ILineContext lineContext, ChannelConfig channelConfig)
            : base(lineContext, channelConfig)
        {
            options     = new TcpServerChannelOptions(channelConfig.CustomOptions);
            requestArgs = new IncomingRequestArgs();
            inBuf       = new byte[InBufferLenght];
            connList    = new List <TcpConnection>();

            tcpListener = null;
            currentConn = null;
            deviceDict  = null;
            thread      = null;
            terminated  = false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Makes the communication channel ready for operating.
        /// </summary>
        public override void MakeReady()
        {
            CheckBehaviorSupport();

            if (options.DeviceMapping == DeviceMapping.ByHelloPacket)
            {
                throw new ScadaException(Locale.IsRussian ?
                                         "Режим сопоставления устройств не поддерживается." :
                                         "Device mapping mode is not supported.");
            }

            if (Behavior == ChannelBehavior.Slave &&
                options.DeviceMapping == DeviceMapping.ByIPAddress)
            {
                deviceDict = new DeviceDictionary();
                deviceDict.AddRange(LineContext.SelectDevices());
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Makes the communication channel ready for operating.
        /// </summary>
        public override void MakeReady()
        {
            CheckBehaviorSupport();

            if (options.ConnectionMode == ConnectionMode.Individual)
            {
                indivConnList = new List <TcpConnection>();
                DeviceDictionary deviceDict = new DeviceDictionary();
                deviceDict.AddRange(LineContext.SelectDevices());

                foreach (DeviceDictionary.DeviceGroup deviceGroup in deviceDict.SelectDeviceGroups())
                {
                    TcpConnection conn = new TcpConnection(Log, new TcpClient())
                    {
                        ReconnectAfter = options.ReconnectAfter
                    };

                    indivConnList.Add(conn);

                    foreach (DeviceLogic deviceLogic in deviceGroup)
                    {
                        conn.BindDevice(deviceLogic);
                        deviceLogic.Connection = conn;
                    }
                }
            }
            else // ConnectionMode.Shared
            {
                sharedConn = new TcpConnection(Log, new TcpClient())
                {
                    ReconnectAfter = options.ReconnectAfter
                };

                SetDeviceConnection(sharedConn);
            }
        }