自动启停风扇任务

zw
lxw 6 months ago
parent 9ef9d0811b
commit e98a740405

@ -1,32 +0,0 @@
namespace Service.BusinessTask;
public abstract class AbstractTaskHandler
{
private volatile bool _stopFlag = false;
public void Start()
{
Thread thread = new Thread(Process);
thread.IsBackground = true;
thread.Name = Name();
thread.Start();
}
private void Process()
{
while (!_stopFlag)
{
Handle();
Thread.Sleep(Interval());
}
}
protected abstract int Interval();
protected abstract void Handle();
protected abstract string Name();
public void Stop()
{
_stopFlag = true;
}
}

@ -1,6 +1,4 @@
using Service.BusinessTask; 
using Service.BusinessTask.MyTask;
namespace Service.Execute namespace Service.Execute
{ {
/// <summary> /// <summary>

@ -1,19 +1,13 @@
using Autofac;
using Entity.Constant;
using Entity.DbModel.Station; using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Entity;
using log4net; using log4net;
using Repository.Station; using Repository.Station;
using Service.Execute;
using Service.Execute.Api;
using Service.Execute.Model;
using Service.Plc.Client; using Service.Plc.Client;
using Service.Station; using Service.Station;
namespace Service.BusinessTask.MyTask; namespace Service.MyTask;
/// <summary> /// <summary>
/// 电池移仓任务 /// 电池移仓任务

@ -0,0 +1,74 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Entity;
using log4net;
using Repository.Station;
using Service.Plc.Client;
using Service.Station;
namespace Service.MyTask;
/// <summary>
/// 电池充电是风扇启停
/// </summary>
[Scope]
public class FanChangeTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(FanChangeTask));
public BinInfoRepository _binInfoRepository { get; set; }
private volatile bool _stop;
public string Name()
{
return "FanChangeTask";
}
public int Interval()
{
return 1000 * 3;
}
/// <para>0无状态</para>
/// <para>1000已全部打开</para>
/// <para>1010已全部关闭</para>
public void Handle()
{
try
{
int count = _binInfoRepository.GetCount(i => i.ChargeStatus == 1);
if (count > 0)
{
PlcMgr.AirBlowerControl(1000);
}
else
{
PlcMgr.AirBlowerControl(1010);
}
}
catch (Exception e)
{
Log.Error($" FanChangeTask err e={e}");
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}

@ -5,7 +5,7 @@ using log4net;
using Repository.Station; using Repository.Station;
using Service.Mgr; using Service.Mgr;
namespace Service.BusinessTask.MyTask; namespace Service.MyTask;
/// <summary> /// <summary>
/// 充电结束上报云平台task /// 充电结束上报云平台task

@ -77,6 +77,8 @@ public class PlcMgr
return 0; return 0;
} }
/// <summary> /// <summary>
/// 是否远程模式 /// 是否远程模式
/// </summary> /// </summary>

Loading…
Cancel
Save