/// <summary> /// /// </summary> /// <param name="cache"></param> public DitchData(DitchDataCache cache) { Debug.Assert(cache.IsComplete()); this.DT = cache.WLDT; this.WL1 = cache.WL1; this.WL2 = cache.WL2; this.InstantFlux = cache.InstantFlux; this.UsedAmount = cache.UsedAmount; this.Voltage = cache.Voltage; }
/// <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); 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(); } } }