@@ -51,7 +51,6 @@ namespace BPASmartClient.JXJFoodBigStation | |||
private void MenuInit() | |||
{ | |||
#region 配方管理菜单 | |||
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>(); | |||
RecipeManage.Add(new SubMenumodel() | |||
@@ -11,7 +11,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
{ | |||
public class GVL_BigStation | |||
{ | |||
/// <summary> | |||
/// 往输送带下发配方完成 | |||
/// </summary> | |||
@@ -32,5 +31,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
/// 记录AGV进站取货的指令顺序 | |||
/// </summary> | |||
public int AgvPickUpPosition { get; set; } | |||
/// <summary> | |||
/// 配方配料的状态 0:无意义 ,1:plc允许下发配方 2:上位机下发配方 3:plc接收到配方(配料中) 4:配料完成 | |||
/// </summary> | |||
public int RecipeDosingStatus { get; set; } | |||
/// <summary> | |||
/// 是否处于手动下发配方 | |||
/// </summary> | |||
public bool IsAllowManual { get; set; } | |||
} | |||
} |
@@ -61,13 +61,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC | |||
/// </summary> | |||
/// <param name="BarrelNum">单个桶的编号</param> | |||
/// <param name="StockBinLocation">单个桶对应的料仓位置</param> | |||
public void StockBinPar(ushort[] Num, ushort[] Location,ushort[] Weight) | |||
public void StockBinPar(short[] Num, short[] Location,short[] Weight) | |||
{ | |||
if (IsConnected) | |||
{ | |||
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, Num); | |||
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, Location); | |||
HK_PLC_S7.Write(HKPlcCommAddress.WeightToPLC, Weight); | |||
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.BarrelNumToPLC, Num); | |||
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.StockBinLocationToPLC, Location); | |||
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.WeightToPLC, Weight); | |||
} | |||
} | |||
} | |||
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodBigStation.Model | |||
{ | |||
public class LocalRecipeDataColl | |||
{ | |||
public ObservableCollection<RemoteRecipeData> Recipes { get; set; } = new ObservableCollection<RemoteRecipeData>(); | |||
} | |||
} |
@@ -35,73 +35,57 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
/// </summary> | |||
public ObservableCollection<RemoteRecipeData> IssuedComplete = new ObservableCollection<RemoteRecipeData>(); | |||
/// <summary> | |||
/// 原料的名称和料仓的位置对应 | |||
/// </summary> | |||
public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>(); | |||
/// <summary> | |||
/// 配方队列 | |||
/// </summary> | |||
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>(); | |||
public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>(); | |||
/// <summary> | |||
/// AGV到达工站队列 | |||
/// </summary> | |||
public ConcurrentQueue<int> AGVToWorkStationQueue = new ConcurrentQueue<int>(); | |||
public ConcurrentQueue<string> AGVToWorkStationQueue = new ConcurrentQueue<string>(); | |||
/// <summary> | |||
/// 接收原料数据 | |||
/// </summary> | |||
public RecipeRawMaterial RawMaterial; | |||
public void Init() | |||
{ | |||
ActionManage.GetInstance.Register(new Action(() => | |||
ActionManage.GetInstance.Register(new Action<DL_Start_DB>((res) => | |||
{ | |||
if (SiemensDevice.IsConnected) | |||
{ | |||
var res = SiemensDevice.Siemens_PLC_S7.Read<string>(SiemensCommAddress.RecipeName); | |||
var res1 = SiemensDevice.Siemens_PLC_S7.Read<uint>(SiemensCommAddress.RecipeID); | |||
var res2 = SiemensDevice.Siemens_PLC_S7.ReadClass<RecipeRawMaterial>(0, 0); | |||
if ((res != null && res is string recipeName) && (res1 != null && res1 is uint recipeID)) | |||
if (res != null) | |||
{ | |||
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID); | |||
if (index == -1) | |||
RawMaterials.Clear(); | |||
for (int i = 0; i < 15; i++) | |||
{ | |||
RawMaterials.Clear(); | |||
for (int i = 0; i < 15; i++) | |||
if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name)) | |||
{ | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
RawMaterialBarrelNum = res2.RawMaterialBarrelNum[i], | |||
RawMaterialLocation = res2.RawMaterialLocation[i], | |||
RawMaterialWeight = res2.RawMaterialWeight[i] | |||
RawMaterialName = res.Material[i].Material_Name, | |||
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum, | |||
RawMaterialWeight = res.Material[i].Material_Weight, | |||
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name] | |||
}); | |||
} | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||
else | |||
{ | |||
RecipeName = recipeName, | |||
RecipeCode = recipeID, | |||
RawMaterial = RawMaterials | |||
}); | |||
//报警,配方的原料名称下发和设备不一致 | |||
} | |||
} | |||
else | |||
Json<LocalRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||
{ | |||
MessageLog.GetInstance.AlarmLog("配方列表中存在该配方ID"); | |||
} | |||
RecipeName = res.RecipeName, | |||
RecipeCode = res.RecipeCode, | |||
RawMaterial = RawMaterials, | |||
TrayCode = res.TrayCode | |||
}); | |||
} | |||
} | |||
}), "西门子下发配方", true); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
if (SiemensDevice.IsConnected) | |||
{ | |||
var res = SiemensDevice.Siemens_PLC_S7.Read<int>(SiemensCommAddress.TrayLocationNum); | |||
var res1 = SiemensDevice.Siemens_PLC_S7.Read<int>(SiemensCommAddress.RecipeID); | |||
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId) | |||
{ | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == recipeId); | |||
if (index >= 0 && index < RemoteRecipes.Count) | |||
{ | |||
RemoteRecipes.ElementAt(index).TrayCode = TrayLocation; | |||
MessageLog.GetInstance.RunLog($"接收到AGV进站信号=>配方编码:{recipeId} 、托盘位置:{TrayLocation}"); | |||
AGVToWorkStationQueue.Enqueue(recipeId); | |||
} | |||
} | |||
} | |||
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 | |||
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; | |||
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; | |||
try | |||
@@ -122,7 +106,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
} | |||
RecipeQueue.Clear(); | |||
Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 | |||
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
ReceviceData(); | |||
@@ -136,12 +120,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
AgvGetInOut(); | |||
} | |||
Thread.Sleep(10); | |||
}), "AGV进站送取货", true); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
ReadSiemensCommData(); | |||
ReadHKPLCCommData(); | |||
Thread.Sleep(10); | |||
}), "读取西门子和海科PLC的数据", true); | |||
} | |||
/// <summary> | |||
@@ -229,7 +213,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
{ | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0)); | |||
int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6 | |||
int RecipeCode = (int)RemoteRecipes.ElementAt(index).RecipeCode; | |||
string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode; | |||
if (TrayLocation > 0 && TrayLocation < 7) | |||
{ | |||
AGV_Delivery(TrayLocation - 1); | |||
@@ -249,7 +233,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
} | |||
private void ReceviceData() | |||
{ | |||
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes; | |||
if (!BigStation.IsAllowManual && RemoteRecipes.Count == 0)//一个配方执行完成后,再获取配方数据 | |||
{ | |||
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes; | |||
} | |||
else if (BigStation.IsAllowManual && RemoteRecipes.Count == 0) | |||
{ | |||
RemoteRecipes = Json<LocalRecipeDataColl>.Data.Recipes; | |||
} | |||
if (RemoteRecipes.Count > 0) | |||
{ | |||
foreach (var data in RemoteRecipes) | |||
@@ -259,9 +250,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
} | |||
} | |||
} | |||
ushort[] BarrelNum = new ushort[15]; | |||
ushort[] Location = new ushort[15]; | |||
ushort[] Weight = new ushort[15]; | |||
short[] BarrelNum = new short[15]; | |||
short[] Location = new short[15]; | |||
short[] Weight = new short[15]; | |||
private void RecipeInfoToHKPLC() | |||
{ | |||
if (RecipeQueue.Count > 0) | |||
@@ -269,26 +260,77 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0)); | |||
if (index >= 0 && index <= RemoteRecipes.Count) | |||
{ | |||
long code = RemoteRecipes.ElementAt(index).RecipeCode; | |||
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.0") is bool)//配方1是否允许下发配发 | |||
string code = RemoteRecipes.ElementAt(index).RecipeCode; | |||
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.0") && BigStation.RecipeDosingStatus == 0)//配方1是否允许下发配发 | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}允许下发"); | |||
BigStation.RecipeDosingStatus = 1; | |||
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) | |||
{ | |||
BarrelNum[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; | |||
Location[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation; | |||
Weight[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight; | |||
BarrelNum[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; | |||
Location[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation; | |||
Weight[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight; | |||
} | |||
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; | |||
BigStation.RecipeDosingStatus = 2; | |||
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); | |||
} | |||
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.4") && BigStation.RecipeDosingStatus == 2) | |||
{ | |||
BigStation.RecipeDosingStatus = 3; | |||
HKDevice.HK_PLC_S7.Write("M5001.4", 0);//复位允许下发配方1信号 | |||
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); | |||
} | |||
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.RecipeDosingFinish) is bool)) | |||
if (BigStation.RecipeDosingStatus == 3) | |||
{ | |||
HKDevice.RecipeDosingFinishReset(); | |||
RecipeQueue.TryDequeue(out code); | |||
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 | |||
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 | |||
for (int i = 0; i < 12; i++) | |||
{ | |||
if (i >= 0 && i < 8) | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read<bool>("M5008." + (i)))//根据配料完成信号, | |||
{ | |||
int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); | |||
if (a >= 0) | |||
{ | |||
int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum; | |||
string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48; | |||
float weight = HKDevice.HK_PLC_S7.Read<float>(address); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read<bool>("M5009." + (i - 8))) | |||
{ | |||
int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); | |||
if (a >= 0) | |||
{ | |||
int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum; | |||
string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48; | |||
float weight = HKDevice.HK_PLC_S7.Read<float>(address); | |||
} | |||
} | |||
} | |||
} | |||
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.RecipeDosingFinish)) || true) | |||
{ | |||
BigStation.RecipeDosingStatus = 4; | |||
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); | |||
HKDevice.RecipeDosingFinishReset(); | |||
RecipeQueue.TryDequeue(out code); | |||
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 | |||
if (!BigStation.IsAllowManual) | |||
{ | |||
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 | |||
} | |||
else | |||
{ | |||
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 | |||
} | |||
BigStation.RecipeDosingStatus = 0; | |||
} | |||
} | |||
} | |||
} | |||
@@ -399,5 +441,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
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); | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||
{ | |||
internal class DL_Finish_DB | |||
{ | |||
/// <summary> | |||
/// 生产工单编码 | |||
/// </summary> | |||
public string Order_No; | |||
/// <summary> | |||
/// 产品名称 | |||
/// </summary> | |||
public string Product_Code; | |||
/// <summary> | |||
/// 原料信息 | |||
/// </summary> | |||
public UDT1[] Material = new UDT1[20]; | |||
/// <summary> | |||
/// 配料完成信号 | |||
/// </summary> | |||
public bool Ask_For_Finish; | |||
/// <summary> | |||
/// 配料完成信号确认 | |||
/// </summary> | |||
public bool Ask_For_Finish_PLC; | |||
} | |||
public class UDT1 | |||
{ | |||
public string Material_Name; | |||
public float Material_Laying_Off_Weight; | |||
public short Material_BarrelNum; | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||
{ | |||
internal class DL_Start_DB | |||
{ | |||
/// <summary> | |||
/// 配方编码 | |||
/// </summary> | |||
public string RecipeCode; | |||
/// <summary> | |||
/// 配发名称 | |||
/// </summary> | |||
public string RecipeName; | |||
/// <summary> | |||
/// 物料信息 | |||
/// </summary> | |||
public UDT[] Material = new UDT[20]; | |||
/// <summary> | |||
/// 托盘编号 | |||
/// </summary> | |||
public int TrayCode; | |||
/// <summary> | |||
/// 配方发送请求 | |||
/// </summary> | |||
public bool Ask_For_Send_Bit; | |||
/// <summary> | |||
/// 上位机确认配方接收完成 | |||
/// </summary> | |||
public bool Ack_Ask_For_Send_Bit; | |||
} | |||
public class UDT | |||
{ | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string Material_Name; | |||
/// <summary> | |||
/// 原料重量 | |||
/// </summary> | |||
public float Material_Weight; | |||
/// <summary> | |||
/// 原料桶号 | |||
/// </summary> | |||
public short Material_BarrelNum; | |||
} | |||
} |
@@ -0,0 +1,60 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||
{ | |||
internal class DL_Status_DB | |||
{ | |||
/// <summary> | |||
/// 生产工单 | |||
/// </summary> | |||
public string Order_No; | |||
/// <summary> | |||
/// 配料开始 | |||
/// </summary> | |||
public bool Dosing_Start; | |||
/// <summary> | |||
/// 配料开始确认 | |||
/// </summary> | |||
public bool Dosing_Confirm; | |||
/// <summary> | |||
/// 托盘占位情况 | |||
/// </summary> | |||
public bool[] Pallet_Position_Occ = new bool[16]; | |||
/// <summary> | |||
/// 工位允许放货架 | |||
/// </summary> | |||
public bool[] Allow_AGV_Put = new bool[16]; | |||
/// <summary> | |||
/// 工位允许取货架 | |||
/// </summary> | |||
public bool[] Allow_AGV_Get = new bool[16]; | |||
/// <summary> | |||
/// AGV请求放货架 | |||
/// </summary> | |||
public bool[] AGV_Request_Put = new bool[16]; | |||
/// <summary> | |||
/// AGV请求取货架 | |||
/// </summary> | |||
public bool[] AGV_Request_Get = new bool[16]; | |||
/// <summary> | |||
/// AGV放托盘完成 | |||
/// </summary> | |||
public bool[] AGV_Put_Done = new bool[16]; | |||
/// <summary> | |||
/// 托盘号 | |||
/// </summary> | |||
public short[] Pan_No = new short[16]; | |||
/// <summary> | |||
/// 配料时间 | |||
/// </summary> | |||
public int DosingTime; | |||
/// <summary> | |||
/// 备用 | |||
/// </summary> | |||
public byte Reserve; | |||
} | |||
} |
@@ -18,8 +18,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
/// <summary> | |||
/// 配方ID | |||
/// </summary> | |||
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } | |||
private long _mRecipeCode; | |||
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } | |||
private string _mRecipeCode; | |||
/// <summary> | |||
/// 托盘编号 | |||
@@ -11,6 +11,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
private int _mIp; | |||
public int DeviceIp { get { return _mIp; } set { _mIp = value; }} | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } | |||
private string _mRawMaterialName; | |||
/// <summary> | |||
/// 原料对应的桶号 | |||
/// </summary> | |||
@@ -23,6 +29,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } } | |||
private double _mRawMaterialWeight; | |||
/// <summary> | |||
/// 实际的下料中重量 | |||
/// </summary> | |||
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } | |||
private float _mLaying_Off_Weight; | |||
/// <summary> | |||
/// 原料对应料仓的位置 | |||
/// </summary> | |||
@@ -6,6 +6,7 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.S7Net; | |||
using System.Threading; | |||
namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||
{ | |||
@@ -14,51 +15,68 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); | |||
public bool IsConnected => Siemens_PLC_S7.IsConnected; | |||
/// <summary> | |||
/// 配方接收信号复位 | |||
/// </summary> | |||
public void RecipeSignReset() | |||
{ | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0); | |||
} | |||
/// <summary> | |||
/// AGV到位信号复位 | |||
/// </summary> | |||
public void AgvSignReset() | |||
{ | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0); | |||
} | |||
public void Init() | |||
{ | |||
if (IsConnected) | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
var res = this.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.RecipeState); | |||
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig)) | |||
var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(1); | |||
var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2); | |||
var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(3); | |||
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit)) | |||
{ | |||
ActionManage.GetInstance.Send("西门子下发配方", res); | |||
res.Ask_For_Send_Bit = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Start_DB>(res, 1); | |||
} | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0])) | |||
{ | |||
ActionManage.GetInstance.Send("AGV到工位1信号", res1); | |||
res1.Allow_AGV_Put[0] = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2); | |||
} | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1])) | |||
{ | |||
ActionManage.GetInstance.Send("AGV到工位2信号", res1); | |||
res1.Allow_AGV_Put[1] = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2); | |||
} | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[2]").Start(res1.Allow_AGV_Put[2])) | |||
{ | |||
ActionManage.GetInstance.Send("AGV到工位3信号", res1); | |||
res1.Allow_AGV_Put[2] = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2); | |||
} | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[3]").Start(res1.Allow_AGV_Put[3])) | |||
{ | |||
ActionManage.GetInstance.Send("AGV到工位4信号", res1); | |||
res1.Allow_AGV_Put[3] = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2); | |||
} | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[4]").Start(res1.Allow_AGV_Put[4])) | |||
{ | |||
ActionManage.GetInstance.Send("西门子下发配方"); | |||
RecipeSignReset(); | |||
ActionManage.GetInstance.Send("AGV到工位5信号", res1); | |||
res1.Allow_AGV_Put[4] = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2); | |||
} | |||
var AgvState = this.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.StateSign); | |||
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig)) | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[5]").Start(res1.Allow_AGV_Put[5])) | |||
{ | |||
ActionManage.GetInstance.Send("AGV到位信号"); | |||
AgvSignReset(); | |||
ActionManage.GetInstance.Send("AGV到工位6信号", res1); | |||
res1.Allow_AGV_Put[5] = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2); | |||
} | |||
if (res2 != null && res2.Ask_For_Finish_PLC) | |||
{ | |||
ActionManage.GetInstance.Send("配料完成信号确认完成"); | |||
res2.Ask_For_Finish_PLC = false; | |||
this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(res2, 3); | |||
} | |||
Thread.Sleep(10); | |||
}), "监听服务数据"); | |||
} | |||
} | |||
/// <summary> | |||
/// 配方配料完成信号 | |||
/// </summary> | |||
/// <param name="TrayLocation"></param> | |||
/// <param name="recipeID"></param> | |||
private void DosingFinsih(int TrayLocation, int recipeID) | |||
{ | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation); | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1); | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID); | |||
} | |||
} | |||
} |
@@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
public TestData() | |||
{ | |||
string recipeName = "配方1"; | |||
long recipeCode = 10001; | |||
string recipeCode = "10001"; | |||
int Traycode = 1; | |||
double RawmaterialWeight = 10; | |||
int RawMaterialbarrelNum = 1; | |||
short RawMaterialbarrelNum = 1; | |||
int RawMaterialLocation = 5; | |||
double RawmaterialWeight1 = 20; | |||
int RawMaterialbarrelNum1 = 2; | |||
short RawMaterialbarrelNum1 = 2; | |||
int RawMaterialLocation1 = 7; | |||
double RawmaterialWeight2 = 30; | |||
int RawMaterialbarrelNum2 = 3; | |||
short RawMaterialbarrelNum2 = 3; | |||
int RawMaterialLocation2 = 9; | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
@@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
RawMaterials.Clear(); | |||
string recipeName_2 = "配方2"; | |||
long recipeCode_2 = 20001; | |||
string recipeCode_2 = "20001"; | |||
int Traycode_2 = 3; | |||
double RawmaterialWeight_2 = 10; | |||
int RawMaterialbarrelNum_2 = 1; | |||
short RawMaterialbarrelNum_2 = 1; | |||
int RawMaterialLocation_2 = 5; | |||
double RawmaterialWeight1_2 = 20; | |||
int RawMaterialbarrelNum1_2 = 2; | |||
short RawMaterialbarrelNum1_2 = 2; | |||
int RawMaterialLocation1_2 = 7; | |||
double RawmaterialWeight2_2 = 30; | |||
int RawMaterialbarrelNum2_2 = 3; | |||
short RawMaterialbarrelNum2_2 = 3; | |||
int RawMaterialLocation2_2 = 9; | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
@@ -17,15 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
{ | |||
public HardwareStatusViewModel() | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() | |||
{ | |||
DeviceName = i.ToString(), | |||
RunStatus = false, | |||
Weight = new Random().Next(0, 100) | |||
}); | |||
} | |||
} | |||
public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>(); | |||
@@ -42,8 +42,8 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } | |||
private long _mRecipeCode; | |||
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } | |||
private string _mRecipeCode; | |||
public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } | |||
private int _mTrayCode; | |||
@@ -27,32 +27,35 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
public RecipeReceiveViewModel() | |||
{ | |||
//Json<LocaPar>.Read(); | |||
Recipes = Json<RemoteRecipeDataColl>.Data.Recipes; | |||
Recipes = Json<LocalRecipeDataColl>.Data.Recipes; | |||
DetailsCommand = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is long num) | |||
if (o != null && o is string num) | |||
{ | |||
ActionManage.GetInstance.CancelRegister("RecipeInfo"); | |||
RecipeInfosView nrv = new RecipeInfosView(); | |||
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num); | |||
ActionManage.GetInstance.Send("RecipeInfo", res); | |||
nrv.Show(); | |||
MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}"); | |||
if (res != null) | |||
{ | |||
ActionManage.GetInstance.Send("RecipeInfo", res); | |||
nrv.Show(); | |||
MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}"); | |||
} | |||
} | |||
}); | |||
NewSimulateRecipe = new RelayCommand(() => | |||
{ | |||
RawMaterials.Clear(); | |||
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + ""; | |||
string recipeName = "配方" + (Json<LocalRecipeDataColl>.Data.Recipes.Count + 1) + ""; | |||
go: | |||
long recipeCode = new Random().Next(10000, 99999); | |||
string recipeCode = new Random().Next(10000, 99999).ToString(); | |||
foreach (var item in Recipes) | |||
{ | |||
if (item.RecipeCode == recipeCode) | |||
{ | |||
goto go; | |||
} | |||
} | |||
} | |||
int trayCode = new Random().Next(1,6); | |||
for (int i = 1; i < 13; i++) | |||
{ | |||
@@ -68,26 +71,23 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel | |||
RawMaterialLocation = i, | |||
}); | |||
} | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||
Json<LocalRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||
{ | |||
RecipeName = recipeName, | |||
RecipeCode = recipeCode, | |||
TrayCode = trayCode, | |||
RawMaterial = RawMaterials, | |||
RecipeName = recipeName, | |||
RecipeCode = recipeCode, | |||
TrayCode = trayCode, | |||
RawMaterial = RawMaterials, | |||
}); | |||
}); | |||
ClearAllRecipe = new RelayCommand(() => | |||
{ | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Clear(); | |||
Json<LocalRecipeDataColl>.Data.Recipes.Clear(); | |||
}); | |||
} | |||
public RelayCommand<object> DetailsCommand { get; set; } | |||
public RelayCommand NewSimulateRecipe { get; set; } | |||
public RelayCommand ClearAllRecipe { get; set; } | |||
public ObservableCollection<RemoteRecipeData> Recipes { get; set; } | |||
} | |||
} |
@@ -18,13 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
public bool IssueRecipeFinishStation1 { get; set; } = false; | |||
/// <summary> | |||
/// 托盘1配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 | |||
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 | |||
/// </summary> | |||
public int RecipeStatusIDTray1 { get; set; } = 0; | |||
/// <summary> | |||
/// 托盘2配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 | |||
/// </summary> | |||
public int RecipeStatusIDTray2 { get; set; } = 0; | |||
public int RecipeStatusID { get; set; } = 0; | |||
/// <summary> | |||
/// 往输送带下发配方完成 | |||
/// </summary> | |||
@@ -65,8 +65,53 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
{ | |||
if (IsConnected) | |||
{ | |||
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, BarrelNum); | |||
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation); | |||
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15) | |||
{ | |||
if (BarrelNum == 1) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX10." + (StockBinLocation - 1), true); | |||
} | |||
else if (StockBinLocation >= 9 && StockBinLocation <= 15) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX11." + (StockBinLocation - 9), true); | |||
} | |||
} | |||
else if (BarrelNum == 2) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX12." + (StockBinLocation - 1), true); | |||
} | |||
else if (StockBinLocation >= 9 && StockBinLocation <= 15) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX13." + (StockBinLocation - 9), true); | |||
} | |||
} | |||
else if (BarrelNum == 3) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX14." + (StockBinLocation - 1), true); | |||
} | |||
else if (StockBinLocation >= 9 && StockBinLocation <= 15) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX15." + (StockBinLocation - 9), true); | |||
} | |||
} | |||
else if (BarrelNum == 4) | |||
{ | |||
if (StockBinLocation >= 1 && StockBinLocation <= 8) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX16." + (StockBinLocation - 1), true); | |||
} | |||
else if (StockBinLocation >= 9 && StockBinLocation <= 15) | |||
{ | |||
HK_PLC_S7.Write<bool>("DB4.DBX17." + (StockBinLocation - 9), true); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
@@ -27,70 +27,71 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
/// </summary> | |||
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>(); | |||
/// <summary> | |||
/// 托盘1 配方队列 | |||
/// 原料的名称和料仓的位置对应 | |||
/// </summary> | |||
public ConcurrentQueue<long> RecipeTray1Queue = new ConcurrentQueue<long>(); | |||
public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>(); | |||
/// <summary> | |||
/// 托盘2 配方队列 | |||
/// 配方队列 | |||
/// </summary> | |||
public ConcurrentQueue<long> RecipeTray2Queue = new ConcurrentQueue<long>(); | |||
public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>(); | |||
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); | |||
public HKDeviceStatus HKDevice = new HKDeviceStatus(); | |||
GVL_SmallStation SmallStation = new GVL_SmallStation(); | |||
XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB(); | |||
/// <summary> | |||
/// 接收原料数据 | |||
/// </summary> | |||
public RecipeRawMaterial RawMaterial; | |||
public void Init() | |||
{ | |||
ActionManage.GetInstance.Register(new Action(() => | |||
for (int i = 0; i < 16; i++) | |||
{ | |||
if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) | |||
{ | |||
if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName)) | |||
{ | |||
RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum); | |||
} | |||
} | |||
} | |||
ActionManage.GetInstance.Register(new Action<XL_Start_DB>((res) => | |||
{ | |||
if (SiemensDevice.IsConnected) | |||
{ | |||
var res = SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.RecipeName); | |||
var res1 = SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.RecipeID); | |||
//int res2 = SiemensDevice.Siemens_PLC_S7.ReadClass<object>(RawMaterial, 0, 0 | |||
int res2 = 0; | |||
if ((res != null && res is string recipeName) && | |||
(res1 != null && res1 is uint recipeID) && | |||
(res2 > 0)) | |||
if (res != null) | |||
{ | |||
RawMaterials.Clear(); | |||
for (int i = 0; i < 15; i++) | |||
{ | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name)) | |||
{ | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
RawMaterialName = res.Material[i].Material_Name, | |||
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum, | |||
RawMaterialWeight = res.Material[i].Material_Weight, | |||
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name] | |||
}); | |||
} | |||
else | |||
{ | |||
RawMaterialBarrelNum = RawMaterial.RawMaterialBarrelNum[i], | |||
RawMaterialLocation = RawMaterial.RawMaterialLocation[i], | |||
RawMaterialWeight = RawMaterial.RawMaterialWeight[i] | |||
}); | |||
//报警,配方的原料名称下发和设备不一致 | |||
} | |||
} | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||
{ | |||
RecipeName = recipeName, | |||
RecipeCode = recipeID, | |||
RawMaterial = RawMaterials | |||
RecipeName = res.RecipeName, | |||
RecipeCode = res.RecipeCode, | |||
RawMaterial = RawMaterials, | |||
TrayCode = res.TrayCode | |||
}); | |||
} | |||
} | |||
}), "西门子下发配方", true); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
if (SiemensDevice.IsConnected) | |||
{ | |||
var res = SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.TrayLocationNum); | |||
var res1 = SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.RecipeID); | |||
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId) | |||
{ | |||
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeId); | |||
if (index >= 0 && index < Json<RemoteRecipeDataColl>.Data.Recipes.Count) | |||
{ | |||
Json<RemoteRecipeDataColl>.Data.Recipes.ElementAt(index).TrayCode = TrayLocation; | |||
} | |||
} | |||
} | |||
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 | |||
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; | |||
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; | |||
try | |||
@@ -110,7 +111,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
} | |||
RecipeTray1Queue.Clear(); | |||
RecipeQueue.Clear(); | |||
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
@@ -424,7 +425,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
break; | |||
case 1: | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApply) is bool)) | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApply))) | |||
{ | |||
SmallStation.AgvDeliveryPosition = 2; | |||
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true); | |||
@@ -438,7 +439,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
break; | |||
case 3: | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool)) | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApplyJack))) | |||
{ | |||
SmallStation.AgvDeliveryPosition = 4; | |||
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true); | |||
@@ -452,7 +453,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
break; | |||
case 5: | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationHaveCargo) is bool)) | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationHaveCargo))) | |||
{ | |||
SmallStation.AgvDeliveryPosition = 0; | |||
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true); | |||
@@ -473,14 +474,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
switch (SmallStation.AgvPickUpPosition) | |||
{ | |||
case 0: | |||
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.PickAGVApply) is bool)) | |||
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickAGVApply))) | |||
{ | |||
SmallStation.AgvPickUpPosition = 1; | |||
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true); | |||
} | |||
break; | |||
case 1: | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVIsApply) is bool)) | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVIsApply))) | |||
{ | |||
SmallStation.AgvPickUpPosition = 2; | |||
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true); | |||
@@ -494,7 +495,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
break; | |||
case 3: | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVFinish) is bool)) | |||
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVFinish))) | |||
{ | |||
SmallStation.AgvPickUpPosition = 0; | |||
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true); | |||
@@ -504,6 +505,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
break; | |||
} | |||
} | |||
/// <summary> | |||
/// 将配方添加到配方队列中 | |||
/// </summary> | |||
private void ReceviceData() | |||
{ | |||
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes; | |||
@@ -511,31 +515,26 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
foreach (var data in RemoteRecipes) | |||
{ | |||
if (data.TrayCode == 1) | |||
{ | |||
if (!(RecipeTray1Queue.Contains(data.RecipeCode))) | |||
RecipeTray1Queue.Enqueue(data.RecipeCode); | |||
} | |||
else if (data.TrayCode == 2) | |||
{ | |||
if (!(RecipeTray2Queue.Contains(data.RecipeCode))) | |||
RecipeTray2Queue.Enqueue(data.RecipeCode); | |||
} | |||
if (!(RecipeQueue.Contains(data.RecipeCode))) | |||
RecipeQueue.Enqueue(data.RecipeCode); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 执行配方队列中的第一个配方 | |||
/// </summary> | |||
private void RecipeInfoToHKPLC() | |||
{ | |||
if (RecipeTray1Queue.Count > 0) | |||
if (RecipeQueue.Count > 0) | |||
{ | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray1Queue.ElementAt(0)); | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0)); | |||
if (index >= 0 && index < RemoteRecipes.Count) | |||
{ | |||
long code = RemoteRecipes.ElementAt(index).RecipeCode; | |||
string code = RemoteRecipes.ElementAt(index).RecipeCode; | |||
int trayCode = RemoteRecipes.ElementAt(index).TrayCode; | |||
if (trayCode == 1 && SmallStation.RecipeStatusIDTray1 == 0) | |||
if (trayCode == 1 && SmallStation.RecipeStatusID == 0) | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") is bool && SmallStation.RecipeStatusIDTray1 == 0) | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") && SmallStation.RecipeStatusID == 0) | |||
{ | |||
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) | |||
{ | |||
@@ -543,16 +542,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false); | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); | |||
SmallStation.RecipeStatusIDTray1 = 1; | |||
SmallStation.RecipeStatusID = 1; | |||
} | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") is bool && SmallStation.RecipeStatusIDTray1 == 1) | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && SmallStation.RecipeStatusID == 1) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false); | |||
SmallStation.RecipeStatusIDTray1 = 2; | |||
SmallStation.RecipeStatusID = 2; | |||
} | |||
if (SmallStation.RecipeStatusIDTray1 == 2) | |||
if (SmallStation.RecipeStatusID == 2) | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0") is bool) | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10"); | |||
if (res != null && res is float loc) | |||
@@ -567,7 +566,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
} | |||
} | |||
else if(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1") is bool) | |||
else if(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14"); | |||
if (res != null && res is float loc) | |||
@@ -582,7 +581,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2") is bool) | |||
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18"); | |||
if (res != null && res is float loc) | |||
@@ -597,7 +596,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3") is bool) | |||
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22"); | |||
if (res != null && res is float loc) | |||
@@ -616,10 +615,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) | |||
{ | |||
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); | |||
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback; | |||
DeviceInquire.GetInstance.GetDevice(i).StatusReset(); | |||
if (i >= 1 && i <= 8) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX30."+ (i-1), true); | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true); | |||
} | |||
else if (i >= 9 && i <= 15) | |||
{ | |||
@@ -627,131 +628,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
} | |||
} | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1") is bool) | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")) | |||
{ | |||
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); | |||
MessageLog.GetInstance.ShowRunLog($"托盘1 配方{res.RecipeName}配料完成"); | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res); | |||
RecipeTray1Queue.TryDequeue(out code); | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); | |||
SmallStation.RecipeStatusIDTray1 = 0; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
if (RecipeTray2Queue.Count > 0) | |||
{ | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray2Queue.ElementAt(0)); | |||
if (index >= 0 && index < RemoteRecipes.Count) | |||
{ | |||
long code = RemoteRecipes.ElementAt(index).RecipeCode; | |||
int trayCode = RemoteRecipes.ElementAt(index).TrayCode; | |||
if (trayCode == 2 && SmallStation.RecipeStatusIDTray2 == 0) | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.6") is bool && SmallStation.RecipeStatusIDTray2 == 0) | |||
{ | |||
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) | |||
{ | |||
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); | |||
} | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.6", false); | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true); | |||
SmallStation.RecipeStatusIDTray2 = 1; | |||
} | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.4") is bool && SmallStation.RecipeStatusIDTray2 == 1) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false); | |||
SmallStation.RecipeStatusIDTray2 = 2; | |||
} | |||
if (SmallStation.RecipeStatusIDTray2 == 2) | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.4") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD26"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.4", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.5") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD30"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.6") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD34"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.7") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD38"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false); | |||
} | |||
} | |||
} | |||
for (int i = 1; i < 16; i++) | |||
{ | |||
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) | |||
MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成"); | |||
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; | |||
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; | |||
for (int i = 0; i < 16; i++) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(i).StatusReset(); | |||
if (i >= 1 && i <= 8) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true); | |||
} | |||
else if (i >= 9 && i <= 15) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true); | |||
} | |||
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; | |||
} | |||
} | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.2") is bool) | |||
{ | |||
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); | |||
MessageLog.GetInstance.ShowRunLog($"托盘2 配方{res.RecipeName}配料完成"); | |||
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3); | |||
RecipeFinishInfo.Ask_For_Finish = true; | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res); | |||
RecipeTray1Queue.TryDequeue(out code); | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false); | |||
SmallStation.RecipeStatusIDTray2 = 0; | |||
RecipeQueue.TryDequeue(out code); | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); | |||
SmallStation.RecipeStatusID = 0; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
@@ -60,9 +60,43 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
Thread.Sleep(200); | |||
}), "设备状态监听"); | |||
} | |||
private void TestData() | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
DeviceNum = i + 1, | |||
Weight = new Random().Next(100, 10000) / 100.0 | |||
}); | |||
devices.Add(new Devices() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
IpAddress = $"192.168.1.{i + 1}", | |||
}); | |||
} | |||
for (int i = 8; i < 16; i++) | |||
{ | |||
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
DeviceNum = i + 1, | |||
Weight = new Random().Next(100, 10000) / 100.0 | |||
}); | |||
devices.Add(new Devices() | |||
{ | |||
DeviceName = $"测试设备{i + 1}", | |||
IpAddress = $"192.168.1.{i + 1}", | |||
}); | |||
} | |||
} | |||
public void Init() | |||
{ | |||
TestData(); | |||
IpAddressLines(); | |||
DeviceDataInit(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
@@ -266,11 +300,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
//{ | |||
// if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; | |||
//} | |||
this.DeviceName = modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", ""); | |||
deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态 | |||
deviceStatus.WeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量 | |||
deviceStatus.NowWeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);//获取下料重量 | |||
deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号 | |||
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码 | |||
@@ -12,7 +12,5 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
public class LocaPar | |||
{ | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>(); | |||
} | |||
} |
@@ -22,6 +22,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
/// </summary> | |||
public float WeightFeedback { get; set; } | |||
/// <summary> | |||
/// 当前出料重量反馈 | |||
/// </summary> | |||
public float NowWeightFeedback { get; set; } | |||
/// <summary> | |||
/// 上限反馈 | |||
/// </summary> | |||
@@ -18,8 +18,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
/// <summary> | |||
/// 配方ID | |||
/// </summary> | |||
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } | |||
private long _mRecipeCode; | |||
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } | |||
private string _mRecipeCode; | |||
/// <summary> | |||
/// 托盘编号 | |||
@@ -11,13 +11,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
public int DeviceIp { get { return _mIp; } set { _mIp = value; }} | |||
private int _mIp; | |||
public int RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } | |||
private int _mRawMaterialName; | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } | |||
private string _mRawMaterialName; | |||
/// <summary> | |||
/// 原料对应的桶号 | |||
/// </summary> | |||
public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } } | |||
private int _mRawMaterialBarrelNum; | |||
public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } } | |||
private short _mRawMaterialBarrelNum; | |||
/// <summary> | |||
/// 需要原料重量 | |||
@@ -25,6 +25,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } } | |||
private double _mRawMaterialWeight; | |||
/// <summary> | |||
/// 实际的下料中重量 | |||
/// </summary> | |||
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } | |||
private float _mLaying_Off_Weight; | |||
/// <summary> | |||
/// 原料对应料仓的位置 | |||
/// </summary> | |||
@@ -6,6 +6,7 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.S7Net; | |||
using System.Threading; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
{ | |||
@@ -14,51 +15,44 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); | |||
public bool IsConnected => Siemens_PLC_S7.IsConnected; | |||
/// <summary> | |||
/// 配方接收信号复位 | |||
/// </summary> | |||
public void RecipeSignReset() | |||
{ | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0); | |||
} | |||
/// <summary> | |||
/// AGV到位信号复位 | |||
/// </summary> | |||
public void AgvSignReset() | |||
{ | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0); | |||
} | |||
public void Init() | |||
{ | |||
if (IsConnected) | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
var res = this.Siemens_PLC_S7.Read<object>(SiemensCommAddress.RecipeState); | |||
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig)) | |||
var res = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(1); | |||
var res1 = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2); | |||
var res2 = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(3); | |||
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit)) | |||
{ | |||
ActionManage.GetInstance.Send("西门子下发配方",res); | |||
res.Ask_For_Send_Bit = false; | |||
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(res, 1); | |||
} | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0])) | |||
{ | |||
ActionManage.GetInstance.Send("西门子下发配方"); | |||
RecipeSignReset(); | |||
ActionManage.GetInstance.Send("AGV到工位1信号",res1); | |||
res1.Allow_AGV_Put[0] = false; | |||
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2); | |||
} | |||
var AgvState = this.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.StateSign); | |||
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig)) | |||
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1])) | |||
{ | |||
ActionManage.GetInstance.Send("AGV到位信号"); | |||
AgvSignReset(); | |||
ActionManage.GetInstance.Send("AGV到工位2信号",res1); | |||
res1.Allow_AGV_Put[1] = false; | |||
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2); | |||
} | |||
if (res2 != null && res2.Ask_For_Finish_PLC) | |||
{ | |||
ActionManage.GetInstance.Send("配料完成信号确认完成"); | |||
res2.Ask_For_Finish_PLC = false; | |||
this.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(res2, 3); | |||
} | |||
Thread.Sleep(10); | |||
}),"监听服务数据"); | |||
} | |||
} | |||
/// <summary> | |||
/// 配方配料完成信号 | |||
/// </summary> | |||
/// <param name="TrayLocation"></param> | |||
/// <param name="recipeID"></param> | |||
private void DosingFinsih(int TrayLocation,int recipeID) | |||
{ | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation); | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1); | |||
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID); | |||
} | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
{ | |||
internal class XL_Finish_DB | |||
{ | |||
/// <summary> | |||
/// 生产工单编码 | |||
/// </summary> | |||
public string Order_No; | |||
/// <summary> | |||
/// 产品名称 | |||
/// </summary> | |||
public string Product_Code; | |||
/// <summary> | |||
/// 原料信息 | |||
/// </summary> | |||
public UDT1[] Material = new UDT1[20]; | |||
/// <summary> | |||
/// 配料完成信号 | |||
/// </summary> | |||
public bool Ask_For_Finish; | |||
/// <summary> | |||
/// 配料完成信号确认 | |||
/// </summary> | |||
public bool Ask_For_Finish_PLC; | |||
} | |||
public class UDT1 | |||
{ | |||
public string Material_Name; | |||
public float Material_Laying_Off_Weight; | |||
public short Material_BarrelNum; | |||
} | |||
} |
@@ -0,0 +1,52 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
{ | |||
internal class XL_Start_DB | |||
{ | |||
/// <summary> | |||
/// 配方编码 | |||
/// </summary> | |||
public string RecipeCode; | |||
/// <summary> | |||
/// 配发名称 | |||
/// </summary> | |||
public string RecipeName; | |||
/// <summary> | |||
/// 物料信息 | |||
/// </summary> | |||
public UDT[] Material = new UDT[20]; | |||
/// <summary> | |||
/// 托盘编号 | |||
/// </summary> | |||
public int TrayCode; | |||
/// <summary> | |||
/// 配方发送请求 | |||
/// </summary> | |||
public bool Ask_For_Send_Bit; | |||
/// <summary> | |||
/// 上位机确认配方接收完成 | |||
/// </summary> | |||
public bool Ack_Ask_For_Send_Bit; | |||
} | |||
public class UDT | |||
{ | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string Material_Name; | |||
/// <summary> | |||
/// 原料重量 | |||
/// </summary> | |||
public float Material_Weight; | |||
/// <summary> | |||
/// 原料桶号 | |||
/// </summary> | |||
public short Material_BarrelNum; | |||
} | |||
} |
@@ -0,0 +1,60 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||
{ | |||
internal class XL_Status_DB | |||
{ | |||
/// <summary> | |||
/// 生产工单 | |||
/// </summary> | |||
public string Order_No; | |||
/// <summary> | |||
/// 配料开始 | |||
/// </summary> | |||
public bool Dosing_Start; | |||
/// <summary> | |||
/// 配料开始确认 | |||
/// </summary> | |||
public bool Dosing_Confirm; | |||
/// <summary> | |||
/// 托盘占位情况 | |||
/// </summary> | |||
public bool[] Pallet_Position_Occ = new bool[16]; | |||
/// <summary> | |||
/// 工位允许放货架 | |||
/// </summary> | |||
public bool[] Allow_AGV_Put = new bool[16]; | |||
/// <summary> | |||
/// 工位允许取货架 | |||
/// </summary> | |||
public bool[] Allow_AGV_Get = new bool[16]; | |||
/// <summary> | |||
/// AGV请求放货架 | |||
/// </summary> | |||
public bool[] AGV_Request_Put = new bool[16]; | |||
/// <summary> | |||
/// AGV请求取货架 | |||
/// </summary> | |||
public bool[] AGV_Request_Get = new bool[16]; | |||
/// <summary> | |||
/// AGV放托盘完成 | |||
/// </summary> | |||
public bool[] AGV_Put_Done = new bool[16]; | |||
/// <summary> | |||
/// 托盘号 | |||
/// </summary> | |||
public short[] Pan_No = new short[16]; | |||
/// <summary> | |||
/// 配料时间 | |||
/// </summary> | |||
public int DosingTime; | |||
/// <summary> | |||
/// 备用 | |||
/// </summary> | |||
public byte Reserve; | |||
} | |||
} |
@@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
public TestData() | |||
{ | |||
string recipeName = "配方1"; | |||
long recipeCode = 10001; | |||
string recipeCode = "10001"; | |||
int Traycode = 1; | |||
double RawmaterialWeight = 10; | |||
int RawMaterialbarrelNum = 1; | |||
short RawMaterialbarrelNum = 1; | |||
int RawMaterialLocation = 5; | |||
double RawmaterialWeight1 = 20; | |||
int RawMaterialbarrelNum1 = 2; | |||
short RawMaterialbarrelNum1 = 2; | |||
int RawMaterialLocation1 = 7; | |||
double RawmaterialWeight2 = 30; | |||
int RawMaterialbarrelNum2 = 3; | |||
short RawMaterialbarrelNum2 = 3; | |||
int RawMaterialLocation2 = 9; | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
@@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
RawMaterials.Clear(); | |||
string recipeName_2 = "配方2"; | |||
long recipeCode_2 = 20001; | |||
string recipeCode_2 = "20001"; | |||
int Traycode_2 = 3; | |||
double RawmaterialWeight_2 = 10; | |||
int RawMaterialbarrelNum_2 = 1; | |||
short RawMaterialbarrelNum_2 = 1; | |||
int RawMaterialLocation_2 = 5; | |||
double RawmaterialWeight1_2 = 20; | |||
int RawMaterialbarrelNum1_2 = 2; | |||
short RawMaterialbarrelNum1_2 = 2; | |||
int RawMaterialLocation1_2 = 7; | |||
double RawmaterialWeight2_2 = 30; | |||
int RawMaterialbarrelNum2_2 = 3; | |||
short RawMaterialbarrelNum2_2 = 3; | |||
int RawMaterialLocation2_2 = 9; | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
@@ -42,8 +42,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } | |||
private long _mRecipeCode; | |||
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } | |||
private string _mRecipeCode; | |||
public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } | |||
private int _mTrayCode; | |||
@@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
Recipes = Json<RemoteRecipeDataColl>.Data.Recipes; | |||
DetailsCommand = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is long num) | |||
if (o != null && o is string num) | |||
{ | |||
ActionManage.GetInstance.CancelRegister("RecipeInfo"); | |||
RecipeInfosView nrv = new RecipeInfosView(); | |||
@@ -45,7 +45,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
RawMaterials.Clear(); | |||
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + ""; | |||
go: | |||
long recipeCode = new Random().Next(1000, 9999); | |||
string recipeCode = new Random().Next(1000, 9999).ToString(); | |||
foreach (var item in Recipes) | |||
{ | |||
if (item.RecipeCode == recipeCode) | |||
@@ -59,7 +59,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||
{ | |||
RawMaterialWeight = new Random().Next(10, 1000), | |||
RawMaterialBarrelNum = new Random().Next(1, 3), | |||
RawMaterialBarrelNum = (short)new Random().Next(1, 3), | |||
RawMaterialLocation = i, | |||
}); | |||
} | |||