Beispiel #1
0
        private void Test()
        {
            if (!radioActiveMode.Checked && !radioPassiveMode.Checked)
            {
                MessageBox.Show("Please Choice Connect Mode!!");
                return;
            }
            _secsGem?.Dispose();
            _secsGem = new SecsGem(
                radioActiveMode.Checked,
                IPAddress.Parse(txtAddress.Text),
                (int)numPort.Value,
                (int)numBufferSize.Value)
            {
                Logger = _logger, DeviceId = (ushort)numDeviceId.Value
            };

            SetTimerSetting();

            _secsGem.ConnectionChanged += delegate
            {
                this.Invoke((MethodInvoker) delegate
                {
                    lbStatus.Text = _secsGem.State.ToString();
                });
            };

            _secsGem.PrimaryMessageReceived += PrimaryMessageReceived;

            buttonConnect.Enabled = false;
            _secsGem.Start();
            buttonDisconnect.Enabled = true;
        }
Beispiel #2
0
        private void btnEnable_Click(object sender, EventArgs e)
        {
            _secsGem?.Dispose();
            _secsGem = new SecsGem(
                radioActiveMode.Checked,
                radioActiveMode.Checked?IPAddress.Parse(txtAddress.Text):IPAddress.Any,
                (int)numPort.Value,
                (int)numBufferSize.Value)
            {
                Logger = _logger, DeviceId = (ushort)numDeviceId.Value
            };
            _secsGem.LinkTestEnable     = true;
            _secsGem.LinkTestInterval   = 60000;
            _secsGem.ConnectionChanged += delegate
            {
                this.Invoke((MethodInvoker) delegate
                {
                    lbStatus.Text = _secsGem.State.ToString();
                    if (_secsGem.State == ConnectionState.Selected && _secsGem.IsActive)
                    {
                        _secsGem.SendAsync(new SecsMessage(1, 13, "Online Request", Item.L(Item.A(), Item.A())));
                    }
                });
            };

            Settings1.Default.ActiveMode = radioActiveMode.Checked;
            Settings1.Default.Save();

            _secsGem.PrimaryMessageReceived += PrimaryMessageReceived;

            btnEnable.Enabled = false;
            _secsGem.Start();
            btnDisable.Enabled = true;
        }
Beispiel #3
0
 void menuItemGemDisable_Click(object sender, EventArgs e)
 {
     if (_secsGem != null)
     {
         EapLogger.Info("SECS/GEM Stop");
         _secsGem.Dispose();
         _secsGem = null;
     }
     gemStatusLabel.Text        = "Disable";
     menuItemGemDisable.Enabled = false;
     menuItemGemEnable.Enabled  = true;
 }
Beispiel #4
0
        void menuItemGemEnable_Click(object sender, EventArgs e)
        {
            EapLogger.Info("SECS/GEM Start");
            gemStatusLabel.Text = "Start";
            _secsGem?.Dispose();
            _secsGem = new SecsGem(
                EAPConfig.Instance.Mode == ConnectionMode.Active,
                IPAddress.Parse(EAPConfig.Instance.IP),
                EAPConfig.Instance.TcpPort, EAPConfig.Instance.SocketRecvBufferSize)
            {
                DeviceId         = EAPConfig.Instance.DeviceId,
                LinkTestInterval = EAPConfig.Instance.LinkTestInterval,
                T3     = EAPConfig.Instance.T3,
                T5     = EAPConfig.Instance.T5,
                T6     = EAPConfig.Instance.T6,
                T7     = EAPConfig.Instance.T7,
                T8     = EAPConfig.Instance.T8,
                Logger = new SecsLogger()
            };
            _secsGem.ConnectionChanged += delegate
            {
                this.Invoke((MethodInvoker) delegate
                {
                    EapLogger.Info("SECS/GEM " + _secsGem.State);
                    gemStatusLabel.Text        = _secsGem.State.ToString();
                    eqpAddressStatusLabel.Text = "Device IP: " + _secsGem.DeviceAddress;
                    if (_secsGem.State == ConnectionState.Selected)
                    {
                        _secsGem.SendAsync(new SecsMessage(1, 13, "TestCommunicationsRequest", Item.L()));
                    }
                });
            };

            _secsGem.PrimaryMessageReceived += PrimaryMsgHandler;
            _secsGem.Start();
            menuItemGemDisable.Enabled = true;
            menuItemGemEnable.Enabled  = false;
        }