|
|
@@ -43,7 +43,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
(res2 > 0)) |
|
|
|
{ |
|
|
|
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID); |
|
|
|
if (!(index >= 0)) |
|
|
|
if (index == -1) |
|
|
|
{ |
|
|
|
RawMaterials.Clear(); |
|
|
|
for (int i = 0; i < 15; i++) |
|
|
@@ -81,6 +81,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
if (index >= 0 && index < Json<RemoteRecipeDataColl>.Data.Recipes.Count) |
|
|
|
{ |
|
|
|
Json<RemoteRecipeDataColl>.Data.Recipes.ElementAt(index).TrayCode = TrayLocation; |
|
|
|
MessageLog.GetInstance.RunLog($"接收到AGV进站信号=>配方编码:{recipeId} 、托盘位置:{TrayLocation}"); |
|
|
|
BigStation.AGVToWorkStationQueue.Enqueue(recipeId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -116,9 +118,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
if (HKDevice.IsConnected && SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
AgvGetInDelivery(); |
|
|
|
AgvGetInPickUp(); |
|
|
|
//AgvGetInPickUp(); |
|
|
|
} |
|
|
|
Thread.Sleep(10); |
|
|
|
|
|
|
|
}), "AGV进站送取货", true); |
|
|
|
ThreadManage.GetInstance().StartLong(new Action(() => { |
|
|
|
ReadSiemensCommData(); |
|
|
|
ReadHKPLCCommData(); |
|
|
|
}), "AGV进站送取货", true); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
@@ -126,64 +133,74 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
/// </summary> |
|
|
|
private void AgvGetInDelivery() |
|
|
|
{ |
|
|
|
|
|
|
|
switch (BigStation.AgvDeliveryPosition) |
|
|
|
//检测AGV到站信号 |
|
|
|
if (BigStation.AGVToWorkStationQueue.Count > 0) |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApply) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 1; |
|
|
|
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 2; |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 3; |
|
|
|
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 4; |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 5; |
|
|
|
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition = 0; |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
int index = BigStation.AGVToWorkStationQueue.ElementAt(0); |
|
|
|
|
|
|
|
} |
|
|
|
//获取工位上是否有小车 |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) |
|
|
|
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar)); |
|
|
|
for (int i = 0; i < 6; i++) |
|
|
|
{ |
|
|
|
switch (BigStation.AgvDeliveryPosition[i]) |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
if (true) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition[i] = 1; |
|
|
|
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true); |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVApply,false); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
if (HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition[i] = 2; |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition[i] = 3; |
|
|
|
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition[i] = 4; |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition[i] = 5; |
|
|
|
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool)) |
|
|
|
{ |
|
|
|
BigStation.AgvDeliveryPosition[i] = 0; |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
//获取工位上是否有小车 |
|
|
|
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) |
|
|
|
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// AGV进站取货 |
|
|
|
/// </summary> |
|
|
|
private void AgvGetInPickUp() |
|
|
|
{ |
|
|
|
switch (BigStation.AgvPickUpPosition) |
|
|
|
/*switch (BigStation.AgvPickUpPosition) |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool)) |
|
|
@@ -215,7 +232,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
private void ReceviceData() |
|
|
|
{ |
|
|
@@ -229,6 +246,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ushort[] BarrelNum = new ushort[15]; |
|
|
|
ushort[] Location = new ushort[15]; |
|
|
|
ushort[] Weight = new ushort[15]; |
|
|
|
private void RecipeInfoToHKPLC() |
|
|
|
{ |
|
|
|
if (BigStation.RecipeQueue.Count > 0) |
|
|
@@ -237,23 +257,124 @@ namespace BPASmartClient.JXJFoodBigStation.Model |
|
|
|
if (index >= 0 && index <= BigStation.RemoteRecipes.Count) |
|
|
|
{ |
|
|
|
long code = BigStation.RemoteRecipes.ElementAt(index).RecipeCode; |
|
|
|
if (RTrig.GetInstance("IsAllowDosing").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.IsAllowDosing) is bool a)) |
|
|
|
if (HKDevice.HK_PLC_S7.Read("M5001.0") is bool)//配方1是否允许下发配发 |
|
|
|
{ |
|
|
|
foreach (var item in BigStation.RemoteRecipes.ElementAt(index).RawMaterial) |
|
|
|
for (int i = 0; i < BigStation.RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) |
|
|
|
{ |
|
|
|
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); |
|
|
|
BarrelNum[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; |
|
|
|
Location[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation; |
|
|
|
Weight[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight; |
|
|
|
} |
|
|
|
HKDevice.AllowDosingSignReset(); |
|
|
|
BigStation.IssueRecipeFinish = true; |
|
|
|
HKDevice.StockBinPar(BarrelNum, Location, Weight); |
|
|
|
HKDevice.HK_PLC_S7.Write("M4001.0", 1);//配发下发完成,to plc |
|
|
|
HKDevice.HK_PLC_S7.Write("M5001.0",0);//复位允许下发配方1信号 |
|
|
|
//BigStation.IssueRecipeFinish = true; |
|
|
|
} |
|
|
|
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool)) |
|
|
|
{ |
|
|
|
HKDevice.RecipeDosingFinishReset(); |
|
|
|
BigStation.RecipeQueue.TryDequeue(out code); |
|
|
|
|
|
|
|
BigStation.IssuedComplete.Add(BigStation.RemoteRecipes.ElementAt(index));//将该配方添加到下 |
|
|
|
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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) => |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
private void ReadHKPLCCommData() |
|
|
|
{ |
|
|
|
if (HKDevice.IsConnected) |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
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(Address,Value); |
|
|
|
} |
|
|
|
} |
|
|
|
private void WriteHKPLC(string Address, object Value) |
|
|
|
{ |
|
|
|
HKDevice.HK_PLC_S7.Write(Address, Value); |
|
|
|
} |
|
|
|
private object ReadSiemens(string Address) |
|
|
|
{ |
|
|
|
if (SiemensDevice.IsConnected) |
|
|
|
{ |
|
|
|
return SiemensDevice.Siemens_PLC_S7.Read(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(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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |