|
@@ -14,6 +14,7 @@ using System.ComponentModel;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
+using static log4net.Appender.RollingFileAppender;
|
|
|
|
|
|
namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
@@ -31,10 +32,22 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
|
|
|
//public Dictionary<int, string> EnvironmentValues { get; set; } = new Dictionary<int, string>();
|
|
|
|
|
|
- public List<string> EnvironmentValues { get; set; } = new List<string>();
|
|
|
- /// <summary>
|
|
|
- ///
|
|
|
- /// </summary>
|
|
|
+ //public List<string> EnvironmentValues { get; set; } = new List<string>();
|
|
|
+
|
|
|
+ #region 曲线图累计 上一时间段值
|
|
|
+ public int? PreRegElectricityConsumptionTotalChart { get; set; }
|
|
|
+
|
|
|
+ public int? PreRegCompressedAirTotalChart { get; set; }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 生产记录累计 上一时间段值
|
|
|
+ public int? PreRegElectricityConsumptionTotalProduction { get; set; }
|
|
|
+
|
|
|
+ public int? PreRegCompressedAirTotalProduction { get; set; }
|
|
|
+
|
|
|
+ public int? PreRegOutputTotalProduction { get; set; }
|
|
|
+ #endregion
|
|
|
+
|
|
|
/// <param name="machieID"></param>
|
|
|
public SampleMachine(string machieID) : base(machieID)
|
|
|
{
|
|
@@ -56,333 +69,28 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
.ToLookup(t => t.AlarmCode).
|
|
|
ToDictionary(t => t.Key, t => t.First());
|
|
|
|
|
|
- var c = 4;
|
|
|
+ Env.DAL.App_BY_EnvironmentValues.DeleteOldData(DateTime.Now);
|
|
|
|
|
|
+ PreRegElectricityConsumptionTotalChart = GetListenReg("累计用电量")?.Value;
|
|
|
+ PreRegCompressedAirTotalChart = GetListenReg("压缩空气累计量")?.Value;
|
|
|
|
|
|
+ PreRegElectricityConsumptionTotalProduction = GetListenReg("累计用电量")?.Value;
|
|
|
+ PreRegCompressedAirTotalProduction = GetListenReg("压缩空气累计量")?.Value;
|
|
|
+ PreRegOutputTotalProduction = GetListenReg("产量统计")?.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private readonly string taiDaAS300 = "台达AS300";
|
|
|
+
|
|
|
//使用事件
|
|
|
private void Schedual_DateTimeChanged1(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
|
|
|
{
|
|
|
// 此在本类内 故是对设备筛选 若在其他类 则需实例化类设备对象如CustoneService文件内
|
|
|
- var DeviceIDTaiDaAS300 = "台达AS300";
|
|
|
- if (BaseDevice.DeviceID == DeviceIDTaiDaAS300)
|
|
|
+ if (BaseDevice.DeviceID == taiDaAS300)
|
|
|
{
|
|
|
- if (GetListenReg("左枪电流") != null)
|
|
|
- {
|
|
|
- var LeftCurrent = GetListenReg("左枪电流").Float;
|
|
|
- var CenterCurrent = GetListenReg("中枪电流").Float;
|
|
|
- var RightCurrent = GetListenReg("右枪电流").Float;
|
|
|
- var LeftAirPressure = GetListenReg("左枪气压").Float;
|
|
|
- var CenterAirPressure = GetListenReg("中枪气压").Float;
|
|
|
- var RightAirPressure = GetListenReg("右枪气压").Float;
|
|
|
-
|
|
|
- //如果秒数发生变化
|
|
|
- if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged)
|
|
|
- {
|
|
|
- // 各字段插入数据 初始化
|
|
|
- Env.DAL.App_BY_EnvironmentValues.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.CenterCurrent_Dec, CenterCurrent),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.LeftCurrent_Dec, LeftCurrent),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.RightCurrent_Dec, RightCurrent),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.CenterAirPressure_Dec, CenterAirPressure),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.LeftAirPressure_Dec, LeftAirPressure),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.RightAirPressure_Dec, RightAirPressure)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (GetListenReg("总通电时间时")?.ScaleValue != null)
|
|
|
- {
|
|
|
- // 做判空
|
|
|
- // 时间格式化
|
|
|
- string ToHMS(double H, double M, double S)
|
|
|
- {
|
|
|
- string h, m, s;
|
|
|
- h = H < 10 ? $"0{H}" : $"{H}";
|
|
|
- m = M < 10 ? $"0{M}" : $"{M}";
|
|
|
- s = S < 10 ? $"0{S}" : $"{S}";
|
|
|
- return $"{h}:{m}:{s}";
|
|
|
- }
|
|
|
- var totalTimeH = GetListenReg("总运行时间时").ScaleValue.Value;
|
|
|
- var totalTimeM = GetListenReg("总运行时间分").ScaleValue.Value;
|
|
|
- var totalTimeS = GetListenReg("总运行时间秒").ScaleValue.Value;
|
|
|
- var totalTimeHMS = ToHMS(totalTimeH, totalTimeM, totalTimeS);
|
|
|
- var runTimeH = GetListenReg("生产运行时间时").ScaleValue.Value;
|
|
|
- var runTimeM = GetListenReg("生产运行时间分").ScaleValue.Value;
|
|
|
- var runTimeS = GetListenReg("生产运行时间秒").ScaleValue.Value;
|
|
|
- var runTimeHMS = ToHMS(runTimeH, runTimeM, runTimeS);
|
|
|
- var standbyTimeH = GetListenReg("待机时间时").ScaleValue.Value;
|
|
|
- var standbyTimeM = GetListenReg("待机时间分").ScaleValue.Value;
|
|
|
- var standbyTimeS = GetListenReg("待机时间秒").ScaleValue.Value;
|
|
|
- var standbyTimeHMS = ToHMS(standbyTimeH, standbyTimeM, standbyTimeS);
|
|
|
- var alarmTimeH = GetListenReg("报警停机时间时").ScaleValue.Value;
|
|
|
- var alarmTimeM = GetListenReg("报警停机时间分").ScaleValue.Value;
|
|
|
- var alarmTimeS = GetListenReg("报警停机时间秒").ScaleValue.Value;
|
|
|
- var alarmTimeHMS = ToHMS(alarmTimeH, alarmTimeM, alarmTimeS);
|
|
|
-
|
|
|
- //如果表一行数据也没有
|
|
|
- if (Env.DAL.App_BY_Machine_Time.GetData<AppBYMachineTimeModel>().Count == 0)
|
|
|
- {
|
|
|
- // 各字段插入数据 初始化
|
|
|
- Env.DAL.App_BY_Machine_Time.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
|
|
|
- );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //如果表只有一行数据 对该数据更新
|
|
|
- if (Env.DAL.App_BY_Machine_Time.GetData<AppBYMachineTimeModel>().Count == 1)
|
|
|
- {
|
|
|
- //每10秒更新一次
|
|
|
- if (e.TimeFlag.Second % 10 == 0)
|
|
|
- {
|
|
|
- // 获取表里的最新一行数据而且是台达AS300型号(此处未写)对其更新
|
|
|
- Env.DAL.App_BY_Machine_Time.Update("ID=(select max(id) from App_BY_Machine_Time)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var appBYMachineTimeModelSql = Env.DAL.GetData<AppBYMachineTimeModel>();
|
|
|
- var lastCreateTime = appBYMachineTimeModelSql.Last().CreateTime;
|
|
|
- var nowTime = DateTime.Now;
|
|
|
- // 如果现在(今天)日期不等于最新一行CreateTime日期则说明今天没有插入新数据
|
|
|
- if (lastCreateTime.Date != nowTime.Date)
|
|
|
- {
|
|
|
- // 插入今天新数据
|
|
|
- Env.DAL.App_BY_Machine_Time.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- // 每10秒且表行数大于1 对最后一行更新
|
|
|
- if (appBYMachineTimeModelSql.Count >= 2)
|
|
|
- {
|
|
|
- // 获取表里倒序第二行寄存器数据
|
|
|
- var oldTotalTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegTotalTimeHMS;
|
|
|
- var oldRunTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegRunTimeHMS;
|
|
|
- var oldStandbyTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegStandbyTimeHMS;
|
|
|
- var oldAlarmTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegAlarmTimeHMS;
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// <param name="timeH">累计寄存器时</param>
|
|
|
- /// <param name="timeM">累计寄存器分</param>
|
|
|
- /// <param name="timeS">累计寄存器秒</param>
|
|
|
- /// <param name="oldTimeHMS">上一次累计寄存器时分秒字符串</param>
|
|
|
- /// <returns>返回当天的寄存器时分秒</returns>
|
|
|
- /// </summary>
|
|
|
- string GetNewTimeHMS(double timeH, double timeM, double timeS, string oldTimeHMS)
|
|
|
- {
|
|
|
- // 新数据 = 新寄存器数 - 旧寄存器数
|
|
|
- var oldTimeHMSArray = oldTimeHMS.Split(new char[] { ':', ':' });
|
|
|
- double oldTimeSumS = Convert.ToDouble(oldTimeHMSArray[0]) * 3600 + Convert.ToDouble(oldTimeHMSArray[1]) * 60 + Convert.ToDouble(oldTimeHMSArray[2]);
|
|
|
- double timeSumS = timeH * 3600 + timeM * 60 + timeS;
|
|
|
- var newTimeSumS = timeSumS - oldTimeSumS;
|
|
|
- var newTimeHMS = new TimeSpan(0, 0, Convert.ToInt32(newTimeSumS)).ToString(@"hh\:mm\:ss");
|
|
|
- return newTimeHMS;
|
|
|
- }
|
|
|
- var newTotalTimeHMS = GetNewTimeHMS(totalTimeH, totalTimeM, totalTimeS, oldTotalTimeHMS);
|
|
|
- var newRunTimeHMS = GetNewTimeHMS(runTimeH, runTimeM, runTimeS, oldRunTimeHMS);
|
|
|
- var newStandbyTimeHMS = GetNewTimeHMS(standbyTimeH, standbyTimeM, standbyTimeS, oldStandbyTimeHMS);
|
|
|
- var newAlarmTimeHMS = GetNewTimeHMS(alarmTimeH, alarmTimeM, alarmTimeS, oldAlarmTimeHMS);
|
|
|
- if (e.TimeFlag.Second % 10 == 0)
|
|
|
- {
|
|
|
- // 获取表里的最新一行数据对其更新
|
|
|
- Env.DAL.App_BY_Machine_Time.Update("ID=(select max(id) from App_BY_Machine_Time)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, newTotalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, newRunTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, newStandbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, newAlarmTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (GetListenReg("产量统计") != null)
|
|
|
- {
|
|
|
- var output = GetListenReg("产量统计").Value;
|
|
|
- var nowTime = DateTime.Now;
|
|
|
-
|
|
|
- // 小时产量
|
|
|
- var hourOutputRows = Env.DAL.App_BY_HourOutput.GetData<AppBYHourOutputModel>();
|
|
|
- if (hourOutputRows.Count == 0)
|
|
|
- {
|
|
|
- Env.DAL.App_BY_HourOutput.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- if (hourOutputRows.Count == 1)
|
|
|
- {
|
|
|
- //每10秒更新一次
|
|
|
- if (e.TimeFlag.Second % 10 == 0)
|
|
|
- {
|
|
|
- // 获取表里的最新一行数据而且是台达AS300型号(此处未写)对其更新
|
|
|
- Env.DAL.App_BY_HourOutput.Update("ID=(select max(id) from App_BY_HourOutput)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (hourOutputRows.Count >= 1)
|
|
|
- {
|
|
|
- // 如果现在(这个小时)不等于最新一行CreateTime小时则说明这个小时没有插入新数据
|
|
|
- if (hourOutputRows.Last().CreateTime.ToString("yyyy-MM-dd HH") != nowTime.ToString("yyyy-MM-dd HH"))
|
|
|
- {
|
|
|
- // 插入这个小时新数据
|
|
|
- Env.DAL.App_BY_HourOutput.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- if (hourOutputRows.Count >= 2)
|
|
|
- {
|
|
|
- var oldHourOutput = hourOutputRows[hourOutputRows.Count - 2].RegOutput;
|
|
|
- var newHourOutput = output - oldHourOutput;
|
|
|
- if (e.TimeFlag.Second % 10 == 0)
|
|
|
- {
|
|
|
- // 获取表里的最新一行数据对其更新
|
|
|
- Env.DAL.App_BY_HourOutput.Update("ID=(select max(id) from App_BY_HourOutput)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, newHourOutput),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 每天产量
|
|
|
- var dayOutputRows = Env.DAL.App_BY_DayOutput.GetData<AppBYDayOutputModel>();
|
|
|
- if (dayOutputRows.Count == 0)
|
|
|
- {
|
|
|
- Env.DAL.App_BY_DayOutput.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- if (dayOutputRows.Count == 1)
|
|
|
- {
|
|
|
- // 每分钟更新一次
|
|
|
- if (e.TimeFlag.Minute % 1 == 0)
|
|
|
- {
|
|
|
- Env.DAL.App_BY_DayOutput.Update("ID=(select max(id) from App_BY_DayOutput)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- // 如果现在(今天)日期不等于最新一行CreateTime日期则说明今天没有插入新数据
|
|
|
- if (dayOutputRows.Count >= 1)
|
|
|
- {
|
|
|
- if (dayOutputRows.Last().CreateTime.Date != nowTime.Date)
|
|
|
- {
|
|
|
- // 插入今天新数据
|
|
|
- Env.DAL.App_BY_DayOutput.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- if (dayOutputRows.Count >= 2)
|
|
|
- {
|
|
|
- var oldDayOutput = dayOutputRows[dayOutputRows.Count - 2].RegOutput;
|
|
|
- var newDayOutput = output - oldDayOutput;
|
|
|
- if (e.TimeFlag.Second % 10 == 0)
|
|
|
- {
|
|
|
- // 获取表里的最新一行数据对其更新
|
|
|
- Env.DAL.App_BY_DayOutput.Update("ID=(select max(id) from App_BY_DayOutput)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, newDayOutput),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 每月产量
|
|
|
- var monthOutputRows = Env.DAL.App_BY_MonthOutput.GetData<AppBYMonthOutputModel>();
|
|
|
- if (monthOutputRows.Count == 0)
|
|
|
- {
|
|
|
- Env.DAL.App_BY_MonthOutput.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- if (monthOutputRows.Count == 1)
|
|
|
- {
|
|
|
- // 每2分钟更新一次
|
|
|
- if (e.TimeFlag.Minute % 2 == 0)
|
|
|
- {
|
|
|
- Env.DAL.App_BY_MonthOutput.Update("ID=(select max(id) from App_BY_MonthOutput)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 如果今月没插入新数据 则插入新数据
|
|
|
- if (monthOutputRows.Count >= 1)
|
|
|
- {
|
|
|
- if (monthOutputRows.Last().CreateTime.ToString("yyyy-MM") != nowTime.ToString("yyyy-MM"))
|
|
|
- {
|
|
|
- // 插入今月新数据
|
|
|
- Env.DAL.App_BY_MonthOutput.Insert(
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.DeviceID_Str, DeviceIDTaiDaAS300),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- if (monthOutputRows.Count >= 2)
|
|
|
- {
|
|
|
- var oldMonthOutput = monthOutputRows[monthOutputRows.Count - 2].RegOutput;
|
|
|
- var newMonthOutput = output - oldMonthOutput;
|
|
|
- if (e.TimeFlag.Second % 10 == 0)
|
|
|
- {
|
|
|
- // 获取表里的最新一行数据对其更新
|
|
|
- Env.DAL.App_BY_MonthOutput.Update("ID=(select max(id) from App_BY_MonthOutput)",
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, newMonthOutput),
|
|
|
- new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ InsertEnvironmentValues(e);
|
|
|
+ InsertMachineTime(e);
|
|
|
+ InsertOutPut(e);
|
|
|
}
|
|
|
}
|
|
|
public string AlarmMsg { get => AlarmCollection.Count() > 0 ? string.Join(":", AlarmCollection.Select(t => t.AlarmCode)) : null; }
|
|
@@ -394,28 +102,10 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
/// <param name="e"></param>
|
|
|
protected override void RegValueChanged(object sender, RegValueChangedEventArgs e)
|
|
|
{
|
|
|
- //var DeviceIDTaiDaAS300 = "台达AS300";
|
|
|
- ////此处是创建一个转型对象
|
|
|
- //var reg = (RegInfo)sender;
|
|
|
- //if (BaseDevice.DeviceID == DeviceIDTaiDaAS300)
|
|
|
- //{
|
|
|
- // if (GetListenReg("手自动").Value == 0) { }
|
|
|
- //}
|
|
|
- //if (reg.)
|
|
|
- //{
|
|
|
- // reg.
|
|
|
- //}
|
|
|
- ////此处筛选对象的属性
|
|
|
- //// 也可以使用getListenReg("左枪电流") 此为baseMachine类的方法 获取寄存器的值 参数是注释表的变量名称
|
|
|
- //if (reg.Comment.Variable == "左枪电流")
|
|
|
- //{
|
|
|
-
|
|
|
-
|
|
|
- //}
|
|
|
+ var reg = (RegInfo)sender;
|
|
|
+ InsertProduction(reg, e);
|
|
|
//base.RegValueChanged(sender, e);
|
|
|
//log.Debug($"{reg.RegName} Value Changed:{reg.OldValue}->{reg.Value}");
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|