/// <summary> /// /// </summary> /// <param name="ditchDevice"></param> private void ShowDitchDevice(DitchDevice ditchDevice) { UCDitchDevice uc = GetUDDitchDevice(); OnlyVisible(uc); uc.DitchDevice = ditchDevice; }
/// <summary> /// /// </summary> /// <param name="task"></param> /// <param name="pr"></param> public void ProcessExecutedTask(Task task, ParseResult pr) { // xd221 modbus // //if (StringHelper.Equal(task.Device.DeviceDefine.DeviceType, // DeviceDefineConst.DDT_XD221Modbus) // && if (StringHelper.Equal(task.Opera.Name, OperaNames.ReadReal)) { object objTemp = pr.NameObjects.GetObject("WL1"); Int16 wl1 = Convert.ToInt16(objTemp); wl1 = MMToCM(wl1); objTemp = pr.NameObjects.GetObject("WL2"); Int16 wl2 = Convert.ToInt16(objTemp); wl2 = MMToCM(wl2); objTemp = pr.NameObjects.GetObject("IF"); uint instantFlux = Convert.ToUInt32(objTemp); if (Config.Default.IsUseFluxFormula) { instantFlux = (uint)YeHeCommuniServerApp.Default.DevieFormaulCollectionMapCollection.CalcInstantFlux( task.Device.ID, DateTime.Now, wl1, wl2); } objTemp = pr.NameObjects.GetObject("Voltage"); int voltage = Convert.ToInt32(objTemp); voltage = voltage / 100; DitchDevice ditchDevice = task.Device as DitchDevice; DitchDataCache cache = ditchDevice.DitchDataCache; cache.SetWLInstantFlux(wl1, wl2, instantFlux, voltage); if (cache.IsComplete()) { ditchDevice.DitchData = new DitchData(cache); DB.DitchDataDBI.Insert(ditchDevice, cache); cache.Clear(); } } if (StringHelper.Equal(task.Opera.Name, XD221ModbusOperaNames.ReadUsedAmount)) { object objTemp = pr.NameObjects.GetObject("usedAmount"); UInt32 usedAmount = Convert.ToUInt32(objTemp); DitchDevice ditchDevice = task.Device as DitchDevice; DitchDataCache cache = ditchDevice.DitchDataCache; cache.SetUsedAmount(usedAmount); if (cache.IsComplete()) { ditchDevice.DitchData = new DitchData(cache); DB.DitchDataDBI.Insert(ditchDevice, cache); cache.Clear(); } } }
/// <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; if (Config.Default.IsUseFluxFormula) { instantFlux = (uint)YeHeCommuniServerApp.Default.DevieFormaulCollectionMapCollection.CalcInstantFlux( task.Device.ID, DateTime.Now, wl1, wl2); } 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; //} }