修改总用水量与总用电量

main
肖果 2 months ago
parent 98d4563571
commit cc2e1bec43

@ -66,6 +66,12 @@ namespace GuideScreen.Common.Repositories
/// <returns></returns>
decimal WaterTotal();
/// <summary>
/// 获取总用电量
/// </summary>
/// <returns></returns>
decimal ElectricityTotal();
/// <summary>
/// 获取厕位使用计
/// </summary>

@ -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;
}
}
/// <summary>
/// 获取总用电量
/// </summary>
/// <returns></returns>
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;
}
}

@ -99,6 +99,12 @@ namespace GuideScreen.Common.Services
/// <returns></returns>
decimal WaterTotal();
/// <summary>
/// 获取总用电量
/// </summary>
/// <returns></returns>
decimal ElectricityTotal();
/// <summary>
/// 获取厕位使用计
/// </summary>

@ -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;
}
/// <summary>
/// 获取总用电量
/// </summary>
/// <returns></returns>
public decimal ElectricityTotal()
{
var ret = this.deviceRecordRepository.ElectricityTotal();
return ret;
}
/// <summary>
/// 获取厕位使用计
/// </summary>

@ -235,44 +235,44 @@ namespace GuideScreen.Common.Services.Impl
/// <summary>
/// 获取今日用电量
/// </summary>
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;
//}
/// <summary>
/// 获取今日用水量
/// </summary>
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;
//}
/// <summary>
/// 获取总用水量
/// </summary>
@ -286,5 +286,19 @@ namespace GuideScreen.Common.Services.Impl
}
return value;
}
/// <summary>
/// 获取总用电量
/// </summary>
/// <returns></returns>
public decimal GetElectricityTotal()
{
var value = deviceRecordService.ElectricityTotal();
if (value > 0)
{
value = Math.Round(value, 2);
}
return value;
}
}
}

@ -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;

@ -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<string, int> 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();
}
}
/// <summary>
/// 错误信息
/// 错误信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@ -115,7 +115,7 @@ namespace GuideScreen.UI
}
/// <summary>
/// 错误提示框
/// 错误提示框
/// </summary>
/// <param name="errMsg"></param>
/// <param name="isDialog"></param>
@ -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<bool>()).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<bool>()).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 气象相关
/// <summary>
/// 获取气象信息
/// 获取气象信息
/// </summary>
/// <returns></returns>
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
}
/// <summary>
/// 显示空气质量
/// 显示空气质量
/// </summary>
/// <param name="model"></param>
private void WeatherAir(WeatherAirModel model)
@ -428,12 +428,12 @@ namespace GuideScreen.UI
btnAQI.Text = "AQI " + model.Now.Category;
}
#endregion 气象相关
#endregion 气象相关
#region 人流统计
#region 人流统计
/// <summary>
/// 人流经过
/// 人流经过
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@ -442,7 +442,7 @@ namespace GuideScreen.UI
}
/// <summary>
/// 客流量更新
/// 客流量更新
/// </summary>
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<bool>());
break;
//男侧位2状态
//男侧位2状态
case PLCPointNameByToiletPosition.ToiletManStatus2:
ToileUseChange(true, 2, e.GetValue<bool>());
break;
//男侧位3状态
//男侧位3状态
case PLCPointNameByToiletPosition.ToiletManStatus3:
ToileUseChange(true, 3, e.GetValue<bool>());
break;
//男侧位4状态
//男侧位4状态
case PLCPointNameByToiletPosition.ToiletManStatus4:
ToileUseChange(true, 4, e.GetValue<bool>());
break;
//男侧位5状态
//男侧位5状态
case PLCPointNameByToiletPosition.ToiletManStatus5:
ToileUseChange(true, 5, e.GetValue<bool>());
break;
//女侧位1状态
//女侧位1状态
case PLCPointNameByToiletPosition.ToiletWomanStatus1:
ToileUseChange(false, 1, e.GetValue<bool>());
break;
//女侧位2状态
//女侧位2状态
case PLCPointNameByToiletPosition.ToiletWomanStatus2:
ToileUseChange(false, 2, e.GetValue<bool>());
break;
//女侧位3状态
//女侧位3状态
case PLCPointNameByToiletPosition.ToiletWomanStatus3:
ToileUseChange(false, 3, e.GetValue<bool>());
break;
#endregion 侧位状态
#endregion 侧位状态
#region 能耗监控
#region 能耗监控
//用电量
//用电量
case PLCPointNameByEnergyMonitoring.ElectricityConsumption:
//总电量
lblElectricityMeter.Text = Convert.ToInt32(e.GetValue<float>()).ToString();
//今日电量
var str = Convert.ToInt32(plcController.GetTodayElectricityConsumption(e.GetValue<float>())).ToString();
//总电量
// lblElectricityMeter.Text = Convert.ToInt32(e.GetValue<float>()).ToString();
//今日电量
// var str = Convert.ToInt32(plcController.GetTodayElectricityConsumption(e.GetValue<float>())).ToString();
//str = str.Aggregate(string.Empty, (c, i) => c + i + " ");
lblElectricQuantity.Text = $"今日耗电量 {str} 千瓦时";
// lblElectricQuantity.Text = $"今日耗电量 {str} 千瓦时";
break;
case PLCPointNameByEnergyMonitoring.WaterConsumption:
//总用水量
//总用水量
//var waterValue = e.GetValue<float>();//* 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<Int16>();
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<float>();
//lblEnviHydrogenSulfide.Text = Math.Round(enviHydrogenSulfide, 2).ToString() + " PPM";
//processEnviHydrogenSulfide.Value = Convert.ToInt32(enviHydrogenSulfide);
break;
case PLCPointNameByEnvironmentalMonitoring.H2S:
//暂无数据
//暂无数据
//var ammoniaGas = e.GetValue<float>();
//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<Int16>();
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<Int16>();
analogMeterElectricity1.Value = runningCurrent;
lblElectricity1.Text = $"{runningCurrent} A";
break;
//运行频率1
//运行频率1
case PLCPointNameByVacuumPumpingStation.RunningFrequency1:
var runningFrequency = e.GetValue<Int16>();
analogMeterFrequency1.Value = runningFrequency;
lblFrequency1.Text = $"{runningFrequency} HZ";
break;
//运行电流2
//运行电流2
case PLCPointNameByVacuumPumpingStation.RunningCurrent2:
var runningCurrent2 = e.GetValue<Int16>();
analogMeterElectricity2.Value = runningCurrent2;
lblElectricity2.Text = $"{runningCurrent2} A";
break;
//运行频率2
//运行频率2
case PLCPointNameByVacuumPumpingStation.RunningFrequency2:
var runningFrequency2 = e.GetValue<Int16>();
analogMeterFrequency2.Value = runningFrequency2;
lblFrequency2.Text = $"{runningFrequency2} HZ";
break;
//1号泵状态
//1号泵状态
case PLCPointNameByVacuumPumpingStation.PumpingStation1:
if (e.GetValue<bool>())
{
@ -612,7 +612,7 @@ namespace GuideScreen.UI
LedBulbOneRun.ForeColor = Color.Gray;
}
break;
//2号泵状态
//2号泵状态
case PLCPointNameByVacuumPumpingStation.PumpingStation2:
if (e.GetValue<bool>())
{
@ -623,28 +623,28 @@ namespace GuideScreen.UI
LedBulbTwoRun.ForeColor = Color.Gray;
}
break;
//1号泵运行次数
//1号泵运行次数
case PLCPointNameByVacuumPumpingStation.PumpStartTimes1:
var pumpStartCount1 = e.GetValue<Int16>();
LedDisplayOneCount.Text = pumpStartCount1.ToString("D6");
break;
//2号泵运行次数
//2号泵运行次数
case PLCPointNameByVacuumPumpingStation.PumpStartTimes2:
var pumpStartCount2 = e.GetValue<Int16>();
LedDisplayTwoCount.Text = pumpStartCount2.ToString("D6");
break;
//1号泵运行时间
//1号泵运行时间
case PLCPointNameByVacuumPumpingStation.PumpAccumulatedStartTime1:
var pumpAccumulatedStartTime1 = e.GetValue<Int16>();
LedDisplayOneTime.Text = pumpAccumulatedStartTime1.ToString("D5") + "H";
break;
//2号泵运行时间
//2号泵运行时间
case PLCPointNameByVacuumPumpingStation.PumpAccumulatedStartTime2:
var pumpAccumulatedStartTime2 = e.GetValue<Int16>();
LedDisplayTwoTime.Text = pumpAccumulatedStartTime2.ToString("D5") + "H";
break;
#endregion 真空泵站
#endregion 真空泵站
default:
break;
@ -660,12 +660,12 @@ namespace GuideScreen.UI
}
}
#endregion PLC获取点位
#endregion PLC获取点位
#region 图表相关
#region 图表相关
/// <summary>
/// 人流量
/// 人流量
/// </summary>
//private void PassengerFlowChart(List<PassengerFlowStatisticsTotalModel> 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
//}
/// <summary>
/// 今日厕位使用情况
/// 今日厕位使用情况
/// </summary>
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
}
/// <summary>
/// 厕位使用统计
/// 厕位使用统计
/// </summary>
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
/// <summary>
/// 真空度曲线图
/// 真空度曲线图
/// </summary>
/// <param name="value"></param>
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 图表相关
/// <summary>
/// 计算用水量
/// 计算用水量
/// </summary>
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();
/// <summary>
/// 日期时间
/// 日期时间
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
}

Loading…
Cancel
Save