Bladeren bron

吉香居大料站代码更新

样式分支
pengliangyang 2 jaren geleden
bovenliggende
commit
e879634ce5
5 gewijzigde bestanden met toevoegingen van 244 en 65 verwijderingen
  1. +9
    -2
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  2. +4
    -3
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  3. +5
    -1
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs
  4. +179
    -58
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  5. +47
    -1
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensCommAddress.cs

+ 9
- 2
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs Bestand weergeven

@@ -16,6 +16,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RemoteRecipeData> IssuedComplete = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
@@ -34,10 +38,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 记录AGV进站送货的指令顺序
/// </summary>
public int AgvDeliveryPosition { get; set; }= 0;
public int[] AgvDeliveryPosition { get; set; }= new int[6];
/// <summary>
/// 记录AGV进站取货的指令顺序
/// </summary>
public int AgvPickUpPosition { get; set; } = 0;
public int[] AgvPickUpPosition { get; set; } = new int[6];

public ConcurrentQueue<int> AGVToWorkStationQueue = new ConcurrentQueue<int>();

}
}

+ 4
- 3
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs Bestand weergeven

@@ -61,12 +61,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
/// </summary>
/// <param name="BarrelNum">单个桶的编号</param>
/// <param name="StockBinLocation">单个桶对应的料仓位置</param>
public void StockBinPar(uint BarrelNum, ushort StockBinLocation)
public void StockBinPar(ushort[] Num, ushort[] Location,ushort[] Weight)
{
if (IsConnected)
{
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, Num);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, Location);
HK_PLC_S7.Write(HKPlcCommAddress.WeightToPLC, Weight);
}
}
}


+ 5
- 1
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs Bestand weergeven

@@ -15,7 +15,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
/// </summary>
public static string IsAllowDosing { get; set; } = "";
/// <summary>
/// 当前料仓位置
///
/// </summary>
public static string StockBinLocation { get; set; } = "";
/// <summary>
@@ -34,6 +34,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
/// </summary>
public static string BarrelNumToPLC { get; set; } = "";
/// <summary>
/// 对应桶号
/// </summary>
public static string WeightToPLC { get; set; } = "";
/// <summary>
/// 当前配料机配料完成
/// </summary>
public static string SingleDosingFinishToPLC { get; set; } = "";


+ 179
- 58
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs Bestand weergeven

@@ -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;
}
}
}
}

+ 47
- 1
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensCommAddress.cs Bestand weergeven

@@ -45,7 +45,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
public static string TrayRecipeIDToSiemens { get; set; } = "";
public static string TrayStateToSiemens { get; set; } = "";
#endregion
#region AGV小车进出工站1
/*#region AGV小车进出工站1
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
@@ -320,6 +320,52 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar6 { get; set; } = "";
#endregion*/
#region AGV进出站
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string DeliveryAGVApply { get; set; } = "M4002";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string DeliveryAGVIsApply { get; set; } = "M5002";
/// <summary>
/// Agv送货 进站顶升申请
/// </summary>
public static string DeliveryAGVApplyJack { get; set; } = "M4004";
/// <summary>
/// Agv送货 进站顶升申请
/// </summary>
public static string DeliveryAGVIsApplyJack { get; set; } = "M5004";
/// <summary>
/// Agv送货 送货完成
/// </summary>
public static string DeliveryAGVFinsih { get; set; } = "M4005";
/// <summary>
/// Agv送货 工位上有货架
/// </summary>
public static string StationHaveCargo { get; set; } = "M5005";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string PickAGVApply { get; set; } = "M4003";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string PickAGVIsApply { get; set; } = "M5003";
/// <summary>
/// Agv送货 取货架完成
/// </summary>
public static string PickCargoAGVFinish { get; set; } = "M4006";
/// <summary>
/// Agv送货 取料完成
/// </summary>
public static string PickAGVFinish { get; set; } = "M5006";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar { get; set; } = "M4007";
#endregion
}
public class RecipeRawMaterial


Laden…
Annuleren
Opslaan