2026-08-26 14:53:08 +08:00
|
|
|
using JY.Inspection.Mes;
|
|
|
|
|
using JY.Model;
|
2026-07-21 19:37:29 +08:00
|
|
|
using JY.Model.Common;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace JY.Inspection
|
|
|
|
|
{
|
|
|
|
|
public partial class HomeForm
|
|
|
|
|
{
|
|
|
|
|
#region 定时任务
|
|
|
|
|
TaskScheduler scheduler = null;
|
|
|
|
|
private void InitTaskScheduler()
|
|
|
|
|
{
|
|
|
|
|
if (scheduler == null)
|
|
|
|
|
{
|
|
|
|
|
scheduler = new TaskScheduler();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scheduler.AddTask(state => {
|
2026-08-26 14:53:08 +08:00
|
|
|
//Debug.WriteLine("Hello");
|
|
|
|
|
List<string> data = this.Invoke(new Func<List<string>>(() => {
|
|
|
|
|
List<string> list = new List<string>();
|
|
|
|
|
|
|
|
|
|
#region 添加电表数据
|
|
|
|
|
//相电压UA
|
|
|
|
|
list.Add(txtPhaseVolUA.Text);
|
|
|
|
|
//相电压UB
|
|
|
|
|
list.Add(txtPhaseVolUB.Text);
|
|
|
|
|
//相电压UC
|
|
|
|
|
list.Add(txtPhaseVolUC.Text);
|
|
|
|
|
//线电压UAB
|
|
|
|
|
list.Add(txtLineVolUAB.Text);
|
|
|
|
|
//线电压UBC
|
|
|
|
|
list.Add(txtLineVolUBC.Text);
|
|
|
|
|
//线电压UAC
|
|
|
|
|
list.Add(txtLineVolUAC.Text);
|
|
|
|
|
|
|
|
|
|
//电流IA
|
|
|
|
|
list.Add(txtIA.Text);
|
|
|
|
|
//电流IB
|
|
|
|
|
list.Add(txtIB.Text);
|
|
|
|
|
//电流IC
|
|
|
|
|
list.Add(txtIC.Text);
|
|
|
|
|
|
|
|
|
|
//A相有功功率
|
|
|
|
|
list.Add(txtPowerA.Text);
|
|
|
|
|
//B相有功功率
|
|
|
|
|
list.Add(txtPowerB.Text);
|
|
|
|
|
//C相有功功率
|
|
|
|
|
list.Add(txtPowerC.Text);
|
|
|
|
|
//总有功功率
|
|
|
|
|
list.Add(txtTotalPower.Text);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
})) as List<string>;
|
|
|
|
|
|
|
|
|
|
if (data == null || data.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Debug.WriteLine($"定时任务执行中, 时间: {DateTime.Now}");
|
|
|
|
|
|
|
|
|
|
new MESDataCombin().UpEnergyDataMqtt(data);
|
|
|
|
|
}, interval: 1000 * 60 * Global.systemConfig.TaskInterval);
|
2026-07-21 19:37:29 +08:00
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|