This commit is contained in:
gcw_MV9p2JJN 2026-01-28 21:04:23 +08:00
parent e8116783c8
commit e1380da7b3
4 changed files with 23 additions and 32 deletions

View File

@ -63,10 +63,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into
try
{
//心跳检测 "DB1010.DBW0"
await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, 1);
await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, (short)1);
// 轮询进站请求信号/工位开始查询请求 "DB1001.DBW2000"
int intoStationAsk = await _plcService.ReadAsync<int>(plcSetting.intoStation.IntoStationAsk);
short intoStationAsk = await _plcService.ReadAsync<short>(plcSetting.intoStation.IntoStationAsk);
if (intoStationAsk == 1)
{
// 处理进站请求
@ -91,7 +91,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
{
ProductSN = productSN,
WorkstationCode = WorkstationCode,
Routingcode = processOperations.First().FkRoutingCode,
Routingcode = processOperations?.First()?.FkRoutingCode??"",
OperationCode = WorkstationCode,
OperationName= plcSetting.WorkStationName,
ProductionLifeStage = 1, // 1表示生产中
@ -104,7 +104,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
//判断该产品是否允许进站
EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations);
// "DB1010.DBW2000"
await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (int)result);
await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (short)result);
}
await Task.Delay(_pollingInterval, stoppingToken);

View File

@ -61,10 +61,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into
try
{
//心跳检测 "DB1010.DBW0"
await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, 1);
await _plcService.WriteAsync(plcSetting.intoStation.Heartbeat, (short)1);
// 轮询进站请求信号/工位开始查询请求 "DB1001.DBW2000"
int intoStationAsk = await _plcService.ReadAsync<int>(plcSetting.intoStation.IntoStationAsk);
short intoStationAsk = await _plcService.ReadAsync<short>(plcSetting.intoStation.IntoStationAsk);
if (intoStationAsk == 1)
{
// 处理进站请求
@ -102,7 +102,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
//判断该产品是否允许进站
EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations);
// "DB1010.DBW2000"
await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (int)result);
await _plcService.WriteAsync(plcSetting.intoStation.IntoStationResp, (short)result);
}
await Task.Delay(_pollingInterval, stoppingToken);

View File

@ -30,7 +30,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
private string WorkstationCode;
private readonly SqlSugarClient Context;
public PlcIntoStationService_OP80_01()
{
Context = DbScoped.SugarScope.CopyNew();
@ -55,10 +55,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into
try
{
//心跳检测
await _plcService.WriteAsync("DB1020.DBW0", 1);
await _plcService.WriteAsync("DB1020.DBW0", (short)1);
// 轮询进站请求信号/工位开始查询请求
int intoStationAsk = await _plcService.ReadAsync<int>("DB1017.DBW2000");
short intoStationAsk = await _plcService.ReadAsync<short>("DB1017.DBW2000");
if (intoStationAsk == 1)
{
// 处理进站请求
@ -67,11 +67,11 @@ namespace RIZO.Service.PLCBackground.Stations.Into
//获取产品SN码
string productModel = await _plcService.ReadStringAsync("DB1017.DBB1000");
string productSN = await _plcService.ReadStringAsync("DB1017.DBB1054");
int ReWorkFlag = await _plcService.ReadAsync<int>("DB1017.DBW8");
short ReWorkFlag = await _plcService.ReadAsync<short>("DB1017.DBW8");
//判断改产品是正常件还是返工件
if (ReWorkFlag == 2)
{
{
}
// 获取工单
@ -79,21 +79,13 @@ namespace RIZO.Service.PLCBackground.Stations.Into
List<ProcessOperation> processOperations = await Context.Queryable<ProcessRouting>().LeftJoin<ProcessOperation>((r, o) => r.RoutingCode == o.FkRoutingCode)
.Where((r, o) => r.FkProductMaterialCode == productModel && r.Status == 1)
.Select((r, o) => o).ToListAsync();
var routingcode = string.Empty;
try
{
routingcode = processOperations.First().FkRoutingCode;
}
catch
{ }
if (routingcode == null || routingcode.Length == 0)
return;
//插入入站请求ASK过站记录
ProductPassStationRecord ASKintoStation = new ProductPassStationRecord
{
ProductSN = productSN,
WorkstationCode = WorkstationCode,
Routingcode = routingcode,
Routingcode = processOperations?.FirstOrDefault()?.FkRoutingCode ?? "",
OperationCode = WorkstationCode,
ProductionLifeStage = 1, // 1表示生产中
PasstationType = 0, // 0表示入站请求
@ -105,9 +97,8 @@ namespace RIZO.Service.PLCBackground.Stations.Into
//判断该产品是否允许进站
EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations);
//进站请求结果
await _plcService.WriteAsync2("DB1317.DBW2000", (int)result);
//设别使能1
await _plcService.WriteAsync2("DB1317.DBW0", 1);
await _plcService.WriteAsync("DB1317.DBW2000", (short)result);
}
await Task.Delay(_pollingInterval, stoppingToken);
@ -227,7 +218,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
//OK 准许进站
result = EntryPermissionResult.AllowIntoStation;
goto InsertPassrecord;
InsertPassrecord:
InsertPassrecord:
//插入入站请求Resp过站记录
ProductPassStationRecord RespintoStation = new ProductPassStationRecord
{
@ -252,7 +243,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
{
return EntryPermissionResult.PreviousStationDataAbnormal;
}
}

View File

@ -52,10 +52,10 @@ namespace RIZO.Service.PLCBackground.Stations.Into
try
{
//心跳检测
await _plcService.WriteAsync("DB1020.DBW0", 1);
await _plcService.WriteAsync("DB1020.DBW0", (short)1);
// 轮询进站请求信号/工位开始查询请求
int intoStationAsk = await _plcService.ReadAsync<int>("DB1021.DBW2000");
short intoStationAsk = await _plcService.ReadAsync<short>("DB1021.DBW2000");
if (intoStationAsk == 1)
{
// 处理进站请求
@ -79,7 +79,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
{
ProductSN = productSN,
WorkstationCode = WorkstationCode,
Routingcode = processOperations.First().FkRoutingCode,
Routingcode = Routingcode = processOperations?.FirstOrDefault()?.FkRoutingCode ?? "",
OperationCode = WorkstationCode,
ProductionLifeStage = 1, // 1表示生产中
PasstationType = 0, // 0表示入站请求
@ -90,7 +90,7 @@ namespace RIZO.Service.PLCBackground.Stations.Into
await Context.Insertable(ASKintoStation).ExecuteCommandAsync();
//判断该产品是否允许进站
EntryPermissionResult result = await checkEntryPermission(productModel, productSN, WorkstationCode, processOperations);
await _plcService.WriteAsync("DB1020.DBW2000", (int)result);
await _plcService.WriteAsync("DB1020.DBW2000", (short)result);
}
await Task.Delay(_pollingInterval, stoppingToken);