pry 1 year ago
parent
commit
7a7b99c63f
2 changed files with 118 additions and 20 deletions
  1. +100
    -2
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  2. +18
    -18
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs

+ 100
- 2
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -58,9 +58,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
}),"海科数据交互",true);
}
/// <summary>
/// 下发配方数据
/// 往plc下发配方数据
/// </summary>
public void StockBinPar(RecipeData recipe)
public void WritePlcRecipeData(RecipeData recipe)
{
if (IsConnected)
{
@@ -135,5 +135,103 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
}
}
}
/// <summary>
/// 读取plc收到的配方数据
/// </summary>
/// <param name="recipe"></param>
/// <returns></returns>
public bool ReadPlcRecipeData(RecipeData recipe)
{
if (IsConnected)
{
if (recipe != null)
{
ushort Code1 = HK_PLC_S7.Read<ushort>("DB99.DBW2.0");
ushort Code2 = HK_PLC_S7.Read<ushort>("DB99.DBW4.0");
if (recipe.TrayCode != Code1 || recipe.TrayCode != Code2)
{
MessageNotify.GetInstance.ShowRunLog($"下发的配方数据,DB99.DBW2.0:{recipe.TrayCode},DB99.DBW2.0:{recipe.TrayCode}");
return false;
}
MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},下发完成");
for (int barrel = 1; barrel < 6; barrel++)
{
if (barrel != 3)//桶的编号不为3 只为1,2,4,5号桶
{
for (int loc = 1; loc < 15; loc++)
{
int index = Array.FindIndex(recipe.RawMaterial.ToArray(), p => p.RawMaterialBarrelNum == barrel && p.RawMaterialLocation == loc);
if (index == -1)
{
float weight0 = (float)0.0;
float ReadWeight = (float)0.0;
string Address = "";
switch (barrel)
{
case 1:
Address = "DB99.DBD" + (6 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
case 2:
Address = "DB99.DBD" + (62 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
case 4:
Address = "DB99.DBD" + (118 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
case 5:
Address = "DB99.DBD" + (174 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
default:
break;
}
if (Math.Round(weight0, 1) != Math.Round(ReadWeight, 1))
{
MessageNotify.GetInstance.ShowRunLog($"地址:{Address},配方重量0,读取plc值{ReadWeight}");
return false;
}
}
else
{
string Address = "";
float ReadWeight = (float)0.0;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
switch (barrel)
{
case 1:
Address = "DB99.DBD" + (6 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
case 2:
Address = "DB99.DBD" + (62 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
case 4:
Address = "DB99.DBD" + (118 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
case 5:
Address = "DB99.DBD" + (174 + 4 * (loc - 1));
ReadWeight = HK_PLC_S7.Read<float>(Address);
break;
default:
break;
}
if (Math.Floor(recipe.RawMaterial.ElementAt(index).RawMaterialWeight) != Math.Floor(ReadWeight))
{
return false;
}
}
}
}
}
return true;
}
return false;
}
return false;
}
}
}

+ 18
- 18
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -227,7 +227,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -235,7 +235,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -392,7 +392,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true);
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -400,7 +400,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true);
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -554,7 +554,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true);
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -562,7 +562,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true);
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -717,7 +717,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true);
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -725,7 +725,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true);
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -1303,7 +1303,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

GVL_BigStation.DosingRecipe1Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -1312,7 +1312,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
else
{
GVL_BigStation.DosingRecipe1Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -1417,7 +1417,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

GVL_BigStation.DosingRecipe2Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true);
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -1426,7 +1426,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
else
{
GVL_BigStation.DosingRecipe2Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true);
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -1530,7 +1530,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");
GVL_BigStation.DosingRecipe3Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true);
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -1539,7 +1539,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
else
{
GVL_BigStation.DosingRecipe3Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true);
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -1643,7 +1643,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");
GVL_BigStation.DosingRecipe4Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true);
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -1652,7 +1652,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
else
{
GVL_BigStation.DosingRecipe4Time = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true);
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -2248,7 +2248,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");

GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -2257,7 +2257,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
else
{
GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.WritePlcRecipeData(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");


Loading…
Cancel
Save