From cc2e1bec434c5e2134031683918442a98d325cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E6=9E=9C?= Date: Wed, 25 Dec 2024 13:38:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=80=BB=E7=94=A8=E6=B0=B4?= =?UTF-8?q?=E9=87=8F=E4=B8=8E=E6=80=BB=E7=94=A8=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IPLCDeviceRecordRepository.cs | 6 + .../Impl/PLCDeviceRecordRepository.cs | 18 +- .../Services/IPLCDeviceRecordService.cs | 6 + .../Services/Impl/PLCDeviceRecordService.cs | 12 + .../Controller/PLCController.cs | 74 +++-- .../GuideScreen.UI/FormScreen.Designer.cs | 16 +- .../GuideScreen/GuideScreen.UI/FormScreen.cs | 299 +++++++++--------- 7 files changed, 250 insertions(+), 181 deletions(-) diff --git a/guidescreen/GuideScreen/GuideScreen.Common/Repositories/IPLCDeviceRecordRepository.cs b/guidescreen/GuideScreen/GuideScreen.Common/Repositories/IPLCDeviceRecordRepository.cs index 7e285ef..467ff8e 100644 --- a/guidescreen/GuideScreen/GuideScreen.Common/Repositories/IPLCDeviceRecordRepository.cs +++ b/guidescreen/GuideScreen/GuideScreen.Common/Repositories/IPLCDeviceRecordRepository.cs @@ -66,6 +66,12 @@ namespace GuideScreen.Common.Repositories /// decimal WaterTotal(); + /// + /// 获取总用电量 + /// + /// + decimal ElectricityTotal(); + /// /// 获取厕位使用计 /// diff --git a/guidescreen/GuideScreen/GuideScreen.Common/Repositories/Impl/PLCDeviceRecordRepository.cs b/guidescreen/GuideScreen/GuideScreen.Common/Repositories/Impl/PLCDeviceRecordRepository.cs index 22dcba5..9dc3dea 100644 --- a/guidescreen/GuideScreen/GuideScreen.Common/Repositories/Impl/PLCDeviceRecordRepository.cs +++ b/guidescreen/GuideScreen/GuideScreen.Common/Repositories/Impl/PLCDeviceRecordRepository.cs @@ -321,8 +321,24 @@ namespace GuideScreen.Common.Repositories.Impl { using (var context = GSDBContext.GetDbContext()) { - var val = context.PLCDeviceRecordDayEntities.Where(f => f.PointName == PLCPointNameByEnergyMonitoring.WaterConsumption).Sum(f => (decimal?)f.RecordValue); + // var val = context.PLCDeviceRecordDayEntities.Where(f => f.PointName == PLCPointNameByEnergyMonitoring.WaterConsumption).Sum(f => (decimal?)f.RecordValue); + //根据侧位数量计算 + var val = context.PLCDeviceRecordDayEntities.Where(f => f.DeviceName == PLCDeviceNames.ToiletPosition).Sum(f => (decimal?)f.RecordValue); + return val ?? 0; + } + } + /// + /// 获取总用电量 + /// + /// + public decimal ElectricityTotal() + { + using (var context = GSDBContext.GetDbContext()) + { + //var val = context.PLCDeviceRecordDayEntities.Where(f => f.PointName == PLCPointNameByEnergyMonitoring.ElectricityConsumption).Sum(f => (decimal?)f.RecordValue); + //根据侧位数量计算 + var val = context.PLCDeviceRecordDayEntities.Where(f => f.DeviceName == PLCDeviceNames.ToiletPosition).Sum(f => (decimal?)f.RecordValue); return val ?? 0; } } diff --git a/guidescreen/GuideScreen/GuideScreen.Common/Services/IPLCDeviceRecordService.cs b/guidescreen/GuideScreen/GuideScreen.Common/Services/IPLCDeviceRecordService.cs index 9a19599..6537f14 100644 --- a/guidescreen/GuideScreen/GuideScreen.Common/Services/IPLCDeviceRecordService.cs +++ b/guidescreen/GuideScreen/GuideScreen.Common/Services/IPLCDeviceRecordService.cs @@ -99,6 +99,12 @@ namespace GuideScreen.Common.Services /// decimal WaterTotal(); + /// + /// 获取总用电量 + /// + /// + decimal ElectricityTotal(); + /// /// 获取厕位使用计 /// diff --git a/guidescreen/GuideScreen/GuideScreen.Common/Services/Impl/PLCDeviceRecordService.cs b/guidescreen/GuideScreen/GuideScreen.Common/Services/Impl/PLCDeviceRecordService.cs index a18a654..24d0c44 100644 --- a/guidescreen/GuideScreen/GuideScreen.Common/Services/Impl/PLCDeviceRecordService.cs +++ b/guidescreen/GuideScreen/GuideScreen.Common/Services/Impl/PLCDeviceRecordService.cs @@ -135,6 +135,7 @@ namespace GuideScreen.Common.Services.Impl DeviceName = PLCDeviceNames.EnergyMonitoring, PointName = name, PointNote = note, + RecordValue = Convert.ToDecimal(value) }; if (dateTime.HasValue) { @@ -235,6 +236,17 @@ namespace GuideScreen.Common.Services.Impl return ret; } + /// + /// 获取总用电量 + /// + /// + public decimal ElectricityTotal() + { + var ret = this.deviceRecordRepository.ElectricityTotal(); + + return ret; + } + /// /// 获取厕位使用计 /// diff --git a/guidescreen/GuideScreen/GuideScreen.UI/Controller/PLCController.cs b/guidescreen/GuideScreen/GuideScreen.UI/Controller/PLCController.cs index a84501a..581fc9e 100644 --- a/guidescreen/GuideScreen/GuideScreen.UI/Controller/PLCController.cs +++ b/guidescreen/GuideScreen/GuideScreen.UI/Controller/PLCController.cs @@ -235,44 +235,44 @@ namespace GuideScreen.Common.Services.Impl /// /// 获取今日用电量 /// - public float GetTodayElectricityConsumption(float total) - { - //获取昨天用电总量 - decimal yesterday = deviceRecordService.GetEnergyMonitoringByDay(PLCPointNameByEnergyMonitoring.ElectricityConsumption, DateTime.Now.AddDays(-1)); - //如果昨日没有记录或为0,就将当前用电量添加当昨日,防止今日用电量为0 - if (yesterday > 0) - { - return total - float.Parse(yesterday.ToString()); + //public float GetTodayElectricityConsumption(float total) + //{ + // //获取昨天用电总量 + // decimal yesterday = deviceRecordService.GetEnergyMonitoringByDay(PLCPointNameByEnergyMonitoring.ElectricityConsumption, DateTime.Now.AddDays(-1)); + // //如果昨日没有记录或为0,就将当前用电量添加当昨日,防止今日用电量为0 + // if (yesterday > 0) + // { + // return total - float.Parse(yesterday.ToString()); - } - else - { - deviceRecordService.UpdateEnergyMonitoringByToday(PLCPointNameByEnergyMonitoring.ElectricityConsumption, "用电量", total, DateTime.Now.AddDays(-1)); - } + // } + // else + // { + // deviceRecordService.UpdateEnergyMonitoringByToday(PLCPointNameByEnergyMonitoring.ElectricityConsumption, "用电量", total, DateTime.Now.AddDays(-1)); + // } - return 0; - } + // return 0; + //} /// /// 获取今日用水量 /// - public float GetTodayWarterConsumption(float total) - { - //获取昨天用电总量 - decimal yesterday = deviceRecordService.GetEnergyMonitoringByDay(PLCPointNameByEnergyMonitoring.WaterConsumption, DateTime.Now.AddDays(-1)); - //如果昨日没有记录或为0,就将当前用电量添加当昨日,防止今日用电量为0 - if (yesterday > 0) - { - return total - float.Parse(yesterday.ToString()); + //public float GetTodayWarterConsumption(float total) + //{ + // //获取昨天用电总量 + // decimal yesterday = deviceRecordService.GetEnergyMonitoringByDay(PLCPointNameByEnergyMonitoring.WaterConsumption, DateTime.Now.AddDays(-1)); + // //如果昨日没有记录或为0,就将当前用电量添加当昨日,防止今日用电量为0 + // if (yesterday > 0) + // { + // return total - float.Parse(yesterday.ToString()); - } - else - { - deviceRecordService.UpdateEnergyMonitoringByToday(PLCPointNameByEnergyMonitoring.WaterConsumption, "用水量", total, DateTime.Now.AddDays(-1)); - } + // } + // else + // { + // deviceRecordService.UpdateEnergyMonitoringByToday(PLCPointNameByEnergyMonitoring.WaterConsumption, "用水量", total, DateTime.Now.AddDays(-1)); + // } - return 0; - } + // return 0; + //} /// /// 获取总用水量 /// @@ -286,5 +286,19 @@ namespace GuideScreen.Common.Services.Impl } return value; } + + /// + /// 获取总用电量 + /// + /// + public decimal GetElectricityTotal() + { + var value = deviceRecordService.ElectricityTotal(); + if (value > 0) + { + value = Math.Round(value, 2); + } + return value; + } } } \ No newline at end of file diff --git a/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.Designer.cs b/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.Designer.cs index eebfbba..4ddadba 100644 --- a/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.Designer.cs +++ b/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.Designer.cs @@ -432,9 +432,9 @@ namespace GuideScreen.UI // this.lblWaterMeter.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold); this.lblWaterMeter.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(128)))), ((int)(((byte)(195))))); - this.lblWaterMeter.Location = new System.Drawing.Point(210, 241); + this.lblWaterMeter.Location = new System.Drawing.Point(216, 241); this.lblWaterMeter.Name = "lblWaterMeter"; - this.lblWaterMeter.Size = new System.Drawing.Size(79, 38); + this.lblWaterMeter.Size = new System.Drawing.Size(144, 38); this.lblWaterMeter.Style = Sunny.UI.UIStyle.Custom; this.lblWaterMeter.StyleCustomMode = true; this.lblWaterMeter.TabIndex = 19; @@ -446,7 +446,7 @@ namespace GuideScreen.UI // this.uiLabel21.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold); this.uiLabel21.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(128)))), ((int)(((byte)(195))))); - this.uiLabel21.Location = new System.Drawing.Point(203, 210); + this.uiLabel21.Location = new System.Drawing.Point(228, 210); this.uiLabel21.Name = "uiLabel21"; this.uiLabel21.Size = new System.Drawing.Size(93, 38); this.uiLabel21.Style = Sunny.UI.UIStyle.Custom; @@ -460,9 +460,9 @@ namespace GuideScreen.UI // this.lblElectricityMeter.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold); this.lblElectricityMeter.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(128)))), ((int)(((byte)(195))))); - this.lblElectricityMeter.Location = new System.Drawing.Point(69, 241); + this.lblElectricityMeter.Location = new System.Drawing.Point(22, 241); this.lblElectricityMeter.Name = "lblElectricityMeter"; - this.lblElectricityMeter.Size = new System.Drawing.Size(79, 38); + this.lblElectricityMeter.Size = new System.Drawing.Size(191, 38); this.lblElectricityMeter.Style = Sunny.UI.UIStyle.Custom; this.lblElectricityMeter.StyleCustomMode = true; this.lblElectricityMeter.TabIndex = 17; @@ -474,7 +474,7 @@ namespace GuideScreen.UI // this.uiLabel18.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold); this.uiLabel18.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(65)))), ((int)(((byte)(128)))), ((int)(((byte)(195))))); - this.uiLabel18.Location = new System.Drawing.Point(56, 211); + this.uiLabel18.Location = new System.Drawing.Point(55, 211); this.uiLabel18.Name = "uiLabel18"; this.uiLabel18.Size = new System.Drawing.Size(105, 38); this.uiLabel18.Style = Sunny.UI.UIStyle.Custom; @@ -779,7 +779,7 @@ namespace GuideScreen.UI // pictureBox10 // this.pictureBox10.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox10.Image"))); - this.pictureBox10.Location = new System.Drawing.Point(219, 155); + this.pictureBox10.Location = new System.Drawing.Point(244, 155); this.pictureBox10.Name = "pictureBox10"; this.pictureBox10.Size = new System.Drawing.Size(61, 52); this.pictureBox10.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -799,7 +799,7 @@ namespace GuideScreen.UI // pictureBox9 // this.pictureBox9.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox9.Image"))); - this.pictureBox9.Location = new System.Drawing.Point(78, 155); + this.pictureBox9.Location = new System.Drawing.Point(77, 155); this.pictureBox9.Name = "pictureBox9"; this.pictureBox9.Size = new System.Drawing.Size(61, 52); this.pictureBox9.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; diff --git a/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.cs b/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.cs index 3b549a3..1ad1924 100644 --- a/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.cs +++ b/guidescreen/GuideScreen/GuideScreen.UI/FormScreen.cs @@ -1,4 +1,4 @@ -using GuideScreen.Common; +using GuideScreen.Common; using GuideScreen.Common.Common; using GuideScreen.Common.Constants; using GuideScreen.Common.Models; @@ -22,37 +22,37 @@ namespace GuideScreen.UI { public partial class FormScreen : UIForm { - //вʹ + //男厕使用数量 private const string currentManNumStrFormat = "5/{0}"; - //Ůʹ + //女厕使用数量 private const string currentWomanNumStrFormat = "3/{0}"; - // + //零点 private const string zeroTime = "00:00:00"; - //ͨ + //通用 private CommonController commonController; - //տ + //今日客流量 private int passengerFlowDayTotal = 0; - //ͳ + //客流统计 private PassengerFlowStatisticsController passengerFlowStatisticsController; - // + //客流总量 private int passengerFlowTotal = 0; - //PLC + //PLC相关 private PLCController plcController; - //ղλʹͳ + //今日厕所侧位使用统计 private IDictionary toilets; - //նx + //真空度x坐标 private int vacuumIndex = 0; - // + //今日气象 private WeatherController weatherController; public FormScreen() @@ -80,15 +80,15 @@ namespace GuideScreen.UI { switch (e.ClickedItem.Text) { - case "̨": + case "后台管理": ControlForm form = new ControlForm(); form.ShowDialog(); break; - case "": + case "报表": ChartForm from = new ChartForm(); from.ShowDialog(); break; - case "ر": + case "关闭": Close(); break; @@ -96,14 +96,14 @@ namespace GuideScreen.UI break; } - if (e.ClickedItem.Text == "ر") + if (e.ClickedItem.Text == "关闭") { Close(); } } /// - /// Ϣ + /// 错误信息 /// /// /// @@ -115,7 +115,7 @@ namespace GuideScreen.UI } /// - /// ʾ + /// 错误提示框 /// /// /// @@ -138,33 +138,33 @@ namespace GuideScreen.UI { try { - // + //加载 plcController.Load(); - //ȡ + //获取标题 lblTitle.Text = commonController.Title; - // + //报警数据 this.txtAlarm.Text = commonController.AlarmText; - //PLCͨ + //开启PLC通信 plcController.Start(); - //ղλʹ + //今日厕位使用情况 toilets = plcController.ToiletPositionRecordTotalByToday(); - //ͳ + //总统计 passengerFlowTotal = plcController.GetToiletRecordTotal(); PassengerFlowUpdate(); - //ն + //真空度 VacuumChart(0); - //ȡϢ + //获取天气信息 await GetWeather(); - //ˮ + //用水量 SetDayWarterAndelEctricity(); } @@ -174,7 +174,7 @@ namespace GuideScreen.UI } } - #region ȡλ + #region 获取点位更新 private void PlcController_PointChnage(object sender, PLCPoint e) { @@ -186,21 +186,21 @@ namespace GuideScreen.UI } catch (Exception ex) { - ErrorDialog("ȡλ" + ex.Message); + ErrorDialog("获取点位错误:" + ex.Message); ex.WriteErrorLog(); } })); } - #endregion ȡλ + #endregion 获取点位更新 - #region Ƿ + #region 厕所是否有人 private void ToileUseChange(bool isMan, int num, bool use) { if (isMan) { - //вʹ + //男厕使用数量 var manNum = plcController.Points.Where(f => f.Name.StartsWith("ToiletMan") && f.GetValue()).Count(); lblCurrentManNum.Text = string.Format(currentManNumStrFormat, manNum); switch (num) @@ -209,7 +209,7 @@ namespace GuideScreen.UI if (use) { pBoxManPitOne.Visible = true; - toilets["в1"]++; + toilets["男厕1"]++; } else { @@ -222,7 +222,7 @@ namespace GuideScreen.UI if (use) { pBoxManPitTwo.Visible = true; - toilets["в2"]++; + toilets["男厕2"]++; } else { @@ -235,7 +235,7 @@ namespace GuideScreen.UI if (use) { pBoxUrinateMan1.Image = Resources.urinateFull; - toilets["в3"]++; + toilets["男厕3"]++; } else { @@ -247,7 +247,7 @@ namespace GuideScreen.UI if (use) { pBoxUrinateMan2.Image = Resources.urinateFull; - toilets["в4"]++; + toilets["男厕4"]++; } else { @@ -259,7 +259,7 @@ namespace GuideScreen.UI if (use) { pBoxUrinateMan3.Image = Resources.urinateFull; - toilets["в5"]++; + toilets["男厕5"]++; } else { @@ -273,7 +273,7 @@ namespace GuideScreen.UI } else { - //Ůʹ + //女厕使用数量 var womanNum = plcController.Points.Where(f => f.Name.StartsWith("ToiletWoman") && f.GetValue()).Count(); lblCurrentWomanNum.Text = string.Format(currentWomanNumStrFormat, womanNum); switch (num) @@ -282,7 +282,7 @@ namespace GuideScreen.UI if (use) { pBoxPitWomanOne.Visible = true; - toilets["Ů1"]++; + toilets["女厕1"]++; } else { @@ -294,7 +294,7 @@ namespace GuideScreen.UI if (use) { pBoxPitWomanTwo.Visible = true; - toilets["Ů2"]++; + toilets["女厕2"]++; } else { @@ -306,7 +306,7 @@ namespace GuideScreen.UI if (use) { pBoxPitWomanThree.Visible = true; - toilets["Ů3"]++; + toilets["女厕3"]++; } else { @@ -324,49 +324,49 @@ namespace GuideScreen.UI passengerFlowTotal++; } - //¿Ϣ + //更新客流信息 PassengerFlowUpdate(); // ToileUseChartByDay(); // ToileUseChartTotal(); - //ˮ + //计算用水量 SetDayWarterAndelEctricity(); } - #endregion Ƿ + #endregion 厕所是否有人 - #region + #region 气象相关 /// - /// ȡϢ + /// 获取气象信息 /// /// private async Task GetWeather() { - //ȡʵʱ + //获取城市实时天气 var weatherModel = await weatherController.GetWeatherNowAsync(); - //ȡ + //获取城市天气质量 var airModel = await weatherController.GetWeatherAirAsync(); - //ȡָ + //获取城市天气指数 var levelModel = await weatherController.GetWeatherIndicesAsync(); this.Invoke(new Action(() => { - //óʵʱ + //设置城市实时天气 if (weatherModel != null && weatherModel.IsSuccee) { DateTime.TryParse(weatherModel.UpdateTime, out DateTime dt); //lblWeatherUpdateTime.Text = dt.ToString("yyyy-MM-dd HH:mm:ss"); lblWeatherText.Text = weatherModel.Now.Text; lblWeatherWindDir.Text = weatherModel.Now.WindDir; - lblWeatherWindScale.Text = weatherModel.Now.WindScale.ToString() + ""; + lblWeatherWindScale.Text = weatherModel.Now.WindScale.ToString() + "级"; lblWeatherHumidity.Text = weatherModel.Now.Humidity.ToString() + "%"; - lblWeatherFeelsLike.Text = weatherModel.Now.FeelsLike.ToString() + "C"; - lblWeatherTemp.Text = weatherModel.Now.Temp.ToString() + "C"; + lblWeatherFeelsLike.Text = weatherModel.Now.FeelsLike.ToString() + "C°"; + lblWeatherTemp.Text = weatherModel.Now.Temp.ToString() + "C°"; var icon = weatherModel.Now.Icon; if (icon == 151) { @@ -374,12 +374,12 @@ namespace GuideScreen.UI } pBoxWeatherIcon.Image = (Image)(Resources.ResourceManager.GetObject($"_{icon}")); } - //ó + //设置城市天气质量 if (airModel != null && airModel.IsSuccee) { WeatherAir(airModel); } - //óָ + //设置城市天气指数 if (levelModel != null && levelModel.IsSuccee && levelModel.Daily.Length == 2) { lblWeatherUltravioletRay.Text = levelModel.Daily[0].Category; @@ -389,7 +389,7 @@ namespace GuideScreen.UI } /// - /// ʾ + /// 显示空气质量 /// /// private void WeatherAir(WeatherAirModel model) @@ -428,12 +428,12 @@ namespace GuideScreen.UI btnAQI.Text = "AQI " + model.Now.Category; } - #endregion + #endregion 气象相关 - #region ͳ + #region 人流统计 /// - /// + /// 人流经过 /// /// /// @@ -442,7 +442,7 @@ namespace GuideScreen.UI } /// - /// + /// 客流量更新 /// private void PassengerFlowUpdate() { @@ -457,89 +457,89 @@ namespace GuideScreen.UI passengerFlowTotal = 1; } // lblPassengerFlowHistoryCount.Text = passengerFlowTotal.ToString("D8").Aggregate(string.Empty, (c, i) => c + i + " "); - //λͼ + //侧位图表 ToileUseChartByDay(); //ToileUseChartTotal(); } - #endregion ͳ + #endregion 人流统计 - #region PLCȡλ + #region PLC获取点位 private void PointChange(PLCPoint e) { Debug.WriteLine(Masuit.Tools.ObjectExtensions.ToJsonString(e)); switch (e.Name) { - #region λ״̬ + #region 侧位状态 - //вλ1״̬ + //男侧位1状态 case PLCPointNameByToiletPosition.ToiletManStatus1: ToileUseChange(true, 1, e.GetValue()); break; - //вλ2״̬ + //男侧位2状态 case PLCPointNameByToiletPosition.ToiletManStatus2: ToileUseChange(true, 2, e.GetValue()); break; - //вλ3״̬ + //男侧位3状态 case PLCPointNameByToiletPosition.ToiletManStatus3: ToileUseChange(true, 3, e.GetValue()); break; - //вλ4״̬ + //男侧位4状态 case PLCPointNameByToiletPosition.ToiletManStatus4: ToileUseChange(true, 4, e.GetValue()); break; - //вλ5״̬ + //男侧位5状态 case PLCPointNameByToiletPosition.ToiletManStatus5: ToileUseChange(true, 5, e.GetValue()); break; - //Ůλ1״̬ + //女侧位1状态 case PLCPointNameByToiletPosition.ToiletWomanStatus1: ToileUseChange(false, 1, e.GetValue()); break; - //Ůλ2״̬ + //女侧位2状态 case PLCPointNameByToiletPosition.ToiletWomanStatus2: ToileUseChange(false, 2, e.GetValue()); break; - //Ůλ3״̬ + //女侧位3状态 case PLCPointNameByToiletPosition.ToiletWomanStatus3: ToileUseChange(false, 3, e.GetValue()); break; - #endregion λ״̬ + #endregion 侧位状态 - #region ܺļ + #region 能耗监控 - //õ + //用电量 case PLCPointNameByEnergyMonitoring.ElectricityConsumption: - //ܵ - lblElectricityMeter.Text = Convert.ToInt32(e.GetValue()).ToString(); - //յ - var str = Convert.ToInt32(plcController.GetTodayElectricityConsumption(e.GetValue())).ToString(); + //总电量 + // lblElectricityMeter.Text = Convert.ToInt32(e.GetValue()).ToString(); + //今日电量 + // var str = Convert.ToInt32(plcController.GetTodayElectricityConsumption(e.GetValue())).ToString(); //str = str.Aggregate(string.Empty, (c, i) => c + i + " "); - lblElectricQuantity.Text = $"պĵ {str} ǧʱ"; + // lblElectricQuantity.Text = $"今日耗电量 {str} 千瓦时"; break; case PLCPointNameByEnergyMonitoring.WaterConsumption: - //ˮ + //总用水量 //var waterValue = e.GetValue();//* 0.001f; //lblWaterMeter.Text = Convert.ToInt32(waterValue).ToString(); - //ˮ + //今日用水量 //var str1 = Convert.ToInt32(plcController.GetTodayWarterConsumption(waterValue)).ToString(); ////str1 = str1.Aggregate(string.Empty, (c, i) => c + i + " "); - //lblDayWarter.Text = $"ˮ {str1} "; + //lblDayWarter.Text = $"今日用水量 {str1} 吨 "; break; - #endregion ܺļ + #endregion 能耗监控 - #region + #region 环境监控 case PLCPointNameByEnvironmentalMonitoring.Temperature: var temperature = e.GetValue(); var temperatureValue = Math.Round(165 * temperature / 1650f - 40, 2); - lblEnvirTempl.Text = temperatureValue + " C"; + lblEnvirTempl.Text = temperatureValue + " °C"; //processEnvirTempl.Value = Convert.ToInt32(temperatureValue) + 40; break; @@ -551,24 +551,24 @@ namespace GuideScreen.UI break; case PLCPointNameByEnvironmentalMonitoring.NH3: - // + //暂无数据 //var enviHydrogenSulfide = e.GetValue(); //lblEnviHydrogenSulfide.Text = Math.Round(enviHydrogenSulfide, 2).ToString() + " PPM"; //processEnviHydrogenSulfide.Value = Convert.ToInt32(enviHydrogenSulfide); break; case PLCPointNameByEnvironmentalMonitoring.H2S: - // + //暂无数据 //var ammoniaGas = e.GetValue(); //lblEnviAmmoniaGas.Text = Math.Round(ammoniaGas, 2).ToString() + " PPM"; //processEnviAmmoniaGas.Value = Convert.ToInt32(ammoniaGas); break; - #endregion + #endregion 环境监控 - #region ձվ + #region 真空泵站 - //ʵʱն + //实时真空度 case PLCPointNameByVacuumPumpingStation.RealTimeVacuum: var realTimeVacuum = e.GetValue(); var value = Math.Abs(realTimeVacuum); @@ -577,31 +577,31 @@ namespace GuideScreen.UI lblVacuum.Text = $"-{value} KPa"; VacuumChart(value); break; - //е1 + //运行电流1 case PLCPointNameByVacuumPumpingStation.RunningCurrent1: var runningCurrent = e.GetValue(); analogMeterElectricity1.Value = runningCurrent; lblElectricity1.Text = $"{runningCurrent} A"; break; - //Ƶ1 + //运行频率1 case PLCPointNameByVacuumPumpingStation.RunningFrequency1: var runningFrequency = e.GetValue(); analogMeterFrequency1.Value = runningFrequency; lblFrequency1.Text = $"{runningFrequency} HZ"; break; - //е2 + //运行电流2 case PLCPointNameByVacuumPumpingStation.RunningCurrent2: var runningCurrent2 = e.GetValue(); analogMeterElectricity2.Value = runningCurrent2; lblElectricity2.Text = $"{runningCurrent2} A"; break; - //Ƶ2 + //运行频率2 case PLCPointNameByVacuumPumpingStation.RunningFrequency2: var runningFrequency2 = e.GetValue(); analogMeterFrequency2.Value = runningFrequency2; lblFrequency2.Text = $"{runningFrequency2} HZ"; break; - //1ű״̬ + //1号泵状态 case PLCPointNameByVacuumPumpingStation.PumpingStation1: if (e.GetValue()) { @@ -612,7 +612,7 @@ namespace GuideScreen.UI LedBulbOneRun.ForeColor = Color.Gray; } break; - //2ű״̬ + //2号泵状态 case PLCPointNameByVacuumPumpingStation.PumpingStation2: if (e.GetValue()) { @@ -623,28 +623,28 @@ namespace GuideScreen.UI LedBulbTwoRun.ForeColor = Color.Gray; } break; - //1űд + //1号泵运行次数 case PLCPointNameByVacuumPumpingStation.PumpStartTimes1: var pumpStartCount1 = e.GetValue(); LedDisplayOneCount.Text = pumpStartCount1.ToString("D6"); break; - //2űд + //2号泵运行次数 case PLCPointNameByVacuumPumpingStation.PumpStartTimes2: var pumpStartCount2 = e.GetValue(); LedDisplayTwoCount.Text = pumpStartCount2.ToString("D6"); break; - //1űʱ + //1号泵运行时间 case PLCPointNameByVacuumPumpingStation.PumpAccumulatedStartTime1: var pumpAccumulatedStartTime1 = e.GetValue(); LedDisplayOneTime.Text = pumpAccumulatedStartTime1.ToString("D5") + "H"; break; - //2űʱ + //2号泵运行时间 case PLCPointNameByVacuumPumpingStation.PumpAccumulatedStartTime2: var pumpAccumulatedStartTime2 = e.GetValue(); LedDisplayTwoTime.Text = pumpAccumulatedStartTime2.ToString("D5") + "H"; break; - #endregion ձվ + #endregion 真空泵站 default: break; @@ -660,12 +660,12 @@ namespace GuideScreen.UI } } - #endregion PLCȡλ + #endregion PLC获取点位 - #region ͼ + #region 图表相关 /// - /// + /// 人流量 /// //private void PassengerFlowChart(List list) //{ @@ -684,15 +684,15 @@ namespace GuideScreen.UI // option.ToolTip.Visible = true; // option.YAxis.Scale = true; - // option.XAxis.Name = ""; - // option.XAxis.AxisLabel.Angle = 60;//(0 ~ 90) - // option.YAxis.Name = "ֵ"; + // option.XAxis.Name = "日期"; + // option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°) + // option.YAxis.Name = "数值"; - // //ʾСλ + // //数据显示小数位数 // series.DecimalPlaces = 0; // option.Series.Add(series); - // //ʾСλ + // //坐标轴显示小数位数 // option.YAxis.AxisLabel.DecimalPlaces = 0; // option.XAxis.AxisLabel.DecimalPlaces = 0; // option.ToolTip.AxisPointer.Type = UIAxisPointerType.Shadow; @@ -701,13 +701,13 @@ namespace GuideScreen.UI //} /// - /// ղλʹ + /// 今日厕位使用情况 /// private void ToileUseChartByDay() { UIBarOption option = new UIBarOption(); option.Title = new UITitle(); - option.Title.Text = "ղλʹü¼"; + option.Title.Text = "今日厕位使用记录"; option.Title.SubText = string.Empty; var series = new UIBarSeries(); @@ -720,15 +720,15 @@ namespace GuideScreen.UI option.ToolTip.Visible = true; option.YAxis.Scale = true; - option.XAxis.Name = "λ"; - //option.XAxis.AxisLabel.Angle = 60;//(0 ~ 90) - //option.YAxis.Name = "ʹô"; + option.XAxis.Name = "厕位"; + //option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°) + //option.YAxis.Name = "使用次数"; - //ʾСλ + //数据显示小数位数 series.DecimalPlaces = 0; option.Series.Add(series); - //ʾСλ + //坐标轴显示小数位数 option.YAxis.AxisLabel.DecimalPlaces = 0; option.XAxis.AxisLabel.DecimalPlaces = 0; option.ToolTip.AxisPointer.Type = UIAxisPointerType.Shadow; @@ -737,13 +737,13 @@ namespace GuideScreen.UI } /// - /// λʹͳ + /// 厕位使用统计 /// private void ToileUseChartTotal() { UIBarOption option = new UIBarOption(); option.Title = new UITitle(); - option.Title.Text = "λʹͳ"; + option.Title.Text = "厕位使用统计"; option.Title.SubText = string.Empty; var series = new UIBarSeries(); @@ -757,15 +757,15 @@ namespace GuideScreen.UI option.ToolTip.Visible = true; option.YAxis.Scale = true; - option.XAxis.Name = "λ"; - //option.XAxis.AxisLabel.Angle = 60;//(0 ~ 90) - //option.YAxis.Name = "ʹô"; + option.XAxis.Name = "厕位"; + //option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°) + //option.YAxis.Name = "使用次数"; - //ʾСλ + //数据显示小数位数 series.DecimalPlaces = 0; option.Series.Add(series); - //ʾСλ + //坐标轴显示小数位数 option.YAxis.AxisLabel.DecimalPlaces = 0; option.XAxis.AxisLabel.DecimalPlaces = 0; option.ToolTip.AxisPointer.Type = UIAxisPointerType.Shadow; @@ -776,7 +776,7 @@ namespace GuideScreen.UI /// - /// նͼ + /// 真空度曲线图 /// /// private void VacuumChart(double value) @@ -789,13 +789,13 @@ namespace GuideScreen.UI option.Title.Text = string.Empty; option.Title.SubText = string.Empty; option.AddSeries(new UILineSeries("vacuumLine")); - //ʾСλ + //坐标轴显示小数位数 option.XAxis.AxisLabel.DecimalPlaces = 0; option.YAxis.AxisLabel.DecimalPlaces = 0; chartVacuum.SetOption(option); } - //նȹ + //真空度过期 if (vacuumIndex > 1000) { vacuumIndex = 0; @@ -807,29 +807,44 @@ namespace GuideScreen.UI } - #endregion ͼ + #endregion 图表相关 /// - /// ˮ + /// 计算用水量 /// private void SetDayWarterAndelEctricity() { var count = toilets.Values.Sum(); - //ÿô1.6ˮ - var value = Convert.ToSingle(Math.Round(count * 0.0016, 4)); + //每用次0.8 升水 + var value = Convert.ToSingle(Math.Round(count * 0.8, 2)); var dayStr = value.ToString().Aggregate(string.Empty, (c, i) => c + i + " "); - lblDayWarter.Text = $"ˮ {dayStr} "; + lblDayWarter.Text = $"今日用水量 {dayStr} L"; + //总用水量 + lblWaterMeter.Text = (1.8m + Math.Round(plcController.GetWaterTotal()*0.8m / 1000m, 2)) + " 吨"; + //今日用电量 单位kW.h每次 0.0003kW.h + var val = Convert.ToSingle(Math.Round(count * 0.0003, 4)); + var str = val.ToString().Aggregate(string.Empty, (c, i) => c + i + " "); + lblElectricQuantity.Text = $"今日耗电量 {str} kW.h"; + //总用电量 + lblElectricityMeter.Text = (6.78m + Math.Round(plcController.GetElectricityTotal() * 0.0003m, 2)) + " kW.h"; plcController.AdddeviceRecord(new PLCPoint { Device = PLCDeviceNames.EnergyMonitoring, Name = PLCPointNameByEnergyMonitoring.WaterConsumption, - Note = "ˮ", + Note = "用水量", DataType = typeof(float), ObjectValue = value, }); - //ˮ - lblWaterMeter.Text = plcController.GetWaterTotal().ToString(); + plcController.AdddeviceRecord(new PLCPoint + { + Device = PLCDeviceNames.EnergyMonitoring, + Name = PLCPointNameByEnergyMonitoring.ElectricityConsumption, + Note = "用电量", + DataType = typeof(float), + ObjectValue = val, + }); + } #region Timer @@ -837,27 +852,27 @@ namespace GuideScreen.UI private Random rd = new Random(); /// - /// ʱ + /// 日期时间 /// /// /// private void timer1_Tick(object sender, EventArgs e) { var dateTime = DateTime.Now; - //ʱ + //日期时间 lblTime.Text = dateTime.ToString("yyyy-MM-dd HH:mm:ss"); - // + //星期 lblweek.Text = DateTime.Today.ToString("dddd", new System.Globalization.CultureInfo("zh-CN")); - //Ժµ + //零点以后更新的数据 if (dateTime.ToString("HH:mm:ss") == zeroTime) { - //²λʹ + //更新厕位使用情况 toilets = plcController.ToiletPositionRecordTotalByToday(); ToileUseChartByDay(); } } - //ʱ + //定时更新气象数据 private async void timer2_Tick(object sender, EventArgs e) { await GetWeather(); @@ -867,7 +882,7 @@ namespace GuideScreen.UI private void timer3_Tick(object sender, EventArgs e) { - // + //报警数据 this.txtAlarm.Text = commonController.AlarmText; } }