Esempio n. 1
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());
            }
        }
Esempio n. 2
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());
            }
        }
Esempio n. 3
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);
            }
        }