@@ -41,21 +41,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// <summary>
/// <summary>
/// 物料集合
/// 物料集合(工位配方集合,五个键分别对应五个工位)
/// </summary>
/// </summary>
public Dictionary<int, ConcurrentQueue<string>> RecipeQueueTray { get; set; } = new Dictionary<int, ConcurrentQueue<string>>();
public Dictionary<int, ConcurrentQueue<string>> RecipeQueueTray { get; set; } = new Dictionary<int, ConcurrentQueue<string>>();
public ConcurrentQueue<string> RecipeQueueTray2 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueueTray2 = new ConcurrentQueue<string>();
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
//XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
// public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
public ObservableCollection<PlcInfos> CommData { get; set; } = new ObservableCollection<PlcInfos>();
public ObservableCollection<PlcInfos> CommData { get; set; } = new ObservableCollection<PlcInfos>();
public ObservableCollection<PlcInfos> ProcessVar { get; set; } = new ObservableCollection<PlcInfos>();
public ObservableCollection<PlcInfos> ProcessVar { get; set; } = new ObservableCollection<PlcInfos>();
XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
/// <summary>
/// <summary>
/// 风送PLC的DB块
/// 风送PLC的DB块
/// </summary>
/// </summary>
@@ -333,8 +333,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read<byte>("DB3.DBB0");
GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read<byte>("DB3.DBB0");
GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read<byte>("DB3.DBB1");
GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read<byte>("DB3.DBB1");
}
}
if (SiemensDevice.IsConnected)
{
// if (SiemensDevice.IsConnected)
// {
ushort TrayCylinder = 0;
ushort TrayCylinder = 0;
ushort TraySensor = 0;
ushort TraySensor = 0;
if (GVL_SmallStation.GetInstance.Station1Sensor)
if (GVL_SmallStation.GetInstance.Station1Sensor)
@@ -353,10 +353,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
TrayCylinder = TrayCylinder.SetBitValue(0, false);
TrayCylinder = TrayCylinder.SetBitValue(0, false);
}
}
this.SiemensDevice.Siemens_PLC_S7.Write<bool>("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet);
this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW190", TraySensor);//添加工位传感器的信号
this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut;
// this.SiemensDevice.Siemens_PLC_S7.Write<bool>("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet);
// this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW190", TraySensor);//添加工位传感器的信号
// this.SiemensDevice.Siemens_PLC_S7.Write<ushort>("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
ushort AGV_Put =0 /* (ushort)SiemensDevice.XL_Status.AgvFinishPut*/ ;
if (AGV_Put.GetBitValue(1))
if (AGV_Put.GetBitValue(1))
{
{
GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true;
GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true;
@@ -365,7 +365,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
}
}
ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet;
ushort AGV_Get =0/* (ushort)SiemensDevice.XL_Status.AgvFinishGet*/ ;
if (AGV_Get.GetBitValue(1))
if (AGV_Get.GetBitValue(1))
{
{
GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true;
GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true;
@@ -374,7 +374,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
}
}
}
// }
}
}
public void CancelOrder()
public void CancelOrder()
@@ -442,16 +442,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
break;
break;
case 3:
case 3:
SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
// SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
GVL_SmallStation.GetInstance.OrderCancelStep = 4;
GVL_SmallStation.GetInstance.OrderCancelStep = 4;
break;
break;
case 4:
case 4:
if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
{
SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
// if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
// {
// SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
GVL_SmallStation.GetInstance.OrderCancelStep = 9;
GVL_SmallStation.GetInstance.OrderCancelStep = 9;
MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
}
// }
break;
break;
case 9:
case 9:
App.Current.Dispatcher.Invoke(() =>
App.Current.Dispatcher.Invoke(() =>
@@ -465,16 +465,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
GVL_SmallStation.GetInstance.OrderCancelStep = 0;
GVL_SmallStation.GetInstance.OrderCancelStep = 0;
break;
break;
case 20:
case 20:
SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
// SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
GVL_SmallStation.GetInstance.OrderCancelStep = 21;
GVL_SmallStation.GetInstance.OrderCancelStep = 21;
break;
break;
case 21:
case 21:
if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
{
SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
// if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
// {
// SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
GVL_SmallStation.GetInstance.OrderCancelStep = 29;
GVL_SmallStation.GetInstance.OrderCancelStep = 29;
MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
}
// }
break;
break;
case 29:
case 29:
App.Current.Dispatcher.Invoke(() =>
App.Current.Dispatcher.Invoke(() =>
@@ -489,16 +489,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//30-39为订单还未下发至上位机
//30-39为订单还未下发至上位机
case 30:
case 30:
SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
// SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
GVL_SmallStation.GetInstance.OrderCancelStep = 31;
GVL_SmallStation.GetInstance.OrderCancelStep = 31;
break;
break;
case 31:
case 31:
if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
{
SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
// if (SiemensDevice.Siemens_PLC_S7.Read<bool>("DB2201.DBX440.1") == false)
// {
// SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
GVL_SmallStation.GetInstance.OrderCancelStep = 39;
GVL_SmallStation.GetInstance.OrderCancelStep = 39;
MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}");
MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}");
}
// }
break;
break;
case 39:
case 39:
GVL_SmallStation.GetInstance.Order_Cancel = false;
GVL_SmallStation.GetInstance.Order_Cancel = false;
@@ -521,33 +521,33 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
foreach (var data in RemoteRecipes)
foreach (var data in RemoteRecipes)
{
{
if (data.TrayCode == 1)
{
if (SiemensDevice.XL_Status is XL_Status_DB status)
{
// if (data.TrayCode == 1)
// {
// if (SiemensDevice.XL_Status is XL_Status_DB status)
// {
switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
{
{
case 3:
case 3:
SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
// SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
// SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
break;
break;
case 4:
case 4:
if (SiemensDevice.XL_Status.Dosing_Confirm)
{
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
// if (SiemensDevice.XL_Status.Dosing_Confirm)
// {
// SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
// SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
}
// }
break;
break;
case 5:
case 5:
if (SiemensDevice.XL_Status.Dosing_Confirm == false)
{
// if (SiemensDevice.XL_Status.Dosing_Confirm == false)
// {
GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
}
// }
break;
break;
case 6:
case 6:
for (int i = 0; i < 5; i++)
for (int i = 0; i < 5; i++)
@@ -574,10 +574,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
break;
default:
default:
break;
break;
}
// }
}
}
}
// }
}
}
}
}
else
else
@@ -598,8 +598,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
foreach (var data in RemoteRecipes)
foreach (var data in RemoteRecipes)
{
{
if (data.TrayCode == 1)
{
// if (data.TrayCode == 1)
// {
for (int i = 0; i < 5; i++)
for (int i = 0; i < 5; i++)
{
{
if (GVL_SmallStation.GetInstance.NotUseSmallStation)
if (GVL_SmallStation.GetInstance.NotUseSmallStation)
@@ -619,7 +619,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
}
}
}
}
// }
}
}
}
}
else
else
@@ -639,6 +639,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
/// </summary>
private void RecipeInfoToHKPLC()
private void RecipeInfoToHKPLC()
{
{
//五个工位AGV控制请求流程。
if (!GVL_SmallStation.GetInstance.NotUseSmallStation)
if (!GVL_SmallStation.GetInstance.NotUseSmallStation)
{
{
for (int i = 0; i < 5; i++)
for (int i = 0; i < 5; i++)
@@ -657,7 +658,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
break;
case 1:
case 1:
if (GVL_SmallStation.GetInstance.Station1HaveTray)
if (GVL_SmallStation.GetInstance.Station1HaveTray)
{
{
HKDevice.HK_PLC_S7.Write("DB4.DBX8." + i, false);
HKDevice.HK_PLC_S7.Write("DB4.DBX8." + i, false);
GVL_SmallStation.GetInstance.Tray_AGVLogic[i] = 2;
GVL_SmallStation.GetInstance.Tray_AGVLogic[i] = 2;
@@ -688,11 +688,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
}
}
}
//工位配料流程
foreach (var recipe in RecipeQueueTray)
foreach (var recipe in RecipeQueueTray)
{
{
//recipeNum就是托盘号,也就是工位号。
int recipeNum = recipe.Key;
int recipeNum = recipe.Key;
//判断工位是否有配方。
if (RecipeQueueTray[recipeNum].Count > 0)
if (RecipeQueueTray[recipeNum].Count > 0)
{
{
//从配方列表里根据配方号查找配方
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray[recipeNum].ElementAt(0));
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray[recipeNum].ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
if (index >= 0 && index < RemoteRecipes.Count)
{
{
@@ -700,44 +705,46 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
string windSend = RemoteRecipes.ElementAt(index).ToString();
string windSend = RemoteRecipes.ElementAt(index).ToString();
//当前只配托盘号为1 ,即工位1 的配方。
if (trayCode == 1)
if (trayCode == 1)
{
{
//如果不使用小料站配料,目前没有这种工作情况。
if (GVL_SmallStation.GetInstance.NotUseSmallStation)
if (GVL_SmallStation.GetInstance.NotUseSmallStation)
{
{
if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish)
if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish)
{
{
Thread.Sleep(5000);
Thread.Sleep(5000);
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
{
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
RecipeFinishInfo.Job_No = (short)trayCode;
for (int i = 0; i < 20; i++)
{
RecipeFinishInfo.Material[i] = new UDT1();
}
for (int i = 0; i < 10; i++)
{
RecipeFinishInfo.Powder[i] = new UDT2();
}
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
{
RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
}
for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
{
RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
}
RecipeFinishInfo.Ask_For_Finish = true;
RecipeFinishInfo.DosingTime = Convert.ToInt16(0);
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
// if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
// {
// RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
// RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
// RecipeFinishInfo.Job_No = (short)trayCode;
// for (int i = 0; i < 20; i++)
// {
// RecipeFinishInfo.Material[i] = new UDT1();
// }
// for (int i = 0; i < 10; i++)
// {
// RecipeFinishInfo.Powder[i] = new UDT2();
// }
// for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
// {
// RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
// RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
// RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
// }
// for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
// {
// RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
// }
// RecipeFinishInfo.Ask_For_Finish = true;
// RecipeFinishInfo.DosingTime = Convert.ToInt16(0);
// SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
}
else
// MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
// }
// else
{
{
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
}
}
@@ -760,9 +767,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
if (GVL_SmallStation.GetInstance.WindSendDosingStatus == 1)
if (GVL_SmallStation.GetInstance.WindSendDosingStatus == 1)
{
{
//清空风送配料数据
WindSend_Write WindSendData111 = new WindSend_Write();
WindSend_Write WindSendData111 = new WindSend_Write();
WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData111, 95);
WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData111, 95);
Thread.Sleep(200);
Thread.Sleep(200);
//设置DB95数据并下发。
WindSendData111.TargetRecipeCode = code;
WindSendData111.TargetRecipeCode = code;
WindSendData111.IsAllowDosing = true;
WindSendData111.IsAllowDosing = true;
foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
@@ -795,6 +804,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
GVL_SmallStation.GetInstance.WindSendDosing = true;
GVL_SmallStation.GetInstance.WindSendDosing = true;
GVL_SmallStation.GetInstance.WindSendDosingStatus = 2;
GVL_SmallStation.GetInstance.WindSendDosingStatus = 2;
//下发配料数据
WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData111, 95);
WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData111, 95);
}
}
}
}
@@ -807,30 +817,39 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
}
}
}
//如果小料仓配方下发状态为0(未下发),则下发配方。并清除该工位配方的配料情况信号。
if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 0)
if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 0)
{
{
GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] = 0;
GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] = 0;
//下发工单,并置位工单下发确认。
HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, recipeNum);
HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, recipeNum);
HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, true);
HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, true);
//下发完成,等待开始制作。
GVL_SmallStation.GetInstance.DosingTime[recipeNum] = DateTime.Now;
GVL_SmallStation.GetInstance.DosingTime[recipeNum] = DateTime.Now;
GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 1;
GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 1;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},下发完成");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},下发完成");
}
}
//确认是否收到工单
bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX4." + recipeNum);
bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX4." + recipeNum);
if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 1)
if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 1)
{
{
//确认PLC收到工单后,复位下发确认信号。
HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, false);
HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, false);
GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 2;
GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 2;
GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] = 0;
GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] = 0;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},配方接收完成");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号{code},配方号{recipeNum + 1},配方接收完成");
}
}
//粉料仓完毕,开始控制小料仓味魔方配料。
if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 2)
if (GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] == 2)
{
{
//味魔方配料。
for (byte i = 1; i < 16; i++)
for (byte i = 1; i < 16; i++)
{
{
//indexArr是各配方位置反馈。
int indexArr = -1;
int indexArr = -1;
if (GVL_SmallStation.GetInstance.plcReadDataDB3.StockBinAllowIssue[i - 1])
if (GVL_SmallStation.GetInstance.plcReadDataDB3.StockBinAllowIssue[i - 1])
{
{
//根据配方号查找各配方的三个桶的位置反馈。位置反馈用的是ushort转16位2进制表示。
switch (recipeNum)
switch (recipeNum)
{
{
case 0:
case 0:
@@ -849,10 +868,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
indexArr = Array.FindIndex(GVL_SmallStation.GetInstance.plcReadDataDB3.Recipe5BarrelPosReserve.ToArray(), p => p == i);
indexArr = Array.FindIndex(GVL_SmallStation.GetInstance.plcReadDataDB3.Recipe5BarrelPosReserve.ToArray(), p => p == i);
break;
break;
}
}
//如果料桶已经到位但没有配料完成信号。
if (indexArr >= 0 && GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum].GetBitValue((byte)i) == false)
if (indexArr >= 0 && GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum].GetBitValue((byte)i) == false)
{
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
//如果重量为0,即不需要配料。则直接设为配料完成。
if (weight <= 0)
if (weight <= 0)
{
{
if (i >= 1 && i <= 8)
if (i >= 1 && i <= 8)
@@ -870,6 +891,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
else
else
{
{
//下发小料仓味魔方配料指令。
if (loc_index >= 0)
if (loc_index >= 0)
{
{
DeviceInquire.GetInstance.GetDevice((int)i)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
DeviceInquire.GetInstance.GetDevice((int)i)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
@@ -886,6 +908,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
//MessageNotify.GetInstance.ShowRunLog($"错误,有允许配料信号,但没有相应的位置 和桶号");
//MessageNotify.GetInstance.ShowRunLog($"错误,有允许配料信号,但没有相应的位置 和桶号");
}
}
//味魔方配料完成后处理。
if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && indexArr >= 0 && GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i))
if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && indexArr >= 0 && GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i))
{
{
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
@@ -895,10 +918,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
else
else
{
{
//配料完成后,先延时一段时间再复位。
Thread.Sleep(GVL_SmallStation.GetInstance.Time);
Thread.Sleep(GVL_SmallStation.GetInstance.Time);
//获取实际下料重量后复位配料完成状态。
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
//计算误差范围是否在允许范围内,如果超出范围,则报警。
float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
int iIndex = Array.FindIndex(Json<DevicePar>.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
if (iIndex >= 0)
if (iIndex >= 0)
@@ -913,6 +941,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
});
});
}
}
}
}
//置位味魔方配料完成信号。
if (i >= 1 && i <= 8)
if (i >= 1 && i <= 8)
{
{
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX12." + (i - 1), true);
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX12." + (i - 1), true);
@@ -929,6 +958,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
}
}
}
//接收到工单配料完成上升沿后。
bool DosingComple = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX6." + recipeNum);
bool DosingComple = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX6." + recipeNum);
if ((RTrig.GetInstance("配方配料完成").Start(DosingComple)) || (GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] > 0 && DosingComple))
if ((RTrig.GetInstance("配方配料完成").Start(DosingComple)) || (GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] > 0 && DosingComple))
{
{
@@ -937,7 +968,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] > 0)
if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] > 0)
{
{
for (int i = 1; i < 17; i++)
for (int i = 1; i < 17; i++)
{
{//看不懂
if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i))
if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum].GetBitValue((byte)i))
{
{
MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
@@ -950,37 +981,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
}
}
if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
{
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
RecipeFinishInfo.Job_No = (short)trayCode;
for (int i = 0; i < 20; i++)
{
RecipeFinishInfo.Material[i] = new UDT1();
}
for (int i = 0; i < 10; i++)
{
RecipeFinishInfo.Powder[i] = new UDT2();
}
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
{
RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
}
for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
{
RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
}
RecipeFinishInfo.Ask_For_Finish = true;
RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
// if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
// {
// RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
// RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
// RecipeFinishInfo.Job_No = (short)trayCode;
// for (int i = 0; i < 20; i++)
// {
// RecipeFinishInfo.Material[i] = new UDT1();
// }
// for (int i = 0; i < 10; i++)
// {
// RecipeFinishInfo.Powder[i] = new UDT2();
// }
// for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
// {
// RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
// RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
// RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
// }
// for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
// {
// RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
// }
// RecipeFinishInfo.Ask_For_Finish = true;
// RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
// SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName);
}
else
// MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
// MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName);
// }
// else
{
{
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName);
MessageNotify.GetInstance.ShowRecipeLog(res.RecipeName);
@@ -1285,8 +1316,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
ObservableCollection<WindSendRawMaterial> WindSendData = new ObservableCollection<WindSendRawMaterial>();
ObservableCollection<WindSendRawMaterial> WindSendData = new ObservableCollection<WindSendRawMaterial>();
if (SiemensDevice.IsConnected)
{
// if (SiemensDevice.IsConnected)
// {
if (res != null && res is XL_Start_DB recipe)
if (res != null && res is XL_Start_DB recipe)
{
{
if (!string.IsNullOrEmpty(recipe.RecipeCode))
if (!string.IsNullOrEmpty(recipe.RecipeCode))
@@ -1344,7 +1375,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
});
});
}
}
}
}
}
// }
}), "SiemensRecipeRecive", true);
}), "SiemensRecipeRecive", true);
//将本地配方发送到西门子配方里,执行配料
//将本地配方发送到西门子配方里,执行配料
@@ -1545,8 +1576,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
{
if (Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
if (Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
{
{
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
// SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
// if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
}
}
}
}
catch (Exception ex)
catch (Exception ex)
@@ -1555,7 +1586,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
finally
finally
{
{
SiemensDevice.Init();
// SiemensDevice.Init();
MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成");
MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成");
}
}
try
try
@@ -1590,11 +1621,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
try
try
{
{
if (!SiemensDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
{
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功");
}
// if (!SiemensDevice.IsConnected && Json<DevicePar>.Data.deviceConnectPar.SiemensConnect)
// {
// SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
// if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功");
// }
}
}
catch (Exception ex)
catch (Exception ex)
{
{