Ejemplo n.º 1
0
        public override void ExecuteCommand(DGNSZSession session, StringRequestInfo requestInfo)
        {
            try
            {
                DeviceConfigInfo conf = (new DeviceConfig()).GetLatestConfigByDeviceCodeAndSensorCode(session.MacID, FLOW_SENSOR_CODE);
                if (conf != null)
                {
                    string   content  = conf.FrameContent;
                    string[] items    = content.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
                    byte[]   sendData = new byte[items.Length];
                    for (int i = 0; i < items.Length; i++)
                    {
                        sendData[i] = byte.Parse(items[i], System.Globalization.NumberStyles.HexNumber);
                    }
                    session.Send(sendData, 0, sendData.Length);
                    session.FlowConf          = conf;
                    session.FlowConf.SendTime = DateTime.Now;
                    session.Logger.Info("多功能漏损监测仪流量(" + session.MacID + ")配置下发成功:" + BitConverter.ToString(sendData));
                    return;
                }

                //流量默认配置帧
                byte[] set = Utility.ApplicationContext.getInstance().getLSFlowDefaultConfig();
                session.Send(set, 0, set.Length);
                session.Logger.Info("多功能漏损监测仪流量(" + session.MacID + ")默认配置下发成功:" + BitConverter.ToString(set));
            }
            catch (Exception e)
            {
                session.Logger.Error("===================================================================");
                session.Logger.Error("服务器下发流量设置失败!");
                session.Logger.Error(e.ToString());
                session.Logger.Error("===================================================================");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update a deviceConfig in the database
        /// </summary>
        /// <param name="ate">Adapter information to update</param>
        public void Update(DeviceConfigInfo doc)
        {
            OracleParameter[] parms = GetDeviceConfigInfoParameters();
            SetDeviceConfigInfoParameters(parms, doc);

            try
            {
                int rst = OracleHelper.ExecuteNonQuery(OracleHelper.ConnectionStringOrderDistributedTransaction, CommandType.Text, SQL_UPDATE_ALARM_DEVICE_CONFIG, parms);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public override void ExecuteCommand(SZSLNoiseSession session, StringRequestInfo requestInfo)
        {
            try
            {
                if (session.MacID == null)
                {
                    return;
                }

                DeviceConfigInfo conf = (new DeviceConfig()).GetDeviceConfByDeviceCodeAndSensorCode(session.MacID,
                                                                                                    sensorTypeCode);

                if (conf != null)
                {
                    string   content  = conf.FrameContent;
                    string[] items    = content.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
                    byte[]   sendData = new byte[items.Length];
                    for (int i = 0; i < items.Length; i++)
                    {
                        sendData[i] = byte.Parse(items[i], System.Globalization.NumberStyles.HexNumber);
                    }
                    //修正时间
                    sendData[15] = byte.Parse(DateTime.Now.ToString("ss"));
                    sendData[16] = byte.Parse(DateTime.Now.ToString("mm"));
                    sendData[17] = byte.Parse(DateTime.Now.ToString("HH"));
                    sendData[18] = byte.Parse("0" + ((int)DateTime.Now.DayOfWeek).ToString());
                    sendData[19] = byte.Parse(DateTime.Now.ToString("dd"));
                    sendData[20] = byte.Parse(DateTime.Now.ToString("MM"));
                    sendData[21] = byte.Parse(DateTime.Now.ToString("yy"));

                    session.Send(sendData, 0, sendData.Length);

                    session.Conf          = conf;
                    session.Conf.SendTime = DateTime.Now;
                    session.Conf.Status   = true;//考虑到冯对每次下发的配置需求
                    new DeviceConfig().Update(session.Conf);

                    session.Logger.Info("服务器->设备:渗漏预警配置信息成功:" + BitConverter.ToString(sendData));
                    return;
                }
                byte[] set = ApplicationContext.getInstance().getDefaultSLConfig();
                session.Send(set, 0, set.Length);
                session.Logger.Info("服务器->设备:渗漏预警默认配置信息成功:" + BitConverter.ToString(set));
            }
            catch (Exception e)
            {
                session.Logger.Error("服务器->设备:渗漏噪声配置信息出错:" + e.Message);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// An internal function to bind values parameters for insert
        /// </summary>
        /// <param name="parms">Database parameters</param>
        /// <param name="doc">Values to bind to parameters</param>
        private void SetDeviceConfigInfoParameters(OracleParameter[] parms, DeviceConfigInfo deviceConfig)
        {
            //modified by predator 2013/1/4
            //parms[0].Value = new Guid(doc.DBID);
            //parms[1].Value = new Guid(doc.Adapter.DBID);
            //parms[2].Value = new Guid(doc.Document.DBID);

            //  parms[0].Value = deviceConfig.DBID;
            //    parms[1].Value = deviceConfig.DeviceCode;
            //   parms[2].Value = deviceConfig.FrameContent;
            //   parms[3].Value = deviceConfig.SendTime;
            //   parms[4].Value = deviceConfig.SensorCode;
            //    parms[5].Value = deviceConfig.Status;
            //   parms[6].Value = deviceConfig.WriteTime;
            parms[0].Value = deviceConfig.SendTime;
            parms[1].Value = deviceConfig.Status;
            parms[2].Value = deviceConfig.DBID;
        }
Ejemplo n.º 5
0
        public override void handleSection(DGNSZSession session)
        {
            //如果传上来的LSSECTION帧中无法获取MacID,则对多功能监测仪下发噪声校时
            if (string.IsNullOrEmpty(session.MacID))
            {
                byte[] set = Utility.ApplicationContext.getInstance().getLSNoiseCALIConfig();
                session.Send(set, 0, set.Length);
                session.Logger.Info("多功能漏损监测仪下发噪声校时配置:" + BitConverter.ToString(set, 0));
                return;
            }

            //如果能能够从数据库中获取到噪声配置信息,则将噪声配置下发给多功能检测仪
            DeviceConfigInfo conf = (new DeviceConfig()).GetLatestConfigByDeviceCodeAndSensorCode(session.MacID, "000032");

            if (null != conf)
            {
                string   content  = conf.FrameContent;
                string[] items    = content.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
                byte[]   sendData = new byte[items.Length];
                for (int i = 0; i < items.Length; i++)
                {
                    sendData[i] = byte.Parse(items[i], System.Globalization.NumberStyles.HexNumber);
                }
                sendData[20] = StringUtil.SEC;
                sendData[21] = StringUtil.MIN;
                sendData[22] = StringUtil.HOR;
                sendData[23] = StringUtil.WEEK;
                sendData[24] = StringUtil.DAY;
                sendData[25] = StringUtil.MON;
                sendData[26] = StringUtil.YEAR;
                session.Send(sendData, 0, sendData.Length);
                session.Logger.Info("多功能漏损监测仪噪声(" + session.MacID + ")配置下发成功:" + BitConverter.ToString(sendData));
                session.NoiseConf          = conf;
                session.NoiseConf.SendTime = DateTime.Now;
            }
            else
            //如果从数据库中获取不到噪声配置,在将噪声的默认配置下发给多功能监测仪。
            {
                byte[] set = Utility.ApplicationContext.getInstance().getLSNoiseDefaultConfig();
                session.Send(set, 0, set.Length);
                session.Logger.Info("多功能漏损监测仪噪声(" + session.MacID + ")默认配置下发成功:" + BitConverter.ToString(set, 0));
            }
        }
Ejemplo n.º 6
0
        public override void ExecuteCommand(WSSession session, StringRequestInfo requestInfo)
        {
            try
            {
                session.Logger.Info("HeartBeat:" + requestInfo.Body);

                string[] bt = requestInfo.Body.Split(',');
                if (string.IsNullOrEmpty(session.MacID))
                {
                    session.MacID = bt[0];
                }
                string stime = bt[1];
                string sdate = stime.Substring(0, 4) + "-" + stime.Substring(4, 2) + "-" + stime.Substring(6, 2)
                               + " " + stime.Substring(8, 2) + ":" + stime.Substring(10, 2) + ":" + stime.Substring(12, 2);
                DateTime upTime = Convert.ToDateTime(sdate);


                TimeSpan ts       = DateTime.Now.Subtract(upTime);
                double   miniutes = ts.TotalMinutes;
                if (miniutes > 10.0)
                {
                    //下发校时
                    String preTimeCal = "SewTiming:" + session.MacID + ",";
                    String postTime   = DateTime.Now.ToString("yyyyMMddHHmmss");
                    String timeCal    = preTimeCal + postTime;

                    byte[] data1 = new byte[timeCal.Length + 2];
                    Encoding.ASCII.GetBytes(timeCal, 0, timeCal.Length, data1, 0);
                    data1[timeCal.Length]     = 0x0D;
                    data1[timeCal.Length + 1] = 0x0A;

                    session.Send(data1, 0, data1.Length);
                    session.Logger.Info("污水下发校时:" + BitConverter.ToString(data1) +
                                        "上传时间:" + upTime + "系统时间:" + DateTime.Now);
                }
                session.Send("HeartBeat:" + requestInfo.Body);

                //增加:进行对应的配置信息下发操作
                DeviceConfigInfo conf = (new DeviceConfig()).GetDeviceConfByDeviceCodeAndSensorCode(session.MacID, SENSOR_TYPE);
                if (conf == null)
                {
                    return;
                }
                ;
                conf.SendTime         = DateTime.Now;
                session.WsConf        = conf;
                session.WsConf.Status = true;
                string content = conf.FrameContent;
                String sdata0  = "SewAcquireInterval:" + session.MacID + "," + content;
                byte[] data0   = new byte[sdata0.Length + 2];
                Encoding.ASCII.GetBytes(sdata0, 0, sdata0.Length, data0, 0);
                data0[sdata0.Length]     = 0x0D;
                data0[sdata0.Length + 1] = 0x0A;
                session.Send(data0, 0, data0.Length);
                session.Logger.Info("有害气体配置信息:" + sdata0);

                session.WsConf.Status   = true;
                session.WsConf.SendTime = DateTime.Now;
                new DeviceConfig().Update(session.WsConf);
            }
            catch (Exception e)
            {
                session.Logger.Error("污水心跳异常!");
                session.Logger.Error(requestInfo.Body);
                session.Logger.Error(e.ToString());
            }
        }
Ejemplo n.º 7
0
        public void Update(DeviceConfigInfo conf)
        {
            IDeviceConfig iDeviceConfig = SensorHub.DALFactory.DeviceConfig.Create();

            iDeviceConfig.Update(conf);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Method to get the work unit document information of the reader current
        /// </summary>
        /// <param name="rdr">OracleDataReader contain the work unit document information</param>
        /// <returns>the device info</returns>
        private DeviceConfigInfo GetDeviceConfigByOracleDataReader(OracleDataReader rdr)
        {
            string[]  colsName;
            int[]     colsOrdinal;
            const int colsCount = 7;

            DeviceConfigInfo info;


            colsName = new string[colsCount] {
                COLUMN_DBID, COLUMN_DEVID, COLUMN_FRAMECONTENT,
                COLUMN_SENDTIME, COLUMN_SENSORID, COLUMN_STATUS,
                COLUMN_WRITETIME
            };
            colsOrdinal = new int[colsCount];

            if (GetColumnsOrdinal(rdr, colsName, colsOrdinal) < 0)
            {
                throw (new Exception("Error"));
            }

            info = new DeviceConfigInfo();

            for (int i = 0; i < colsCount; i++)
            {
                if (colsOrdinal[i] < 0 || rdr.IsDBNull(colsOrdinal[i]))
                {
                    continue;
                }
                switch (i)
                {
                case 0:
                    info.DBID = rdr.GetInt32(colsOrdinal[i]);
                    break;

                case 1:
                    info.DeviceCode = rdr.GetString(colsOrdinal[i]);
                    break;

                case 2:
                    info.FrameContent = rdr.GetString(colsOrdinal[i]);
                    break;

                case 3:
                    info.SendTime = rdr.GetDateTime(colsOrdinal[i]);
                    break;

                case 4:
                    info.SensorCode = rdr.GetString(colsOrdinal[i]);
                    break;

                case 5:
                    info.Status = false;
                    break;

                case 6:
                    info.WriteTime = rdr.GetDateTime(colsOrdinal[i]);
                    break;
                }
            }

            return(info);
        }