Exemplo n.º 1
0
        /// <summary>
        /// 处理终端OFF的信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0xFF00(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            // 终端没电关机
            _0xFF00 xff00 = new _0xFF00();

            xff00.Content = obj.MsgContent;
            xff00.Unpackage();
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.Voltage     = "G0000";
                        act.OnlineStyle = (byte)LinkType.OFF;
                        if (xff00.GPSInfo.Available)
                        {
                            act.Latitude   = xff00.GPSInfo.Latitude;
                            act.Longitude  = xff00.GPSInfo.Longitude;
                            act.GpsUpdated = false;
                        }
                    });
                }
            }
            if (xff00.GPSInfo.Available)
            {
                SaveGpsInfo(xff00.GPSInfo, equipment, obj.TerminalID, "Battery OFF" + GetPackageType(obj.ProtocolType));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 处理运转时间消息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x6004(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x6004DX x6004 = new _0x6004DX();

            x6004.Type    = obj.TerminalType;
            x6004.Content = obj.MsgContent;
            x6004.Unpackage();
            HandleEquipmentRuntime(equipment, x6004.TotalWorkTime);
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.Runtime             = equipment.Runtime;
                        act.AccumulativeRuntime = equipment.AccumulativeRuntime;
                        if (obj.TerminalType == Protocol.TerminalTypes.DH || obj.TerminalType == Protocol.TerminalTypes.DX)
                        {
                            // EPOS命令时清空报警  2015/09/24 08:00
                            act.Alarm = ALARM;
                        }
                    });
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理报警信息
        /// </summary>
        /// <param name="obj"></param>
        private void Handle0x2000(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            // 报警
            _0x2000 x2000 = new _0x2000();

            x2000.Content = obj.MsgContent;
            x2000.Unpackage();
            if (null != equipment)
            {
                EquipmentInstance.Update(f => f.id == equipment.id, act =>
                {
                    if (x2000.AlarmBIN[0] == '1')
                    {
                        // Main Power Disconnect
                        act.Voltage = "G0000";
                        // 主电断报警之后进入睡眠状态
                        act.OnlineStyle = (byte)LinkType.SLEEP;
                    }
                    if (x2000.GPSInfo.Available)
                    {
                        act.Latitude   = x2000.GPSInfo.Latitude;
                        act.Longitude  = x2000.GPSInfo.Longitude;
                        act.GpsUpdated = false;
                    }
                });
            }
            if (x2000.GPSInfo.Available)
            {
                SaveGpsInfo(x2000.GPSInfo, equipment, obj.TerminalID, "0x2000");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 发送命令并返回新增命令的id,外部捕获这个id并轮询这条命令的发送状态
        /// </summary>
        /// <param name="Sim">sim卡号码(11位数字,everdigm的sim卡号码后面带三个0,如89001435000)</param>
        /// <param name="Content">命令内容</param>
        /// <param name="sender">命令发送者的ID</param>
        /// <returns>命令记录的id,后续通过这个id查询命令状态</returns>
        private static int SendSMSCommand(TB_Terminal terminal, string Content, int sender)
        {
            string simno = terminal.Sim;

            // 判断Unitel的卡号,前面两位是89,且长度是8位数字
            simno = simno[0] == '8' && simno[1] == '9' ? simno.Substring(0, 8) : simno;
            string ret = SMSUtility.SendSMS(simno, Content);

            using (var bll = new CommandBLL())
            {
                // 查看发送成功与否的状态
                CommandStatus cs = ret.Equals("SUCCESS") ? CommandStatus.SentBySMS : CommandStatus.SentFail;

                // 新建一个命令发送类实体
                TB_Command ct = bll.GetObject();
                simno             = (simno[0] == '8' && simno[1] == '9' && simno.Length < 11) ? (simno + "000") : simno;
                ct.DestinationNo  = simno;
                ct.Status         = (byte)cs;
                ct.Content        = Content;
                ct.ActualSendTime = DateTime.Now;
                ct.Terminal       = terminal.id;
                ct.SendUser       = (0 == sender ? (int?)null : sender);

                var id = bll.Add(ct).id;
                // 保存终端的命令发送条数

                return(id);
            }
        }
Exemplo n.º 5
0
 public TempTerminal(TB_Terminal obj)
 {
     Id        = obj.id;
     Sim       = obj.Sim;
     Number    = obj.Number;
     Satellite = (int?)null == obj.Satellite ? "" : obj.TB_Satellite.CardNo;
 }
Exemplo n.º 6
0
        /// <summary>
        /// 确定打印终端标签
        /// </summary>
        /// <param name="item"></param>
        /// <param name="state"></param>
        private void ConfirmTerminalLabel(TB_Terminal item, byte state)
        {
            string json = format("{0}\"Number\":\"{1}\",\"LabelPrintStatus\":{2}{3}", "{", item.Number, state, "}");
            string url  = ParseUrl(PrintType, CmdPrint, json);

            FetchingHttpRequest(url).ContinueWith((task) => {
                string text = task.Result;
                // 保存打印状态成功
                if (!string.IsNullOrEmpty(text) && text.Contains("\"State\":0"))
                {
                    if (state == (byte)PrintStatus.Handling)
                    {
                        // 如果保存的是正在打印状态则启动打印
                        Task.Factory.StartNew(() => PrintTerminalLabel(item));
                    }
                    else
                    {
                        ConfirmTaskHandleComplete();
                    }
                }
                else
                {
                    //log(format("================ process end of handle \"{0}\" error: {1}\r\n", (PrintStatus)state, text));
                    // 处理错误时,设置进行下一次轮训
                    PerformExitOrContinue();
                }
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// 处理定期报告信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x1001(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x1001 x1001 = new _0x1001();

            x1001.Content = obj.MsgContent;
            x1001.Unpackage();
            if (null != equipment)
            {
                EquipmentInstance.Update(f => f.id == equipment.id, act => {
                    act.Signal = x1001.CSQ_1 > 0 ? x1001.CSQ_1 : (x1001.CSQ_2 > 0 ? x1001.CSQ_2 : byte.MinValue);
                    if (x1001.WorkTime > 0)
                    {
                        act.Runtime = (int)x1001.WorkTime;
                    }
                });
            }

            var pos = GetGpsinfoFrom1001(x1001, true);

            pos.Equipment  = null == equipment ? (int?)null : equipment.id;
            pos.Terminal   = obj.TerminalID;
            pos.StoreTimes = null == equipment ? 0 : equipment.StoreTimes;
            PositionInstance.Add(pos);

            pos            = GetGpsinfoFrom1001(x1001, false);
            pos.Equipment  = null == equipment ? (int?)null : equipment.id;
            pos.Terminal   = obj.TerminalID;
            pos.StoreTimes = null == equipment ? 0 : equipment.StoreTimes;
            PositionInstance.Add(pos);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 处理终端OFF的信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0xFF00(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            // 终端没电关机
            _0xFF00 xff00 = new _0xFF00();

            xff00.Content = obj.MsgContent;
            xff00.Unpackage();
            if (null != equipment)
            {
                EquipmentInstance.Update(f => f.id == equipment.id, act =>
                {
                    act.Voltage     = "G0000";
                    act.OnlineStyle = (byte)LinkType.OFF;
                    if (xff00.GPSInfo.Available)
                    {
                        act.Latitude   = xff00.GPSInfo.Latitude;
                        act.Longitude  = xff00.GPSInfo.Longitude;
                        act.GpsUpdated = false;
                    }
                });
            }
            if (xff00.GPSInfo.Available)
            {
                SaveGpsInfo(xff00.GPSInfo, equipment, obj.TerminalID, "0xFF00");
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 处理命令回复的定位信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x1000(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x1000 x1000 = new _0x1000();

            x1000.Content = obj.MsgContent;
            x1000.Unpackage();
            if (null != equipment)
            {
                if (x1000.GPSInfo.Available)
                {
                    using (var bll = new EquipmentBLL())
                    {
                        bll.Update(f => f.id == equipment.id, act =>
                        {
                            act.Latitude   = x1000.GPSInfo.Latitude;
                            act.Longitude  = x1000.GPSInfo.Longitude;
                            act.GpsUpdated = false;
                        });
                    }
                }
            }
            if (x1000.GPSInfo.Available)
            {
                SaveGpsInfo(x1000.GPSInfo, equipment, obj.TerminalID, "Position command" + GetPackageType(obj.ProtocolType));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 处理设备的开关机信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x5000(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            // 发动机启动/关闭信息
            _0x5000 x5000 = new _0x5000();

            x5000.Content = obj.MsgContent;
            x5000.Unpackage();
            if (null != equipment)
            {
                EquipmentInstance.Update(f => f.id == equipment.id, act =>
                {
                    act.Voltage = string.Format("G{0}", ((int)Math.Floor(x5000.GeneratorVoltage * 10)).ToString("0000"));

                    if (x5000.GPSInfo.Available)
                    {
                        act.Latitude   = x5000.GPSInfo.Latitude;
                        act.Longitude  = x5000.GPSInfo.Longitude;
                        act.GpsUpdated = false;
                    }
                });
            }
            if (x5000.GPSInfo.Available)
            {
                SaveGpsInfo(x5000.GPSInfo, equipment, obj.TerminalID, "0x5000");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 处理装载机的0x600B初始化运转时间的回复
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x600B(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x600B x600B = new _0x600B();

            x600B.Content = obj.MsgContent;
            x600B.Unpackage();
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        // 600B时直接重置所有的运转时间
                        act.Runtime             = (int)x600B.Worktime;
                        act.AccumulativeRuntime = (int)x600B.Worktime;
                        // 装载机的总运转时间初始化时,将其特定的初始化时间设为0
                        if (act.InitializedRuntime > 0)
                        {
                            act.InitializedRuntime = 0;
                        }
                        // 更改运转时间时,同时清空补偿的运转时间  2017/11/24 10:40
                        if (act.CompensatedHours > 0)
                        {
                            act.CompensatedHours = 0;
                        }
                    });
                }
            }
        }
Exemplo n.º 12
0
        private void NewTerminal()
        {
            TB_Terminal t = null;

            // 如果没有输入Sim卡号码则查询是否具有相同终端号码的记录
            if (string.IsNullOrEmpty(txtSimcard.Value.Trim()))
            {
                t = TerminalInstance.Find(f => f.Number.Equals(txtNumber.Value.Trim()) && f.Delete == false);
            }
            else
            {
                // 如果有Sim卡号码输入则查询终端或Sim卡号码是否有相同记录存在
                t = TerminalInstance.Find(f => (f.Number.Equals(txtNumber.Value.Trim()) || f.Sim.Equals(txtSimcard.Value.Trim())) && f.Delete == false);
            }

            if (null != t)
            {
                ShowNotification("./terminal_register.aspx", "Terminal exist: " + TerminalInstance.ToString(t), false);
            }
            else
            {
                t = TerminalInstance.GetObject();
                BuildObject(t);
                TerminalInstance.Add(t);

                SaveHistory(new TB_AccountHistory
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("AddTerminal")).id,
                    ObjectA  = TerminalInstance.ToString(t)
                });

                ShowNotification("./terminal_list.aspx", "You added a new terminal: " + TerminalInstance.ToString(t));
            }
        }
Exemplo n.º 13
0
        private void Handle0x3000(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x3000 x3000 = new _0x3000();

            x3000.Content = obj.MsgContent;
            x3000.Unpackage();
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.LockStatus = CustomConvert.GetHex(x3000.Type);
                        // 存储锁车状态
                        act.LockEffected = (byte)((x3000.Type == 0x40 || x3000.Type == 0x0F || x3000.Type == 0xFF) ? 1 : 0);
                        if (x3000.GPSInfo.Available)
                        {
                            act.Latitude   = x3000.GPSInfo.Latitude;
                            act.Longitude  = x3000.GPSInfo.Longitude;
                            act.GpsUpdated = false;
                        }
                    });
                }
            }
            if (x3000.GPSInfo.Available)
            {
                SaveGpsInfo(x3000.GPSInfo, equipment, obj.TerminalID, ("Security: " + x3000.Flag + GetPackageType(obj.ProtocolType)));
            }
        }
Exemplo n.º 14
0
 private void BuildObject(TB_Terminal obj)
 {
     obj.Number = txtNumber.Value.Trim();
     //obj.Satellite = txtSatellite.Value.Trim();
     obj.Sim  = txtSimcard.Value.Trim();
     obj.Type = byte.Parse(_dx_normal.Checked ? _dx_normal.Value : (_dx.Checked ? _dx.Value : _ld.Value));
 }
Exemplo n.º 15
0
        /// <summary>
        /// 处理定期报告信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x1001(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x1001 x1001 = new _0x1001();

            x1001.Content = obj.MsgContent;
            x1001.Unpackage();
            HandleEquipmentRuntime(equipment, x1001.WorkTime);
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.Signal = (x1001.CSQ_1 > 0 && x1001.CSQ_1 <= 31) ? x1001.CSQ_1 :
                                     ((x1001.CSQ_2 > 0 && x1001.CSQ_2 <= 31) ? x1001.CSQ_2 : byte.MinValue);
                        // 去掉 0x1001 里面的运转时间更新
                        //if (x1001.WorkTime > 0)
                        //{
                        act.AccumulativeRuntime = equipment.AccumulativeRuntime;
                        act.Runtime             = equipment.Runtime;
                        //}
                        // 更新0x1001里的定位信息  2015/09/09 23:29
                        if (x1001.Available_2)
                        {
                            act.Latitude  = x1001.Latitude_2;
                            act.Longitude = x1001.Longitude_2;
                        }
                        else if (x1001.Available_1)
                        {
                            act.Latitude  = x1001.Latitude_1;
                            act.Longitude = x1001.Longitude_1;
                        }
                    });
                }
            }

            using (var posbll = new PositionBLL())
            {
                var pos = GetGpsinfoFrom1001(x1001, true);
                if ((pos.Longitude > 0 && pos.Longitude < 180) && (pos.Latitude > 0 && pos.Latitude < 90))
                {
                    pos.Equipment  = null == equipment ? (int?)null : equipment.id;
                    pos.Terminal   = obj.TerminalID;
                    pos.StoreTimes = null == equipment ? 0 : equipment.StoreTimes;
                    pos.Type       = "Period report" + GetPackageType(obj.ProtocolType);
                    posbll.Add(pos);
                }

                pos = GetGpsinfoFrom1001(x1001, false);
                if ((pos.Longitude > 0 && pos.Longitude < 180) && (pos.Latitude > 0 && pos.Latitude < 90))
                {
                    pos.Equipment  = null == equipment ? (int?)null : equipment.id;
                    pos.Terminal   = obj.TerminalID;
                    pos.StoreTimes = null == equipment ? 0 : equipment.StoreTimes;
                    pos.Type       = "Period report" + GetPackageType(obj.ProtocolType);
                    posbll.Add(pos);
                }
            }
        }
Exemplo n.º 16
0
        private void HandleCommand(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            switch (obj.CommandID)
            {
            case 0x1000:
                Handle0x1000(obj, equipment, terminal);
                break;

            case 0x1001:
                HandleTerminalVersion(obj, terminal);
                Handle0x1001(obj, equipment, terminal);
                break;

            case 0x2000:
                Handle0x2000(obj, equipment, terminal);
                break;

            case 0x5000:
                Handle0x5000(obj, equipment, terminal);
                break;

            case 0x6000: break;

            case 0x6001: break;

            case 0x6004: break;

            case 0x6007:
                Handle0x6007(obj, equipment, terminal);
                break;

            case 0xBB00:
                HandleTerminalVersion(obj, terminal);
                break;

            case 0xBB0F:
                break;

            case 0xCC00:
                HandleTerminalVersion(obj, terminal);
                break;

            case 0xDD00:
                HandleTerminalVersion(obj, terminal);
                break;

            case 0xDD02:
                break;

            case 0xEE00:
                HandleTerminalVersion(obj, terminal);
                break;

            case 0xFF00:
                Handle0xFF00(obj, equipment, terminal);
                break;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 处理设备的开关机信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x5000(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            // 发动机启动/关闭信息
            _0x5000 x5000 = new _0x5000();

            x5000.Type    = obj.TerminalType;
            x5000.Content = obj.MsgContent;
            x5000.Unpackage();
            HandleEquipmentRuntime(equipment, x5000.WorkTime);
            if (null != equipment)
            {
                string vol = format("G{0}0", ((int)Math.Floor(x5000.GeneratorVoltage * 10)).ToString("000"));
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.Voltage = vol;
                        if (x5000.GeneratorVoltage > 20.0)
                        {
                            // 开机的时候清空报警信息  2015/09/24 08:00
                            act.Alarm = ALARM;
                        }

                        if (x5000.GeneratorVoltage < 20)
                        {
                            act.Rpm = 0;
                        }

                        act.Runtime             = equipment.Runtime;
                        act.AccumulativeRuntime = equipment.AccumulativeRuntime;
                        //if (x5000.WorkTime > 0)
                        //{
                        //    // 如果总运转时间大于等于当前服务器中保存的时间则更新,否则不更新
                        //    if (x5000.WorkTime >= act.Runtime)
                        //    {
                        //        act.Runtime = (int)x5000.WorkTime;
                        //    }
                        //}
                        if (x5000.GPSInfo.Available)
                        {
                            act.Latitude   = x5000.GPSInfo.Latitude;
                            act.Longitude  = x5000.GPSInfo.Longitude;
                            act.GpsUpdated = false;
                        }
                    });
                }
            }
            if (x5000.GPSInfo.Available)
            {
                SaveGpsInfo(x5000.GPSInfo, equipment, obj.TerminalID, "Eng.: " + x5000.State + GetPackageType(obj.ProtocolType));
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// 发送命令
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="sms"></param>
 /// <returns></returns>
 private string SendCommand(TB_Terminal obj, bool sms)
 {
     if (null == User)
     {
         return(ResponseMessage(-1, "Your session was expired, please try to login again."));
     }
     else
     {
         var extra = GetParamenter("param");
         var id    = CommandUtility.SendCommand(obj, cmd, sms, User.id, extra);
         return(ResponseMessage(0, id.ToString()));
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// 处理保安命令
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x6007(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x6007 x6007 = new _0x6007();

            x6007.Content = obj.MsgContent;
            x6007.Unpackage();
            if (null != equipment)
            {
                EquipmentInstance.Update(f => f.id == equipment.id, act => {
                    act.LockStatus = CustomConvert.GetHex(x6007.Code);
                });
            }
        }
Exemplo n.º 20
0
        private void HandlerTerminalLabel(string json)
        {
            TB_Terminal obj = JsonConvert.ToObject <TB_Terminal>(json);

            if (null != obj && obj.id > 0)
            {
                Task.Factory.StartNew(() => ConfirmTerminalLabel(obj, (byte)PrintStatus.Handling));
            }
            else
            {
                PerformExitOrContinue();
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// 更新终端的信息
 /// </summary>
 /// <param name="obj"></param>
 protected void Update(TB_Terminal obj)
 {
     TerminalInstance.Update(f => f.id == obj.id, act =>
     {
         act.Delete    = obj.Delete;
         act.Firmware  = obj.Firmware;
         act.HasBound  = obj.HasBound;
         act.Number    = obj.Number;
         act.Revision  = obj.Revision;
         act.Satellite = obj.Satellite;
         act.Sim       = obj.Sim;
         act.Type      = obj.Type;
     });
 }
Exemplo n.º 22
0
 /// <summary>
 /// 打印终端终端标签
 /// </summary>
 private void PrintTerminalLabel(TB_Terminal item)
 {
     if (frmThis.InvokeRequired)
     {
         frmThis.Invoke(new Action(() =>
         {
             PrintTerminalLabelDirectly(item);
         }));
     }
     else
     {
         PrintTerminalLabelDirectly(item);
     }
 }
Exemplo n.º 23
0
        private string GetEquipment(TB_Terminal terminal, TB_Equipment equipment)
        {
            if (null == equipment)
            {
                return("<a href=\"./equipment_terminal.aspx?key=" + Utility.UrlEncode(Utility.Encrypt(terminal.id.ToString())) + "\">bind</a>");
            }

            if (string.IsNullOrEmpty(terminal.Sim))
            {
                return("no sim card");
            }

            return("<a href=\"#unbind_" + terminal.id + "\">" + EquipmentInstance.GetFullNumber(equipment) + "</a>");
        }
Exemplo n.º 24
0
        /// <summary>
        /// 处理EE00命令
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0xEE00(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0xEE00 xee00 = new _0xEE00();

            xee00.Content = obj.MsgContent;
            xee00.Unpackage();
            // 更新终端发送命令的结果
            if (null != equipment && xee00.ErrorCommand.Equals("0x6007"))
            {
                // 更新锁车状态
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.LockStatus = xee00.ErrorParamenter;
                    });
                }
            }
            // 更新命令的发送状态
            using (var bll = new CommandBLL())
            {
                bll.Update(f => f.DestinationNo == obj.TerminalID &&
                           f.Command == xee00.ErrorCommand &&
                           f.ScheduleTime >= DateTime.Now.AddMinutes(-3) &&
                           f.Status >= (byte)CommandStatus.SentByTCP &&
                           f.Status <= (byte)CommandStatus.SentToDest, act =>
                {
                    byte b = 0x10;
                    switch (xee00.Error)
                    {
                    case 0x20:
                        b = (byte)CommandStatus.EposFail;
                        break;

                    case 0x30:
                        b = (byte)CommandStatus.EngNotStart;
                        break;

                    default:
                        b = (byte)CommandStatus.NoFunction;
                        break;
                    }
                    act.Status = b;
                });
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// 处理DD00命令
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0xDD00(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0xDD00 xdd00 = new _0xDD00();

            xdd00.Content = obj.MsgContent;
            xdd00.Unpackage();
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act => { act.Signal = xdd00.CSQ; });
                }
            }
            //if (null != terminal)
            //{
            //    TerminalInstance.Update(f => f.id == terminal.id, act => { act.Firmware = xdd00.Firmware; });
            //}
        }
Exemplo n.º 26
0
        /// <summary>
        /// 处理仪表盘数据
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0x6000(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0x6000 x6000 = new _0x6000();

            x6000.Content = obj.MsgContent;
            x6000.Unpackage();
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.Rpm = (short)x6000.RPM;
                        // EPOS命令时清空报警  2015/09/24 08:00
                        act.Alarm = ALARM;
                    });
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 处理终端版本的信息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="terminal"></param>
        private void HandleTerminalVersion(TX300 obj, TB_Terminal terminal)
        {
            // 处理终端版本信息
            byte[] version = new byte[7];
            byte   rev     = 0;

            if (obj.CommandID == 0xDD00)
            {
                Buffer.BlockCopy(obj.MsgContent, 1, version, 0, 7);
            }
            else if (obj.CommandID == 0x1001)
            {
                Buffer.BlockCopy(obj.MsgContent, 25, version, 0, 7);
                // revision
                rev = obj.MsgContent[32];
            }
            else
            {
                Buffer.BlockCopy(obj.MsgContent, 0, version, 0, 7);
            }
            string ver = Encoding.ASCII.GetString(version);

            version = null;
            if (obj.CommandID == 0xBB00)
            {
                // revision
                string s = Encoding.ASCII.GetString(obj.MsgContent, 7, 2);
                rev = byte.Parse(s);
            }
            using (var bll = new TerminalBLL())
            {
                bll.Update(f => f.id == terminal.id, act =>
                {
                    act.Firmware = ver;
                    if (rev > 0)
                    {
                        act.Revision = rev;
                    }
                });
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// 处理DD02卫星功能命令
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0xDD02(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0xDD02 xdd02 = new _0xDD02();

            xdd02.Content = obj.MsgContent;
            xdd02.Unpackage();
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act => { act.SatelliteStatus = xdd02.Status; });
                }
            }
            if (null != terminal)
            {
                using (var bll = new TerminalBLL())
                {
                    bll.Update(f => f.id == terminal.id, act => { act.SatelliteStatus = xdd02.Status; });
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 处理报警信息
        /// </summary>
        /// <param name="obj"></param>
        private void Handle0x2000(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            // 报警
            _0x2000 x2000 = new _0x2000();

            x2000.Content = obj.MsgContent;
            x2000.Unpackage();
            if (null != equipment)
            {
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        if (x2000.AlarmBIN[0] == '1')
                        {
                            // Main Power Disconnect
                            act.Voltage = "G0000";
                            // 主电断报警之后进入睡眠状态
                            act.OnlineStyle = (byte)LinkType.SLEEP;
                        }
                        // 同时更新设备的报警状态  2015/09/10 14:02
                        act.Alarm = x2000.AlarmBIN;
                        if (x2000.GPSInfo.Available)
                        {
                            act.Latitude   = x2000.GPSInfo.Latitude;
                            act.Longitude  = x2000.GPSInfo.Longitude;
                            act.GpsUpdated = false;
                        }
                    });
                }
            }
            long gps = -1;

            if (x2000.GPSInfo.Available)
            {
                gps = SaveGpsInfo(x2000.GPSInfo, equipment, obj.TerminalID, "Alarm report" + GetPackageType(obj.ProtocolType));
            }
            // 保存报警信息
            SaveAlarm(equipment, obj.TerminalID, gps, x2000.AlarmBIN);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 打印终端标签
        /// </summary>
        /// <param name="item"></param>
        private void PrintTerminalLabelDirectly(TB_Terminal item)
        {
            DisableButtons(true);
            try
            {
                try
                {
                    NameValueCollection nvc = ConfigurationManager.AppSettings;
                    TscLib.openport(nvc["PrinterName"]);
                    TscLib.clearbuffer();
                    //宽度mm,高度mm,速度,浓度,感应器,间距mm,偏移量mm
                    TscLib.setup(nvc["LabelWidth"], nvc["LabelHeight"], "2", "10", "0", "3", "0");
                    TscLib.windowsfont(int.Parse(nvc["TerminalProductNo_x"]), int.Parse(nvc["TerminalProductNo_y"]), 25, 180, 0, 0, "Arial", nvc["TerminalProductNo"]);
                    TscLib.windowsfont(int.Parse(nvc["TerminalModel_x"]), int.Parse(nvc["TerminalModel_y"]), 25, 180, 0, 0, "Arial", nvc["TerminalModel"]);
                    TscLib.windowsfont(int.Parse(nvc["TerminalNumber_x"]), int.Parse(nvc["TerminalNumber_y"]), 25, 180, 0, 0, "Arial", item.Number);
                    TscLib.windowsfont(int.Parse(nvc["TerminalSimCard_x"]), int.Parse(nvc["TerminalSimCard_y"]), 25, 180, 0, 0, "Arial", item.Sim);
                    TscLib.windowsfont(int.Parse(nvc["TerminalMFD_x"]), int.Parse(nvc["TerminalMFD_y"]), 25, 180, 0, 0, "Arial", item.ProductionDate.Value.ToString("yyyy/MM/dd"));
                    TscLib.windowsfont(int.Parse(nvc["TerminalRV_x"]), int.Parse(nvc["TerminalRV_y"]), 25, 180, 0, 0, "Arial", nvc["TerminalRV"]);
                    TscLib.windowsfont(int.Parse(nvc["TerminalMF_x"]), int.Parse(nvc["TerminalMF_y"]), 25, 180, 0, 0, "Arial", nvc["TerminalMF"]);
                    // 条形码
                    TscLib.barcode(nvc["TerminalBAR_x"], nvc["TerminalBAR_x"], "128", "40", "0", "0", "4", "1", item.Number);
                    // 打印
                    TscLib.printlabel("1", "1");
                    Win32.TimeDelay(TIMER_INTEVAL);

                    // 打印完毕通知服务器保存已打印的状态
                    Task.Factory.StartNew(() => ConfirmTerminalLabel(item, (byte)PrintStatus.Printed));
                }
                finally
                {
                    TscLib.closeport();
                }
            }
            catch (Exception e)
            {
                log(string.Format("Print terminal label error: {0}, StackTrace: {1}", e.Message, e.StackTrace));
                PerformExitOrContinue();
            }
            DisableButtons(false);
        }