diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index 70effaaa..c32b6ba0 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -19,12 +19,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC public PlcReadAddressDB45 DeviceStatus = new PlcReadAddressDB45(); public void Init() { - ThreadManage.GetInstance().StartLong(new Action(() => + ThreadManage.GetInstance().StartLong(new Action(() => { if (IsConnected) { var res = this.HK_PLC_S7.ReadClass(45); - if ( res != null && res is PlcReadAddressDB45 data) + if (res != null && res is PlcReadAddressDB45 data) { DeviceStatus = data; } @@ -35,7 +35,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC } } Thread.Sleep(10); - }),"海科PLC设备状态",true); + }), "海科PLC设备状态", true); } ///// ///// 单个配料机配料完成 @@ -70,6 +70,20 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC //{ // HK_PLC_S7.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0); //} + + private void TempStockBinPar(int num, ushort StockBinLocation, string info) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write($"DB4.DBX{num}." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write($"DB4.DBX{num + 1}." + (StockBinLocation - 9), true); + } + MessageNotify.GetInstance.ShowRunLog($"托盘{info}号桶在料仓{StockBinLocation}配料"); + } + /// /// 下发配方数据 /// @@ -85,51 +99,55 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { if (BarrelNum == 6) { - 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); - } - MessageNotify.GetInstance.ShowRunLog($"托盘1—1号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(10, StockBinLocation, "1—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); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘1—1号桶在料仓{StockBinLocation}配料"); } else if (BarrelNum == 7) { - 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); - } - MessageNotify.GetInstance.ShowRunLog($"托盘1—2号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(12, StockBinLocation, "1—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); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘1—2号桶在料仓{StockBinLocation}配料"); } else if (BarrelNum == 8) { - 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); - } - MessageNotify.GetInstance.ShowRunLog($"托盘1—3号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(14, StockBinLocation, "1—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); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘1—3号桶在料仓{StockBinLocation}配料"); } 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); - } - MessageNotify.GetInstance.ShowRunLog($"托盘1—4号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(16, StockBinLocation, "1—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); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘1—4号桶在料仓{StockBinLocation}配料"); } } } @@ -139,58 +157,62 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { if (BarrelNum == 6) { - if (StockBinLocation >= 1 && StockBinLocation <= 8) - { - HK_PLC_S7.Write("DB4.DBX18." + (StockBinLocation - 1), true); - } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) - { - HK_PLC_S7.Write("DB4.DBX19." + (StockBinLocation - 9), true); - } - MessageNotify.GetInstance.ShowRunLog($"托盘2—1号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(18, StockBinLocation, "2—1"); + //if (StockBinLocation >= 1 && StockBinLocation <= 8) + //{ + // HK_PLC_S7.Write("DB4.DBX18." + (StockBinLocation - 1), true); + //} + //else if (StockBinLocation >= 9 && StockBinLocation <= 15) + //{ + // HK_PLC_S7.Write("DB4.DBX19." + (StockBinLocation - 9), true); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘2—1号桶在料仓{StockBinLocation}配料"); } else if (BarrelNum == 7) { - if (StockBinLocation >= 1 && StockBinLocation <= 8) - { - HK_PLC_S7.Write("DB4.DBX20." + (StockBinLocation - 1), true); - } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) - { - HK_PLC_S7.Write("DB4.DBX21." + (StockBinLocation - 9), true); - } - MessageNotify.GetInstance.ShowRunLog($"托盘2—2号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(20, StockBinLocation, "2—2"); + //if (StockBinLocation >= 1 && StockBinLocation <= 8) + //{ + // HK_PLC_S7.Write("DB4.DBX20." + (StockBinLocation - 1), true); + //} + //else if (StockBinLocation >= 9 && StockBinLocation <= 15) + //{ + // HK_PLC_S7.Write("DB4.DBX21." + (StockBinLocation - 9), true); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘2—2号桶在料仓{StockBinLocation}配料"); } else if (BarrelNum == 8) { - if (StockBinLocation >= 1 && StockBinLocation <= 8) - { - HK_PLC_S7.Write("DB4.DBX22." + (StockBinLocation - 1), true); - } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) - { - HK_PLC_S7.Write("DB4.DBX23." + (StockBinLocation - 9), true); - } - MessageNotify.GetInstance.ShowRunLog($"托盘2—3号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(22, StockBinLocation, "2—3"); + //if (StockBinLocation >= 1 && StockBinLocation <= 8) + //{ + // HK_PLC_S7.Write("DB4.DBX22." + (StockBinLocation - 1), true); + //} + //else if (StockBinLocation >= 9 && StockBinLocation <= 15) + //{ + // HK_PLC_S7.Write("DB4.DBX23." + (StockBinLocation - 9), true); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘2—3号桶在料仓{StockBinLocation}配料"); } else if (BarrelNum == 4) { - if (StockBinLocation >= 1 && StockBinLocation <= 8) - { - HK_PLC_S7.Write("DB4.DBX24." + (StockBinLocation - 1), true); - } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) - { - HK_PLC_S7.Write("DB4.DBX25." + (StockBinLocation - 9), true); - } - MessageNotify.GetInstance.ShowRunLog($"托盘2—4号桶在料仓{StockBinLocation}配料"); + TempStockBinPar(24, StockBinLocation, "2—4"); + //if (StockBinLocation >= 1 && StockBinLocation <= 8) + //{ + // HK_PLC_S7.Write("DB4.DBX24." + (StockBinLocation - 1), true); + //} + //else if (StockBinLocation >= 9 && StockBinLocation <= 15) + //{ + // HK_PLC_S7.Write("DB4.DBX25." + (StockBinLocation - 9), true); + //} + //MessageNotify.GetInstance.ShowRunLog($"托盘2—4号桶在料仓{StockBinLocation}配料"); } } } } } - public void IssueRecipeToPlc(ObservableCollection rawMaterials,int recipeLoction) + public void IssueRecipeToPlc(ObservableCollection rawMaterials, int recipeLoction) { bool[] barrel = new bool[16]; bool[] barrel1 = new bool[16]; @@ -205,7 +227,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC switch (item.RawMaterialBarrelNum) { case 6: - barrel[item.RawMaterialLocation-1] = true; + barrel[item.RawMaterialLocation - 1] = true; barrel1[item.RawMaterialLocation - 1] = true; break; case 7: @@ -271,4 +293,4 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC } } -} \ No newline at end of file +} \ No newline at end of file