增加定时任务
This commit is contained in:
@@ -152,7 +152,6 @@ namespace JY.Inspection
|
||||
|
||||
private ByteTransformBase TransformBase = new ByteTransformBase();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用于电芯出站时向FMS上报出站及生产数据
|
||||
/// </summary>
|
||||
@@ -417,8 +416,7 @@ namespace JY.Inspection
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 页面事件
|
||||
#region 页面事件
|
||||
private void HomeForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -471,6 +469,8 @@ namespace JY.Inspection
|
||||
_speech.SelectVoice(neededVoice.VoiceInfo.Name);
|
||||
}
|
||||
|
||||
InitTaskScheduler();
|
||||
|
||||
LogManagerControl.AddLog("程序已启动", LogAddtype.local);
|
||||
}
|
||||
|
||||
@@ -867,7 +867,6 @@ namespace JY.Inspection
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
||||
if (mCOMState.Token.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
@@ -875,8 +874,6 @@ namespace JY.Inspection
|
||||
resetEventRecv.WaitOne();
|
||||
if (isEnabled)
|
||||
{
|
||||
|
||||
|
||||
if (master !=null)
|
||||
{
|
||||
try
|
||||
@@ -884,8 +881,7 @@ namespace JY.Inspection
|
||||
List<int> resylt = GetListInt(13);
|
||||
List<double> resylt_float = new List<double>();
|
||||
OperateResult<ushort[]> result = new OperateResult<ushort[]>();
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < Global.Instructions.Count; i++)
|
||||
{
|
||||
ushort startAddress = (ushort)System.Convert.ToInt32(Global.Instructions[i], 16);
|
||||
@@ -912,7 +908,7 @@ namespace JY.Inspection
|
||||
resylt_float.Add((Convert.ToDouble(resylt[index++]) / 10));
|
||||
//线电压UAC
|
||||
resylt_float.Add((Convert.ToDouble(resylt[index++]) / 10));
|
||||
;
|
||||
|
||||
//电流IA
|
||||
resylt_float.Add((Convert.ToDouble(resylt[index++]) / 1000));
|
||||
//电流IB
|
||||
@@ -940,7 +936,7 @@ namespace JY.Inspection
|
||||
for (int i = 0; i < resylt.Count; i++)
|
||||
{
|
||||
omronPLCCom.lstMcUI[0].WriteDReg($"W380[{i.ToString()}]", (float)resylt_float[i]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
this.Invoke(new Action(() =>
|
||||
@@ -1402,9 +1398,6 @@ namespace JY.Inspection
|
||||
FrmCCDQuery frm = new FrmCCDQuery();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region PLC读写
|
||||
@@ -1560,10 +1553,7 @@ namespace JY.Inspection
|
||||
omronPLCCom.lstMcUI[i].OmronStart(false);
|
||||
omronPLCCom.lstMcUI[i].IsRun = false;
|
||||
omronPLCCom.lstMcUI[i].btnStart.Text = "启动";
|
||||
omronPLCCom.lstMcUI[i].HeartBeat = false;
|
||||
|
||||
|
||||
|
||||
omronPLCCom.lstMcUI[i].HeartBeat = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using JY.Model;
|
||||
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 => {
|
||||
Debug.WriteLine("Hello");
|
||||
}, interval: 1000 * 60);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -307,6 +307,9 @@
|
||||
<Compile Include="Frm\ListViewBuff.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="HomeFormExtend.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Mes\MESDataCombin.cs" />
|
||||
<Compile Include="Mes\MesLog.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
|
||||
Reference in New Issue
Block a user