Exemple #1
0
        /// <summary>
        /// Create by : 2018/09/17 AKB Nguyen Thanh Tung
        /// Meno      : Get Info Device
        /// </summary>
        public void LoadInfoDevice()
        {
            txtDev1ActualValue.Text = string.Empty;
            txtDev1AlarmValue.Text  = string.Empty;
            txtDev2ActualValue.Text = string.Empty;
            txtDev2AlarmValue.Text  = string.Empty;
            txtPeriod.Text          = string.Empty;
            txtFailLevel.Text       = string.Empty;
            txtAverage.Text         = string.Empty;
            txtPeriod2.Text         = string.Empty;
            txtFailLevel2.Text      = string.Empty;
            txtAverage2.Text        = string.Empty;

            btnDevice1.Enabled     = false;
            btnStopDevice1.Enabled = false;
            btnDevice2.Enabled     = false;
            btnStopDevice2.Enabled = false;

            btnWalkingStart.Enabled  = false;
            btnWalkingStart2.Enabled = false;

            _deviceInfo = _iSetting.GetListDevice();

            for (var i = 0; i < _deviceInfo.Length; i++)
            {
                _deviceInfo[i].deviceType = i;
                _deviceInfo[i].active     = _deviceInfo[i].active && !string.IsNullOrEmpty(_deviceInfo[i].ipAddress);

                switch (i)
                {
                case DEVICE1:
                    txtDev1AlarmValue.Text     = _deviceInfo[DEVICE1].AlarmValue > 0 ? _deviceInfo[DEVICE1].AlarmValue.ToString() : string.Empty;
                    txtDev1AlarmValue.ReadOnly = !_deviceInfo[DEVICE1].active;
                    txtPeriod.Text             = _deviceInfo[DEVICE1].period > 0 ? _deviceInfo[DEVICE1].period.ToString() : string.Empty;
                    txtFailLevel.Text          = _deviceInfo[DEVICE1].failLevel > 0 ? _deviceInfo[DEVICE1].failLevel.ToString() : string.Empty;
                    txtPeriod.ReadOnly         = !_deviceInfo[DEVICE1].active;
                    txtFailLevel.ReadOnly      = !_deviceInfo[DEVICE1].active;
                    btnDevice1.Enabled         = _deviceInfo[DEVICE1].active;
                    btnWalkingStart.Enabled    = _deviceInfo[DEVICE1].active;
                    break;

                case DEVICE2:
                    txtDev2AlarmValue.ReadOnly = !_deviceInfo[DEVICE2].active;
                    txtDev2AlarmValue.Text     = _deviceInfo[DEVICE2].AlarmValue > 0 ? _deviceInfo[DEVICE2].AlarmValue.ToString() : string.Empty;
                    txtPeriod2.Text            = _deviceInfo[DEVICE2].period > 0 ? _deviceInfo[DEVICE2].period.ToString() : string.Empty;
                    txtFailLevel2.Text         = _deviceInfo[DEVICE2].failLevel > 0 ? _deviceInfo[DEVICE2].failLevel.ToString() : string.Empty;
                    txtFailLevel2.ReadOnly     = !_deviceInfo[DEVICE2].active;
                    txtPeriod2.ReadOnly        = !_deviceInfo[DEVICE2].active;
                    btnDevice2.Enabled         = _deviceInfo[DEVICE2].active;
                    btnWalkingStart2.Enabled   = _deviceInfo[DEVICE2].active;
                    break;

                default:
                    continue;
                }
            }
        }
Exemple #2
0
        private void btnActivate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtKey.Text))
            {
                ShowMsg(MessageBoxIcon.Warning, MSG_KEY_BLANLK);
                txtKey.Focus();
                return;
            }

            if (!clsCommon.ValidateMachineAndDevices(iSetting.GetListDevice(), txtKey.Text))
            {
                ShowMsg(MessageBoxIcon.Error, MSG_ACTIVATE_ERR);
                txtKey.Focus();
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
            graphForm?.Show();
        }