|
|
@@ -48,27 +48,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
public ConcurrentQueue<string> RecipeQueue4 = new ConcurrentQueue<string>(); |
|
|
|
public ConcurrentQueue<string> RecipeQueue5 = new ConcurrentQueue<string>(); |
|
|
|
/// <summary> |
|
|
|
/// AGV到达工站队列 |
|
|
|
/// </summary> |
|
|
|
public ConcurrentQueue<string> AGVToWorkStationQueue = new ConcurrentQueue<string>(); |
|
|
|
/// <summary> |
|
|
|
/// 接收原料数据 |
|
|
|
/// </summary> |
|
|
|
public RecipeRawMaterial RawMaterial; |
|
|
|
public void Init() |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add("1", 1); |
|
|
|
RawMaterialsNamePos.Add("2", 2); |
|
|
|
RawMaterialsNamePos.Add("3", 3); |
|
|
|
RawMaterialsNamePos.Add("4", 4); |
|
|
|
RawMaterialsNamePos.Add("5", 5); |
|
|
|
RawMaterialsNamePos.Add("6", 6); |
|
|
|
RawMaterialsNamePos.Add("7", 7); |
|
|
|
RawMaterialsNamePos.Add("8", 8); |
|
|
|
RawMaterialsNamePos.Add("9", 9); |
|
|
|
RawMaterialsNamePos.Add("10", 10); |
|
|
|
RawMaterialsNamePos.Add("11", 11); |
|
|
|
RawMaterialsNamePos.Add("12", 12); |
|
|
|
ActionManage.GetInstance.Register(new Action<object>((res) => |
|
|
|
{ |
|
|
|
ObservableCollection<RawMaterial> RawMaterials = new ObservableCollection<RawMaterial>(); |
|
|
@@ -87,7 +71,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, |
|
|
|
RawMaterialWeight = recipe.Material[i].Material_Weight, |
|
|
|
RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@@ -99,7 +83,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
RecipeName = recipe.RecipeName, |
|
|
|
RecipeCode = recipe.RecipeCode, |
|
|
|
RawMaterial = RawMaterials, |
|
|
|
TrayCode = recipe.TrayCode |
|
|
|
//TrayCode = recipe.Order_No, |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@@ -108,7 +92,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; |
|
|
|
try |
|
|
|
{ |
|
|
|
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); |
|
|
|
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); |
|
|
|
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); |
|
|
|
if (HKDevice.IsConnected) |
|
|
|
{ |
|
|
@@ -138,136 +122,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败"); |
|
|
|
} |
|
|
|
}), "ManualSendRecipe", true); |
|
|
|
RecipeQueue1.Clear(); |
|
|
|
|
|
|
|
|
|
|
|
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 |
|
|
|
ThreadManage.GetInstance().StartLong(new Action(() => |
|
|
|
{ |
|
|
|
//ReadPLCDeviceInfo(); |
|
|
|
ReceviceData(); |
|
|
|
RecipeInfoToHKPLC(); |
|
|
|
Thread.Sleep(10); |
|
|
|
}), "流程处理", true); |
|
|
|
ThreadManage.GetInstance().StartLong(new Action(() => |
|
|
|
{ |
|
|
|
if (HKDevice.IsConnected && SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
AgvGetInOut(); |
|
|
|
} |
|
|
|
Thread.Sleep(10); |
|
|
|
}), "AGV进站送取货", true); |
|
|
|
ThreadManage.GetInstance().StartLong(new Action(() => |
|
|
|
{ |
|
|
|
ReadSiemensCommData(); |
|
|
|
ReadHKPLCCommData(); |
|
|
|
Thread.Sleep(10); |
|
|
|
}), "读取西门子和海科PLC的数据", true); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// AGV送货 |
|
|
|
/// </summary> |
|
|
|
/// <param name="bitNum"></param> |
|
|
|
private void AGV_Delivery(int bitNum) |
|
|
|
{ |
|
|
|
if ((ReadSiemens("M4002." + bitNum) is bool) && BigStation.AgvDeliveryPosition == 0) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 1; |
|
|
|
WriteHKPLC("M4002." + bitNum, true); |
|
|
|
WriteSiemens("M4002." + bitNum, false); |
|
|
|
} |
|
|
|
else if (ReadHK("M5002." + bitNum) is bool && BigStation.AgvDeliveryPosition == 1) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 2; |
|
|
|
WriteSiemens("M5002." + bitNum, true); |
|
|
|
WriteHKPLC("M5002." + bitNum, false); |
|
|
|
} |
|
|
|
else if (ReadSiemens("M4004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 2) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 3; |
|
|
|
WriteHKPLC("M4004." + bitNum, true); |
|
|
|
WriteSiemens("M4004." + bitNum, false); |
|
|
|
} |
|
|
|
else if (ReadHK("M5004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 3) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 4; |
|
|
|
WriteSiemens("M5004." + bitNum, true); |
|
|
|
WriteHKPLC("M5004." + bitNum, false); |
|
|
|
} |
|
|
|
else if (ReadSiemens("M4005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 4) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 5; |
|
|
|
WriteHKPLC("M4005." + bitNum, true); |
|
|
|
WriteSiemens("M4005." + bitNum, false); |
|
|
|
} |
|
|
|
else if (ReadHK("M5005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 5) |
|
|
|
{ |
|
|
|
WriteSiemens("M5005." + bitNum, true); |
|
|
|
WriteHKPLC("M5005." + bitNum, false); |
|
|
|
} |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// AGV取货 |
|
|
|
/// </summary> |
|
|
|
/// <param name="bitNum"></param> |
|
|
|
private void AGV_Pick(int bitNum) |
|
|
|
{ |
|
|
|
if (ReadSiemens("M4003" + bitNum) is bool && BigStation.AgvPickUpPosition == 0) |
|
|
|
{ |
|
|
|
BigStation.AgvPickUpPosition = 1; |
|
|
|
WriteHKPLC("M4003." + bitNum, true); |
|
|
|
WriteSiemens("M4003." + bitNum, false); |
|
|
|
} |
|
|
|
if (ReadHK("M5003" + bitNum) is bool && BigStation.AgvPickUpPosition == 1) |
|
|
|
{ |
|
|
|
BigStation.AgvPickUpPosition = 2; |
|
|
|
WriteSiemens("M5003" + bitNum, true); |
|
|
|
WriteHKPLC("M5003" + bitNum, false); |
|
|
|
} |
|
|
|
if (ReadSiemens("M4006." + bitNum) is bool && BigStation.AgvPickUpPosition == 2) |
|
|
|
{ |
|
|
|
BigStation.AgvPickUpPosition = 3; |
|
|
|
WriteHKPLC("M4006." + bitNum, true); |
|
|
|
WriteSiemens("M4006." + bitNum, false); |
|
|
|
} |
|
|
|
if (ReadHK("M5006." + bitNum) is bool && BigStation.AgvPickUpPosition == 3) |
|
|
|
{ |
|
|
|
WriteSiemens("M5006." + bitNum, true); |
|
|
|
WriteHKPLC("M5006." + bitNum, false); |
|
|
|
} |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// AGV进站送货 |
|
|
|
/// </summary> |
|
|
|
private void AgvGetInOut() |
|
|
|
{ |
|
|
|
//获取工位上是否有小车 |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write<bool>(SiemensCommAddress.StationIsExistCar, (bool) |
|
|
|
HKDevice.HK_PLC_S7.Read<bool>("M4007.0")); |
|
|
|
//检测AGV到站信号 |
|
|
|
if (AGVToWorkStationQueue.Count > 0) |
|
|
|
{ |
|
|
|
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0)); |
|
|
|
int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6 |
|
|
|
string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode; |
|
|
|
if (TrayLocation > 0 && TrayLocation < 7) |
|
|
|
{ |
|
|
|
AGV_Delivery(TrayLocation - 1); |
|
|
|
if (BigStation.AgvDeliveryPosition == 5) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 0; |
|
|
|
} |
|
|
|
AGV_Pick(TrayLocation - 1); |
|
|
|
if (BigStation.AgvPickUpPosition == 3) |
|
|
|
{ |
|
|
|
BigStation.AgvPickUpPosition = 0; |
|
|
|
AGVToWorkStationQueue.TryDequeue(out RecipeCode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private void ReceviceData() |
|
|
|
{ |
|
|
@@ -318,6 +182,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
RecipeQueue4.Clear(); |
|
|
|
RecipeQueue5.Clear(); |
|
|
|
BigStation.Recipe1DosingStatus = 0; |
|
|
|
BigStation.Recipe2DosingStatus = 0; |
|
|
|
BigStation.Recipe3DosingStatus = 0; |
|
|
|
BigStation.Recipe4DosingStatus = 0; |
|
|
|
BigStation.Recipe5DosingStatus = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
private void RecipeInfoToHKPLC() |
|
|
@@ -333,23 +201,20 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
{ |
|
|
|
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); |
|
|
|
HKDevice.PlcWrite.Recipe1IssuedFinish = true; |
|
|
|
//HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX0.1", false);//复位允许下发配方1信号 |
|
|
|
BigStation.Recipe1DosingStatus = 1; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); |
|
|
|
} |
|
|
|
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && BigStation.Recipe1DosingStatus == 1) |
|
|
|
{ |
|
|
|
BigStation.Recipe1DosingStatus = 2; |
|
|
|
HKDevice.PlcWrite.Recipe1IssuedFinish = false; |
|
|
|
HKDevice.PlcWrite.RecipeCode = 0; |
|
|
|
HKDevice.PlcWrite.TrayCode = 0; |
|
|
|
WeightReset(); |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); |
|
|
|
StockBinParReset(); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); |
|
|
|
} |
|
|
|
if (BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) |
|
|
|
{ |
|
|
|
BigStation.Recipe1DosingStatus = 3; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
if (HKDevice.PlcRead.Recipe1TrayCode == 1) |
|
|
|
{ |
|
|
|
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
@@ -425,7 +290,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
{ |
|
|
|
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3); |
|
|
|
} |
|
|
|
//HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.1",false); |
|
|
|
RecipeQueue1.TryDequeue(out code); |
|
|
|
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 |
|
|
|
if (!BigStation.IsAllowManual) |
|
|
@@ -453,21 +317,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); |
|
|
|
HKDevice.PlcWrite.Recipe2IssuedFinish = true; |
|
|
|
BigStation.Recipe2DosingStatus = 1; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); |
|
|
|
} |
|
|
|
if (HKDevice.PlcRead.ReceiveFinishRecipe2 && BigStation.Recipe2DosingStatus == 1) |
|
|
|
{ |
|
|
|
BigStation.Recipe2DosingStatus = 2; |
|
|
|
HKDevice.PlcWrite.Recipe2IssuedFinish = false; |
|
|
|
HKDevice.PlcWrite.RecipeCode = 0; |
|
|
|
HKDevice.PlcWrite.TrayCode = 0; |
|
|
|
WeightReset(); |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); |
|
|
|
StockBinParReset(); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); |
|
|
|
} |
|
|
|
if (BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) |
|
|
|
{ |
|
|
|
BigStation.Recipe2DosingStatus = 3; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
if (HKDevice.PlcRead.Recipe2TrayCode > 0) |
|
|
|
{ |
|
|
|
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
@@ -529,7 +391,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; |
|
|
|
FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; |
|
|
|
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) |
|
|
@@ -539,11 +400,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; |
|
|
|
FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); |
|
|
|
} |
|
|
|
RecipeQueue2.TryDequeue(out code); |
|
|
|
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 |
|
|
@@ -556,7 +417,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 |
|
|
|
} |
|
|
|
BigStation.Recipe2DosingStatus = 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -572,20 +432,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); |
|
|
|
HKDevice.PlcWrite.Recipe3IssuedFinish = true; |
|
|
|
BigStation.Recipe3DosingStatus = 1; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); |
|
|
|
} |
|
|
|
if (HKDevice.PlcRead.ReceiveFinishRecipe3 && BigStation.Recipe3DosingStatus == 1) |
|
|
|
{ |
|
|
|
BigStation.Recipe3DosingStatus = 2; |
|
|
|
HKDevice.PlcWrite.RecipeCode = 0; |
|
|
|
HKDevice.PlcWrite.TrayCode = 0; |
|
|
|
WeightReset(); |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); |
|
|
|
StockBinParReset(); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); |
|
|
|
} |
|
|
|
if (HKDevice.PlcRead.Recipe3DosingFinish && BigStation.Recipe3DosingStatus == 2) |
|
|
|
{ |
|
|
|
BigStation.Recipe3DosingStatus = 3; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
if (HKDevice.PlcRead.Recipe3TrayCode > 0) |
|
|
|
{ |
|
|
|
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
@@ -691,21 +549,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); |
|
|
|
HKDevice.PlcWrite.Recipe4IssuedFinish = true; |
|
|
|
BigStation.Recipe4DosingStatus = 1; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); |
|
|
|
} |
|
|
|
if (HKDevice.PlcRead.ReceiveFinishRecipe4 && BigStation.Recipe4DosingStatus == 1) |
|
|
|
{ |
|
|
|
BigStation.Recipe4DosingStatus = 2; |
|
|
|
HKDevice.PlcWrite.Recipe4IssuedFinish = false; |
|
|
|
HKDevice.PlcWrite.RecipeCode = 0; |
|
|
|
HKDevice.PlcWrite.TrayCode = 0; |
|
|
|
WeightReset(); |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); |
|
|
|
StockBinParReset(); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); |
|
|
|
} |
|
|
|
if (BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) |
|
|
|
{ |
|
|
|
BigStation.Recipe4DosingStatus = 3; |
|
|
|
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); |
|
|
|
if (HKDevice.PlcRead.Recipe4TrayCode > 0) |
|
|
|
{ |
|
|
|
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
@@ -799,128 +655,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public ConcurrentDictionary<string, Object> ReadHKPLCData = new ConcurrentDictionary<string, object>(); |
|
|
|
public ConcurrentDictionary<string, Object> ReadSiemensData = new ConcurrentDictionary<string, object>(); |
|
|
|
|
|
|
|
|
|
|
|
private void ReadSiemensCommData() |
|
|
|
{ |
|
|
|
if (SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
GetSiemensStatus("", new Action<object>((obj) => |
|
|
|
{ |
|
|
|
if (obj is bool[] bools && bools.Length > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
private void ReadHKPLCCommData() |
|
|
|
{ |
|
|
|
if (HKDevice.IsConnected) |
|
|
|
{ |
|
|
|
GetHKStatus("", new Action<object>((obj) => |
|
|
|
{ |
|
|
|
if (obj is bool[] bools && bools.Length > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
private void GetHKStatus(string key, Action<object> action) |
|
|
|
{ |
|
|
|
if (ReadHKPLCData.ContainsKey(key)) |
|
|
|
{ |
|
|
|
if (ReadHKPLCData[key] != null) |
|
|
|
{ |
|
|
|
action?.Invoke(ReadHKPLCData[key]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private void GetSiemensStatus(string key, Action<object> action) |
|
|
|
{ |
|
|
|
|
|
|
|
if (ReadSiemensData.ContainsKey(key)) |
|
|
|
{ |
|
|
|
if (ReadSiemensData[key] != null) |
|
|
|
{ |
|
|
|
action?.Invoke(ReadSiemensData[key]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private void WriteSiemens(string Address, object Value) |
|
|
|
{ |
|
|
|
if (SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write<object>(Address, Value); |
|
|
|
} |
|
|
|
} |
|
|
|
private void WriteHKPLC(string Address, object Value) |
|
|
|
{ |
|
|
|
HKDevice.HK_PLC_S7.Write<object>(Address, Value); |
|
|
|
} |
|
|
|
private object ReadSiemens(string Address) |
|
|
|
{ |
|
|
|
if (SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
return SiemensDevice.Siemens_PLC_S7.Read<object>(Address); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
private bool[] ReadBoolsSiemens(int address, int count) |
|
|
|
{ |
|
|
|
if (SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
return SiemensDevice.Siemens_PLC_S7.ReadBools(address, count); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
private object ReadHK(string Address) |
|
|
|
{ |
|
|
|
if (HKDevice.IsConnected) |
|
|
|
{ |
|
|
|
return HKDevice.HK_PLC_S7.Read<object>(Address); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
private bool[] ReadBoolsHK(int address, int count) |
|
|
|
{ |
|
|
|
if (HKDevice.IsConnected) |
|
|
|
{ |
|
|
|
return HKDevice.HK_PLC_S7.ReadBools(address, count); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 获取料仓的原料名称和原料位置 |
|
|
|
/// 下发配方的数据复位 |
|
|
|
/// </summary> |
|
|
|
private void ReadPLCDeviceInfo() |
|
|
|
{ |
|
|
|
/*for (int i = 0; i < 12; i++) |
|
|
|
{ |
|
|
|
string RawMaterialName = HKDevice.HK_PLC_S7.Read<string>(""); |
|
|
|
short RawMaterialLocation = HKDevice.HK_PLC_S7.Read<short>(""); |
|
|
|
if (RawMaterialsNamePos.ContainsKey(RawMaterialName)) |
|
|
|
RawMaterialsNamePos.Add(RawMaterialName, RawMaterialLocation); |
|
|
|
}*/ |
|
|
|
|
|
|
|
} |
|
|
|
private void WeightReset() |
|
|
|
private void StockBinParReset() |
|
|
|
{ |
|
|
|
|
|
|
|
HKDevice.PlcWrite.RecipeCode = 0; |
|
|
|
HKDevice.PlcWrite.TrayCode = 0; |
|
|
|
|
|
|
|
HKDevice.PlcWrite.Bareel1Bin1SetWeight = 0; |
|
|
|
HKDevice.PlcWrite.Bareel1Bin2SetWeight = 0; |
|
|
|
HKDevice.PlcWrite.Bareel1Bin3SetWeight = 0; |
|
|
@@ -982,5 +725,82 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0; |
|
|
|
HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0; |
|
|
|
} |
|
|
|
private void testData() |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Clear(); |
|
|
|
if (!HKDevice.IsConnected) |
|
|
|
{ |
|
|
|
HKDevice.StockBinName.RawMaterialName1 = "1"; |
|
|
|
HKDevice.StockBinName.RawMaterialName2 = "2"; |
|
|
|
HKDevice.StockBinName.RawMaterialName3 = "3"; |
|
|
|
HKDevice.StockBinName.RawMaterialName4 = "4"; |
|
|
|
HKDevice.StockBinName.RawMaterialName5 = "5"; |
|
|
|
HKDevice.StockBinName.RawMaterialName6 = "6"; |
|
|
|
HKDevice.StockBinName.RawMaterialName7 = "7"; |
|
|
|
HKDevice.StockBinName.RawMaterialName8 = "8"; |
|
|
|
HKDevice.StockBinName.RawMaterialName9 = "9"; |
|
|
|
HKDevice.StockBinName.RawMaterialName10 = "10"; |
|
|
|
HKDevice.StockBinName.RawMaterialName11 = "11"; |
|
|
|
HKDevice.StockBinName.RawMaterialName12 = "12"; |
|
|
|
HKDevice.StockBinName.RawMaterialName13 = "13"; |
|
|
|
HKDevice.StockBinName.RawMaterialName14 = "14"; |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName2)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName2, 2); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName3)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName3, 3); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName4)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName4, 4); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName5)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName5, 5); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName6)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName6, 6); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName7)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName7, 7); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName8)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName8, 8); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName9)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName9, 9); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName10)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName10, 10); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName11)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName11, 11); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName12)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName12, 12); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName13)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName13, 13); |
|
|
|
} |
|
|
|
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14)) |
|
|
|
{ |
|
|
|
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |