/// <summary> /// /// </summary> /// <returns></returns> internal GRData ToGRData() { GRData r = new GRData(); r.DT = this.AnalogData.DT; r.BP1 = this.AnalogData.BP1; r.BP2 = this.AnalogData.BP2; r.BT1 = this.AnalogData.BT1; r.BT2 = this.AnalogData.BT2; r.GP1 = this.AnalogData.GP1; r.GP2 = this.AnalogData.GP2; r.GT1 = this.AnalogData.GT1; r.GT2 = this.AnalogData.GT2; r.I1 = this.AnalogData.I1; r.IR = this.AnalogData.IR; r.OD = Convert.ToInt32(this.AnalogData.OD); r.OT = this.AnalogData.OT; r.S1 = Convert.ToInt32(this.AnalogData.S1); r.SR = Convert.ToInt32(this.AnalogData.SR); r.WL = this.AnalogData.WL; r.CM1 = this.StatusData.CM1; r.CM2 = this.StatusData.CM2; r.CM3 = this.StatusData.CM3; r.RM1 = this.StatusData.RM1; r.RM2 = this.StatusData.RM2; r.Warn = new WarnWrapper(this.StatusData.AlarmList); return(r); }
private void ProcessDataCache(LYR001Device d, LYR001DataCache dataCache) { if (dataCache.IsComplete()) { GRData grdata = dataCache.ToGRData(); d.DeviceDataManager.Last = grdata; // save // int id = GuidHelper.ConvertToInt32(d.Guid); DBI.Instance.InsertGRData(id, grdata); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="data"></param> internal void InsertXD1100Data(int id, GRData data) { string s = " INSERT INTO tblGRData(DT, GT1, BT1, GT2, BT2, OT, GTBase2, GP1, BP1, WL, GP2, BP2, I1, I2, IR, S1, S2, SR, OD, PA2, IH1, SH1, CM1, CM2, CM3, RM1, RM2, DeviceID)" + " VALUES(@dt, @gt1, @BT1, @GT2, @BT2, @OT, @GTBase2, @GP1, @BP1, @WL, @GP2, @BP2, @I1, @I2, @IR, @S1, @S2, @SR, @OD, @PA2, @IH1, @SH1, @CM1, @CM2, @CM3, @RM1, @RM2, @DeviceID)"; ListDictionary listDict = new ListDictionary(); listDict.Add("DT", data.DT); listDict.Add("GT1", data.GT1); listDict.Add("BT1", data.BT1); listDict.Add("GT2", data.GT2); listDict.Add("BT2", data.BT2); listDict.Add("OT", data.OT); listDict.Add("GTBase2", data.GTBase2); listDict.Add("GP1", data.GP1); listDict.Add("BP1", data.BP1); listDict.Add("WL", data.WL); listDict.Add("GP2", data.GP2); listDict.Add("BP2", data.BP2); listDict.Add("I1", data.I1); listDict.Add("I2", data.I2); listDict.Add("IR", data.IR); listDict.Add("S1", data.S1); listDict.Add("S2", data.S2); listDict.Add("SR", data.SR); listDict.Add("OD", data.OD); listDict.Add("PA2", data.PA2); listDict.Add("IH1", data.IH1); listDict.Add("SH1", data.SH1); listDict.Add("CM1", data.CM1.PumpStatusEnum); listDict.Add("CM2", data.CM2.PumpStatusEnum); listDict.Add("CM3", data.CM3.PumpStatusEnum); listDict.Add("RM1", data.RM1.PumpStatusEnum); listDict.Add("RM2", data.RM2.PumpStatusEnum); listDict.Add("DeviceID", id); ExecuteScalar(s, listDict); InsertGRAlarmData(id, data.DT, data.Warn.WarnList); }
/// <summary> /// /// </summary> /// <param name="d"></param> /// <param name="parseResult"></param> private void ProcessReadReal(ITask task, IParseResult pr) { GRData data = new GRData(); data.DT = DateTime.Now; data.GT1 = Convert.ToSingle(pr.Results["GT1"]); data.BT1 = Convert.ToSingle(pr.Results["BT1"]); data.GT2 = Convert.ToSingle(pr.Results["GT2"]); data.BT2 = Convert.ToSingle(pr.Results["BT2"]); data.OT = Convert.ToSingle(pr.Results["OT"]); data.GTBase2 = Convert.ToSingle(pr.Results["GTBase2"]); data.GP1 = Convert.ToSingle(pr.Results["GP1"]); data.BP1 = Convert.ToSingle(pr.Results["BP1"]); data.WL = Convert.ToSingle(pr.Results["WL"]); data.GP2 = Convert.ToSingle(pr.Results["GP2"]); data.BP2 = Convert.ToSingle(pr.Results["BP2"]); data.I1 = Convert.ToSingle(pr.Results["I1"]); data.IR = Convert.ToSingle(pr.Results["IR"]); data.I2 = Convert.ToSingle(pr.Results["I2"]); data.S2 = Convert.ToInt32(pr.Results["S2"]); data.S1 = Convert.ToInt32(pr.Results["S1"]); data.SR = Convert.ToInt32(pr.Results["SR"]); data.OD = Convert.ToInt32(pr.Results["OD"]); //data.IH1 = Convert.ToDouble (parseResult.Results ["IH1"]); //data.SH1 = Convert.ToDouble (parseResult.Results ["SH1"]); data.IH1 = 0d; data.SH1 = 0d; // 2012-10-09 xd1100 pump status // bool[] pumpStatusArray = (bool[])pr.Results["pumpstate"]; data.CM1 = IsPumpRun(pumpStatusArray[0]); data.CM2 = IsPumpRun(pumpStatusArray[1]); data.CM3 = IsPumpRun(pumpStatusArray[2]); data.RM1 = IsPumpRun(pumpStatusArray[3]); data.RM2 = IsPumpRun(pumpStatusArray[4]); object objWarn = pr.Results["Warn"]; IList listWarn = (IList)objWarn; bool isContainsPowerAlaram = listWarn.Contains(POWER_ALARM); if (!isContainsPowerAlaram) { if (HasPowerAlaramInStatus(task.Device as XD1100Device)) { listWarn.Add(POWER_ALARM); } } WarnWrapper ww = new WarnWrapper(listWarn); data.Warn = ww; XD1100Device d = (XD1100Device)task.Device; //List<IFluxProvider> fluxProviderList = GetFluxProviderList(d); DeviceCollection fluxDevices = d.Station.Devices.GetDevices(this.KIND_FLUX); fluxDevices = RemoveUnkonwnPlaceDevice(fluxDevices); bool hasFluxDevices = fluxDevices.Count > 0; bool hasFluxData = fluxDevices.HasData(HasDataOption.All); bool success = true; if (hasFluxDevices) { if (hasFluxData) { Hashtable fluxResultHashTable = GetFluxDatas(fluxDevices); foreach (object obj in fluxResultHashTable.Keys) { FluxPlace place = (FluxPlace)obj; List <double> list = (List <double>)fluxResultHashTable[obj]; switch (place) { case FluxPlace.FirstSide: data.I1 = Convert.ToSingle(list[0]); data.S1 = Convert.ToInt32(list[1]); break; case FluxPlace.SecondSide: data.I2 = Convert.ToSingle(list[0]); data.S2 = Convert.ToInt32(list[1]); break; case FluxPlace.RecruitSide: data.IR = Convert.ToSingle(list[0]); data.SR = Convert.ToInt32(list[1]); break; default: break; } } } else { success = false; } } if (!success) { return; } DeviceCollection heatDevices = d.Station.Devices.GetDevices(KIND_HEAT); //heatDevices = RemoveUnkonwnPlaceDevice(heatDevices); heatDevices = this.Filter(heatDevices, FluxPlace.FirstSide); bool hasHeatDevices = heatDevices.Count > 0; bool hasHeatData = heatDevices.HasData(HasDataOption.All); if (hasHeatDevices) { if (hasHeatData) { double instantFlux = 0d; double sumFlux = 0d; double ih = 0d; double sh = 0d; foreach (IDevice hd in heatDevices) { IData last = hd.DeviceDataManager.Last; ih += Convert.ToDouble(last.GetValue("InstantHeat")); sh += Convert.ToDouble(last.GetValue("SumHeat")); instantFlux += Convert.ToDouble(last.GetValue("InstantFlux")); sumFlux += Convert.ToDouble(last.GetValue("Sum")); } data.I1 = Convert.ToSingle(instantFlux); data.S1 = Convert.ToInt32(sumFlux); data.IH1 = ih; data.SH1 = sh; } else { success = false; } } if (!success) { return; } switch (d.HtmMode.ModeValue) { case ModeValue.Indirect: data.CyclePumpDatas.Add(new PumpData("1#", Convert.ToInt32(pr.Results["cyclefrequency"]))); data.RecruitPumpDatas.Add(new PumpData("1#", Convert.ToInt32(pr.Results["recruitfrequency"]))); break; case ModeValue.Direct: data.GT1 = data.GT2; data.BT1 = data.BT2; break; case ModeValue.Mixed: data.BT1 = data.BT2; data.CyclePumpDatas.AddRange( new PumpData("1#", Convert.ToInt32(pr.Results["cyclefrequency"])), new PumpData("2#", Convert.ToInt32(pr.Results["recruitfrequency"])), new PumpData("3#", Convert.ToInt32(pr.Results["I2"]))); break; } d.DeviceDataManager.Last = data; // save // int id = GuidHelper.ConvertToInt32(d.Guid); DBI.Instance.InsertXD1100Data(id, data); }