public override void TextChange() { TTime = DateTime.Now; ThreePhaseElectricMeter_Logs = MysqlMethod.Search_ThreePhaseElectricMeter_Log($"{TTime:yyyyMMdd000000}", $"{TTime:yyyyMMdd235959}", ElectricConfig.GatewayIndex, ElectricConfig.DeviceIndex); LinechartControl.DataSource = ThreePhaseElectricMeter_Logs; LinechartControl.Refresh(); var data = ElectricAbsProtocols.Single(g => g.GatewayIndex == ElectricConfig.GatewayIndex & g.DeviceIndex == ElectricConfig.DeviceIndex); if (data.ConnectFlag) { ElectricTypeEnum electricTypeEnum = (ElectricTypeEnum)data.ElectricTypeEnum; switch (electricTypeEnum) { case ElectricTypeEnum.BAW_4C: { ThreePhaseElectricMeterData threePhaseElectric = (ThreePhaseElectricMeterData)data; rsvlabelControl.Text = threePhaseElectric.rsv.ToString("F2"); stvlabelControl.Text = threePhaseElectric.stv.ToString("F2"); trvlabelControl.Text = threePhaseElectric.trv.ToString("F2"); ralabelControl.Text = threePhaseElectric.ra.ToString("F2"); salabelControl.Text = threePhaseElectric.sa.ToString("F2"); talabelControl.Text = threePhaseElectric.ta.ToString("F2"); pfelabelControl.Text = threePhaseElectric.pfe.ToString("F3"); hzlabelControl.Text = threePhaseElectric.hz.ToString("F2"); kwlabelControl.Text = threePhaseElectric.kw.ToString("F2"); kwhlabelControl.Text = threePhaseElectric.kwh.ToString("F2"); kvarlabelControl.Text = threePhaseElectric.kvar.ToString("F2"); kvarhlabelControl.Text = threePhaseElectric.kvarh.ToString("F2"); } break; } } }
public override void TextChange() { if (ElectricConfig != null && Form1.ConnectionFlag) { groupControl.CustomHeaderButtons[0].Properties.Enabled = Form1.AdministraturFlag;//更改名稱按鈕 ElectricEnumType = (ElectricEnumType)ElectricConfig.ElectricEnumType; PhaseEnumType = (PhaseEnumType)ElectricConfig.PhaseEnumType; #region 電表名稱 if (groupControl.Text != $"總表 - {ElectricConfig.DeviceName}") { groupControl.Text = $"總表 - {ElectricConfig.DeviceName}"; } #endregion #region 電表數值 var Data = AbsProtocols.Where(g => g.GatewayIndex == ElectricConfig.GatewayIndex & g.DeviceIndex == ElectricConfig.DeviceIndex).ToList(); if (Data.Count > 0) { switch (ElectricEnumType) { case ElectricEnumType.PA310: { PA310Protocol protocol = (PA310Protocol)Data[0]; RSvlabelControl.Text = protocol.RSv.ToString("F2"); STvlabelControl.Text = protocol.STv.ToString("F2"); TRvlabelControl.Text = protocol.TRv.ToString("F2"); RalabelControl.Text = protocol.RA.ToString("F2"); SalabelControl.Text = protocol.SA.ToString("F2"); TalabelControl.Text = protocol.TA.ToString("F2"); PFlabelControl.Text = protocol.PF.ToString("F2"); kWlabelControl.Text = protocol.kW.ToString("F2"); kWhlabelControl.Text = protocol.kWh.ToString("F2"); } break; case ElectricEnumType.HC660: { HC6600Protocol protocol = (HC6600Protocol)Data[0]; RSvlabelControl.Text = protocol.RSv.ToString("F2"); STvlabelControl.Text = protocol.STv.ToString("F2"); TRvlabelControl.Text = protocol.TRv.ToString("F2"); RalabelControl.Text = protocol.RA.ToString("F2"); SalabelControl.Text = protocol.SA.ToString("F2"); TalabelControl.Text = protocol.TA.ToString("F2"); PFlabelControl.Text = protocol.PF.ToString("F2"); kWlabelControl.Text = protocol.kW.ToString("F2"); kWhlabelControl.Text = protocol.kWh.ToString("F2"); } break; case ElectricEnumType.CPM6: { CPM6Protocol protocol = (CPM6Protocol)Data[0]; RSvlabelControl.Text = protocol.RSv.ToString("F2"); STvlabelControl.Text = protocol.STv.ToString("F2"); TRvlabelControl.Text = protocol.TRv.ToString("F2"); RalabelControl.Text = protocol.RA.ToString("F2"); SalabelControl.Text = protocol.SA.ToString("F2"); TalabelControl.Text = protocol.TA.ToString("F2"); PFlabelControl.Text = protocol.PF.ToString("F2"); kWlabelControl.Text = protocol.kW.ToString("F2"); kWhlabelControl.Text = protocol.kWh.ToString("F2"); } break; case ElectricEnumType.PA60: { PA60Protocol protocol = (PA60Protocol)Data[0]; RSvlabelControl.Text = protocol.RSv[ElectricConfig.LoopEnumType].ToString("F2"); STvlabelControl.Text = protocol.STv[ElectricConfig.LoopEnumType].ToString("F2"); TRvlabelControl.Text = protocol.TRv[ElectricConfig.LoopEnumType].ToString("F2"); RalabelControl.Text = protocol.RA[ElectricConfig.LoopEnumType].ToString("F2"); SalabelControl.Text = protocol.SA[ElectricConfig.LoopEnumType].ToString("F2"); TalabelControl.Text = protocol.TA[ElectricConfig.LoopEnumType].ToString("F2"); PFlabelControl.Text = protocol.PF[ElectricConfig.LoopEnumType].ToString("F2"); kWlabelControl.Text = protocol.kW[ElectricConfig.LoopEnumType].ToString("F2"); kWhlabelControl.Text = protocol.kWh[ElectricConfig.LoopEnumType].ToString("F2"); } break; case ElectricEnumType.ABBM2M: { ABBM2MProtocol protocol = (ABBM2MProtocol)Data[0]; RSvlabelControl.Text = protocol.RSv.ToString("F2"); STvlabelControl.Text = protocol.STv.ToString("F2"); TRvlabelControl.Text = protocol.TRv.ToString("F2"); RalabelControl.Text = protocol.RA.ToString("F2"); SalabelControl.Text = protocol.SA.ToString("F2"); TalabelControl.Text = protocol.TA.ToString("F2"); PFlabelControl.Text = protocol.PF.ToString("F2"); kWlabelControl.Text = protocol.kW.ToString("F2"); kWhlabelControl.Text = protocol.kWh.ToString("F2"); } break; case ElectricEnumType.PM200: { PM200Protocol protocol = (PM200Protocol)Data[0]; RSvlabelControl.Text = protocol.RSv.ToString("F2"); STvlabelControl.Text = protocol.STv.ToString("F2"); TRvlabelControl.Text = protocol.TRv.ToString("F2"); RalabelControl.Text = protocol.RA.ToString("F2"); SalabelControl.Text = protocol.SA.ToString("F2"); TalabelControl.Text = protocol.TA.ToString("F2"); PFlabelControl.Text = protocol.PF.ToString("F2"); kWlabelControl.Text = protocol.kW.ToString("F2"); kWhlabelControl.Text = protocol.kWh.ToString("F2"); } break; case ElectricEnumType.TWCPM4: { TWCPM4Protocol protocol = (TWCPM4Protocol)Data[0]; RSvlabelControl.Text = protocol.RSv.ToString("F2"); STvlabelControl.Text = protocol.STv.ToString("F2"); TRvlabelControl.Text = protocol.TRv.ToString("F2"); RalabelControl.Text = protocol.RA.ToString("F2"); SalabelControl.Text = protocol.SA.ToString("F2"); TalabelControl.Text = protocol.TA.ToString("F2"); PFlabelControl.Text = protocol.PF.ToString("F2"); kWlabelControl.Text = protocol.kW.ToString("F2"); kWhlabelControl.Text = protocol.kWh.ToString("F2"); } break; } } #endregion var NowkWh = SqlMethod.Search_ElectricTotalPrice(0, ElectricConfig.GatewayIndex, ElectricConfig.DeviceIndex); //本日累積用電度 var MonthkWh = SqlMethod.Search_ElectricTotalPrice(2, ElectricConfig.GatewayIndex, ElectricConfig.DeviceIndex); //本月累積用電度 if (NowkWh.Count > 0) { DaykWhlabelControl.Appearance.Font = CalculateFontSize(NowkWh[0].KwhTotal.ToString("F1") + " kWh", DaykWhlabelControl); DaykWhlabelControl.Text = NowkWh[0].KwhTotal.ToString("F1") + " kWh"; } if (MonthkWh.Count > 0) { MonthkWhlabelControl.Appearance.Font = CalculateFontSize(MonthkWh[0].KwhTotal.ToString("F1") + " kWh", MonthkWhlabelControl); MonthkWhlabelControl.Text = MonthkWh[0].KwhTotal.ToString("F1") + " kWh"; } #region 曲線圖 TimeSpan timeSpan = DateTime.Now.Subtract(LineTime); if (timeSpan.TotalSeconds > 20) { if (SqlMethod != null) { var SQLline = SqlMethod.Search_ThreePhaseElectricMeter_Log(DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyyMMdd"), ElectricConfig.GatewayIndex, ElectricConfig.DeviceIndex); TotalMeterSeries.DataSource = SQLline; } LinechartControl.Refresh(); LineTime = DateTime.Now; } #endregion } else if (!Form1.ConnectionFlag) { groupControl.CustomHeaderButtons[0].Properties.Enabled = Form1.AdministraturFlag;//更改名稱按鈕 #region 電表名稱 if (groupControl.Text != $"總表 - {ElectricConfig.DeviceName}") { groupControl.Text = $"總表 - {ElectricConfig.DeviceName}"; } #endregion RSvlabelControl.Text = (Convert.ToDouble(rnd.Next(2100, 2200)) / 10).ToString("F1"); STvlabelControl.Text = (Convert.ToDouble(rnd.Next(2100, 2200)) / 10).ToString("F1"); TRvlabelControl.Text = (Convert.ToDouble(rnd.Next(2100, 2200)) / 10).ToString("F1"); RalabelControl.Text = (Convert.ToDouble(rnd.Next(1100, 2200)) / 100).ToString("F2"); SalabelControl.Text = (Convert.ToDouble(rnd.Next(1100, 2200)) / 100).ToString("F2"); TalabelControl.Text = (Convert.ToDouble(rnd.Next(1100, 2200)) / 100).ToString("F2"); PFlabelControl.Text = (Convert.ToDouble(rnd.Next(9800, 10000)) / 100).ToString("F2"); kWlabelControl.Text = (Convert.ToDouble(rnd.Next(2000, 3000)) / 100).ToString("F2"); kWhlabelControl.Text = (Convert.ToDouble(rnd.Next(21000, 22000)) / 100).ToString("F2"); } }