Exemplo n.º 1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ESMonitor.Model.TaskNotice model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ESMonitor.Model.TaskNotice model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 3
0
        public override bool ProcessCommand(byte[] buffer, int offset, int packetLen)//packetLen是总的数据长度
        {
            var res = _responseCmd.DecodeFrame(buffer, packetLen);

            if (!res)
            {
                return(false);
            }

            var devId = DevsManage.GetDevId(_responseCmd.NodeId);

            if (devId <= 0)
            {
                return(false);
            }

            //Check command
            switch ((ProtocolCmdType)_responseCmd.CmdType)
            {
            case ProtocolCmdType.SysComm:
                if (_responseCmd.CmdByte == (Byte)ProtocolCmdByte.HeartBeat)
                {
                    if (!DevsManage.IsRegistered(devId))
                    {
                        DevsManage.Register(devId);    //注册
                        DevsManage.SetDevStatus(devId, (int)CommStatus.Free);
                        EsProtocolMgr.Add(devId, this);
                        AdjustTime();
                    }
                    else
                    {
                        if (!EsProtocolMgr.IsSocketConect(devId, this))
                        {
                            EsProtocolMgr.Add(devId, this);    //此处顺序有问题
                        }
                    }

                    DevsManage.SetTimeOutCount(devId, 3);

                    //更新心跳时间
                    DevsManage.UpdateHeartBeatTime(devId);

                    DoHeartBeat();
                }
                break;

            case ProtocolCmdType.ModuleCfg:
                break;

            case ProtocolCmdType.ModuleCtrl:
                if (_responseCmd.CmdByte == (byte)ProtocolCmdByte.GetGpsInfo)
                {
                    DevsManage.UpdateRecvTime(devId);
                    AddTaskResponse(devId, buffer, packetLen);
                }
                break;

            case ProtocolCmdType.DevCtrl:
                break;

            case ProtocolCmdType.DevResponse:
                if (_responseCmd.CmdByte == (Byte)ProtocolCmdByte.AutoUploadAllEsParams)
                {
                    var esParams = new EsData();

                    if (_responseCmd.DecodeAutoUploadEsParamsCmd(ref esParams))
                    {
                        var dataId = AddEsMin(devId, esParams);
                        var model  = new ESMonitor.Model.TaskNotice();
                        try
                        {
                            model.DevId      = devId;
                            model.Data       = buffer;
                            model.Length     = packetLen;
                            model.TaskId     = dataId;
                            model.UpdateTime = DateTime.Now;
                            _tnBll.Add(model);
                        }
                        catch (Exception ex)
                        {
                            Program.Logger.ErrorFormat("保存TaskNotice错误: {0},ESMIN_ID{1},TaskNoticeID{2}", ex.Message, dataId, model.TaskId);
                            Program.Logger.Error(ex.StackTrace);
                        }
                        DevsManage.UpdateAutoUploadTime(devId);
                    }
                }
                else
                {
                    DevsManage.UpdateRecvTime(devId);
                    AddTaskResponse(devId, buffer, packetLen);
                }
                break;

            case ProtocolCmdType.DevStatus:
                if (_responseCmd.CmdByte == (byte)ProtocolCmdByte.GetGpsInfo)
                {
                    DevsManage.UpdateRecvTime(devId);
                    UpdateDevGps(_responseCmd, devId);
                }
                break;
            }

            return(true);
        }