Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="task"></param>
        /// <param name="pr"></param>
        public void ProcessExecutedTask(Task task, ParseResult pr)
        {
            if (StringHelper.Equal(task.Opera.Name, OperaNames.ReadReal))
            {
                //
                // 功能码:     0x10
                // 数据数:     0位
                // 成功后返回: 0x21+0x58+0x44+地址+0x80+功能码+0x12+日期+时间+已用水量+瞬时流量+闸前水位+闸后水位+CRC16

                // 日期(3字节BCD码 年+月+日)
                // 时间(3字节BCD码 时+分+秒)
                // 已用水量(4字节)(无符号整型)带一位小数点	m3          <b>
                // 瞬时流量(4字节)(无符号整型)带一位小数点	m3/h        <c>
                // 闸前水位(2字节)带两位小数点  m                         <a>
                // 闸后水位(2字节)带两位小数点  m
                //
                // 供电电压 (2Byte) 两位小数点                              <d>

                // 水位, 单位CM, <a>
                //
                int  wl1         = (Int16)pr.NameObjects.GetObject("WL1");
                int  wl2         = (Int16)pr.NameObjects.GetObject("WL2");
                uint instantFlux = (UInt32)pr.NameObjects.GetObject("IF");
                uint usedAmount  = (uint)pr.NameObjects.GetObject("usedAmount");

                object objTemp = pr.NameObjects.GetObject("voltage");
                int    voltage = Convert.ToInt32(objTemp);

                // <c>
                //
                instantFlux = (uint)(instantFlux / 10);
                // <b>
                //
                usedAmount = (uint)(usedAmount / 10);

                // <d>
                //
                voltage = voltage / 100;

                DitchDevice ditchDevice = task.Device as DitchDevice;
                ditchDevice.DitchData = new DitchData(wl1, wl2, instantFlux, usedAmount, voltage);
                DB.DitchDataDBI.Insert(ditchDevice, DateTime.Now, instantFlux, wl1, wl2, usedAmount, voltage);
            }

            if (StringHelper.Equal(task.Opera.Name, OperaNames.ReadParams))
            {
                XD221Params p           = ProcessParams(pr);
                XD221Device xd221Device = task.Device as XD221Device;
                xd221Device.Xd221Params = p;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="dd"></param>
 /// <param name="name"></param>
 /// <param name="address"></param>
 /// <returns></returns>
 public static XD221Device Create(DeviceDefine dd, string name, int address)
 {
     XD221Device d = new XD221Device(dd, name, address);
     return d;
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dd"></param>
        /// <param name="name"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        static public XD221Device Create(DeviceDefine dd, string name, int address)
        {
            XD221Device d = new XD221Device(dd, name, address);

            return(d);
        }