Exemple #1
0
        /// <summary>
        /// 获取记录操作函数
        /// </summary>
        /// <param name="data"></param>
        private static void OperationRecordHandler(byte[] data)
        {
            if (data[3] == 2)//0x02
            {
                switch (data[5])
                {
                case 2:    //0x02
                    //RecordLog.GetInstance().WriteLog(Level.Info, "操作错误.");
                    break;

                case 3:    //0x03
                    RecordLog.GetInstance().WriteLog(Level.Info, "所有开门事件记录已经上报.");
                    return;

                case 4:    //0x04
                    RecordLog.GetInstance().WriteLog(Level.Info, "所有操作记录等非开门事件已经上报.");
                    return;

                default:
                    return;
                }
            }
            else
            {
                BleProtocol.Record = new OperationRecord();
                int year   = BleProtocol.Bcd2Int(data[10]);
                int month  = BleProtocol.Bcd2Int(data[9]);
                int day    = BleProtocol.Bcd2Int(data[8]);
                int hour   = BleProtocol.Bcd2Int(data[7]);
                int minute = BleProtocol.Bcd2Int(data[6]);
                int second = BleProtocol.Bcd2Int(data[5]);
                BleProtocol.Record.Date = new DateTime(2000 + year, month, day, hour, minute, second); // 日期
                //BleProtocol.Record.UserId = (int)data[11] + ((int)data[12] << 8); //id
                BleProtocol.Record.UserId        = (int)data[11];                                      //id
                BleProtocol.Record.OperationType = (int)data[12] + (int)data[13];                      //机械操作方式
                BleProtocol.Record.UserType      = (int)data[14] + (int)data[15];                      //开锁方式
                EventClass.GetInstance()._battery = (int)data[16];
            }
        }
Exemple #2
0
        /// <summary>
        /// 读取报警记录函数
        /// </summary>
        /// <param name="data"></param>
        private static void WarningRecordHandler(byte[] data)
        {
            if (data[3] == 2)//0x02
            {
                switch (data[5])
                {
                case 2:    //0x02
                    //RecordLog.GetInstance().WriteLog(Level.Info, "操作错误.");
                    break;

                case 3:    //0x03
                    RecordLog.GetInstance().WriteLog(Level.Info, "开门报警事件全部上报.");
                    return;

                case 4:    //0x04
                    RecordLog.GetInstance().WriteLog(Level.Info, "配置等其他报警事件已上报.");
                    return;

                default:
                    return;
                }
            }
            else
            {
                BleProtocol.warningRecord = new WarningRecord();
                int year   = BleProtocol.Bcd2Int(data[10]);
                int month  = BleProtocol.Bcd2Int(data[9]);
                int day    = BleProtocol.Bcd2Int(data[8]);
                int hour   = BleProtocol.Bcd2Int(data[7]);
                int minute = BleProtocol.Bcd2Int(data[6]);
                int second = BleProtocol.Bcd2Int(data[5]);
                BleProtocol.warningRecord.Date          = new DateTime(2000 + year, month, day, hour, minute, second);
                BleProtocol.warningRecord.WarningType   = (int)data[11];
                BleProtocol.warningRecord.WarningStatus = (int)data[12];
            }
        }