/// <summary> /// /// </summary> /// <param name="d"></param> /// <returns></returns> private static string GetExtend(XD1100Device d) { StringStringDictionary ssDict = new StringStringDictionary(); ssDict["HtmMode"] = d.HtmMode.ModeValue.ToString(); string extend = StringStringDictionaryConverter.ToString(ssDict); return extend; }
/// <summary> /// /// </summary> /// <param name="d"></param> /// <returns></returns> private static string GetExtend(XD1100Device d) { StringStringDictionary ssDict = new StringStringDictionary(); ssDict["HtmMode"] = d.HtmMode.ModeValue.ToString(); string extend = StringStringDictionaryConverter.ToString(ssDict); return(extend); }
/// <summary> /// /// </summary> /// <returns></returns> private bool HasPowerAlaramInStatus(XD1100Device xd1100) { bool b = xd1100.StatusAndAlarmDictionary.ContainsKey(XD1100Device.StatusAndAlarmEnum.AlaramPower); if (b) { return(xd1100.StatusAndAlarmDictionary[XD1100Device.StatusAndAlarmEnum.AlaramPower]); } return(false); }
/// <summary> /// /// </summary> /// <param name="task"></param> /// <param name="parseResult"></param> private void ProcessReadStatus(ITask task, IParseResult pr) { XD1100Device d = (XD1100Device )task.Device; byte[] bsStatus = (byte[])pr.Results["data"]; Debug.Assert(bsStatus.Length == 4); byte b = bsStatus[3]; bool hasPowerAlarm = (b & (byte)Math.Pow(2, 7)) > 0; d.StatusAndAlarmDictionary[XD1100Device.StatusAndAlarmEnum.AlaramPower] = hasPowerAlarm; }
/// <summary> /// /// </summary> /// <param name="device"></param> protected override void OnAdd(IDevice device) { XD1100Device d = (XD1100Device)device; string s = string.Format( "insert into tblDevice(DeviceAddress, deviceType, stationID, DeviceExtend, DeviceName) values({0}, '{1}', {2}, '{3}', '{4}')", d.Address, d.DeviceType.Type.Name, GuidHelper.ConvertToInt32(d.Station.Guid), GetExtend(d), d.Name ); DBI.Instance.ExecuteScalar(s); d.Guid = GuidHelper.Create(GetMaxDeviceID(DBI.Instance)); }
/// <summary> /// /// </summary> /// <param name="deviceSource"></param> /// <returns></returns> public override IDevice OnCreate(IDeviceSource deviceSource) { XD1100DeviceSource source = (XD1100DeviceSource)deviceSource; XD1100Device d = new XD1100Device(); d.Address = source.Address; d.Name = source.DeviceName; d.DeviceSource = source; d.DeviceType = this.Dpu.DeviceType; d.Dpu = this.Dpu; d.Guid = source.Guid; d.StationGuid = source.StationGuid; d.HtmMode = HeatTransferMode.Parse(source.HtmModeValue); d.Pickers = Dpu.OperaFactory.CreatePickers(this.Dpu.DeviceType.Type.Name); //d.DeviceDataManager.Last = new XD1100Data(); return d; }
/// <summary> /// /// </summary> /// <param name="deviceSource"></param> /// <returns></returns> public override IDevice OnCreate(IDeviceSource deviceSource) { XD1100DeviceSource source = (XD1100DeviceSource)deviceSource; XD1100Device d = new XD1100Device(); d.Address = source.Address; d.Name = source.DeviceName; d.DeviceSource = source; d.DeviceType = this.Dpu.DeviceType; d.Dpu = this.Dpu; d.Guid = source.Guid; d.StationGuid = source.StationGuid; d.HtmMode = HeatTransferMode.Parse(source.HtmModeValue); d.Pickers = Dpu.OperaFactory.CreatePickers(this.Dpu.DeviceType.Type.Name); //d.DeviceDataManager.Last = new XD1100Data(); return(d); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _mnuTemperatureLine_Click(object sender, EventArgs e) { XD1100Device selectedXd1100 = SoftManager.GetSoft().SelectedHardwareItem as XD1100Device; if (selectedXd1100 != null) { string stationName = selectedXd1100.Station.Name; int deviceID = GuidHelper.ConvertToInt32(selectedXd1100.Guid); LocalController c = new LocalController(); frmXD100ModbusTemperatureControl f = new frmXD100ModbusTemperatureControl(stationName, deviceID, c); f.ShowDialog(); } else { NUnit.UiKit.UserMessage.Display("selecte xd1100 device first"); } }
/// <summary> /// /// </summary> /// <returns></returns> private bool HasPowerAlaramInStatus(XD1100Device xd1100) { bool b = xd1100.StatusAndAlarmDictionary.ContainsKey(XD1100Device.StatusAndAlarmEnum.AlaramPower); if (b) { return xd1100.StatusAndAlarmDictionary[XD1100Device.StatusAndAlarmEnum.AlaramPower]; } return false; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void parentMenuItem_DropDownOpening(object sender, EventArgs e) { XD1100Device d = SoftManager.GetSoft().SelectedHardwareItem as XD1100Device; this._mnuTemperatureLine.Visible = d != null; }
/// <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); }