diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index 82d33a71..a244f722 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -51,7 +51,6 @@ namespace BPASmartClient.JXJFoodBigStation private void MenuInit() { - #region 配方管理菜单 ObservableCollection RecipeManage = new ObservableCollection(); RecipeManage.Add(new SubMenumodel() @@ -123,13 +122,6 @@ namespace BPASmartClient.JXJFoodBigStation #region 硬件设备监控 ObservableCollection DeviceMonitor = new ObservableCollection(); DeviceMonitor.Add(new SubMenumodel() - { - SubMenuName = "料仓管理", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - AssemblyName = "BPASmartClient.JXJFoodBigStation", - ToggleWindowPath = "View.DeviceManageView" - }); - DeviceMonitor.Add(new SubMenumodel() { SubMenuName = "设备状态", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, diff --git a/BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs index 864395d9..1b1be6ac 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs @@ -21,7 +21,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } private string _mDeviceName; - + public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } } + private int _mDeviceNum; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 49d9601e..67038353 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -11,7 +11,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model { public class GVL_BigStation { - /// /// 往输送带下发配方完成 /// @@ -32,5 +31,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// 记录AGV进站取货的指令顺序 /// public int AgvPickUpPosition { get; set; } + + /// + /// 配方配料的状态 0:无意义 ,1:plc允许下发配方 2:上位机下发配方 3:plc接收到配方(配料中) 4:配料完成 + /// + public int RecipeDosingStatus { get; set; } + /// + /// 是否处于手动下发配方 + /// + public bool IsAllowManual { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index 3afa9987..5397868f 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -61,13 +61,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC /// /// 单个桶的编号 /// 单个桶对应的料仓位置 - 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(HKPlcCommAddress.BarrelNumToPLC, Num); + HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, Location); + HK_PLC_S7.Write(HKPlcCommAddress.WeightToPLC, Weight); } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs b/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs new file mode 100644 index 00000000..40957ee5 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs @@ -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 Recipes { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index b8229495..6d206609 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -35,73 +35,57 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// public ObservableCollection IssuedComplete = new ObservableCollection(); /// + /// 原料的名称和料仓的位置对应 + /// + public Dictionary RawMaterialsNamePos = new Dictionary(); + /// /// 配方队列 /// - public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); + public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); /// /// AGV到达工站队列 /// - public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); + public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); /// /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; public void Init() { - ActionManage.GetInstance.Register(new Action(() => + ActionManage.GetInstance.Register(new Action((res) => { if (SiemensDevice.IsConnected) { - var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID); - var res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(0, 0); - if ((res != null && res is string recipeName) && (res1 != null && res1 is uint recipeID)) + if (res != null) { - int index = Array.FindIndex(Json.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.Data.Recipes.Add(new RemoteRecipeData() + else { - RecipeName = recipeName, - RecipeCode = recipeID, - RawMaterial = RawMaterials - }); + //报警,配方的原料名称下发和设备不一致 + } } - else + Json.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(SiemensCommAddress.TrayLocationNum); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(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.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 + //Json.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); } /// @@ -223,13 +207,13 @@ 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 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.Data.Recipes; + if (!BigStation.IsAllowManual && RemoteRecipes.Count == 0)//一个配方执行完成后,再获取配方数据 + { + RemoteRecipes = Json.Data.Recipes; + } + else if (BigStation.IsAllowManual && RemoteRecipes.Count == 0) + { + RemoteRecipes = Json.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("M5001.0") is bool)//配方1是否允许下发配发 + string code = RemoteRecipes.ElementAt(index).RecipeCode; + if (HKDevice.HK_PLC_S7.Read("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("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(HKPlcCommAddress.RecipeDosingFinish) is bool)) + if (BigStation.RecipeDosingStatus == 3) { - HKDevice.RecipeDosingFinishReset(); - RecipeQueue.TryDequeue(out code); - IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + for (int i = 0; i < 12; i++) + { + if (i >= 0 && i < 8) + { + if (HKDevice.HK_PLC_S7.Read("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(address); + } + } + } + else + { + if (HKDevice.HK_PLC_S7.Read("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(address); + } + } + } + } + if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(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.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + } + else + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + } + BigStation.RecipeDosingStatus = 0; + } } } } @@ -399,5 +441,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model return null; } } + /// + /// 获取料仓的原料名称和原料位置 + /// + private void ReadPLCDeviceInfo() + { + for (int i = 0; i < 12; i++) + { + string RawMaterialName = HKDevice.HK_PLC_S7.Read(""); + short RawMaterialLocation = HKDevice.HK_PLC_S7.Read(""); + if (RawMaterialsNamePos.ContainsKey(RawMaterialName)) + RawMaterialsNamePos.Add(RawMaterialName, RawMaterialLocation); + } + } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs index fb8c4e38..bdbd7869 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs @@ -28,11 +28,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model private double _mRawMaterialWeight; /// - /// 原料对应料仓的位置/名称 + /// 原料对应料仓的位置 /// public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } } private int _mRawMaterialLocation; + /// + /// 原料名称 + /// + public string RawMaterialName { get { return _rawMaterNmae; } set { _rawMaterNmae = value;OnPropertyChanged(); } } + + private string _rawMaterNmae; /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs index fa8ab739..63e1a8bf 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs @@ -34,8 +34,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 配方编码 /// - public long RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } - private long _mRecipCode; + public string RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } + private string _mRecipCode; /// /// 托盘编号 diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs new file mode 100644 index 00000000..4394ac10 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs @@ -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 + { + /// + /// 生产工单编码 + /// + public string Order_No; + /// + /// 产品名称 + /// + public string Product_Code; + /// + /// 原料信息 + /// + public UDT1[] Material = new UDT1[20]; + /// + /// 配料完成信号 + /// + public bool Ask_For_Finish; + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC; + + } + public class UDT1 + { + public string Material_Name; + public float Material_Laying_Off_Weight; + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs new file mode 100644 index 00000000..13066a70 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs @@ -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 + { + /// + /// 配方编码 + /// + public string RecipeCode; + /// + /// 配发名称 + /// + public string RecipeName; + /// + /// 物料信息 + /// + public UDT[] Material = new UDT[20]; + /// + /// 托盘编号 + /// + public int TrayCode; + /// + /// 配方发送请求 + /// + public bool Ask_For_Send_Bit; + /// + /// 上位机确认配方接收完成 + /// + public bool Ack_Ask_For_Send_Bit; + } + public class UDT + { + /// + /// 原料名称 + /// + public string Material_Name; + /// + /// 原料重量 + /// + public float Material_Weight; + /// + /// 原料桶号 + /// + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs new file mode 100644 index 00000000..562da3bf --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs @@ -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 + { + /// + /// 生产工单 + /// + public string Order_No; + /// + /// 配料开始 + /// + public bool Dosing_Start; + /// + /// 配料开始确认 + /// + public bool Dosing_Confirm; + /// + /// 托盘占位情况 + /// + public bool[] Pallet_Position_Occ = new bool[16]; + /// + /// 工位允许放货架 + /// + public bool[] Allow_AGV_Put = new bool[16]; + /// + /// 工位允许取货架 + /// + public bool[] Allow_AGV_Get = new bool[16]; + /// + /// AGV请求放货架 + /// + public bool[] AGV_Request_Put = new bool[16]; + /// + /// AGV请求取货架 + /// + public bool[] AGV_Request_Get = new bool[16]; + /// + /// AGV放托盘完成 + /// + public bool[] AGV_Put_Done = new bool[16]; + /// + /// 托盘号 + /// + public short[] Pan_No = new short[16]; + /// + /// 配料时间 + /// + public int DosingTime; + /// + /// 备用 + /// + public byte Reserve; + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs index 45b13638..383a0d10 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs @@ -20,8 +20,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 配方ID /// - public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } - private long _mRecipeCode; + public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } + private string _mRecipeCode; /// /// 托盘编号 diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs index 3f95a527..f73a00d8 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs @@ -12,6 +12,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model private int _mIp; public int DeviceIp { get { return _mIp; } set { _mIp = value; }} + /// + /// 原料名称 + /// + public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } + private string _mRawMaterialName; + /// /// 原料对应的桶号 /// @@ -24,6 +30,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } private double _mRawMaterialWeight; + /// + /// 实际的下料中重量 + /// + public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } + private float _mLaying_Off_Weight; + /// /// 原料对应料仓的位置 /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index ce9fa65a..a6b9db25 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -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; - /// - /// 配方接收信号复位 - /// - public void RecipeSignReset() - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0); - } - /// - /// AGV到位信号复位 - /// - 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(SiemensCommAddress.RecipeState); - if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig)) + var res = this.Siemens_PLC_S7.ReadClass(1); + var res1 = this.Siemens_PLC_S7.ReadClass(2); + var res2 = this.Siemens_PLC_S7.ReadClass(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(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(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(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(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(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(res1, 2); } - var AgvState = this.Siemens_PLC_S7.Read(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(res1, 2); } + + if (res2 != null && res2.Ask_For_Finish_PLC) + { + ActionManage.GetInstance.Send("配料完成信号确认完成"); + res2.Ask_For_Finish_PLC = false; + this.Siemens_PLC_S7.WriteClass(res2, 3); + } + Thread.Sleep(10); }), "监听服务数据"); } } - /// - /// 配方配料完成信号 - /// - /// - /// - 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); - } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/TestData.cs b/BPASmartClient.JXJFoodBigStation/Model/TestData.cs index b7b7c45e..44c7bfa7 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/TestData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/TestData.cs @@ -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() { diff --git a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml index 49105063..89977ed2 100644 --- a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml @@ -15,7 +15,59 @@ - + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + - + - + + @@ -396,7 +515,7 @@ Height="{Binding ElementName=gr, Path=ActualHeight}" Margin="10,0,30,0" ConveyorBeltWidth="70" - Direction="1" + Direction="2" StrokeBrush="#00BEFA" StrokeDashArray="1.5 1.5" StrokeFillBrush="#00BEFA" @@ -406,6 +525,8 @@ - - + + + - + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs index 8ff0e43b..5a54f04f 100644 --- a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs @@ -1,4 +1,6 @@ -using System; +using BPASmartClient.CustomResource.UserControls; +using BPASmartClient.Helper; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,6 +11,7 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -20,11 +23,231 @@ namespace BPASmartClient.JXJFoodBigStation.View /// public partial class HardwareStatusView : UserControl { + Storyboard storyboard; public HardwareStatusView() { InitializeComponent(); + storyboard = Resources["Open"] as Storyboard; + ActionManage.GetInstance.CancelRegister("StartTopDevice"); + ActionManage.GetInstance.CancelRegister("StopTopDevice"); + ActionManage.GetInstance.CancelRegister("StartBottomDevice"); + ActionManage.GetInstance.CancelRegister("StopBottomDevice"); + ActionManage.GetInstance.Register(new Action((deviceName) => { + foreach (var item in this.FListView.Items) + { + var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag.ToString() == deviceName.ToString()&& storyboard != null) + { + pt.Visibility = Visibility.Visible; + pt.BeginStoryboard(storyboard); + } + + } + } + + }),"StartTopDevice" ); + + ActionManage.GetInstance.Register(new Action((deviceName) => { + foreach (var item in this.FListView.Items) + { + var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag.ToString() == deviceName.ToString()) + + pt.Visibility = Visibility.Collapsed; + } + } + + }), "StopTopDevice"); + + ActionManage.GetInstance.Register(new Action((deviceName) => { + foreach (var item in this.buttonListView.Items) + { + var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path1", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag.ToString() == deviceName.ToString() && storyboard != null) + { + pt.Visibility = Visibility.Visible; + pt.BeginStoryboard(storyboard); + } + + } + } + + }), "StartBottomDevice"); + + ActionManage.GetInstance.Register(new Action((deviceName) => { + foreach (var item in this.buttonListView.Items) + { + var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path1", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag.ToString() == deviceName.ToString()) + + pt.Visibility = Visibility.Collapsed; + } + } + + }), "StopBottomDevice"); + + } + //顶部启动下料动画 + private void IcoButton_Click(object sender, RoutedEventArgs e) + { + foreach (var item in this.FListView.Items) + { + var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag == (sender as IcoButton).Tag&&storyboard!=null) + { + pt.Visibility = Visibility.Visible; + pt.BeginStoryboard(storyboard); + } + + } + } } + //顶部停止下料动画 + private void IcoButton_Click_1(object sender, RoutedEventArgs e) + { + foreach (var item in this.FListView.Items) + { + var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag == (sender as IcoButton).Tag) + + pt.Visibility = Visibility.Collapsed; + } + } + } + //底部启动下料动画 + private void IcoButton_Click_2(object sender, RoutedEventArgs e) + { + foreach (var item in this.buttonListView.Items) + { + var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path1", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag == (sender as IcoButton).Tag && storyboard != null) + { + pt.Visibility = Visibility.Visible; + pt.BeginStoryboard(storyboard); + } + + } + } + } + //底部停止下料动画 + private void IcoButton_Click_3(object sender, RoutedEventArgs e) + { + foreach (var item in this.buttonListView.Items) + { + var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item); + + // Getting the ContentPresenter of myListBoxItem + var myContentPresenter = FindVisualChild(myListBoxItem); + + // Finding textBlock from the DataTemplate that is set on that ContentPresenter + DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; + + var obj = myDataTemplate.FindName("path1", myContentPresenter); + Path pt = obj as Path; + if (pt != null) + { + if (pt.Tag == (sender as IcoButton).Tag) + + pt.Visibility = Visibility.Collapsed; + } + } + } + + private childItem FindVisualChild(DependencyObject obj) + where childItem : DependencyObject + { + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) + { + DependencyObject child = VisualTreeHelper.GetChild(obj, i); + if (child != null && child is childItem) + return (childItem)child; + else + { + childItem childOfChild = FindVisualChild(child); + if (childOfChild != null) + return childOfChild; + } + } + return null; + } } } diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml index 124a23fb..e233caee 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml @@ -334,7 +334,7 @@ - + + + @@ -362,7 +364,7 @@ Background="Transparent" BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Right" Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" - CommandParameter="{Binding RawMaterialLocation}"> + CommandParameter="{Binding RawMaterialName}"> diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml index 9947abee..c752dcda 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml @@ -168,7 +168,7 @@ Foreground="Aqua" IcoText="" Style="{StaticResource IcoButtonStyle}" /> - + Style="{StaticResource IcoButtonStyle}" />--> - + - + diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml index 728a2611..6b05d7cf 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml @@ -473,6 +473,7 @@ - + diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs index b75502cd..68319389 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs @@ -22,6 +22,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = i.ToString(), + DeviceNum=i, RunStatus = false, Weight = new Random().Next(0, 100) }); @@ -31,13 +32,55 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = i.ToString(), + DeviceNum = i, RunStatus = false, Weight = new Random().Next(0, 100) }); } + + StartCommand = new RelayCommand((deviceName) => { + //PLC控制 + + //动画 + if (deviceName != null) + { + var top= TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); + if (top != null) + { + ActionManage.GetInstance.Send("StartTopDevice", deviceName); + } + var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); + if (bottom != null) + { + ActionManage.GetInstance.Send("StartBottomDevice", deviceName); + } + } + }); + StopCommand = new RelayCommand((deviceName) => { + //PLC控制 + + //动画 + if (deviceName != null) + { + var top = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); + if (top != null) + { + ActionManage.GetInstance.Send("StopTopDevice", deviceName); + } + var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); + if (bottom != null) + { + ActionManage.GetInstance.Send("StopBottomDevice", deviceName); + } + } + }); } public ObservableCollection TopDeviceCurrentStatuses { get; set; } = new ObservableCollection(); public ObservableCollection BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection(); + + public RelayCommand StartCommand { get; set; } + + public RelayCommand StopCommand { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs index ce915cd8..56c353ca 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs @@ -47,7 +47,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel if (name == null) { go: - long recipeCode = new Random().Next(10000, 99999); + string recipeCode = new Random().Next(10000, 99999).ToString(); var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode); if (res == null) { @@ -76,6 +76,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel bom.RawMaterial.Add(item); } bom.RecipeName = RecipeName; + bom.TrayCode = TrayCode; Json.Save(); ActionManage.GetInstance.Send("CloseRecipeInfosView"); } @@ -88,7 +89,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel if (bom == null && rec != null)//配方名称更改 { - prop: long recipeCode = new Random().Next(10000, 99999);//配方唯一ID,后期根据实际要求更改 + prop: string recipeCode = new Random().Next(10000, 99999).ToString();//配方唯一ID,后期根据实际要求更改 var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode); if (res == null) { @@ -108,9 +109,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel ActionManage.GetInstance.Send("CloseNewRecipeView"); }); - RemoveRecipe = new RelayCommand((materilaName) => { + RemoveRecipe = new RelayCommand((materilaName) => { - var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialLocation==materilaName); + var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialName==materilaName); if (res != null) RawMaterialsInfo.Remove(res); }); @@ -123,8 +124,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; @@ -137,7 +138,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public RelayCommand SaveAs { get; set; } - public RelayCommand RemoveRecipe { get; set; } + public RelayCommand RemoveRecipe { get; set; } public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection() ; } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs index b4065c4a..2e4b30a0 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs @@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel Recipes = Json.Data.Recipes; DetailsCommand = new RelayCommand((o) => { - if (o != null && o is long num) + if (o != null && o is string num) { ActionManage.GetInstance.CancelRegister("RecipeInfo"); RecipeInfosView nrv = new RecipeInfosView(); @@ -45,51 +45,51 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel RecipeInfosView nrv = new RecipeInfosView(); nrv.ShowDialog(); }); - - NewSimulateRecipe = new RelayCommand(() => - { - RawMaterials.Clear(); - string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; - go: - long recipeCode = new Random().Next(10000, 99999); - 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++) - { - int a = new Random().Next(1, 5); - if (a == 3) - { - a = 1; - } - RawMaterials.Add(new RawMaterialModel() - { - RawMaterialWeight = new Random().Next(10, 1000), - RawMaterialBarrelNum = a, - RawMaterialLocation = i, - }); - } - Json.Data.Recipes.Add(new RecipeModel() - { - RecipeName = recipeName, - RecipeCode = recipeCode, - TrayCode = trayCode, - RawMaterial = RawMaterials, - }); - - }); + //模拟配方 + //NewSimulateRecipe = new RelayCommand(() => + //{ + // RawMaterials.Clear(); + // string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; + //go: + // 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++) + // { + // int a = new Random().Next(1, 5); + // if (a == 3) + // { + // a = 1; + // } + // RawMaterials.Add(new RawMaterialModel() + // { + // RawMaterialWeight = new Random().Next(10, 1000), + // RawMaterialBarrelNum = a, + // RawMaterialLocation = i, + // }); + // } + // Json.Data.Recipes.Add(new RecipeModel() + // { + // RecipeName = recipeName, + // RecipeCode = recipeCode, + // TrayCode = trayCode, + // RawMaterial = RawMaterials, + // }); + // Json.Save(); + //}); ClearAllRecipe = new RelayCommand(() => { Json.Data.Recipes.Clear(); Json.Save(); }); - RemoveCommand = new RelayCommand((recipeCode) => { + RemoveCommand = new RelayCommand((recipeCode) => { var res = Recipes.FirstOrDefault(p=>p.RecipeCode==recipeCode); if(res!=null) @@ -102,13 +102,12 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel } public RelayCommand DetailsCommand { get; set; } - public RelayCommand NewSimulateRecipe { get; set; } public RelayCommand ClearAllRecipe { get; set; } public RelayCommand NewRecipe { get; set; } - public RelayCommand RemoveCommand { get; set; } + public RelayCommand RemoveCommand { get; set; } public ObservableCollection Recipes { get; set; } = new ObservableCollection(); } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs index dc00f618..06cdd6af 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs @@ -14,7 +14,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel internal class RecipeSendDownViewModel:ObservableObject { - public static ObservableCollection Recipes { get; set; } = Json.Data.Recipes; + public ObservableCollection Recipes { get; set; } = Json.Data.Recipes; /// /// 当前正在制作的配方 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index 198b6706..4bc409a8 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -18,13 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public bool IssueRecipeFinishStation1 { get; set; } = false; /// - /// 托盘1配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 + /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// - public int RecipeStatusIDTray1 { get; set; } = 0; - /// - /// 托盘2配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 - /// - public int RecipeStatusIDTray2 { get; set; } = 0; + public int RecipeStatusID { get; set; } = 0; /// /// 往输送带下发配方完成 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index 14c9e29d..3466f7a5 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -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("DB4.DBX10." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX11." + (StockBinLocation - 9), true); + } + } + else if (BarrelNum == 2) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX12." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX13." + (StockBinLocation - 9), true); + } + } + else if (BarrelNum == 3) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX14." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX15." + (StockBinLocation - 9), true); + } + } + else if (BarrelNum == 4) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX16." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX17." + (StockBinLocation - 9), true); + } + } + } } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index cc8e1b58..abd7e42c 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -27,69 +27,71 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public ObservableCollection RemoteRecipes = new ObservableCollection(); /// - /// 托盘1 配方队列 + /// 原料的名称和料仓的位置对应 /// - public ConcurrentQueue RecipeTray1Queue = new ConcurrentQueue(); + public Dictionary RawMaterialsNamePos = new Dictionary(); /// - /// 托盘2 配方队列 + /// 配方队列 /// - public ConcurrentQueue RecipeTray2Queue = new ConcurrentQueue(); + public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); GVL_SmallStation SmallStation = new GVL_SmallStation(); + XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB(); /// /// 接收原料数据 /// 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((res) => { if (SiemensDevice.IsConnected) { - var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID); - int res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(RawMaterial, 0, 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.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(SiemensCommAddress.TrayLocationNum); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID); - if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId) - { - int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == recipeId); - if (index >= 0 && index < Json.Data.Recipes.Count) - { - Json.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 @@ -109,7 +111,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { } - RecipeTray1Queue.Clear(); + RecipeQueue.Clear(); //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { @@ -416,42 +418,42 @@ namespace BPASmartClient.JXJFoodSmallStation.Model switch (SmallStation.AgvDeliveryPosition) { case 0: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApply) is bool)) + if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApply) is bool)) { SmallStation.AgvDeliveryPosition = 1; HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true); } break; case 1: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply))) { SmallStation.AgvDeliveryPosition = 2; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true); } break; case 2: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool)) + if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool)) { SmallStation.AgvDeliveryPosition = 3; HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true); } break; case 3: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack))) { SmallStation.AgvDeliveryPosition = 4; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true); } break; case 4: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool)) + if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool)) { SmallStation.AgvDeliveryPosition = 5; HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true); } break; case 5: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo))) { SmallStation.AgvDeliveryPosition = 0; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true); @@ -462,7 +464,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } //获取工位上是否有小车 SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) - HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray)); + HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray)); } /// /// AGV进站取货 @@ -472,28 +474,28 @@ namespace BPASmartClient.JXJFoodSmallStation.Model switch (SmallStation.AgvPickUpPosition) { case 0: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool)) + if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(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(HKPlcCommAddress.PickAGVIsApply) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVIsApply))) { SmallStation.AgvPickUpPosition = 2; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true); } break; case 2: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickCargoAGVFinish) is bool)) + if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickCargoAGVFinish) is bool)) { SmallStation.AgvPickUpPosition = 3; HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true); } break; case 3: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish))) { SmallStation.AgvPickUpPosition = 0; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true); @@ -503,6 +505,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; } } + /// + /// 将配方添加到配方队列中 + /// private void ReceviceData() { RemoteRecipes = Json.Data.Recipes; @@ -510,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); } } } + /// + /// 执行配方队列中的第一个配方 + /// 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("DB3.DBX1.5") is bool && SmallStation.RecipeStatusIDTray1 == 0) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") && SmallStation.RecipeStatusID == 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) { @@ -542,18 +542,18 @@ 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("DB3.DBX1.3") is bool && SmallStation.RecipeStatusIDTray1 == 1) + if (HKDevice.HK_PLC_S7.Read("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("DB3.DBX50.0") is bool) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0")) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10"); + 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); @@ -566,9 +566,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1") is bool) + else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1")) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); + 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); @@ -581,9 +581,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2") is bool) + else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2")) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18"); + 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); @@ -596,9 +596,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3") is bool) + else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3")) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22"); + 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); @@ -615,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) { @@ -626,131 +628,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1") is bool) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) { 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 (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("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) + 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("DB3.DBX1.2") is bool) - { - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); - MessageLog.GetInstance.ShowRunLog($"托盘2 配方{res.RecipeName}配料完成"); + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 3); + RecipeFinishInfo.Ask_For_Finish = true; Json.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; } } - } + } } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 9fa18cdf..16ac5f45 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -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);//获取设备故障编码 diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs index 1c8ced08..3d109842 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs @@ -12,7 +12,5 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public class LocaPar { public ObservableCollection Recipes { get; set; } = new ObservableCollection(); - - } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs index 61b4febb..fdb08d26 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs @@ -22,6 +22,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public float WeightFeedback { get; set; } + /// + /// 当前出料重量反馈 + /// + public float NowWeightFeedback { get; set; } + /// /// 上限反馈 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs index d08b6b7b..16ae94d4 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs @@ -18,8 +18,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 配方ID /// - public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } - private long _mRecipeCode; + public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } + private string _mRecipeCode; /// /// 托盘编号 diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs index 2e0bbe27..359c1eda 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs @@ -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; /// /// 原料对应的桶号 /// - public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } } - private int _mRawMaterialBarrelNum; + public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } } + private short _mRawMaterialBarrelNum; /// /// 需要原料重量 @@ -25,6 +25,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } } private double _mRawMaterialWeight; + /// + /// 实际的下料中重量 + /// + public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } + private float _mLaying_Off_Weight; + /// /// 原料对应料仓的位置 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index 6d9944a9..792c9f16 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -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; - /// - /// 配方接收信号复位 - /// - public void RecipeSignReset() - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0); - } - /// - /// AGV到位信号复位 - /// - 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(SiemensCommAddress.RecipeState); - if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig)) + var res = this.Siemens_PLC_S7.ReadClass(1); + var res1 = this.Siemens_PLC_S7.ReadClass(2); + var res2 = this.Siemens_PLC_S7.ReadClass(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(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(res1, 2); } - var AgvState = this.Siemens_PLC_S7.Read(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(res1, 2); } + + if (res2 != null && res2.Ask_For_Finish_PLC) + { + ActionManage.GetInstance.Send("配料完成信号确认完成"); + res2.Ask_For_Finish_PLC = false; + this.Siemens_PLC_S7.WriteClass(res2, 3); + } + Thread.Sleep(10); }),"监听服务数据"); } } - /// - /// 配方配料完成信号 - /// - /// - /// - 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); - } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs new file mode 100644 index 00000000..24e7608d --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs @@ -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 + { + /// + /// 生产工单编码 + /// + public string Order_No; + /// + /// 产品名称 + /// + public string Product_Code; + /// + /// 原料信息 + /// + public UDT1[] Material = new UDT1[20]; + /// + /// 配料完成信号 + /// + public bool Ask_For_Finish; + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC; + + } + public class UDT1 + { + public string Material_Name; + public float Material_Laying_Off_Weight; + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs new file mode 100644 index 00000000..9dcb5ac9 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs @@ -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 + { + /// + /// 配方编码 + /// + public string RecipeCode; + /// + /// 配发名称 + /// + public string RecipeName; + /// + /// 物料信息 + /// + public UDT[] Material = new UDT[20]; + /// + /// 托盘编号 + /// + public int TrayCode; + /// + /// 配方发送请求 + /// + public bool Ask_For_Send_Bit; + /// + /// 上位机确认配方接收完成 + /// + public bool Ack_Ask_For_Send_Bit; + + } + public class UDT + { + /// + /// 原料名称 + /// + public string Material_Name; + /// + /// 原料重量 + /// + public float Material_Weight; + /// + /// 原料桶号 + /// + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs new file mode 100644 index 00000000..fc06a44a --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs @@ -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 + { + /// + /// 生产工单 + /// + public string Order_No; + /// + /// 配料开始 + /// + public bool Dosing_Start; + /// + /// 配料开始确认 + /// + public bool Dosing_Confirm; + /// + /// 托盘占位情况 + /// + public bool[] Pallet_Position_Occ = new bool[16]; + /// + /// 工位允许放货架 + /// + public bool[] Allow_AGV_Put = new bool[16]; + /// + /// 工位允许取货架 + /// + public bool[] Allow_AGV_Get = new bool[16]; + /// + /// AGV请求放货架 + /// + public bool[] AGV_Request_Put = new bool[16]; + /// + /// AGV请求取货架 + /// + public bool[] AGV_Request_Get = new bool[16]; + /// + /// AGV放托盘完成 + /// + public bool[] AGV_Put_Done = new bool[16]; + /// + /// 托盘号 + /// + public short[] Pan_No = new short[16]; + /// + /// 配料时间 + /// + public int DosingTime; + /// + /// 备用 + /// + public byte Reserve; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs b/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs index 6503b448..8f96ff0d 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs @@ -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() { diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs index 5cee9780..d9f689f9 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs @@ -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; diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs index 36857a1e..b4d61bb2 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs @@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel Recipes = Json.Data.Recipes; DetailsCommand = new RelayCommand((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.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, }); } diff --git a/BPASmartClient.MinimalistUI/MainWindow.xaml b/BPASmartClient.MinimalistUI/MainWindow.xaml index ac26bcf1..99662bea 100644 --- a/BPASmartClient.MinimalistUI/MainWindow.xaml +++ b/BPASmartClient.MinimalistUI/MainWindow.xaml @@ -14,7 +14,5 @@ - - diff --git a/BPASmartClient.MinimalistUI/物料仓管理.lay b/BPASmartClient.MinimalistUI/物料仓管理.lay index 38c15d13..e0c8bf8f 100644 Binary files a/BPASmartClient.MinimalistUI/物料仓管理.lay and b/BPASmartClient.MinimalistUI/物料仓管理.lay differ diff --git a/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs b/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs index 8f13609e..73a3a4af 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs @@ -45,22 +45,22 @@ namespace BPASmartClient.SCADAControl.CustomerControls { DefaultStyleKeyProperty.OverrideMetadata(typeof(SwitchButton), new FrameworkPropertyMetadata(typeof(SwitchButton))); } - [Category("事件")] - public string Value + [Category("事件")] + public string BindingIsChecked { - get { return (string)GetValue(ValueProperty); } - set { SetValue(ValueProperty,value); } + get { return (string)GetValue(BingIsCheckedProperty); } + set { SetValue(BingIsCheckedProperty, value); } } - public static readonly DependencyProperty ValueProperty = - DependencyProperty.Register("Value",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); + public static readonly DependencyProperty BingIsCheckedProperty = + DependencyProperty.Register("BindingIsChecked", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); [Category("事件")] - public string Text + public string SendText { - get { return (string)GetValue(TextProperty); } - set { SetValue(TextProperty,value); } + get { return (string)GetValue(SendTextProperty); } + set { SetValue(SendTextProperty, value); } } - public static readonly DependencyProperty TextProperty = - DependencyProperty.Register("Text",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); + public static readonly DependencyProperty SendTextProperty = + DependencyProperty.Register("SendText", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty)); /// /// 不勾选时执行代码 @@ -92,7 +92,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls set { SetValue(TimeCountProperty,value); } } public static readonly DependencyProperty TimeCountProperty = - DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(5)); + DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(100)); protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); @@ -175,9 +175,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls propertyBing[propertyInfo.Name] = propName.ToString(); } } - timer.Interval = TimeSpan.FromMilliseconds(TimeCount); - timer.Tick += Timer_Tick; ; - timer.Start(); + if (propertyBing.Count > 0) + { + timer.Interval = TimeSpan.FromMilliseconds(TimeCount); + timer.Tick += Timer_Tick; ; + timer.Start(); + } this.Click += SwitchButton_Click; } @@ -214,7 +217,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls _checked = false; } EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); + SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); this.GetType().GetProperty("IsChecked").SetValue(this,_checked); } } @@ -243,7 +246,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls { object _value = b[str[1]].VarVaule; EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType }); + SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType }); } } } diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs index 51ac1363..58481edd 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs @@ -140,7 +140,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls Direction = 2; } } - timer.Interval = TimeSpan.FromSeconds(TimeCount); + timer.Interval = TimeSpan.FromMilliseconds(TimeCount); timer.Tick += Timer_Tick; timer.Start(); @@ -189,13 +189,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls #region 属性 [Category("事件")] - public string Value + public string SendText { - get { return (string)GetValue(ValueProperty); } - set { SetValue(ValueProperty,value); } + get { return (string)GetValue(SendTextProperty); } + set { SetValue(SendTextProperty, value); } } - public static readonly DependencyProperty ValueProperty = - DependencyProperty.Register("Value",typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged))); + public static readonly DependencyProperty SendTextProperty = + DependencyProperty.Register("SendText", typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged))); private static void OnValuePropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) { (d as TheMQTT)?.RefreshMQTT(); @@ -203,9 +203,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls public void RefreshMQTT() { PublishInfo publishInfo = new PublishInfo(); - if (!string.IsNullOrEmpty(Value)) + if (!string.IsNullOrEmpty(SendText)) { - publishInfo.PublishModels.Add(JsonConvert.DeserializeObject(Value)); + publishInfo.PublishModels.Add(JsonConvert.DeserializeObject(SendText)); if (mQTT.client != null && mQTT.client.IsConnected) mQTT.MqttPublishAsync("DistributedHostComputer/Control",JsonConvert.SerializeObject(publishInfo)); } @@ -278,7 +278,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls set { SetValue(TimeCountProperty,value); } } public static readonly DependencyProperty TimeCountProperty = - DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(5)); + DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(1000)); [Category("数据绑定-数据来源")] public string DataSouceInformation { diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs index feb7fb29..da06aa11 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs @@ -130,7 +130,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls Direction = 2; } } - timer.Interval = TimeSpan.FromSeconds(TimeCount); + timer.Interval = TimeSpan.FromMilliseconds(TimeCount); timer.Tick += Timer_Tick; timer.Start(); @@ -271,7 +271,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls set { SetValue(TimeCountProperty,value); } } public static readonly DependencyProperty TimeCountProperty = - DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(5)); + DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(100)); [Category("数据绑定-数据来源")] public string DataSouceInformation { diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs index 18eed157..7321df16 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs @@ -87,9 +87,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls } } - timer.Interval = TimeSpan.FromMilliseconds(TimeCount); - timer.Tick += Timer_Tick; ; - timer.Start(); + if (propertyBing.Count > 0) + { + timer.Interval = TimeSpan.FromMilliseconds(TimeCount); + timer.Tick += Timer_Tick; ; + timer.Start(); + } } /// /// 属性刷新事件 diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs index df758606..e5032dae 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs @@ -67,7 +67,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls { object _value = b[str[1]].VarVaule; EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - ChangedText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType }); + SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType }); } } } @@ -109,13 +109,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls public static readonly DependencyProperty ValueChangedExecuteProperty = DependencyProperty.Register("ValueChangedExecute",typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty)); [Category("事件")] - public string ChangedText + public string SendText { - get { return (string)GetValue(ChaTextProperty); } - set { SetValue(ChaTextProperty,value); } + get { return (string)GetValue(SendTextProperty); } + set { SetValue(SendTextProperty, value); } } - public static readonly DependencyProperty ChaTextProperty = - DependencyProperty.Register("ChangedText",typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty)); + public static readonly DependencyProperty SendTextProperty = + DependencyProperty.Register("SendText", typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty)); [Category("数据绑定-数据来源")] public int TimeCount { @@ -123,7 +123,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls set { SetValue(TimeCountProperty,value); } } public static readonly DependencyProperty TimeCountProperty = - DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(5)); + DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(100)); public event EventHandler PropertyChange; //声明一个事件 /// /// 属性刷新器 @@ -147,9 +147,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls propertyBing[propertyInfo.Name] = propName.ToString(); } } - timer.Interval = TimeSpan.FromMilliseconds(TimeCount); - timer.Tick += Timer_Tick; ; - timer.Start(); + if (propertyBing.Count > 0) + { + timer.Interval = TimeSpan.FromMilliseconds(TimeCount); + timer.Tick += Timer_Tick; ; + timer.Start(); + } } /// /// 属性刷新事件 diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs index 731dff92..9daa1436 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs @@ -62,21 +62,21 @@ namespace BPASmartClient.SCADAControl.CustomerControls } } [Category("事件")] - public string Value + public string BindingIsChecked { - get { return (string)GetValue(ValueProperty); } - set { SetValue(ValueProperty,value); } + get { return (string)GetValue(BindingIsCheckedProperty); } + set { SetValue(BindingIsCheckedProperty, value); } } - public static readonly DependencyProperty ValueProperty = - DependencyProperty.Register("Value",typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); + public static readonly DependencyProperty BindingIsCheckedProperty = + DependencyProperty.Register("BindingIsChecked", typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); [Category("事件")] - public string Text + public string SendText { - get { return (string)GetValue(TextProperty); } - set { SetValue(TextProperty,value); } + get { return (string)GetValue(SendTextProperty); } + set { SetValue(SendTextProperty, value); } } - public static readonly DependencyProperty TextProperty = - DependencyProperty.Register("Text",typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); + public static readonly DependencyProperty SendTextProperty = + DependencyProperty.Register("SendText", typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty)); /// /// 不勾选时执行代码 /// @@ -107,7 +107,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls set { SetValue(TimeCountProperty,value); } } public static readonly DependencyProperty TimeCountProperty = - DependencyProperty.Register("TimeCount",typeof(int),typeof(TheToggleButton),new PropertyMetadata(5)); + DependencyProperty.Register("TimeCount",typeof(int),typeof(TheToggleButton),new PropertyMetadata(100)); /// /// 属性刷新器 /// @@ -127,9 +127,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls propertyBing[propertyInfo.Name] = propName.ToString(); } } - timer.Interval = TimeSpan.FromMilliseconds(TimeCount); - timer.Tick += Timer_Tick; ; - timer.Start(); + if (propertyBing.Count > 0) + { + timer.Interval = TimeSpan.FromMilliseconds(TimeCount); + timer.Tick += Timer_Tick; ; + timer.Start(); + } Click += TheToggleButton_Click; Checked += TheCheckBox_Checked; Unchecked += TheCheckBox_Unchecked; @@ -168,7 +171,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls _checked = false; } EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); + SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType }); this.GetType().GetProperty("IsChecked").SetValue(this,_checked); } @@ -198,7 +201,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls { object _value = b[str[1]].VarVaule; EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType); - Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType }); + SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType }); } } } diff --git a/BeDesignerSCADA/Common/PropertyHelper.cs b/BeDesignerSCADA/Common/PropertyHelper.cs index 8ac00c8e..0a5eabe1 100644 --- a/BeDesignerSCADA/Common/PropertyHelper.cs +++ b/BeDesignerSCADA/Common/PropertyHelper.cs @@ -14,7 +14,7 @@ namespace BeDesignerSCADA.Common { public static string[] ableProperties = new string[] { "IsChecked", "Value", "CurValue", "StatusValue", "NumberValue", "Text", - "Direction","RefreshData","ChangedText","Content" + "Direction","RefreshData","ChangedText","Content","SendText" }; public static List GetCustomerControlProperty(List selectItems) { diff --git a/BeDesignerSCADA/Controls/CanvasPanel.cs b/BeDesignerSCADA/Controls/CanvasPanel.cs index 581cebe9..4b5e9878 100644 --- a/BeDesignerSCADA/Controls/CanvasPanel.cs +++ b/BeDesignerSCADA/Controls/CanvasPanel.cs @@ -35,9 +35,6 @@ namespace BeDesignerSCADA.Controls SetTopLayerCommand = new RelayCommand(SetTopLayer); SetBottomLayerCommand = new RelayCommand(SetBottomLayer); SelectedItems = new ObservableCollection(); - //ResourceDictionary resourceDictionary = new ResourceDictionary(); - //Application.LoadComponent(resourceDictionary, new Uri("/BeDesignerSCADA;component/Themes/Styles.xaml", UriKind.Relative)); - //ContextMenu = resourceDictionary.FindName("CanvasRightMenu") as ContextMenu; ContextMenu=Application.Current.Resources["CanvasRightMenu"] as ContextMenu; KeyDown += CanvasPanel_KeyDown; } diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml new file mode 100644 index 00000000..9b56aae9 --- /dev/null +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 绑定: + + + + + + + + + + + + + + + + + + + + diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs new file mode 100644 index 00000000..8d4337a3 --- /dev/null +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs @@ -0,0 +1,359 @@ +using BeDesignerSCADA.ViewModel; +using BeDesignerSCADA.ViewModel; +using BPASmart.Model; +using BPASmartClient.Compiler; +using BPASmartClient.DATABUS; +using BPASmartClient.MessageName; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BeDesignerSCADA.Controls +{ + /// + /// MainCanvasPanel.xaml 的交互逻辑 + /// + public partial class MainCanvasPanel : System.Windows.Controls.UserControl + { + /// + /// 布局文件路径 + /// + public string Path=string.Empty; + MainViewModel viewModel = new MainViewModel(); + public MainCanvasPanel(string _Path) + { + InitializeComponent(); + Path= _Path; + this.DataContext = viewModel; + viewModel.Loaded(cav, runCanvas); + //控件加载 + Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); + var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name); + CtlList.ItemsSource = controls; + //读取文件 + FileRead(_Path); + } + public MainCanvasPanel() + { + InitializeComponent(); + this.DataContext = viewModel; + viewModel.Loaded(cav, runCanvas); + //控件加载 + Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); + var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name); + CtlList.ItemsSource = controls; + } + + #region 位置调整 + /// + /// 左对齐 + /// + /// + /// + private void AglinLeftBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignLeft(); + } + /// + /// 底部对齐 + /// + /// + /// + private void AglinBottomBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignBottom(); + } + /// + /// 顶部对齐 + /// + /// + /// + private void AglinTopBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignTop(); + } + /// + /// 右对齐 + /// + /// + /// + private void AglinRightBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignRight(); + } + /// + /// 居中 + /// + /// + /// + private void AglinCenterBtn_Click(object sender, RoutedEventArgs e) + { + cav.AlignCenter(); + } + /// + /// 垂直分布 + /// + /// + /// + private void VerticalLayoutBtn_Click(object sender, RoutedEventArgs e) + { + cav.VertialLayout(); + } + /// + /// 水平分布 + /// + /// + /// + private void HorizontalLayoutBtn_Click(object sender, RoutedEventArgs e) + { + cav.HorizontalLayout(); + } + #endregion + + #region 其他事件操作 + /// + /// 运行 + /// + /// + /// + private void RunBtn_Click(object sender, RoutedEventArgs e) + { + if (sender is System.Windows.Controls.Button btn) + { + if (btn.Tag.ToString() == "运行") + { + cav.ClearSelection(); + runCanvas.Run(cav.Generator()); + } + else if (btn.Tag.ToString() == "停止") + { + runCanvas.Destory(); + } + } + } + /// + /// 加载 + /// + /// + /// + private void LoadBtn_Click(object sender, RoutedEventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "布局文件|*.lay"; + if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + cav.Load(ofd.FileName); + } + + DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250))); + da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da); + + DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250))); + daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + cav.BeginAnimation(OpacityProperty, daop); + } + /// + /// 读取文件 + /// + /// + public void FileRead(string path) + { + try + { + if (File.Exists(path)) + { + cav.Load(path); + + + DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250))); + da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da); + + DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250))); + daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; + cav.BeginAnimation(OpacityProperty, daop); + } + } + catch (Exception ex) + { + + } + } + /// + /// 保存文件 + /// + public void FileSave() + { + SaveBtn_Click(null, null); + } + /// + /// 保存 + /// + /// + /// + private void SaveBtn_Click(object sender, RoutedEventArgs e) + { + string str = cav.Save(); + File.WriteAllText(Path, str, Encoding.Unicode); + } + /// + /// 模拟消息发送 + /// + /// + /// + private void MNBtn_Click(object sender, RoutedEventArgs e) + { + + } + #endregion + + #region 左侧控件栏移动 + /// + /// 移动到右侧 + /// + /// + /// + private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) + { + if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed) + { + DragDrop.DoDragDrop(CtlList, CtlList.SelectedItem, System.Windows.DragDropEffects.Copy); + codeEditor.Text = cav.Save(); + } + } + /// + /// 显示代码 + /// + /// + /// + private void showCode_Click(object sender, RoutedEventArgs e) + { + codeEditor.Text = cav.Save(); + } + /// + /// 编辑 + /// + /// + /// + private void ToggleButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (sender is ToggleButton) + { + ToggleButton toggle = (ToggleButton)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (propertyGridCommand != null) + { + viewModel.Edit(propertyGridCommand); + } + } + } + catch (Exception ex) + { + + } + } + /// + /// 变量选择 + /// + /// + /// + private void ComboBoxValue_TextChanged(object sender, TextChangedEventArgs e) + { + try + { + if (sender is System.Windows.Controls.ComboBox) + { + System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) + propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}"; + } + } + catch (Exception ex) + { + + } + } + /// + /// 变量下拉框打开事件 + /// + /// + /// + private void valuebox_DropDownOpened(object sender, EventArgs e) + { + try + { + viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection(); + if (sender is System.Windows.Controls.ComboBox) + { + System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; + if (toggle.Tag == null) return; + if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(toggle.Tag.ToString())) + { + Class_DataBus.GetInstance().Dic_DeviceData[toggle.Tag.ToString()].Keys?.ToList().ForEach(key => { viewModel.DevValueList.Add(key); }); + } + } + } + catch (Exception ex) + { + + } + + } + /// + /// 设备名称选择 + /// + /// + /// + private void ComboBoxName_TextChanged(object sender, TextChangedEventArgs e) + { + try + { + if (sender is System.Windows.Controls.ComboBox) + { + System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; + Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; + if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) + propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}"; + else if (!string.IsNullOrEmpty(toggle.Text)) + propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}"; + + } + } + catch (Exception ex) + { + + } + } + /// + /// 设备名称下拉框打开事件 + /// + /// + /// + private void namebox_DropDownOpened(object sender, EventArgs e) + { + viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection(); + Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); }); + } + #endregion + } +} diff --git a/BeDesignerSCADA/Controls/RunCanvas.xaml.cs b/BeDesignerSCADA/Controls/RunCanvas.xaml.cs index 2b8aaa8e..8df988d2 100644 --- a/BeDesignerSCADA/Controls/RunCanvas.xaml.cs +++ b/BeDesignerSCADA/Controls/RunCanvas.xaml.cs @@ -47,11 +47,6 @@ namespace BeDesignerSCADA.Controls RootCanvas.Children.Clear(); foreach (FrameworkElement element in canvas) { - //if (element.GetType().GetInterface("IExecutable")!=null) - //{ - // element.GetType().GetProperty("IsExecuteState").SetValue(element, true); - //} - if (element is IExecutable executable) executable.IsExecuteState = true; diff --git a/BeDesignerSCADA/MainTest.xaml b/BeDesignerSCADA/MainTest.xaml new file mode 100644 index 00000000..aabf5c5c --- /dev/null +++ b/BeDesignerSCADA/MainTest.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/BeDesignerSCADA/MainTest.xaml.cs b/BeDesignerSCADA/MainTest.xaml.cs new file mode 100644 index 00000000..5536bed8 --- /dev/null +++ b/BeDesignerSCADA/MainTest.xaml.cs @@ -0,0 +1,30 @@ +using BeDesignerSCADA.Controls; +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.Shapes; + +namespace BeDesignerSCADA +{ + /// + /// MainTest.xaml 的交互逻辑 + /// + public partial class MainTest : Window + { + public MainTest() + { + InitializeComponent(); + MainCanvasPanel mainCanvas=new MainCanvasPanel(@"D:\fengyoufu\代码\Code\C#项目\新上位机代码\BPASmartClient.MinimalistUI\bin\Debug\net6.0-windows\LayoutFile\物料仓管理.lay"); + main.Children.Add(mainCanvas); + } + } +} diff --git a/BeDesignerSCADA/MainWindow.xaml b/BeDesignerSCADA/MainWindow.xaml index 32129c55..54f6980f 100644 --- a/BeDesignerSCADA/MainWindow.xaml +++ b/BeDesignerSCADA/MainWindow.xaml @@ -28,12 +28,16 @@ - - - - - - + + + + + + + + + + @@ -175,9 +179,7 @@ - - - + @@ -253,7 +255,7 @@ - + diff --git a/BeDesignerSCADA/MainWindow.xaml.cs b/BeDesignerSCADA/MainWindow.xaml.cs index bc7a404a..c7adfb4d 100644 --- a/BeDesignerSCADA/MainWindow.xaml.cs +++ b/BeDesignerSCADA/MainWindow.xaml.cs @@ -33,23 +33,23 @@ namespace BeDesignerSCADA /// public partial class MainWindow : Window { + MainViewModel viewModel=new MainViewModel(); public MainWindow() { InitializeComponent(); - //Loading(); this.DataContext = viewModel; - viewModel.Loaded(cav); + viewModel.Loaded(cav, runCanvas); //控件加载 - Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); - //Assembly assembly = Assembly.GetExecutingAssembly(); - var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null); + Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); + var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o=>o.Name); CtlList.ItemsSource = controls; - viewModel.propertyGrid = kzxy; - //LoadFile(); } #region 加载数据中心与事件中心 + /// + /// 加载数据中心 + /// public void Loading() { //try @@ -132,7 +132,6 @@ namespace BeDesignerSCADA // System.Windows.MessageBox.Show(ex.Message); //} } - /// /// 加载本地文件 /// @@ -257,7 +256,6 @@ namespace BeDesignerSCADA } } } - /// /// 加载 /// @@ -280,7 +278,6 @@ namespace BeDesignerSCADA daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; cav.BeginAnimation(OpacityProperty, daop); } - /// /// 保存 /// @@ -297,7 +294,6 @@ namespace BeDesignerSCADA File.WriteAllText(sfd.FileName, str, Encoding.Unicode); } } - /// /// 模拟消息发送 /// @@ -310,6 +306,11 @@ namespace BeDesignerSCADA #endregion #region 左侧控件栏移动 + /// + /// 移动到右侧 + /// + /// + /// private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed) @@ -318,7 +319,6 @@ namespace BeDesignerSCADA codeEditor.Text = cav.Save(); } } - /// /// 显示代码 /// @@ -328,7 +328,6 @@ namespace BeDesignerSCADA { codeEditor.Text = cav.Save(); } - /// /// 编辑 /// @@ -353,9 +352,8 @@ namespace BeDesignerSCADA } } - /// - /// 变量编辑 + /// 变量选择 /// /// /// @@ -367,10 +365,8 @@ namespace BeDesignerSCADA { System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; - if (toggle.Tag != null) + if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text)) propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}"; - else - propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}." + "}"; } } catch (Exception ex) @@ -378,12 +374,16 @@ namespace BeDesignerSCADA } } + /// + /// 变量下拉框打开事件 + /// + /// + /// private void valuebox_DropDownOpened(object sender,EventArgs e) { try { viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection(); - if (sender is System.Windows.Controls.ComboBox) { System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; @@ -413,9 +413,9 @@ namespace BeDesignerSCADA { System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; - if(toggle.Tag!=null) + if(toggle.Tag!=null && !string.IsNullOrEmpty(toggle.Text)) propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}"; - else + else if(!string.IsNullOrEmpty(toggle.Text)) propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}"; } @@ -425,17 +425,16 @@ namespace BeDesignerSCADA } } - - + /// + /// 设备名称下拉框打开事件 + /// + /// + /// private void namebox_DropDownOpened(object sender,EventArgs e) { viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection(); Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); }); } #endregion - - } - - } diff --git a/BeDesignerSCADA/Themes/Styles.xaml b/BeDesignerSCADA/Themes/Styles.xaml index 083b0edd..1619a743 100644 --- a/BeDesignerSCADA/Themes/Styles.xaml +++ b/BeDesignerSCADA/Themes/Styles.xaml @@ -300,16 +300,16 @@ - - + + - - + + - - + + @@ -323,23 +323,23 @@ - - + + - - + + - - + + - - + + diff --git a/BeDesignerSCADA/ViewModel/MainViewModel.cs b/BeDesignerSCADA/ViewModel/MainViewModel.cs index 077eec96..c37b2470 100644 --- a/BeDesignerSCADA/ViewModel/MainViewModel.cs +++ b/BeDesignerSCADA/ViewModel/MainViewModel.cs @@ -38,15 +38,10 @@ namespace BeDesignerSCADA.ViewModel { IsRunning = !IsRunning; }); - } #region 变量 /// - /// 设置 - /// - public Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid propertyGrid = null; - /// /// 是否正在运行状态 /// private bool _IsRunning = false; @@ -72,6 +67,7 @@ namespace BeDesignerSCADA.ViewModel OnPropertyChanged("IsRunning"); } } + /// /// 画布是否显示 /// @@ -144,12 +140,14 @@ namespace BeDesignerSCADA.ViewModel if (_CanSelectedItem == value) return; _CanSelectedItem = value; - DataSX(); + SelectedPropertyDataRefresh(); OnPropertyChanged("CanSelectedItem"); } } - + /// + /// 控制协议属性 + /// private PropertyGridCommand _pro; public PropertyGridCommand PropeObject { @@ -164,6 +162,9 @@ namespace BeDesignerSCADA.ViewModel } } + /// + /// 设备名称集合 + /// private ObservableCollection _DevNameList; public ObservableCollection DevNameList { @@ -177,6 +178,10 @@ namespace BeDesignerSCADA.ViewModel OnPropertyChanged("DevNameList"); } } + + /// + /// 设备变量集合 + /// private ObservableCollection _DevValueList; public ObservableCollection DevValueList { @@ -197,11 +202,9 @@ namespace BeDesignerSCADA.ViewModel /// 启动或者停止 /// public RelayCommand RunUiCommand { get; set; } - #endregion #region 常用函数 - /// /// 显示当前xaml代码 /// @@ -212,16 +215,24 @@ namespace BeDesignerSCADA.ViewModel #endregion #region 脚本编辑数据 + /// + /// 当前编辑界面 + /// public CanvasPanel canvasPanel; /// + /// 当前运行界面 + /// + public RunCanvas runCanvas; + /// /// 加载 /// /// - public void Loaded(object obj) + public void Loaded(object objCan,object objRun) { - canvasPanel = obj as CanvasPanel; - } + canvasPanel = objCan as CanvasPanel; + runCanvas = objRun as RunCanvas; + } /// /// 编辑 /// @@ -246,42 +257,14 @@ namespace BeDesignerSCADA.ViewModel #endregion #region 属性填充 - Dictionary EventName = new Dictionary { - - {"Name","名称" }, - {"Text","文本" }, - {"Content","按钮文本" }, - {"Title","标题" }, - {"Value","变量" }, - {"ClickExec","点击事件" }, - {"ValueChangedExecute" , "值改变事件"}, - {"TikcExecute" , "定时触发"}, - {"CheckedExec" , "勾选事件"}, - {"UnCheckedExec" , "取消勾选事件"}, - {"EventReceiveNameList" , "接收消息集"}, - - //{"DataSouceType" , "数据来源类型"}, - { "TimeCount" , "定时间隔"}, - - { "InterfaceMode" , "接口类型"}, - { "InterfaceParameters" , "接口参数"}, - - { "DataSouceInformation" , "连接信息"}, - - { "DeviceName" , "设备名称"}, - { "DeviceValuleName" , "设备解析变量"}, - {"FDataSouce" , "数据源"}, - { "Code" , "代码过滤脚本"}, - { "GenerateData" , "数据结果"}, - }; /// - /// 数据刷新 + /// 选中属性数据刷新 /// - public void DataSX() + public void SelectedPropertyDataRefresh() { //属性变量 PropertyGridCommand cmd = new PropertyGridCommand(); - var content = CanSelectedItem;// as System.Windows.Controls.Control; + var content = CanSelectedItem; if (content is IExecutable executable) executable.PropertyChange += Executable_PropertyChange; @@ -303,7 +286,6 @@ namespace BeDesignerSCADA.ViewModel PropeObject = null; PropeObject = cmd; } - /// /// 内部属性变化通知 /// @@ -319,7 +301,6 @@ namespace BeDesignerSCADA.ViewModel DevValueList = new System.Collections.ObjectModel.ObservableCollection(); Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { DevNameList.Add(key); }); } - /// /// 修改属性后 /// @@ -348,7 +329,6 @@ namespace BeDesignerSCADA.ViewModel } } - /// /// 设置变量 /// @@ -357,13 +337,28 @@ namespace BeDesignerSCADA.ViewModel { try { - // if (CanSelectedItem is System.Windows.Controls.Control) + var content = CanSelectedItem; + if (Name == "Content" ? (content is BPASmartClient.SCADAControl.CustomerControls.TheButton) : true) { - var content = CanSelectedItem;// as System.Windows.Controls.Control; - if (Name == "Content" ? (content is BPASmartClient.SCADAControl.CustomerControls.TheButton) : true) + System.Reflection.PropertyInfo info = content.GetType().GetProperty(Name); + if (info != null) { - System.Reflection.PropertyInfo info = content.GetType().GetProperty(Name); - info?.SetValue(content,value,null); + if (info.ToString().Contains("Double")) + { + info?.SetValue(content, Double.Parse(value.ToString()), null); + } + else if (info.ToString().Contains("String")) + { + info?.SetValue(content, value, null); + } + else if (info.ToString().Contains("Int")) + { + info?.SetValue(content, int.Parse(value.ToString()), null); + } + else + { + info?.SetValue(content, value, null); + } } } } @@ -390,7 +385,6 @@ namespace BeDesignerSCADA.ViewModel // FieldInfo fld = type.GetField("Browsable",BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreReturn | BindingFlags.GetProperty); fld.SetValue(attrs[type],visible); } - /// /// 获取指定对象的指定成员变量 /// @@ -472,6 +466,33 @@ namespace BeDesignerSCADA.ViewModel } #endregion + + Dictionary EventName = new Dictionary { + {"Name","名称" }, + {"Text","文本" }, + {"Content","按钮文本" }, + {"Title","标题" }, + {"Value","变量" }, + {"BindingIsChecked","勾选状态" }, + + + {"ClickExec","点击事件" }, + {"ValueChangedExecute" , "值改变事件"}, + {"TikcExecute" , "定时触发"}, + {"CheckedExec" , "勾选事件"}, + {"UnCheckedExec" , "取消勾选事件"}, + {"EventReceiveNameList" , "接收消息集"}, + + { "TimeCount" , "定时间隔"}, + { "InterfaceMode" , "接口类型"}, + { "InterfaceParameters" , "接口参数"}, + { "DataSouceInformation" , "连接信息"}, + { "DeviceName" , "设备名称"}, + { "DeviceValuleName" , "设备解析变量"}, + {"FDataSouce" , "数据源"}, + { "Code" , "代码过滤脚本"}, + { "GenerateData" , "数据结果"}, + }; } @@ -483,7 +504,8 @@ namespace BeDesignerSCADA.ViewModel private string _标题; private string _文本1; private object _变量; - + private string _勾选状态; + [Category("基本属性"), Description("Name"), Browsable(false), PropertyOrder(1)] public string 名称 { @@ -559,6 +581,22 @@ namespace BeDesignerSCADA.ViewModel OnPropertyChanged("变量"); } } + [Category("基本属性"), Description("BindingIsChecked"), Browsable(false), PropertyOrder(5)] + public string 勾选状态 + { + get + { + return _勾选状态; + } + set + { + if (_勾选状态 == value) + return; + _勾选状态 = value; + OnPropertyChanged("勾选状态"); + } + } + //[Category("基本属性"), Description("Content"), Browsable(true), PropertyOrder(2)] //public string 内容 { get; set; } //[Category("基本属性"), Description("Header"), Browsable(true), PropertyOrder(3)] @@ -696,26 +734,6 @@ namespace BeDesignerSCADA.ViewModel } } - - - - //private DataTypeEnum _数据来源类型; - //[Category("*数据绑定模块*"), Description("DataSouceType"), Browsable(true), PropertyOrder(1)] - //public DataTypeEnum 数据来源类型 - //{ - // get - // { - // return _数据来源类型; - // } - // set - // { - // if (_数据来源类型 == value) - // return; - // _数据来源类型 = value; - // OnPropertyChanged("数据来源类型"); - // } - //} - private string _设备名称; [Category("*数据绑定模块*"), Description("DeviceName"), Browsable(true), PropertyOrder(2)] public string 设备名称 diff --git a/WPFDemo/WPFDemo.csproj b/WPFDemo/WPFDemo.csproj index 9f859991..a7f49412 100644 --- a/WPFDemo/WPFDemo.csproj +++ b/WPFDemo/WPFDemo.csproj @@ -20,6 +20,7 @@ +