using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using HBLConsole.Abstract; using HBLConsole.Service; using HBLConsole.Factory; using HBLConsole.Model; namespace HBLConsole.Business.AbstractServer { public class ControlBase : ControlAbstract { public override void Init() { Main(); ReadData(); ResetProgram(); } public override void Main() { ThreadManage.GetInstance.StartLong(new Action(() => { if (MainAction != null) MainAction(); Thread.Sleep(100); }), "MainTask"); } public override void ReadData() { ThreadManage.GetInstance.StartLong(new Action(() => { if (ReadDataAction != null) ReadDataAction(); Thread.Sleep(100); }), "ReadPLCData"); } public override void ResetProgram() { ThreadManage.GetInstance.StartLong(new Action(() => { if (RTrig.GetInstance("ResetProgram").Start(DeviceData.Initing)) { ThreadManage.GetInstance.StopTask("MainTask", new Action(() => { ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() => { SimpleFactory.GetInstance.CreateGvl(); ReadData(); Main(); })); })); } Thread.Sleep(10); }), "ResetProgram"); } } }