You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.2 KiB

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;
}
/// 1000打开右侧关闭左侧
/// 1001打开左侧关闭右侧
/// 1002全部打开
/// 1003全部关闭
public void Handle()
{
try
{
int countL = _binInfoRepository.GetCount(i =>
i.ChargeStatus == 1 && Convert.ToInt32(i.No) >= 1 && Convert.ToInt32(i.No) <= 8);
int countR = _binInfoRepository.GetCount(i =>
i.ChargeStatus == 1 && Convert.ToInt32(i.No) >= 11 && Convert.ToInt32(i.No) <= 18);
if (countL > 0 && countR <= 0)
{
if (PlcMgr.ExhaustFanStatusRadar() != 1000)
PlcMgr.AirBlowerControl(1000);
}
else if (countL <= 0 && countR > 0)
{
if (PlcMgr.ExhaustFanStatusRadar() != 1001)
PlcMgr.AirBlowerControl(1001);
}
else if (countL > 0 && countR > 0)
{
if (PlcMgr.ExhaustFanStatusRadar() != 1002)
PlcMgr.AirBlowerControl(1002);
}
else
{
if (PlcMgr.ExhaustFanStatusRadar() != 1003)
PlcMgr.AirBlowerControl(1003);
}
}
catch (Exception e)
{
Log.Error($" FanChangeTask err e={e}");
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}