风机控制

master
lxw 6 months ago
parent 2832c7b584
commit 2d58c230f0

@ -54,6 +54,18 @@ public class PlcMgr
return false;
}
public static bool AirBlowerControl(ushort value)
{
if (PlcClient != null)
{
HostToPlcData.ExhaustFanControl.Value = value;
return PlcClient.WriteValue(HostToPlcData.ExhaustFanControl);
}
return false;
}
/// <summary>
/// 是否远程模式
/// </summary>
@ -63,19 +75,18 @@ public class PlcMgr
if ((DateTime.Now - DataValidityTime).Seconds <= DataTimeSeconds)
{
return PlcToHostData.RemoteLocalControlState.Value == 1010;
}
else
{
return false;
}
}
public static bool IsAuto()
{
if ((DateTime.Now - DataValidityTime).Seconds <= DataTimeSeconds)
{
return PlcToHostData.ModeControl.Value == 1010;
}
else
{
@ -203,7 +214,7 @@ public class PlcMgr
}
//需要将数据转换成byte数组
OperateResult operateResult = PlcClient.Write("x=16;111",encode);
OperateResult operateResult = PlcClient.Write("x=16;111", encode);
return operateResult.IsSuccess;
}
@ -317,8 +328,10 @@ public class PlcMgr
writeHostToPlc.LightingControl.Value = 1000;
bResult = PlcClient.WriteValue(writeHostToPlc.LightIn);
}
return bResult;
}
/// <summary>
/// 获取当前灯光状态
/// </summary>
@ -329,6 +342,7 @@ public class PlcMgr
{
return PlcToHostData.LightStatus.Value;
}
return default;
}
@ -345,8 +359,7 @@ public class PlcMgr
writeHostToPlc.LightingControl.Value = 1010;
bResult = PlcClient.WriteValue(writeHostToPlc.LightIn);
}
return bResult;
}
}

@ -19,8 +19,8 @@ namespace WebStarter.Controllers;
[Route("api/[controller]")]
public class BinInfoController : ControllerBase
{
private readonly BinInfoRepository _BinInfoRepository;
public BinInfoController(BinInfoRepository infoRepository)
{
_BinInfoRepository = infoRepository;
@ -37,7 +37,7 @@ public class BinInfoController : ControllerBase
[HttpGet("UpdateCanChargeFlag/{id}/{flag}")]
public Result<bool> UpdateCanChargeFlag(int id, int flag)
{
_BinInfoRepository.Update(it=>it.CanChargeFlag==flag,it=>it.Id==id);
_BinInfoRepository.Update(it => it.CanChargeFlag == flag, it => it.Id == id);
return Result<bool>.Success();
}
@ -48,7 +48,7 @@ public class BinInfoController : ControllerBase
{
No = "10"
});
BinInfo queryByClause = _BinInfoRepository.QueryByClause(i=>i.Id==16);
BinInfo queryByClause = _BinInfoRepository.QueryByClause(i => i.Id == 16);
return Result<bool>.Success();
}
@ -64,10 +64,19 @@ public class BinInfoController : ControllerBase
[HttpGet("UpdateCanSwapFlag/{id}/{flag}")]
public async Task<Result<bool>> UpdateCanSwapFlag(int id, int flag)
{
_BinInfoRepository.Update(it=>it.CanSwapFlag==flag,it=>it.Id==id);
_BinInfoRepository.Update(it => it.CanSwapFlag == flag, it => it.Id == id);
return Result<bool>.Success();
}
/// <summary>
/// 风机控制 1000全部打开
///1010全部关闭
/// </summary>
/// <returns></returns>
[HttpGet("AirBlowerControl/{cmd}")]
public Result<bool> AirBlower(ushort cmd)
{
return PlcMgr.AirBlowerControl(cmd) ? Result<bool>.Success() : Result<bool>.Fail();
}
}
Loading…
Cancel
Save