Example #1
0
 private void LoginForm_Load(object sender, EventArgs e)
 {
     if (ReadWriteRegistry.ReadRegistry("isInvalid") == null)
     {
         ReadWriteRegistry.WriteRegistry("isInvalid", "false");
     }
     users = readWriteData.ReadData();
     //循环添加到Combox
     foreach (UsersInfo userInfo in users.Values)
     {
         cbUserName.Items.Add(userInfo.UserName);
     }
     //用户名默认选中第一个
     if (cbUserName.Items.Count > 0)
     {
         cbUserName.SelectedIndex = 0;
         txtPWD.Text = users[cbUserName.SelectedItem.ToString().Trim()].PassWord;
     }
 }
Example #2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     this.timer1.Stop();
     if (SerialPort.GetPortNames().Length != 0)
     {
         //读取配置文件
         string portName = ReadWriteXml.ReadXml("PortName");
         string baudRate = ReadWriteXml.ReadXml("BaudRate");
         CDMASMS.Set(portName, Convert.ToInt32(baudRate));
         if (CDMASMS.Open())
         {
             string TSX             = CDMASMS.SendAT("AT^MEID").Replace("\r\n", "").Replace("OK", "");
             string production_Name = CDMASMS.SendAT("AT+CGMM").Replace("\r\n", "").Replace("OK", "");
             if (TSX.Length == 14 && production_Name.IndexOf("MC323") != -1)
             {
                 TSX = SysFunction.GetSecurit(TSX.Remove(3, 5));
                 if (tsx.Equals(TSX))
                 {
                     string netstat = CDMASMS.SendAT("AT+CREG?").Replace("\r\n", "").Replace("OK", "");
                     if (netstat.Split(',')[1] == "1")
                     {
                         if (ReadWriteRegistry.ReadRegistry("isInvalid") == null)
                         {
                             ReadWriteRegistry.WriteRegistry("isInvalid", "false");
                         }
                         if (ReadWriteRegistry.ReadRegistry("isInvalid") == "true")
                         {
                             this.DialogResult = DialogResult.Abort;
                         }
                         else
                         {
                             CDMASMS.DeviceInitialize();
                             this.DialogResult = DialogResult.OK;
                         }
                         this.Close();
                     }
                     else
                     {
                         UMessageBox.Show("未注册到本地网络!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         CDMASMS.Close();
                         this.Close();
                     }
                 }
                 else
                 {
                     UMessageBox.Show("硬件不匹配!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     CDMASMS.Close();
                     this.Close();
                 }
             }
             else
             {
                 UMessageBox.Show("串口打开失败,请在系统设置中重新配置串口数据。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.DialogResult = DialogResult.No;
                 this.Close();
             }
         }
         else
         {
             UMessageBox.Show("串口打开失败,请在系统设置中重新配置串口数据。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
             this.DialogResult = DialogResult.No;
             this.Close();
         }
     }
     else
     {
         UMessageBox.Show("读取硬件信息失败!请确认硬件设备连接正确。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
         CDMASMS.Close();
         this.Close();
     }
 }
Example #3
0
        /// <summary>
        /// 信息分析结果
        /// </summary>
        /// <param name="smsMsg"></param>
        public static void MsgResult(string smsMsg)
        {
            string[] s = new string[smsMsg.Length];
            for (int i = 0; i < smsMsg.Length - 1; i++)
            {
                s[i] = smsMsg.Substring(i, 1);
            }
            #region 报警信息
            if (s[0] + s[1] == "33")
            {
                Message = true;
            }
            if (s[0] + s[1] == "55")
            {
                Message = false;
            }
            #endregion

            #region 井盖是否打开
            if (s[2] + s[3] == "01")
            {
                IsOpen = true;
            }
            if (s[2] + s[3] == "02")
            {
                IsOpen = false;
            }
            #endregion

            #region 是否失效
            if (s[0] + s[1] + s[2] + s[3] == "5AC5")
            {
                ReadWriteRegistry.WriteRegistry("isInvalid", "true");
                isInvalid = true;
            }
            if (s[0] + s[1] + s[2] + s[3] == "5BD5")
            {
                ReadWriteRegistry.WriteRegistry("isInvalid", "false");
                isInvalid = false;
            }
            #endregion

            #region 电量是否报警
            if (s[4] + s[5] == "00")
            {
                IsElectricityAlarm = false;
            }
            if (s[4] + s[5] == "01")
            {
                IsElectricityAlarm = true;
            }
            #endregion

            #region 信号强度
            Signal_Strength = s[6] + s[7];
            #endregion

            #region 温度湿度
            if (s[8] + s[9] + s[10] + s[11] + s[12] == "00000")
            {
                Temperature = "无温度数据";
            }
            else
            {
                Temperature = s[8] + s[9] + s[10] + s[11] + s[12];
            }
            if (s[13] + s[14] + s[15] + s[16] + s[17] == "00000")
            {
                Humidity = "无湿度数据";
            }
            else
            {
                Humidity = s[13] + s[14] + s[15] + s[16] + s[17];
            }
            #endregion

            #region 烟感
            if (s[18] + s[19] + s[20] + s[21] == "0000")
            {
                SmokeMsg = false;
            }
            else
            {
                SmokeMsg = true;
                if (s[18] + s[19] == "01")
                {
                    IsSmokeAlarm = false;
                }
                else
                {
                    IsSmokeAlarm = true;
                }
                if (s[20] + s[21] == "00")
                {
                    IsSmoke_PowerAlarm = false;
                }
                else
                {
                    IsSmoke_PowerAlarm = true;
                }
            }
            #endregion
        }