风机控制

master
lxw 6 months ago
parent 2832c7b584
commit 2d58c230f0

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

@ -19,9 +19,9 @@ namespace WebStarter.Controllers;
[Route("api/[controller]")] [Route("api/[controller]")]
public class BinInfoController : ControllerBase public class BinInfoController : ControllerBase
{ {
private readonly BinInfoRepository _BinInfoRepository; private readonly BinInfoRepository _BinInfoRepository;
public BinInfoController(BinInfoRepository infoRepository)
public BinInfoController(BinInfoRepository infoRepository)
{ {
_BinInfoRepository = infoRepository; _BinInfoRepository = infoRepository;
} }
@ -35,24 +35,24 @@ public class BinInfoController : ControllerBase
/// <param name="putBinNo"></param> /// <param name="putBinNo"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("UpdateCanChargeFlag/{id}/{flag}")] [HttpGet("UpdateCanChargeFlag/{id}/{flag}")]
public Result<bool> UpdateCanChargeFlag(int id, int 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(); return Result<bool>.Success();
} }
[HttpGet("insert")] [HttpGet("insert")]
public Result<bool> insert() public Result<bool> insert()
{ {
_BinInfoRepository.Insert(new BinInfo() _BinInfoRepository.Insert(new BinInfo()
{ {
No = "10" No = "10"
}); });
BinInfo queryByClause = _BinInfoRepository.QueryByClause(i=>i.Id==16); BinInfo queryByClause = _BinInfoRepository.QueryByClause(i => i.Id == 16);
return Result<bool>.Success(); return Result<bool>.Success();
} }
/// <summary> /// <summary>
/// 启用禁用换电 /// 启用禁用换电
/// id:仓位id /// id:仓位id
@ -64,10 +64,19 @@ public class BinInfoController : ControllerBase
[HttpGet("UpdateCanSwapFlag/{id}/{flag}")] [HttpGet("UpdateCanSwapFlag/{id}/{flag}")]
public async Task<Result<bool>> UpdateCanSwapFlag(int id, int 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(); 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