|
|
@@ -188,6 +188,16 @@ namespace BPASmartClient.DosingHKProject.Model |
|
|
|
GVL_SmallStation.GetInstance.RecipeStatusID = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int cnt_sensor1 = 0; |
|
|
|
int cnt_sensor2 = 0; |
|
|
|
int cnt_sensor3 = 0; |
|
|
|
int cnt_sensor4 = 0; |
|
|
|
int cnt_sensor5 = 0; |
|
|
|
int cnt_sensor6 = 0; |
|
|
|
int cnt_sensor7 = 0; |
|
|
|
int cnt_sensor8 = 0; |
|
|
|
int barrel1 = 0; |
|
|
|
/// <summary> |
|
|
|
/// 执行配方队列中的第一个配方 |
|
|
|
/// </summary> |
|
|
@@ -199,12 +209,214 @@ namespace BPASmartClient.DosingHKProject.Model |
|
|
|
if (index >= 0 && index < RemoteRecipes.Count) |
|
|
|
{ |
|
|
|
string code = RemoteRecipes.ElementAt(index).RecipeCode; |
|
|
|
int trayCode = RemoteRecipes.ElementAt(index).TrayCode; |
|
|
|
string recipeName = RemoteRecipes.ElementAt(index).RecipeName; |
|
|
|
string windSend = RemoteRecipes.ElementAt(index).ToString(); |
|
|
|
#region sensor处理 |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Load) |
|
|
|
{ |
|
|
|
cnt_sensor1++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor1 >= 50) |
|
|
|
{ |
|
|
|
if (barrel1 >= 0 && barrel1 < GVL_SmallStation.MaxBarrelNum) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[barrel1] == 0) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[barrel1] = 1; |
|
|
|
barrel1++; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//报错,超过最大的桶号数 |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor1 = 0; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station1) |
|
|
|
{ |
|
|
|
cnt_sensor2++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor2 >= 50) |
|
|
|
{ |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[i] = 2; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor2 = 0; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station2) |
|
|
|
{ |
|
|
|
cnt_sensor3++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor3 >= 50) |
|
|
|
{ |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 2) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[i] = 3; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor3 = 0; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station3) |
|
|
|
{ |
|
|
|
cnt_sensor4++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor4 >= 50) |
|
|
|
{ |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 3) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[i] = 4; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor4 = 0; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station4) |
|
|
|
{ |
|
|
|
cnt_sensor5++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor5 >= 50) |
|
|
|
{ |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 4) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[i] = 5; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor5 = 0; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station5) |
|
|
|
{ |
|
|
|
cnt_sensor6++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor6 >= 50) |
|
|
|
{ |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 5) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[i] = 6; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor6 = 0; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station6) |
|
|
|
{ |
|
|
|
cnt_sensor7++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor7 >= 50) |
|
|
|
{ |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 6) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[i] = 7; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor7 = 0; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Unload) |
|
|
|
{ |
|
|
|
HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.0", false); |
|
|
|
HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.1", false); |
|
|
|
MessageLog.GetInstance.ShowRunLog($"下料桶堵料,线体不运行"); |
|
|
|
cnt_sensor8++; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (cnt_sensor8 >= 50) |
|
|
|
{ |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 7) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.Barrel_Location[i] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cnt_sensor8 = 0; |
|
|
|
} |
|
|
|
#endregion |
|
|
|
for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station1 && GVL_SmallStation.GetInstance.Barrel_Location[i] == 1) |
|
|
|
{ |
|
|
|
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
|
{ |
|
|
|
if ((item.RawMaterialLocation == i+1 || item.RawMaterialLocation == i+7) && item.IsDosingFinish == false && item.RawMaterialBarrelNum == i+1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.AllowDosing_Pos[i] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station1 && GVL_SmallStation.GetInstance.Barrel_Location[0] == 1) |
|
|
|
{ |
|
|
|
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
|
{ |
|
|
|
if ((item.RawMaterialLocation == 1 || item.RawMaterialLocation == 7) && item.IsDosingFinish == false && item.RawMaterialBarrelNum == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.AllowDosing_Pos[0] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station2 && GVL_SmallStation.GetInstance.Barrel_Location[1] == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.AllowDosing_Pos[1] = true; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station3 && GVL_SmallStation.GetInstance.Barrel_Location[2] == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.AllowDosing_Pos[2] = true; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station4 && GVL_SmallStation.GetInstance.Barrel_Location[3] == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.AllowDosing_Pos[3] = true; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station5 && GVL_SmallStation.GetInstance.Barrel_Location[4] == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.AllowDosing_Pos[4] = true; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station6 && GVL_SmallStation.GetInstance.Barrel_Location[5] == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.AllowDosing_Pos[5] = true; |
|
|
|
} |
|
|
|
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.RecipeStatusID == 0) |
|
|
|
{ |
|
|
|
RunInit(); |
|
|
|
if (RunInit() == 1) |
|
|
|
{ |
|
|
|
GVL_SmallStation.GetInstance.RecipeStatusID = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.RecipeStatusID == 1) |
|
|
|
{ |
|
|
@@ -214,28 +426,29 @@ namespace BPASmartClient.DosingHKProject.Model |
|
|
|
} |
|
|
|
if (HKDevice.HK_PLC_S7.Read<bool>("DB2.DBX3.0") && HKDevice.HK_PLC_S7.Read<bool>("DB2.DBX3.1") && GVL_SmallStation.GetInstance.RecipeStatusID == 2) |
|
|
|
{ |
|
|
|
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Load) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
GVL_SmallStation.GetInstance.RecipeStatusID = 3; |
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.RecipeStatusID == 3) |
|
|
|
{ |
|
|
|
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0"))) |
|
|
|
for (int i = 0; i < 6; i++) |
|
|
|
{ |
|
|
|
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10"); |
|
|
|
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料"); |
|
|
|
if (res > 0 && res is float loc) |
|
|
|
|
|
|
|
} |
|
|
|
if (GVL_SmallStation.GetInstance.AllowDosing_Pos[0]) |
|
|
|
{ |
|
|
|
int res = 1; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方:{recipeName},1号桶,{res}料仓,允许配料"); |
|
|
|
if (res > 0 ) |
|
|
|
{ |
|
|
|
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); |
|
|
|
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == res); |
|
|
|
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; |
|
|
|
if (loc_index >= 0) |
|
|
|
{ |
|
|
|
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量 |
|
|
|
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; |
|
|
|
DeviceInquire.GetInstance.GetDevice((int)res)?.Start(weight);//根据料仓编号 启动并写入每个原料重量 |
|
|
|
GVL_SmallStation.GetInstance.StockInIsWork = (int)res; |
|
|
|
} |
|
|
|
GVL_SmallStation.GetInstance.DosingTray1 = true; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成"); |
|
|
|
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)res}号仓,配料完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1"))) |
|
|
|