public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag0, CasicSession session)
        {
            SensorException0Tag sensorException0 = tag as SensorException0Tag;
            String state = sensorException0.state;
            int    type  = getPduType(devCode);//获取设备类型

            //todo list:根据设备类型来进行存储

            switch (type)
            {
            case 7:
                //液位监测仪 探测0
                new BLL.DjLiquid().setDeviceStatus(devCode, state);
                break;

            case 2:
                //噪声记录仪
                new BLL.SlNoise().setDeviceStatus(devCode, state);
                break;

            default:
                break;
            }
        }
Пример #2
0
        //0000 0071 前四个字节暂时不用
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:解析井盖传感器数据并保存
            UploadTag wellTag    = tag as UploadTag;
            int       itv        = wellTag.CollectInter;
            String    collecTime = wellTag.CollectTime;
            int       len        = wellTag.Len;
            String    dataValue  = wellTag.DataValue;

            session.Logger.Info("井盖数据上传TAG:oid:" + wellTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);

            int num = len / 1; //上传的井盖数据个数
            List <Model.WellSensorInfo> djs = new List <WellSensorInfo>();

            //井盖数据tag之前,无系统日期tag数据
            // DateTime baseTime = Convert.ToDateTime(CasicCmd.currentSystemDate + " " + collecTime);
            for (int i = 0; i < num; i++)
            {
                //上传的有状态数据、设备ID、可能有电池电量等数据
                WellSensorInfo wellInfo = new WellSensorInfo();
                wellInfo.DEVID   = devCode;
                wellInfo.LOGTIME = DateTime.Now;
                byte   btStatus = byte.Parse(dataValue, System.Globalization.NumberStyles.HexNumber);
                string descn    = "";
                switch (btStatus)
                {
                case 0:
                    descn = "状态正常";
                    new BLL.WellInfo().saveDeviceStatus(wellInfo.DEVID, WellAlarmEnum.NORMAL);
                    break;

                case 1:
                    descn = "井盖开启";
                    saveWellAlarm(wellInfo.DEVID, session);
                    break;

                case 2:
                    descn = "时钟故障";
                    new BLL.WellInfo().saveDeviceStatus(wellInfo.DEVID, WellAlarmEnum.SYS_ERROR);
                    break;

                case 3:
                    descn = "低电压";
                    new BLL.WellInfo().saveDeviceStatus(wellInfo.DEVID, WellAlarmEnum.BATTERY_LOW);
                    break;

                default:
                    descn = "未知状态";
                    break;
                }
                wellInfo.DESCN  = descn;
                wellInfo.STATUS = btStatus + "";
                djs.Add(wellInfo);
            }
            new BLL.WellInfo().insert(djs);
            session.Logger.Info("井盖数据保存成功");
        }
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            SystemTimeTag sysTag = tag as SystemTimeTag;

            session.Logger.Info("系统时间TAG:oid:" + sysTag.Oid +
                                "系统时间:" + sysTag.SysTime);
        }
Пример #4
0
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag0, CasicSession session)
        {
            //更新系统日期
            SystemDateTag systemDateTag = tag as SystemDateTag;

            //CasicCmd.currentSystemDate = systemDateTag.CollectDate;

            session.Logger.Info("系统日期TAG:oid:" + systemDateTag.Oid +
                                "系统日期:" + systemDateTag.CollectDate);
        }
Пример #5
0
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:解析腐蚀速率数据,保存腐蚀速率

            UploadTag fsslTag    = tag as UploadTag;
            int       itv        = fsslTag.CollectInter;
            String    collecTime = fsslTag.CollectTime;
            int       len        = fsslTag.Len;
            String    dataValue  = fsslTag.DataValue;

            session.Logger.Info("腐蚀速率数据上传TAG:oid:" + fsslTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);

            int num = len / 20; //上传的腐蚀速率的组数,1组5个数据,1个数据4个字节

            /*
             * 开路电位OCP:单位V
             * 溶液电阻Rs:单位Ω.cm2
             * 极化电阻Rp:单位Ω.cm2
             * 腐蚀电流密度Icorr:单位mA/cm2
             * 腐蚀速率Vcorr:单位mm/a
             * */
            List <Model.AKFSSLInfo> djs = new List <Model.AKFSSLInfo>();

            DateTime baseTime = Convert.ToDateTime(systemDateTag.CollectDate + " " + collecTime);

            for (int i = 0; i < num; i++)
            {
                Model.AKFSSLInfo fssl           = new Model.AKFSSLInfo();
                String           openCircultVol = strHexToFloat(dataValue.Substring(i * 40, 8)).ToString("f4");
                String           ryResist       = strHexToFloat(dataValue.Substring(i * 40 + 8, 8)).ToString("f4");
                String           jhResist       = strHexToFloat(dataValue.Substring(i * 40 + 16, 8)).ToString("f4");
                String           concurDen      = strHexToFloat(dataValue.Substring(i * 40 + 24, 8)).ToString("f4");
                String           errosionRate   = strHexToFloat(dataValue.Substring(i * 40 + 32, 8)).ToString("f4");

                fssl.Cell        = (cellTag == null ? "" : cellTag.Cell);
                fssl.OpenCir     = openCircultVol;
                fssl.RyResist    = ryResist;
                fssl.JhResist    = jhResist;
                fssl.CurrentDen  = concurDen;
                fssl.ErrosionRat = errosionRate;
                fssl.LogTime     = DateTime.Now;
                fssl.UpTime      = baseTime.AddMinutes(i * itv);
                fssl.DEVCODE     = devCode;
                djs.Add(fssl);
            }
            new BLL.AKFSSL().insert(djs);
            new BLL.AKFSSL().saveAlarmInfo(djs);
            //  new BLL.DjLiquid().updateDevStatus(CasicCmd.devCode);
            session.Logger.Info("腐蚀速率数据保存成功");
        }
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:处理对应的心跳上传数据
            UploadTag heartBeatTag = tag as UploadTag;
            int       itv          = heartBeatTag.CollectInter;
            String    collecTime   = heartBeatTag.CollectTime;
            int       len          = heartBeatTag.Len;
            String    dataValue    = heartBeatTag.DataValue;

            session.Logger.Info("心跳上传TAG:oid:" + heartBeatTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);
        }
Пример #7
0
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            WakeUpTag wakeUpTag = tag as WakeUpTag;

            if (session.devMaps.ContainsKey(devCode))
            {
                CasicSession.DeviceDTO dev = session.devMaps[devCode];

                byte flag = byte.Parse(wakeUpTag.DataValue, System.Globalization.NumberStyles.HexNumber);

                dev.IsWakeUp             = flag == 0?true:false; //上传0代表已经唤醒
                session.devMaps[devCode] = dev;
                session.Logger.Info("设备唤醒" + devCode);

                session.Logger.Info("唤醒TAG:oid:" + wakeUpTag.Oid +
                                    "唤醒状态:" + wakeUpTag.IsWAkeUp);
            }
        }
Пример #8
0
        //0000 0071 前四个字节暂时不用
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:解析流量数据保存流量数据
            UploadTag noiseTag   = tag as UploadTag;
            int       itv        = noiseTag.CollectInter;
            String    collecTime = noiseTag.CollectTime;
            int       len        = noiseTag.Len;
            String    dataValue  = noiseTag.DataValue;

            session.Logger.Info("噪声数据上传TAG:oid:" + noiseTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);

            int num = len / 4; //上传的流量数据个数,修改未2个字节//yxw修改为4个字节,加频率
            List <Model.SlNoiseInfo> djs = new List <SlNoiseInfo>();

            DateTime baseTime = Convert.ToDateTime(systemDateTag.CollectDate + " " + collecTime);

            for (int i = 0; i < num; i++)
            {
                // DjNoiseInfo noiseInfo = new DjNoiseInfo();
                SlNoiseInfo slNoiseInfo = new SlNoiseInfo();
                //TODO LIST:密集开始时间、密集间隔、密集样本数、无线开启时间、
                //无线关闭时间、密集噪声、电池电量
                slNoiseInfo.CELL    = (cellTag == null ? "" : cellTag.Cell);
                slNoiseInfo.LOGTIME = DateTime.Now;
                slNoiseInfo.UPTIME  = baseTime.AddMinutes(i * itv);
                slNoiseInfo.SRCID   = devCode;
                slNoiseInfo.DSTID   = "FFFF";
                String dStr      = dataValue.Substring(i * 8 + 0, 4);
                String frequency = dataValue.Substring(i * 8 + 4, 4);

                slNoiseInfo.DENSEDATA = int.Parse(dStr.Substring(0, 2) + dStr.Substring(2, 2), System.Globalization.NumberStyles.HexNumber).ToString();
                slNoiseInfo.FREQUENCY = int.Parse(frequency.Substring(0, 2) + frequency.Substring(2, 2), System.Globalization.NumberStyles.HexNumber).ToString();
                djs.Add(slNoiseInfo);
            }
            new BLL.SlNoise().insert(djs);
            new BLL.SlNoise().SaveZZAlarmInfo(djs);
            new BLL.SlNoise().updateDevStatus(devCode);

            session.Logger.Info("噪声数据保存成功");
        }
        //TODO LIST:默认打印出来未处理的tag信息
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            switch (tag.Oid)
            {
            case "10000022":
                //TODO LIST:处理ip的逻辑
                String ad_ip = getInfoFromStrEncoding(tag);
                session.Logger.Info("服务器IP TAG" + " oid:" + tag.Oid + " len:" + tag.Len + " value:" + tag.DataValue + " IP:" + ad_ip);
                break;

            case "10000023":
                //TODO LIST:处理端口的逻
                String ad_port = getInfoFromStrEncoding(tag);
                session.Logger.Info("服务器端口 TAG" + " oid:" + tag.Oid + " len:" + tag.Len + " value" + tag.DataValue + " PORT:" + ad_port);
                break;

            default:
                session.Logger.Info("未处理TAG" + " oid:" + tag.Oid + " len:" + tag.Len + " value:" + tag.DataValue);
                break;
            }
        }
Пример #10
0
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:解析压力数据保存压力数据
            UploadTag rqTag      = tag as UploadTag;
            int       itv        = rqTag.CollectInter;
            String    collecTime = rqTag.CollectTime;
            int       len        = rqTag.Len;
            String    dataValue  = rqTag.DataValue;

            session.Logger.Info("燃气数据上传TAG:oid:" + rqTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);

            int num = len / 4; //上传的燃气数据个数
            List <Model.RQPeriodInfo> rqs = new List <Model.RQPeriodInfo>();

            DateTime baseTime = Convert.ToDateTime(systemDateTag.CollectDate + " " + collecTime);

            for (int i = 0; i < num; i++)
            {
                String density = strHexToFloat(dataValue.Substring(i * 8, 8)).ToString();

                Model.RQPeriodInfo rq = new Model.RQPeriodInfo();
                rq.ADDRESS     = devCode;
                rq.INPRESS     = "0";
                rq.OUTPRESS    = "0";
                rq.FLOW        = "0";
                rq.STRENGTH    = density;
                rq.TEMPERATURE = "0";
                rq.CELL        = (cellTag == null ? "" : cellTag.Cell);
                rq.UPTIME      = baseTime.AddMinutes(i * itv);
                rq.LOGTIME     = DateTime.Now;
                rqs.Add(rq);
            }
            BLL.RQPeriod bll = new BLL.RQPeriod();
            bll.insert(rqs);
            bll.saveAlarmInfo(rqs);
            session.Logger.Info("燃气数据保存成功");
        }
Пример #11
0
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:解析压力数据保存压力数据
            UploadTag pressTag   = tag as UploadTag;
            int       itv        = pressTag.CollectInter;
            String    collecTime = pressTag.CollectTime;
            int       len        = pressTag.Len;
            String    dataValue  = pressTag.DataValue;

            session.Logger.Info("压力数据上传TAG:oid:" + pressTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);

            int num = len / 4; //上传的液位数据个数
            //List<Model.CasicPress> djs = new List<Model.CasicPress>();
            List <Model.DjPressInfo> djs = new List <Model.DjPressInfo>();

            DateTime baseTime = Convert.ToDateTime(systemDateTag.CollectDate + " " + collecTime);

            for (int i = 0; i < num; i++)
            {
                DjPressInfo pressInfo = new DjPressInfo();
                String      press     = strHexToFloat(dataValue.Substring(i * 8, 8)).ToString();

                //TODO LIST:电池电量
                pressInfo.CELL      = (cellTag == null ? "" : cellTag.Cell);
                pressInfo.PRESSDATA = press;
                pressInfo.LOGTIME   = DateTime.Now;
                pressInfo.UPTIME    = baseTime.AddMinutes(i * itv);
                pressInfo.DEVID     = devCode;

                djs.Add(pressInfo);
            }

            new BLL.DjPress().insert(djs);
            //new BLL.DjPress().saveAlarmInfo(djs);
            new BLL.DjPress().updateDevStatus(devCode);
            session.Logger.Info("压力数据保存成功");
        }
Пример #12
0
        public static Tag create(String oid, int len, String value)
        {
            Tag tag;

            if (UploadTag.isUploadTag(oid))
            {
                tag = new UploadTag(oid, len, value);
            }
            else if (oid == SystemDateTag.SYSTEM_DATE_OID)
            {
                tag = new SystemDateTag(oid, len, value);
            }
            else if (oid == SystemTimeTag.SYSTEM_TIME_OID)
            {
                tag = new SystemTimeTag(oid, len, value);
            }
            else if (oid == WakeUpTag.WAKEUP_TAG_OID)
            {
                tag = new WakeUpTag(oid, len, value);
            }
            else if (oid == CellTag.CELL_TAG_OID)
            {
                tag = new CellTag(oid, len, value);
            }
            else if (oid == SensorException0Tag.SENSOR_EXCEP0_TAG_OID)
            {
                tag = new SensorException0Tag(oid, len, value);
            }
            else if (oid == SensorException1Tag.SENSOR_EXCEP1_TAG_OID)
            {
                tag = new SensorException1Tag(oid, len, value);
            }
            else
            {
                tag = new NormalTag(oid, len, value);
            }
            return(tag);
        }
Пример #13
0
 public void handleTag(Tag tag, String devCode, CellTag cellTag,
                       SystemDateTag systemDateTag, CasicSession session)
 {
     if (this.isThisTag(tag))
     {
         //处理当前逻辑
         this.execute(tag, devCode, cellTag, systemDateTag, session);
     }
     else
     {
         if (nextHandler != null)
         {
             nextHandler.handleTag(tag, devCode, cellTag, systemDateTag,
                                   session);
         }
         else
         {
             //TODO LIST:用默认的TagHandler来处理
             nextHandler = new DefaultTagHandler();
             nextHandler.execute(tag, devCode, cellTag, systemDateTag,
                                 session);
         }
     }
 }
Пример #14
0
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:解析水表数据,保存水表欧数据
            UploadTag tempTag    = tag as UploadTag;
            int       itv        = tempTag.CollectInter;
            String    collecTime = tempTag.CollectTime;
            int       len        = tempTag.Len;
            String    dataValue  = tempTag.DataValue;

            session.Logger.Info("水表数据上传TAG:oid:" + tempTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);

            int num = len / 4; //上传的温度数据个数
            List <Model.CasicWaterMeter> djs = new List <Model.CasicWaterMeter>();

            DateTime baseTime = Convert.ToDateTime(systemDateTag.CollectDate + " " + collecTime);

            for (int i = 0; i < num; i++)
            {
                Model.CasicWaterMeter tempInfo = new CasicWaterMeter();
                String temp = strHexToInt32(dataValue.Substring(i * 8, 8)).ToString();

                //TODO LIST:电池电量
                tempInfo.Cell    = (cellTag == null ? "" : cellTag.Cell);
                tempInfo.Data    = temp;
                tempInfo.LogTime = DateTime.Now;
                tempInfo.UpTime  = baseTime.AddMinutes(i * itv);
                tempInfo.DEVCODE = devCode;
                djs.Add(tempInfo);
            }
            new BLL.CasicWaterMeter().insert(djs);
            new BLL.CasicWaterMeter().saveAlarmInfo(djs);
            new BLL.CasicWaterMeter().updateDevStatus(devCode);
            session.Logger.Info("水表数据保存成功");
        }
Пример #15
0
        public override void execute(Tag tag, String devCode, CellTag cellTag,
                                     SystemDateTag systemDateTag, CasicSession session)
        {
            //TODO LIST:解析腐蚀环境数据,保存腐蚀环境数据
            UploadTag fshjTag    = tag as UploadTag;
            int       itv        = fshjTag.CollectInter;
            String    collecTime = fshjTag.CollectTime;
            int       len        = fshjTag.Len;
            String    dataValue  = fshjTag.DataValue;

            session.Logger.Info("腐蚀环境数据上传TAG:oid:" + fshjTag.Oid + " 采集间隔: " +
                                itv + "采集时间:" + collecTime + "上传数值:" + dataValue);

            int num = len / (2 * 16); //上传的数据组数,1组16个数据,每个数据4个字节
            List <Model.AKFSHJInfo> djs = new List <Model.AKFSHJInfo>();

            DateTime baseTime = Convert.ToDateTime(systemDateTag.CollectDate + " " + collecTime);

            for (int i = 0; i < num; i++)
            {
                Model.AKFSHJInfo fshjInfo = new  Model.AKFSHJInfo();

                String underVol1 = strHexToInt(dataValue.Substring(i * 64, 4)).ToString();
                String underVol2 = strHexToInt(dataValue.Substring(i * 64 + 4, 4)).ToString();
                String underVol3 = strHexToInt(dataValue.Substring(i * 64 + 8, 4)).ToString();
                String underVol4 = strHexToInt(dataValue.Substring(i * 64 + 12, 4)).ToString();
                String underVol5 = strHexToInt(dataValue.Substring(i * 64 + 16, 4)).ToString();
                String underVol6 = strHexToInt(dataValue.Substring(i * 64 + 20, 4)).ToString();


                String under_temp1  = (strHexToInt(dataValue.Substring(i * 64 + 24, 4)) / 10.0).ToString();
                String under_temp2  = (strHexToInt(dataValue.Substring(i * 64 + 28, 4)) / 10.0).ToString();
                String outter_temp1 = (strHexToInt(dataValue.Substring(i * 64 + 32, 4)) / 10.0).ToString();
                String outter_temp2 = (strHexToInt(dataValue.Substring(i * 64 + 36, 4)) / 10.0).ToString();

                String underWater1 = strHexToInt(dataValue.Substring(i * 64 + 40, 4)).ToString();
                String underWater2 = strHexToInt(dataValue.Substring(i * 64 + 44, 4)).ToString();
                String underWater3 = strHexToInt(dataValue.Substring(i * 64 + 48, 4)).ToString();
                String underWater4 = strHexToInt(dataValue.Substring(i * 64 + 52, 4)).ToString();
                String underWater5 = strHexToInt(dataValue.Substring(i * 64 + 56, 4)).ToString();
                String underWater6 = strHexToInt(dataValue.Substring(i * 64 + 60, 4)).ToString();

                fshjInfo.UnderTemp1  = under_temp1;
                fshjInfo.UnderTemp2  = under_temp2;
                fshjInfo.OutterTemp1 = outter_temp1;
                fshjInfo.OutterTemp2 = outter_temp2;
                fshjInfo.UnderVo11   = underVol1;
                fshjInfo.UnderVo12   = underVol2;
                fshjInfo.UnderVo13   = underVol3;
                fshjInfo.UnderVo14   = underVol4;
                fshjInfo.UnderVo15   = underVol5;
                fshjInfo.UnderVo16   = underVol6;

                fshjInfo.UnderWaterIn1 = underWater1;
                fshjInfo.UnderWaterIn2 = underWater2;
                fshjInfo.UnderWaterIn3 = underWater3;
                fshjInfo.UnderWaterIn4 = underWater4;
                fshjInfo.UnderWaterIn5 = underWater5;
                fshjInfo.UnderWaterIn6 = underWater6;

                fshjInfo.Cell    = (cellTag == null ? "" : cellTag.Cell);
                fshjInfo.LogTime = DateTime.Now;
                fshjInfo.UpTime  = baseTime.AddMinutes(i * itv);
                fshjInfo.DEVCODE = devCode;
                djs.Add(fshjInfo);
            }
            new BLL.AKFSHJ().insert(djs);
            String pipeType = new BLL.AKFSHJ().getHeatPipeTypeByDevCode(devCode);

            new BLL.AKFSHJ().saveAlarmInfo(djs, pipeType);
            //new BLL.AKFSHJ().saveAlarmInfo(djs);//todo list:生成报警规则
            session.Logger.Info("腐蚀环境数据保存成功");
        }
Пример #16
0
 public override void execute(Tag tag, String devCode, CellTag cellTag,
                              SystemDateTag systemDateTag, CasicSession session)
 {
     CellTag slCellTag = tag as CellTag;
     //  CasicCmd.cell = slCellTag.Cell;
 }
Пример #17
0
 public abstract void execute(Tag tag, String devCode, CellTag cellTag,
                              SystemDateTag systemDateTag, CasicSession session);
Пример #18
0
        public override void ExecuteCommand(CasicSession session, StringRequestInfo requestInfo)
        {
            //casicSession = session;

            //TODO: construct the receving casic data
            String preamble    = requestInfo.Parameters[0];
            String version     = requestInfo.Parameters[1];
            String leng        = requestInfo.Parameters[2];
            String deviceId    = requestInfo.Parameters[3];
            String routeFlag   = requestInfo.Parameters[4];
            String dstNodeAddr = requestInfo.Parameters[5];
            String pduType     = requestInfo.Parameters[6];
            String seq         = requestInfo.Parameters[7];
            String settings    = requestInfo.Parameters[8];
            String crcs        = requestInfo.Parameters[9];

            //print the receving data
            String devType  = getDeviceTypeByPdu(pduType);
            String operType = getOpeTypeByPdu(pduType);

            session.Logger.Info("AD接收数据:" + requestInfo.Body);
            session.Logger.Info("当前版本:" + version);
            session.Logger.Info("设备编号:" + deviceId);
            session.Logger.Info("路由标志:" + routeFlag);
            session.Logger.Info("目标节点地址:" + dstNodeAddr);
            session.Logger.Info("设备类型:" + devType);
            session.Logger.Info("操作类型" + operType);
            session.Logger.Info("序列seq:" + seq);

            //update the device code
            //devCode = deviceId;

            //如果是集中器更新session,如果不是把设备切换成在线
            if (devType == "集中器")
            {
                session.HubAddr = deviceId;
                new BLL.AlarmConcentrator().setHubOnLine(deviceId);
            }
            else
            {
                new BLL.DevHub().setOnLineByDevcode(deviceId);
            }

            //判断是返回的设置确认数据帧,更新DeviceConfig表
            if (operType == "SetResponse")
            {
                new BLL.DeviceConfig().clearDeviceConfigByDevCode(deviceId);
                return;
            }

            //TODO LIST:更新会话中session信息
            this.updateSessionInfo(session, requestInfo);

            //upload periodically or config query according to oid
            //获取电量信息,系统时间,传递给对应的handler
            List <Tag>    tags          = this.getTags(settings, session);
            CellTag       cellTag       = this.getCellTag(tags);
            SystemDateTag systemDateTag = this.getSystemDateTag(tags);

            try
            {
                //TODO LIST:处理主动上报的数据、参数查询、参数设置
                TagHandler systemDateHandler = new SystemDateTagHandler();
                TagHandler noiseHandler      = new NoiseTagHandler();
                TagHandler liquidHandler     = new LiquidTagHandler();
                TagHandler wellHandler       = new WellTagHandler();
                TagHandler sysTimeHandler    = new SystemTimeTagHandler();
                TagHandler wakeupHandler     = new WakeUpTagHandler();
                TagHandler cellTagHandler    = new CellTagHandler();
                TagHandler waterMeterHadler  = new WaterMeterTagHandler();
                TagHandler pressHandler      = new PressTagHandler();
                TagHandler tempHandler       = new TempTagHandler();
                TagHandler fsslHandler       = new FSSLTagHandler();
                TagHandler fshjHandler       = new FSHJTagHandler();
                TagHandler rqHandler         = new RQTagHandler();
                TagHandler sensorExp0        = new SensorException0TagHandler();
                TagHandler sensorExp1        = new SensorException1TagHandler();

                systemDateHandler.NextHandler = noiseHandler;
                noiseHandler.NextHandler      = liquidHandler;
                liquidHandler.NextHandler     = waterMeterHadler;
                waterMeterHadler.NextHandler  = wellHandler;
                wellHandler.NextHandler       = tempHandler;
                tempHandler.NextHandler       = pressHandler;
                pressHandler.NextHandler      = rqHandler;
                rqHandler.NextHandler         = sysTimeHandler;
                sysTimeHandler.NextHandler    = wakeupHandler;
                wakeupHandler.NextHandler     = cellTagHandler;
                cellTagHandler.NextHandler    = fsslHandler;
                fsslHandler.NextHandler       = fshjHandler;
                fshjHandler.NextHandler       = sensorExp0;
                sensorExp0.NextHandler        = sensorExp1;

                foreach (Tag tag in tags)
                {
                    //采用责任链的方式来处理各个tag:
                    //目前已经处理噪声、液位、系统时间、系统日期tag
                    systemDateHandler.handleTag(tag, deviceId, cellTag,
                                                systemDateTag, session);
                }
                if (routeFlag == "03") //GPRS
                {
                    senderGPRSConfig(devType, deviceId, version, session);
                }
                else //433
                {
                    //下发返回的信息
                    if ((operType != "GetResponse") && (devType != "井盖传感器") &&
                        isfinishe(pduType) &&
                        (operType == "TrapRequest" || operType == "OnlineRequest")
                        )
                    {
                        HeadConfig       headConfig    = new HeadConfig(version, deviceId, pduType, seq, routeFlag, dstNodeAddr);
                        TrapRespConfig   trapResp      = new TrapRespConfig(headConfig);
                        SystemTimeConfig sysTimeConfig = new SystemTimeConfig(trapResp);
                        if (session.devMaps.ContainsKey(deviceId))
                        {
                            CasicSession.DeviceDTO dto = session.devMaps[deviceId];
                            trapResp.NoSeq = dto.Seq;
                        }
                        byte[] btConfig = sysTimeConfig.getConfig(new byte[0]);

                        session.Logger.Info(devType + ":" + deviceId + " CRC校验前数据:" + BitConverter.ToString(btConfig));
                        String strCrc =
                            StringUtil.To16HexString((String.Format("{0:X}", (int)CodeUtils.CRC16_AD(btConfig))));
                        session.Logger.Info(devType + ":" + deviceId + " 生成的CRC校验:" + strCrc);
                        byte[] btcrc =
                        {
                            CodeUtils.String2Byte(strCrc.Substring(0, 2)),
                            CodeUtils.String2Byte(strCrc.Substring(2, 2))
                        };
                        byte[] afcrc = new byte[btConfig.Length + 2];
                        btConfig.CopyTo(afcrc, 0);
                        btcrc.CopyTo(afcrc, btConfig.Length);

                        session.Logger.Info(devType + ":" + deviceId + " CRC校验后数据:" + BitConverter.ToString(afcrc));
                        session.Send(afcrc, 0, afcrc.Length);

                        CasicSession.DeviceDTO dto0 = session.devMaps[deviceId];
                        dto0.Seq = 0x00;
                        session.devMaps[deviceId] = dto0;
                    }
                }
            }
            catch (Exception e)
            {
                session.Logger.Error(e.ToString());
            }
        }