diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs
index 07f5fe58..35938e45 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs
@@ -95,7 +95,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
///
/// 工位上是否有小车
///
- public static string StationIsExistCar { get; set; } = "M4007";
+ public static string StationIsExistTray { get; set; } = "M4007";
#endregion
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
index 7788c885..c45af3fe 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
@@ -106,7 +106,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
{
- //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S7200Smart, HK_PLC_IP);
+ //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (HKDevice.IsConnected)
{
@@ -190,28 +190,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model
///
private void AGV_Pick(int bitNum)
{
- if (ReadSiemens("M4003"+ bitNum) is bool && BigStation.AgvPickUpPosition == 0)
+ if (ReadSiemens("M4003."+ bitNum) is bool && BigStation.AgvPickUpPosition == 0)
{
BigStation.AgvPickUpPosition = 1;
- WriteHKPLC("M4003" + bitNum, true);
- WriteSiemens("M4003" + bitNum, false);
+ WriteHKPLC("M4003." + bitNum, true);
+ WriteSiemens("M4003." + bitNum, false);
}
- if (ReadHK("M5003" + bitNum) is bool && BigStation.AgvPickUpPosition == 1)
+ if (ReadHK("M5003." + bitNum) is bool && BigStation.AgvPickUpPosition == 1)
{
BigStation.AgvPickUpPosition = 2;
- WriteSiemens("M5003" + bitNum, true);
- WriteHKPLC("M5003" + bitNum,false);
+ WriteSiemens("M5003." + bitNum, true);
+ WriteHKPLC("M5003." + bitNum,false);
}
- if (ReadSiemens("M4006" + bitNum) is bool && BigStation.AgvPickUpPosition == 2)
+ if (ReadSiemens("M4006." + bitNum) is bool && BigStation.AgvPickUpPosition == 2)
{
BigStation.AgvPickUpPosition = 3;
- WriteHKPLC("M4006" + bitNum, true);
- WriteSiemens("M4006" + bitNum, false);
+ WriteHKPLC("M4006." + bitNum, true);
+ WriteSiemens("M4006." + bitNum, false);
}
- if (ReadHK("M5006" + bitNum) is bool && BigStation.AgvPickUpPosition == 3)
+ if (ReadHK("M5006." + bitNum) is bool && BigStation.AgvPickUpPosition == 3)
{
- WriteSiemens("M5006" + bitNum, true);
- WriteHKPLC("M5006" + bitNum, false);
+ WriteSiemens("M5006." + bitNum, true);
+ WriteHKPLC("M5006." + bitNum, false);
}
}
///
@@ -221,26 +221,26 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
- HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar));
+ HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray));
//检测AGV到站信号
if (AGVToWorkStationQueue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0));
int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6
- int recipe = (int)RemoteRecipes.ElementAt(index).RecipeCode;
+ int RecipeCode = (int)RemoteRecipes.ElementAt(index).RecipeCode;
if (TrayLocation > 0 && TrayLocation < 7)
{
AGV_Delivery(TrayLocation - 1);
if (BigStation.AgvDeliveryPosition == 5)
{
BigStation.AgvDeliveryPosition = 0;
- AGVToWorkStationQueue.TryDequeue(out recipe);
+ //AGVToWorkStationQueue.TryDequeue(out RecipeCode);
}
AGV_Pick(TrayLocation - 1);
if (BigStation.AgvPickUpPosition == 3)
{
BigStation.AgvPickUpPosition = 0;
- AGVToWorkStationQueue.TryDequeue(out recipe);
+ AGVToWorkStationQueue.TryDequeue(out RecipeCode);
}
}
}
@@ -293,6 +293,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
public ConcurrentDictionary ReadHKPLCData = new ConcurrentDictionary();
public ConcurrentDictionary ReadSiemensData = new ConcurrentDictionary();
+
+
private void ReadSiemensCommData()
{
if (SiemensDevice.IsConnected)
@@ -310,7 +312,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
if (HKDevice.IsConnected)
{
+ GetSiemensStatus("", new Action
public int AgvPickUpPosition { get; set; } = 0;
+
+
+
+ #region AGV进出站 从HK PLC读取
+ public bool Agv { get; set; } = false;
+ #endregion
}
}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs
index 80a9398b..56bebdb7 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs
@@ -44,11 +44,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
public static string RecipeDosingFinish { get; set; } = "";
#endregion
- #region AGV进出站
+ #region AGV进出站1
///
/// Agv送货 进站申请
///
- public static string DeliveryAGVApply { get; set; } = "";
+ public static string DeliveryAGVApply { get; set; } = "DB3.DBX0.1";
///
/// Agv送货 进站申请
///
@@ -88,7 +88,53 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
///
/// 工位上是否有小车
///
- public static string StationIsExistCar { get; set; } = "";
+ public static string StationIsExistTray { get; set; } = "";
+ #endregion
+ #region AGV进出站2
+ ///
+ /// Agv送货 进站申请
+ ///
+ public static string DeliveryAGVApplyStation2 { get; set; } = "";
+ ///
+ /// Agv送货 进站申请
+ ///
+ public static string DeliveryAGVIsApplyStation2 { get; set; } = "";
+ ///
+ /// Agv送货 进站顶升申请
+ ///
+ public static string DeliveryAGVApplyJackStation2 { get; set; } = "";
+ ///
+ /// Agv送货 进站顶升申请
+ ///
+ public static string DeliveryAGVIsApplyJackStation2 { get; set; } = "";
+ ///
+ /// Agv送货 送货完成
+ ///
+ public static string DeliveryAGVFinsihStation2 { get; set; } = "";
+ ///
+ /// Agv送货 工位上有货架
+ ///
+ public static string StationHaveCargoStation2 { get; set; } = "";
+ ///
+ /// Agv送货 进站申请
+ ///
+ public static string PickAGVApplyStation2 { get; set; } = "";
+ ///
+ /// Agv送货 进站申请
+ ///
+ public static string PickAGVIsApplyStation2 { get; set; } = "";
+ ///
+ /// Agv送货 取货架完成
+ ///
+ public static string PickCargoAGVFinishStation2 { get; set; } = "";
+ ///
+ /// Agv送货 取料完成
+ ///
+ public static string PickAGVFinishStation2 { get; set; } = "";
+ ///
+ /// 工位上是否有货架
+ ///
+ public static string StationIsExistTrayStation2 { get; set; } = "";
#endregion
}
}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
index c27a8b9f..cc8e1b58 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
@@ -1,4 +1,5 @@
-using BPASmartClient.Helper;
+using BPASmartClient.CustomResource.Pages.Model;
+using BPASmartClient.Helper;
using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using BPASmartClient.Modbus;
@@ -21,6 +22,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private ProcessControl() { }
public ObservableCollection RawMaterials { get; set; } = new ObservableCollection();
+ ///
+ /// 配方数据
+ ///
+ public ObservableCollection RemoteRecipes = new ObservableCollection();
+ ///
+ /// 托盘1 配方队列
+ ///
+ public ConcurrentQueue RecipeTray1Queue = new ConcurrentQueue();
+ ///
+ /// 托盘2 配方队列
+ ///
+ public ConcurrentQueue RecipeTray2Queue = new ConcurrentQueue();
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
@@ -96,7 +109,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
}
- SmallStation.RecipeQueue.Clear();
+ RecipeTray1Queue.Clear();
//Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -113,6 +126,287 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
Thread.Sleep(10);
}), "AGV进站送取货", true);
+ ThreadManage.GetInstance().StartLong(new Action(() =>
+ {
+ if (HKDevice.IsConnected)
+ {
+ ManualOpen();
+ ManualClose();
+ }
+ Thread.Sleep(10);
+ }), "手动操作", true);
+ }
+ private void ManualOpen()
+ {
+ ActionManage.GetInstance.Register(new Action((o) =>
+ {
+ if (o != null)
+ {
+ if (o.ToString().Contains("升降气缸"))
+ {
+ int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
+ switch (index)
+ {
+ case 1:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 2:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 3:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 4:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 5:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 6:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 7:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 8:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 9:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 10:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 11:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 12:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 13:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 14:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 15:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ default:
+ break;
+
+ }
+ }
+ else if (o.ToString().Contains("阻挡气缸"))
+ {
+ int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
+ switch (index)
+ {
+ case 1:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 2:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 3:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 4:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 5:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 6:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 7:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 8:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 9:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 10:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 11:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 12:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 13:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 14:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 15:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ default:
+ break;
+
+ }
+ }
+ else if (o.ToString().Contains("托盘气缸"))
+ {
+ int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
+ switch (index)
+ {
+ case 1:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ case 2:
+ HKDevice.HK_PLC_S7.Write("", true);
+ break;
+ default:
+ break;
+
+ }
+ }
+
+ }
+ }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
+ }
+ private void ManualClose()
+ {
+ ActionManage.GetInstance.Register(new Action((o) =>
+ {
+ if (o != null)
+ {
+ if (o.ToString().Contains("升降气缸"))
+ {
+ int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
+ switch (index)
+ {
+ case 1:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 2:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 3:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 4:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 5:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 6:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 7:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 8:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 9:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 10:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 11:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 12:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 13:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 14:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 15:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ default:
+ break;
+
+ }
+ }
+ else if (o.ToString().Contains("阻挡气缸"))
+ {
+ int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
+ switch (index)
+ {
+ case 1:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 2:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 3:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 4:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 5:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 6:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 7:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 8:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 9:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 10:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 11:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 12:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 13:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 14:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 15:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ default:
+ break;
+
+ }
+ }
+ else if (o.ToString().Contains("托盘气缸"))
+ {
+ int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
+ switch (index)
+ {
+ case 1:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ case 2:
+ HKDevice.HK_PLC_S7.Write("", false);
+ break;
+ default:
+ break;
+
+ }
+ }
+
+ }
+ }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
}
///
/// AGV进站送货
@@ -168,7 +462,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
- HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar));
+ HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray));
}
///
/// AGV进站取货
@@ -211,59 +505,252 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
private void ReceviceData()
{
- SmallStation.RemoteRecipes = Json.Data.Recipes;
- if (Json.Data.Recipes.Count > 0)
+ RemoteRecipes = Json.Data.Recipes;
+ if (RemoteRecipes.Count > 0)
{
- foreach (var data in Json.Data.Recipes)
+ foreach (var data in RemoteRecipes)
{
- if(!(SmallStation.RecipeQueue.Contains(data.RecipeCode)))
- SmallStation.RecipeQueue.Enqueue(data.RecipeCode);
+ 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);
+ }
}
}
}
private void RecipeInfoToHKPLC()
{
- if (SmallStation.RecipeQueue.Count > 0)
+ if (RecipeTray1Queue.Count > 0)
{
- int index = Array.FindIndex(SmallStation.RemoteRecipes.ToArray(), p => p.RecipeCode == SmallStation.RecipeQueue.ElementAt(0));
- if (index >= 0 && index <= SmallStation.RemoteRecipes.Count)
+ int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray1Queue.ElementAt(0));
+ if (index >= 0 && index < RemoteRecipes.Count)
{
- long code = SmallStation.RemoteRecipes.ElementAt(index).RecipeCode;
- if (RTrig.GetInstance("IsAllowDosing").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.IsAllowDosing) is bool a))
+ long code = RemoteRecipes.ElementAt(index).RecipeCode;
+ int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
+ if (trayCode == 1 && SmallStation.RecipeStatusIDTray1 == 0)
{
- foreach (var item in SmallStation.RemoteRecipes.ElementAt(index).RawMaterial)
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") is bool && SmallStation.RecipeStatusIDTray1 == 0)
{
- HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
+ foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
+ {
+ HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
+ }
+ HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false);
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
+ SmallStation.RecipeStatusIDTray1 = 1;
}
- HKDevice.AllowDosingSignReset();
- SmallStation.IssueRecipeFinish = true;
- }
- if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StockState) is bool) && SmallStation.IssueRecipeFinish)
- {
- var res = HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StockBinLocation);
- if (res != null && res is int loc)
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") is bool && SmallStation.RecipeStatusIDTray1 == 1)
{
- int loc_index = Array.FindIndex(SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- double weight = SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
- if (loc_index >= 1 && loc_index <= 15)
+ HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
+ SmallStation.RecipeStatusIDTray1 = 2;
+ }
+ if (SmallStation.RecipeStatusIDTray1 == 2)
+ {
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10");
+ 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.0", false);
+ }
+ }
+ }
+ else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14");
+ 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.1", false);
+ }
+ }
+ }
+ else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18");
+ 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.2", false);
+ }
+ }
+ }
+ else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22");
+ 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.3", false);
+ }
+ }
+ }
+ for (int i = 1; i < 16; i++)
{
- //DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
- SmallStation.StockInIsWork = loc_index;
- HKDevice.StockStateSignReset();
+ if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
+ {
+ 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);
+ }
+ }
+ }
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1") is bool)
+ {
+ var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
+ MessageLog.GetInstance.ShowRunLog($"托盘1 配方{res.RecipeName}配料完成");
+ Json.Data.Recipes.Remove(res);
+ RecipeTray1Queue.TryDequeue(out code);
+ HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
+ SmallStation.RecipeStatusIDTray1 = 0;
}
}
- }
- /*if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool))
+ }
+ }
+ }
+ 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)
{
- HKDevice.SingleDosing((uint)SmallStation.StockInIsWork);
- DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).OutRawMaterialReset();
+ if (HKDevice.HK_PLC_S7.Read("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("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("DB3.DBX50.4") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("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("DB3.DBX50.5") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("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("DB3.DBX50.6") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("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("DB3.DBX50.7") is bool)
+ {
+ var res = HKDevice.HK_PLC_S7.Read("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)
+ {
+ 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);
+ }
+ }
+ }
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.2") is bool)
+ {
+ var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
+ MessageLog.GetInstance.ShowRunLog($"托盘2 配方{res.RecipeName}配料完成");
+ Json.Data.Recipes.Remove(res);
+ RecipeTray1Queue.TryDequeue(out code);
+ HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false);
+ SmallStation.RecipeStatusIDTray2 = 0;
+ }
+ }
}
- if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool))
- {
- HKDevice.RecipeDosingFinishReset();
- SmallStation.RecipeQueue.TryDequeue(out code);
- Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
- }*/
}
}
}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ActionMenu.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ActionMenu.cs
new file mode 100644
index 00000000..8b075561
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ActionMenu.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model
+{
+ public class ActionMenu : ObservableObject
+ {
+ public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } }
+ private string _mCommandParameter;
+
+ //public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } }
+ //private Permission[] _mpermission;
+
+ public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } }
+ private string _mMenuName;
+
+
+ //public string NameSpace { get { return _mNameSpace; } set { _mNameSpace = value; OnPropertyChanged(); } }
+ //private string _mNameSpace;
+
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ConveyorServer.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ConveyorServer.cs
new file mode 100644
index 00000000..f5afcca4
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/ConveyorServer.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model
+{
+ public class ConveyorServer
+ {
+ public ConveyorServer()
+ {
+
+ }
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/CylinderStatusModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/CylinderStatusModel.cs
new file mode 100644
index 00000000..dac384d5
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/CylinderStatusModel.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model
+{
+ public class CylinderStatusModel : ObservableObject
+ {
+ ///
+ /// 气缸原点信号
+ ///
+ public bool HomeStatus { get { return _mHomeStatus; } set { _mHomeStatus = value; OnPropertyChanged(); } }
+ private bool _mHomeStatus;
+
+ ///
+ /// 气缸到位信号
+ ///
+ public bool InPlace { get { return _mInPlace; } set { _mInPlace = value; OnPropertyChanged(); } }
+ private bool _mInPlace;
+
+
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs
index 85307518..80fbd5c2 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs
@@ -54,6 +54,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
///
public static string RunStatus { get; set; } = "LW60";
+ ///
+ /// 出料完成,置位该信号,plc复位运行状态
+ ///
+ public static string FinfishStatus { get; set; } = "LW40";
+
///
/// 慢加重量
///
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs
index b122df2b..0cfa5646 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-namespace BPASmartClient.JXJFoodSmallStation
+namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class DeviceCurrentStatus : ObservableObject
{
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
similarity index 94%
rename from BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs
rename to BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
index afff4ad6..9fa18cdf 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
@@ -1,19 +1,16 @@
-using BPASmartClient.Helper;
-using BPASmartClient.Modbus;
+using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.JXJFoodSmallStation.ViewModel;
+using BPASmartClient.Helper;
+using BPASmartClient.Modbus;
+using BPASmartClient.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Diagnostics;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Net.NetworkInformation;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using BPASmartClient.CustomResource.UserControls.MessageShow;
-using BPASmartClient.CustomResource.Pages.Model;
-using System.Collections.ObjectModel;
-using BPASmartClient.Model;
namespace BPASmartClient.JXJFoodSmallStation.Model
{
@@ -54,10 +51,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum;
}
- int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key);
+ int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key && p.DeviceName != DeviceLists.ElementAt(i).Value.DeviceName);
if (deviceIndex >= 0 && deviceIndex < devices.Count)
{
- devices.ElementAt(i).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName;
+ devices.ElementAt(deviceIndex).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName;
}
}
Thread.Sleep(200);
@@ -66,7 +63,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public void Init()
{
- devices.Add(new Devices() { DeviceName = "测试", IpAddress = "192.168.0.1" });
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -91,6 +87,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
return new DeviceStatus();
}
+ public DeviceStatus GetDevice(int location)
+ {
+ if (location > 0 && location < 16)
+ {
+ var res = DeviceLists.Values.FirstOrDefault(p => p.deviceStatus.DeviceNum == location);
+ if (res != null) return res;
+ }
+ return new DeviceStatus();
+ }
public List GetDevice()
{
@@ -150,7 +155,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip });
- if (TopDeviceCurrentStatuses.Count <= 8)
+ if (TopDeviceCurrentStatuses.Count <= 7)
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName });
else
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName });
@@ -170,7 +175,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null)
{
- Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 });
+ Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1});
}
}
else
@@ -235,7 +240,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
#region 对象属性声明
public string DeviceName = String.Empty;
public string IpAddress => modbusTcp.IPAdress;
-
///
/// 设备状态
///
@@ -276,6 +280,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
AlarmHelper.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7);
AlarmHelper.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8);
AlarmHelper.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9);
+ AlarmHelper.Alarm.EStop1 = true;
Thread.Sleep(100);
}), $"{DeviceName} 开始监听", true);
}
@@ -289,7 +294,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public void StatusReset()
{
- this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);
+ this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1);
+ //var res = modbusTcp.Read(DeviceAddress.RunStatus);
}
public void Dispose()
@@ -314,7 +320,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed);
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight);
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo);
- modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed);
+ modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100);
}
}
}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs
index f402a8b1..3b083760 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
-namespace BPASmartClient.JXJFoodSmallStation
+namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class DevicePar
{
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs
index d768b403..73131f06 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-namespace BPASmartClient.JXJFoodSmallStation
+namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class DeviceParModel : ObservableObject
{
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeProcess.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeProcess.cs
new file mode 100644
index 00000000..053cf5d2
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeProcess.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model
+{
+ public class RecipeProcess : ObservableObject
+ {
+ public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } }
+ private string _mRawMaterialName;
+
+
+ public int RawMaterialStatus { get { return _mRawMaterialStatus; } set { _mRawMaterialStatus = value; OnPropertyChanged(); } }
+ private int _mRawMaterialStatus;
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs
index b012fc71..2e0bbe27 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs
@@ -8,9 +8,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class RemoteRecipeRawMaterial
{
- private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}
+ private int _mIp;
+ public int RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
+ private int _mRawMaterialName;
///
/// 原料对应的桶号
///
diff --git a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml
index 2bb91f48..7b766109 100644
--- a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml
+++ b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml
@@ -60,7 +60,7 @@
+ Columns="8" />
@@ -68,7 +68,9 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml.cs b/BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml.cs
new file mode 100644
index 00000000..92557371
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace BPASmartClient.JXJFoodSmallStation.View
+{
+ ///
+ /// ManualControlView.xaml 的交互逻辑
+ ///
+ public partial class ManualControlView : UserControl
+ {
+ public ManualControlView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml b/BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml
index b6282a75..453719a9 100644
--- a/BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml
+++ b/BPASmartClient.JXJFoodSmallStation/View/RecipeControlView.xaml
@@ -9,8 +9,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
- d:DesignHeight="450"
- d:DesignWidth="800"
+ d:DesignHeight="800"
+ d:DesignWidth="1400"
mc:Ignorable="d">
@@ -20,8 +20,8 @@
-
-
+
+
-
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
+
-
+
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
- -->
-
+
+
+
+
-
+
-
+
-
+
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
+
diff --git a/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml b/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml
index 20d5eba9..dbfac736 100644
--- a/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml
+++ b/BPASmartClient.JXJFoodSmallStation/View/RecipeSettingsView.xaml
@@ -24,7 +24,6 @@
-
@@ -37,6 +36,8 @@
+
+
@@ -90,322 +91,199 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+ Foreground="#FF2AB2E7"
+ Text="配方信息:" />
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- -->
-
+
+
+
-
-
-
-
-
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs
index 15a55cac..6a22651e 100644
--- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ChangeDeviceNameViewModel.cs
@@ -28,25 +28,28 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
ErrorInfo = "设备名称不能为空";
return;
}
- int index = Array.FindIndex(DeviceListViewModel.devices.ToArray(), p => p.IpAddress == IpAddress);
- if (index >= 0 && index < DeviceListViewModel.devices.Count)
+ int index = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.IpAddress == IpAddress);
+ if (index >= 0 && index < DeviceInquire.GetInstance.devices.Count)
{
- if (DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == DeviceName) != null)
+ if (DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == DeviceName) != null)
ErrorInfo = "设备名称已存在";
else
{
- var res = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceListViewModel.devices.ElementAt(index).DeviceName);
- res.RawMaterialName = DeviceName;
- DeviceListViewModel.devices.ElementAt(index).DeviceName = DeviceName;
- DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称
- for (int i = 0; i < Json.Data.Recipes.Count; i++)
+ var res = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(index).DeviceName);
+ if (res != null)
{
- for (int m = 0; m < Json.Data.Recipes.ElementAt(i).RawMaterials.Count; m++)
+ res.RawMaterialName = DeviceName;
+ DeviceInquire.GetInstance.devices.ElementAt(index).DeviceName = DeviceName;
+ DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称
+ for (int i = 0; i < Json.Data.Recipes.Count; i++)
{
- Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName;
+ for (int m = 0; m < Json.Data.Recipes.ElementAt(i).RawMaterials.Count; m++)
+ {
+ Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName;
+ }
}
+ ActionManage.GetInstance.Send("ChangeDeviceNameViewClose");
}
- ActionManage.GetInstance.Send("ChangeDeviceNameViewClose");
}
}
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs
index f6a2130d..5f1a4eda 100644
--- a/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs
@@ -33,7 +33,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public RelayCommand ChangeNameCommand { get; set; }
//public static ObservableCollection devices { get; set; } = new ObservableCollection();
- public static ObservableCollection devices { get; set; }
+ public ObservableCollection devices { get; set; }
}
public class Devices : ObservableObject
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs
new file mode 100644
index 00000000..e2d385bc
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System.Collections.ObjectModel;
+using Microsoft.Toolkit.Mvvm.Input;
+using BPASmartClient.Helper;
+
+namespace BPASmartClient.JXJFoodSmallStation.ViewModel
+{
+ public class ManualControlViewModel : ObservableObject
+ {
+ public ManualControlViewModel()
+ {
+ for (int i = 0; i < 15; i++)
+ {
+ cylinderModels.Add(new CylinderModel()
+ {
+ Name = $"升降气缸 {i + 1}",
+ LeftTog = false,
+ RightTog = false,
+ });
+
+ BlockCylinders.Add(new CylinderModel()
+ {
+ Name = $"阻挡气缸 {i + 1}",
+ LeftTog = false,
+ RightTog = false,
+ });
+ }
+
+ for (int i = 0; i < 2; i++)
+ {
+ PalletCylinders.Add(new CylinderModel()
+ {
+ Name = $"托盘气缸 {i + 1}",
+ LeftTog = false,
+ RightTog = false,
+ });
+ }
+
+ Open = new RelayCommand((o) =>
+ {
+ ActionManage.GetInstance.Send("ManualOpen", o);
+ });
+
+
+ Close = new RelayCommand((o) =>
+ {
+ ActionManage.GetInstance.Send("ManualClose", o);
+ });
+ }
+
+ ///
+ /// 升降气缸
+ ///
+ public ObservableCollection cylinderModels { get; set; } = new ObservableCollection();
+
+ ///
+ /// 阻挡气缸
+ ///
+ public ObservableCollection BlockCylinders { get; set; } = new ObservableCollection();
+
+ ///
+ /// 托盘气缸
+ ///
+ public ObservableCollection PalletCylinders { get; set; } = new ObservableCollection();
+
+ public RelayCommand Open { get; set; }
+
+ public RelayCommand Close { get; set; }
+
+ }
+
+ public class CylinderModel : ObservableObject
+ {
+
+ public bool LeftTog { get { return _mLeftTog; } set { _mLeftTog = value; OnPropertyChanged(); } }
+ private bool _mLeftTog;
+
+ public bool RightTog { get { return _mRightTog; } set { _mRightTog = value; OnPropertyChanged(); } }
+ private bool _mRightTog;
+
+ public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } }
+ private string _mName;
+
+
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs
index cc22b060..77f133fe 100644
--- a/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs
@@ -59,14 +59,14 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
if (RecipeName == String.Empty) { ErrorInfo = "配方名称未填写"; return; }
for (int i = 0; i < RawMaterials.Count; i++)
{
- var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName);
+ var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName);
if (res != null)
{
RawMaterials.ElementAt(i).DeviceIp = res.IpAddress;//根据设备名称和原料名称的唯一匹配关系,给原料配置IP
RawMaterials.ElementAt(i).RawMaterialSource = 1;
}
var su = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == RawMaterials.ElementAt(i).RawMaterialName);
- if(su != null)
+ if (su != null)
{
RawMaterials.ElementAt(i).RawMaterialSource = su.RawMaterialSource;
}
@@ -179,7 +179,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public RelayCommand SaveCommand { get; set; }
- public ObservableCollection RawMaterials { get; set; } = new ObservableCollection ();
+ public ObservableCollection RawMaterials { get; set; } = new ObservableCollection();
public ObservableCollection RawMaterialNames { get; set; } = new ObservableCollection();
diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs
index 0de7948f..3eecce7e 100644
--- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs
+++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs
@@ -78,13 +78,18 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RawMaterialId = item.RawMaterialId,
});
}));
-
}
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成
- devices.TryDequeue(out string deviceName);
- UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表
- App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));//完成后清空当前配方
+ devices.TryDequeue(out string deviceName);
+ App.Current.Dispatcher.Invoke(new Action(() =>
+ {
+ UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表
+ }));
+ App.Current.Dispatcher.Invoke(new Action(() => {
+ recipeProcesses.Clear();
+ CurrentRecipeName = string.Empty;
+ }));//完成后清空当前配方
}
}
@@ -112,30 +117,52 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
}
- Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus;
- var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList();
- if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料
+
+
+ var proc = recipeProcesses.Where(p=>p.RecipeStatus==3).ToList();
+ if (proc != null && proc.Count > 0 && proc.Count== recipeProcesses.Count)
{
- for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++)
+ int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName);
+ if (recipIndex >= 0 && recipIndex < Recipes.Count)
{
- DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0
- App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
+ for (int n = 0; n < recipeProcesses.Count; n++)
+ {
+ DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0
+ MessageLog.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp);
+ }
+ App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
+ Recipes.ElementAt(recipIndex).IsEnable = true;
+ Recipes.ElementAt(recipIndex).Are.Set();
}
- Recipes.ElementAt(i).IsEnable = true;
- Recipes.ElementAt(i).Are.Set();
- }
+ }
+
+
+
+
+ //Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus;
+ //var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList();
+ //if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料
+ //{
+ // for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++)
+ // {
+ // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0
+ // App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
+ // }
+ // Recipes.ElementAt(i).IsEnable = true;
+ // Recipes.ElementAt(i).Are.Set();
+ //}
}
}
Thread.Sleep(100);
}), "RecipeControlViewModelStatusInquire");
//测试数据
- RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" };
+ /* RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" };
RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" };
RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" };
RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" };
ObservableCollection rawMaterials = new ObservableCollection { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 };
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials });
- UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });
+ UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });*/
}