NXX 2 years ago
parent
commit
9794f6ff18
59 changed files with 2105 additions and 1110 deletions
  1. +2
    -2
      BPASmartClient.Business/LocalMqtt.cs
  2. +23
    -0
      BPASmartClient.Helper/ExpandMethod.cs
  3. +17
    -0
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  4. +7
    -0
      BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
  5. +15
    -1
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  6. +36
    -16
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs
  7. +34
    -394
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  8. +64
    -0
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcReadAddressDB45.cs
  9. +382
    -100
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  10. +2
    -2
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs
  11. +1
    -1
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs
  12. +7
    -7
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs
  13. +12
    -6
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
  14. +2
    -1
      BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml
  15. +88
    -0
      BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml
  16. +28
    -0
      BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml.cs
  17. +14
    -17
      BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs
  18. +61
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs
  19. +3
    -2
      BPASmartClient.JXJFoodSmallStation/App.config
  20. +21
    -2
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  21. +10
    -0
      BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
  22. +50
    -31
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  23. +9
    -9
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
  24. +58
    -0
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB45.cs
  25. +13
    -0
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs
  26. +337
    -247
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  27. +34
    -22
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  28. +20
    -18
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs
  29. +3
    -3
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs
  30. +1
    -1
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs
  31. +11
    -6
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs
  32. +69
    -15
      BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs
  33. +5
    -0
      BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs
  34. +18
    -49
      BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs
  35. +50
    -0
      BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Write.cs
  36. +94
    -0
      BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml
  37. +28
    -0
      BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml.cs
  38. +1
    -1
      BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml
  39. +10
    -6
      BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml
  40. +5
    -1
      BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs
  41. +64
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs
  42. +1
    -1
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs
  43. +2
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
  44. +138
    -101
      BPASmartClient.MorkF/Control_MorkF.cs
  45. +169
    -2
      BPASmartClient.MorkF/GVL_MorkF.cs
  46. +6
    -0
      BPASmartClient.S7Net/SiemensHelper.cs
  47. +1
    -1
      BPASmartClient.ScreenALL/App.config
  48. +30
    -5
      BPASmartClient.ScreenLib/Helper/Main.cs
  49. +1
    -1
      BPASmartClient.ScreenMaxWok/App.config
  50. +2
    -1
      BPASmartClient.ScreenMinWok/App.config
  51. +1
    -1
      BPASmartClient.ScreenMorks/App.config
  52. +1
    -1
      BPASmartClient.ScreenSplitMeals/App.config
  53. +7
    -5
      DosingSystem/Model/ConveyerBeltModel.cs
  54. +1
    -1
      DosingSystem/Model/DeviceInquire.cs
  55. +3
    -3
      DosingSystem/Service/SiemensDevice.cs
  56. +1
    -1
      DosingSystem/View/NewRecipeView.xaml
  57. +20
    -14
      DosingSystem/View/RecipeControlView.xaml
  58. +6
    -6
      DosingSystem/ViewModel/ManualControlViewModel.cs
  59. +6
    -4
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 2
- 2
BPASmartClient.Business/LocalMqtt.cs View File

@@ -32,8 +32,8 @@ namespace BPASmartClient.Business
{
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(DeviceType)) ;
});
mQTTProxy.Connect("admin", "public", "10.2.1.254", 1883, $"{DeviceType}_设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
});
mQTTProxy.Connect("emqx_u_block", "emqx_p_admin3658765490789", "47.108.65.220", 1883, $"{DeviceType}_设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");//"10.2.1.254""admin", "public"
}

public void Start()


+ 23
- 0
BPASmartClient.Helper/ExpandMethod.cs View File

@@ -161,7 +161,30 @@ namespace BPASmartClient.Helper
return (data & 1 << offset - 1) == 0 ? false : true;
}

public static ushort SetBitValue(this ushort data, byte offset, bool val)
{
if (offset > 16 || offset < 1)
{
return data;
}

int num = 1 << offset - 1;
return (ushort)(val ? (data | num) : (data & ~num));
}
public static bool GetBitValue(this ushort data, byte offset)
{
if (offset > 16 || offset < 1)
{
return false;
}

if ((data & (1 << offset - 1)) != 0)
{
return true;
}

return false;
}





+ 17
- 0
BPASmartClient.JXJFoodBigStation/App.xaml.cs View File

@@ -22,8 +22,18 @@ namespace BPASmartClient.JXJFoodBigStation
public partial class App : Application
{
public static Window MainWindow;
public EventWaitHandle ProgramStarted { get; set; }
protected override void OnStartup(StartupEventArgs e)
{
bool createNew;
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "BigStationApp", out createNew);
if (!createNew)
{
MessageBox.Show("程序已启动");
App.Current.Shutdown();
Environment.Exit(0);
}
BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
base.OnStartup(e);
MenuInit();
DataInit();
@@ -141,6 +151,13 @@ namespace BPASmartClient.JXJFoodBigStation
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.HKPlcCommMonitorView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "手动流程",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.ManualFlowView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{


+ 7
- 0
BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj View File

@@ -23,6 +23,9 @@
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Update="View\ManualFlowView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
@@ -37,6 +40,10 @@
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\ManualFlowView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\RecipeInfosView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>


+ 15
- 1
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs View File

@@ -1,4 +1,5 @@
using BPASmartClient.JXJFoodBigStation.Model.Siemens;
using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
using BPASmartClient.JXJFoodBigStation.Model.Siemens;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -15,6 +16,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// plc心跳上传
/// </summary>
public static bool HeartBeatFromPlc { get; set; }

/// <summary>
/// plc心跳下发
/// </summary>
public static bool HeartBeatToPlc { get; set; }
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
@@ -42,5 +48,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public static int SiemensSendRecipeStatus { get; set; } = 0;

public const int Max_DosingSotckBinNum = 14;

public static ushort AGVPutTray { get; set; }
public static ushort AGVGetTray { get; set; }

public static ushort TraySensor { get; set; }
public static ushort TrayCylinder { get; set; }

public static DB_Read HKPlc_Read = new DB_Read();
}
}

+ 36
- 16
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs View File

@@ -9,16 +9,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public class DB_Read
{
[PlcComm("plc心跳上报")]
/// <summary>
/// plc心跳上报
/// </summary>
public bool HeartBeat { get; set; }
[PlcComm("配方1允许下发配方")]
/// <summary>
/// 配方1允许下发配方
/// </summary>
public bool IsAllowIssueRecipe1 { get; set; }

[PlcComm("配方2允许下发配方")]
public bool IsAllowIssueRecipe2 { get; set; }

@@ -29,9 +22,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public bool IsAllowIssueRecipe4 { get; set; }

[PlcComm("配方1接收配方完成")]
/// <summary>
/// 配方1 接收配方完成
/// </summary>
public bool ReceiveFinishRecipe1 { get; set; }
[PlcComm("配方2接收配方完成")]
public bool ReceiveFinishRecipe2 { get; set; }
@@ -40,9 +30,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
[PlcComm("配方4接收配方完成")]
public bool ReceiveFinishRecipe4 { get; set; }
[PlcComm("配方1配料完成")]
/// <summary>
/// 配方1 配料完成
/// </summary>
public bool Recipe1DosingFinish { get; set; }
[PlcComm("配方2配料完成")]
public bool Recipe2DosingFinish { get; set; }
@@ -51,9 +38,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
[PlcComm("配方4配料完成")]
public bool Recipe4DosingFinish { get; set; }
[PlcComm("配方1托盘编号")]
/// <summary>
/// 配方1 托盘编号
/// </summary>
public short Recipe1TrayCode { get; set; }
[PlcComm("配方2托盘编号")]
public short Recipe2TrayCode { get; set; }
@@ -89,5 +73,41 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public float StockBin13ActualWeight { get; set; }
[PlcComm("料仓14实际下料重量")]
public float StockBin14ActualWeight { get; set; }
/*[PlcComm("托盘到位")]
public ushort TrayInPlace { get; set; }
[PlcComm("托盘传感器信号")]
public ushort TraySensor { get; set; }
[PlcComm("托盘1气缸信号")]
public ushort TrayCylinder { get; set; }*/
[PlcComm("托盘1到位")]
public bool Tray1InPlace { get; set; }
[PlcComm("托盘2到位")]
public bool Tray2InPlace { get; set; }
[PlcComm("托盘3到位")]
public bool Tray3InPlace { get; set; }
[PlcComm("托盘4到位")]
public bool Tray4InPlace { get; set; }
[PlcComm("托盘5到位")]
public bool Tray5InPlace { get; set; }
[PlcComm("托盘1气缸信号")]
public bool Tray1Cylinder { get; set; }
[PlcComm("托盘2气缸信号")]
public bool Tray2Cylinder { get; set; }
[PlcComm("托盘3气缸信号")]
public bool Tray3Cylinder { get; set; }
[PlcComm("托盘4气缸信号")]
public bool Tray4Cylinder { get; set; }
[PlcComm("托盘5气缸信号")]
public bool Tray5Cylinder { get; set; }
[PlcComm("托盘1传感器信号")]
public bool Tray1Sensor { get; set; }
[PlcComm("托盘2传感器信号")]
public bool Tray2Sensor { get; set; }
[PlcComm("托盘3传感器信号")]
public bool Tray3Sensor { get; set; }
[PlcComm("托盘4传感器信号")]
public bool Tray4Sensor { get; set; }
[PlcComm("托盘5传感器信号")]
public bool Tray5Sensor { get; set; }
}
}

+ 34
- 394
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -8,6 +8,7 @@ using BPASmartClient.CustomResource.Pages.Model;
using System.Threading.Tasks;
using BPASmartClient.S7Net;
using System.Threading;
using BPASmartClient.JXJFoodBigStation.Model.Siemens;

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
@@ -15,30 +16,37 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
public SiemensHelper HK_PLC_S7 = new SiemensHelper();
public bool IsConnected => HK_PLC_S7.IsConnected;
public DB_Write PlcWrite = new DB_Write();
public DB_Read PlcRead = new DB_Read();
public DL_DataColl_DB DataColl =new DL_DataColl_DB();
public StockBinName StockBinName = new StockBinName();
public void Init()
{
if (IsConnected)
DB_Write PlcWrite = new DB_Write();
HK_PLC_S7.WriteClass<DB_Write>(PlcWrite, 99);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ThreadManage.GetInstance().StartLong(new Action(() =>
if (IsConnected)
{
HK_PLC_S7.WriteClass<DB_Write>(PlcWrite, 99);
var res1 = HK_PLC_S7.ReadClass<DB_Read>(98);
var res2 = HK_PLC_S7.ReadClass<StockBinName>(97);
if (res1 != null && res1 is DB_Read data1)
{
PlcRead = data1;
GVL_BigStation.HeartBeatFromPlc = data1.HeartBeat;//读取plc心跳
GVL_BigStation.HKPlc_Read = data1;
}
if (res2 != null && res2 is StockBinName data2)
{
StockBinName = data2;
}
Thread.Sleep(10);
}),"信号收发处理");
}
var res3 = HK_PLC_S7.ReadClass<DL_DataColl_DB>(48);
if (res3 != null && res3 is DL_DataColl_DB data)
{
DataColl = data;
}
}
Thread.Sleep(10);
}),"信号收发处理");
}
/// <summary>
/// 下发配方数据
@@ -49,8 +57,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
if (recipe != null)
{
PlcWrite.RecipeCode = Convert.ToInt16(recipe.RecipeCode);
PlcWrite.TrayCode = Convert.ToInt16(recipe.TrayCode);
HK_PLC_S7.Write("DB99.DBW2.0",Convert.ToInt16(recipe.TrayCode));
HK_PLC_S7.Write("DB99.DBW4.0", Convert.ToInt16(recipe.TrayCode));
for (int barrel = 1; barrel < 6; barrel++)
{
if (barrel != 3)//桶的编号不为3 只为1,2,4,5号桶
@@ -63,204 +71,20 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
switch (barrel)
{
case 1:
switch (loc)
{
case 1:
PlcWrite.Bareel1Bin1SetWeight = 0;
break;
case 2:
PlcWrite.Bareel1Bin2SetWeight = 0;
break;
case 3:
PlcWrite.Bareel1Bin3SetWeight = 0;
break;
case 4:
PlcWrite.Bareel1Bin4SetWeight = 0;
break;
case 5:
PlcWrite.Bareel1Bin5SetWeight = 0;
break;
case 6:
PlcWrite.Bareel1Bin6SetWeight = 0;
break;
case 7:
PlcWrite.Bareel1Bin7SetWeight = 0;
break;
case 8:
PlcWrite.Bareel1Bin8SetWeight = 0;
break;
case 9:
PlcWrite.Bareel1Bin9SetWeight = 0;
break;
case 10:
PlcWrite.Bareel1Bin10SetWeight = 0;
break;
case 11:
PlcWrite.Bareel1Bin11SetWeight = 0;
break;
case 12:
PlcWrite.Bareel1Bin12SetWeight = 0;
break;
case 13:
PlcWrite.Bareel1Bin13SetWeight = 0;
break;
case 14:
PlcWrite.Bareel1Bin14SetWeight = 0;
break;
default:
break;
}

string address = "DB99.DBD" + (6 + 4 * (loc - 1));
HK_PLC_S7.Write(address, 0);
break;
case 2:
switch (loc)
{
case 1:
PlcWrite.Bareel2Bin1SetWeight = 0;
break;
case 2:
PlcWrite.Bareel2Bin2SetWeight = 0;
break;
case 3:
PlcWrite.Bareel2Bin3SetWeight = 0;
break;
case 4:
PlcWrite.Bareel2Bin4SetWeight = 0;
break;
case 5:
PlcWrite.Bareel2Bin5SetWeight = 0;
break;
case 6:
PlcWrite.Bareel2Bin6SetWeight = 0;
break;
case 7:
PlcWrite.Bareel2Bin7SetWeight = 0;
break;
case 8:
PlcWrite.Bareel2Bin8SetWeight = 0;
break;
case 9:
PlcWrite.Bareel2Bin9SetWeight = 0;
break;
case 10:
PlcWrite.Bareel2Bin10SetWeight = 0;
break;
case 11:
PlcWrite.Bareel2Bin11SetWeight = 0;
break;
case 12:
PlcWrite.Bareel2Bin12SetWeight = 0;
break;
case 13:
PlcWrite.Bareel2Bin13SetWeight = 0;
break;
case 14:
PlcWrite.Bareel2Bin14SetWeight = 0;
break;
default:
break;
}

string address1 = "DB99.DBD" + (62 + 4 * (loc - 1));
HK_PLC_S7.Write(address1, 0);
break;
case 4:
switch (loc)
{
case 1:
PlcWrite.Bareel4Bin1SetWeight = 0;
break;
case 2:
PlcWrite.Bareel4Bin2SetWeight = 0;
break;
case 3:
PlcWrite.Bareel4Bin3SetWeight = 0;
break;
case 4:
PlcWrite.Bareel4Bin4SetWeight = 0;
break;
case 5:
PlcWrite.Bareel4Bin5SetWeight = 0;
break;
case 6:
PlcWrite.Bareel4Bin6SetWeight = 0;
break;
case 7:
PlcWrite.Bareel4Bin7SetWeight = 0;
break;
case 8:
PlcWrite.Bareel4Bin8SetWeight = 0;
break;
case 9:
PlcWrite.Bareel4Bin9SetWeight = 0;
break;
case 10:
PlcWrite.Bareel4Bin10SetWeight = 0;
break;
case 11:
PlcWrite.Bareel4Bin11SetWeight = 0;
break;
case 12:
PlcWrite.Bareel4Bin12SetWeight = 0;
break;
case 13:
PlcWrite.Bareel4Bin13SetWeight = 0;
break;
case 14:
PlcWrite.Bareel4Bin14SetWeight = 0;
break;
default:
break;
}

string address2 = "DB99.DBD" + (118 + 4 * (loc - 1));
HK_PLC_S7.Write(address2, 0);
break;
case 5:
switch (loc)
{
case 1:
PlcWrite.Bareel5Bin1SetWeight = 0;
break;
case 2:
PlcWrite.Bareel5Bin2SetWeight = 0;
break;
case 3:
PlcWrite.Bareel5Bin3SetWeight = 0;
break;
case 4:
PlcWrite.Bareel5Bin4SetWeight = 0;
break;
case 5:
PlcWrite.Bareel5Bin5SetWeight = 0;
break;
case 6:
PlcWrite.Bareel5Bin6SetWeight = 0;
break;
case 7:
PlcWrite.Bareel5Bin7SetWeight = 0;
break;
case 8:
PlcWrite.Bareel5Bin8SetWeight = 0;
break;
case 9:
PlcWrite.Bareel5Bin9SetWeight = 0;
break;
case 10:
PlcWrite.Bareel5Bin10SetWeight = 0;
break;
case 11:
PlcWrite.Bareel5Bin11SetWeight = 0;
break;
case 12:
PlcWrite.Bareel5Bin12SetWeight = 0;
break;
case 13:
PlcWrite.Bareel5Bin13SetWeight = 0;
break;
case 14:
PlcWrite.Bareel5Bin14SetWeight = 0;
break;
default:
break;
}

string address3 = "DB99.DBD" + (174 + 4 * (loc - 1));
HK_PLC_S7.Write(address3, 0);
break;
default:
break;
@@ -273,204 +97,20 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
switch (barrel)
{
case 1:
switch (loc)
{
case 1:
PlcWrite.Bareel1Bin1SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 2:
PlcWrite.Bareel1Bin2SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 3:
PlcWrite.Bareel1Bin3SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 4:
PlcWrite.Bareel1Bin4SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 5:
PlcWrite.Bareel1Bin5SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 6:
PlcWrite.Bareel1Bin6SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 7:
PlcWrite.Bareel1Bin7SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 8:
PlcWrite.Bareel1Bin8SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 9:
PlcWrite.Bareel1Bin9SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 10:
PlcWrite.Bareel1Bin10SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 11:
PlcWrite.Bareel1Bin11SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 12:
PlcWrite.Bareel1Bin12SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 13:
PlcWrite.Bareel1Bin13SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 14:
PlcWrite.Bareel1Bin14SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
default:
break;
}

string address = "DB99.DBD" + (6 + 4 * (loc - 1));
HK_PLC_S7.Write(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
break;
case 2:
switch (loc)
{
case 1:
PlcWrite.Bareel2Bin1SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 2:
PlcWrite.Bareel2Bin2SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 3:
PlcWrite.Bareel2Bin3SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 4:
PlcWrite.Bareel2Bin4SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 5:
PlcWrite.Bareel2Bin5SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 6:
PlcWrite.Bareel2Bin6SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 7:
PlcWrite.Bareel2Bin7SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 8:
PlcWrite.Bareel2Bin8SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 9:
PlcWrite.Bareel2Bin9SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 10:
PlcWrite.Bareel2Bin10SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 11:
PlcWrite.Bareel2Bin11SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 12:
PlcWrite.Bareel2Bin12SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 13:
PlcWrite.Bareel2Bin13SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 14:
PlcWrite.Bareel2Bin14SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
default:
break;
}

string address1 = "DB99.DBD" + (62 + 4 * (loc - 1));
HK_PLC_S7.Write(address1, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
break;
case 4:
switch (loc)
{
case 1:
PlcWrite.Bareel4Bin1SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 2:
PlcWrite.Bareel4Bin2SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 3:
PlcWrite.Bareel4Bin3SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 4:
PlcWrite.Bareel4Bin4SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 5:
PlcWrite.Bareel4Bin5SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 6:
PlcWrite.Bareel4Bin6SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 7:
PlcWrite.Bareel4Bin7SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 8:
PlcWrite.Bareel4Bin8SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 9:
PlcWrite.Bareel4Bin9SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 10:
PlcWrite.Bareel4Bin10SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 11:
PlcWrite.Bareel4Bin11SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 12:
PlcWrite.Bareel4Bin12SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 13:
PlcWrite.Bareel4Bin13SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 14:
PlcWrite.Bareel4Bin14SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
default:
break;
}

string address2 = "DB99.DBD" + (118 + 4 * (loc - 1));
HK_PLC_S7.Write(address2, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
break;
case 5:
switch (loc)
{
case 1:
PlcWrite.Bareel5Bin1SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 2:
PlcWrite.Bareel5Bin2SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 3:
PlcWrite.Bareel5Bin3SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 4:
PlcWrite.Bareel5Bin4SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 5:
PlcWrite.Bareel5Bin5SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 6:
PlcWrite.Bareel5Bin6SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 7:
PlcWrite.Bareel5Bin7SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 8:
PlcWrite.Bareel5Bin8SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 9:
PlcWrite.Bareel5Bin9SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 10:
PlcWrite.Bareel5Bin10SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 11:
PlcWrite.Bareel5Bin11SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 12:
PlcWrite.Bareel5Bin12SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 13:
PlcWrite.Bareel5Bin13SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
case 14:
PlcWrite.Bareel5Bin14SetWeight = recipe.RawMaterial.ElementAt(index).RawMaterialWeight;
break;
default:
break;
}

string address3 = "DB99.DBD" + (174 + 4 * (loc - 1));
HK_PLC_S7.Write(address3, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
break;
default:
break;


+ 64
- 0
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcReadAddressDB45.cs View File

@@ -0,0 +1,64 @@
using BPASmartClient.S7Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
public class PlcReadAddressDB45
{
[Siemens(16)]
public string RecipeCode { get; set; }
[Siemens(16)]
public string RecipeName { get; set; }
/// <summary>
/// 缺料本机
/// </summary>
public bool DeviceInComplete { get; set; }
/// <summary>
/// 上游缺料
/// </summary>
public bool TopInComple { get; set; }
/// <summary>
/// 下游堵料
/// </summary>
public bool DownWindrow { get; set; }
/// <summary>
/// 设备启动
/// </summary>
public bool DeviceStart { get; set; }
/// <summary>
/// 设备停止
/// </summary>
public bool DeviceStop { get; set; }
/// <summary>
/// 设备急停
/// </summary>
public bool DeviceEStop { get; set; }
/// <summary>
/// 设备暂停
/// </summary>
public bool DevicePause { get; set; }
/// <summary>
/// 设备故障
/// </summary>
public bool DeviceAlarm { get; set; }
/// <summary>
/// 上位机给plc的心跳
/// </summary>
public bool HeartBeat { get; set; }
/// <summary>
/// 设备模式
/// </summary>
public short DeviceMode { get; set; }
/// <summary>
/// 设备报警
/// </summary>
public bool[] AlarmInfo { get; set; } = new bool[24];
public int Reserved1 { get; set; }
public int Reserved2 { get; set; }

}
}

+ 382
- 100
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -31,7 +31,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// 本地配方数据
/// </summary>
public ObservableCollection<RecipeData> LocalRecipes = new ObservableCollection<RecipeData>();

/// <summary>
/// 配方等待执行
/// </summary>
@@ -108,8 +107,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP);
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (HKDevice.IsConnected)
{
HKDevice.Init();
@@ -125,6 +124,91 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{

}
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (!HKDevice.IsConnected)
{
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP);
MessageNotify.GetInstance.ShowRunLog("海科plc重新连接成功");
}
if (!SiemensDevice.IsConnected)
{
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
MessageNotify.GetInstance.ShowRunLog("西门子plc重新连接");
}
GVL_BigStation.HeartBeatToPlc = !GVL_BigStation.HeartBeatToPlc;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.0", GVL_BigStation.HeartBeatToPlc);
GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳
if (HKDevice.IsConnected)
{
if (GVL_BigStation.AGVPutTray.GetBitValue(1))
{
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", true);
}
else
{
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false);
}
if (GVL_BigStation.AGVPutTray.GetBitValue(2))
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", true);
}
else
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false);
}
if (GVL_BigStation.AGVPutTray.GetBitValue(3))
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", true);
}
else
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false);
}
if (GVL_BigStation.AGVPutTray.GetBitValue(4))
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", true);
}
else
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false);
}
if (GVL_BigStation.AGVPutTray.GetBitValue(5))
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", true);
}
else
{
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false);
}

GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(1, HKDevice.PlcRead.Tray1Sensor);
GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(2, HKDevice.PlcRead.Tray2Sensor);
GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(3, HKDevice.PlcRead.Tray3Sensor);
GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(4, HKDevice.PlcRead.Tray4Sensor);
GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(5, HKDevice.PlcRead.Tray5Sensor);
GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(1, !HKDevice.PlcRead.Tray1Cylinder);
GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(2, !HKDevice.PlcRead.Tray2Cylinder);
GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(3, !HKDevice.PlcRead.Tray3Cylinder);
GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(4, !HKDevice.PlcRead.Tray4Cylinder);
GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(5, !HKDevice.PlcRead.Tray5Cylinder);
if (HKDevice.PlcRead.IsAllowIssueRecipe1 || HKDevice.PlcRead.IsAllowIssueRecipe2 || HKDevice.PlcRead.IsAllowIssueRecipe3 || HKDevice.PlcRead.IsAllowIssueRecipe4)
{
GVL_BigStation.Order_Request = true;
}
}
if (SiemensDevice.IsConnected)
{
GVL_BigStation.AGVPutTray = SiemensDevice.DL_Status.AGV_Put_Done;
GVL_BigStation.AGVGetTray = SiemensDevice.DL_Status.AGV_Get_Done;
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW30", GVL_BigStation.TraySensor);
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW32", GVL_BigStation.TrayCylinder);
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW34", (ushort)15);
}
Thread.Sleep(10);
}),"设备连接",true);


LocalRecipeQueue1.Clear();
LocalRecipeQueue2.Clear();
LocalRecipeQueue3.Clear();
@@ -134,20 +218,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model
SiemensRecipeQueue3.Clear();
SiemensRecipeQueue4.Clear();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "西门子配方执行流程", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (GVL_BigStation.IsUseLocalRecipe)
{
LocalRecipeRecevice();
LocalRecipeDosing();
}
else
{
ReceviceData();
RecipeInfoToHKPLC();
}
Thread.Sleep(10);
}), "本地配方执行流程", true);
}), "西门子配方执行流程", true);
}
private void LocalRecipeRecevice()
{
@@ -202,27 +285,72 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (LocalRecipeQueue1.Count > 0)
{
int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue1.ElementAt(0));
foreach (var item in LocalRecipes.ElementAt(0).RawMaterial)
{
item.RawMaterialLocation = (int)RawMaterialsNamePos[item.RawMaterialName];
}
if (index >= 0 && index < LocalRecipes.Count)
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe1IssuedFinish = true;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1)
{
GVL_BigStation.Recipe1DosingStatus = 2;
HKDevice.PlcWrite.Recipe1IssuedFinish = false;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
}
if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
{
GVL_BigStation.Recipe1DosingStatus = 3;
GVL_BigStation.Recipe1DosingStatus = 3;
switch (trayCode)
{
case 1:
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false);
break;
case 2:
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false);
break;
case 3:
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false);
break;
case 4:
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false);
break;
case 5:
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false);
break;
default:
break;
}
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe1TrayCode == 1)
{
@@ -303,17 +431,38 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 &&Inplace)//配方2是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe2IssuedFinish = true;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true);
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1)
{
GVL_BigStation.Recipe2DosingStatus = 2;
HKDevice.PlcWrite.Recipe2IssuedFinish = false;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
@@ -400,16 +549,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1));
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2));
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3));
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4));
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5));
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe3IssuedFinish = true;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true);
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1)
{
GVL_BigStation.Recipe3DosingStatus = 2;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
@@ -497,17 +673,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe4IssuedFinish = true;
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1));
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2));
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3));
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4));
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5));
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 && Inplace)//配方4是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true);
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1)
{
GVL_BigStation.Recipe4DosingStatus = 2;
HKDevice.PlcWrite.Recipe4IssuedFinish = false;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
@@ -747,17 +949,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1));
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2));
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3));
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4));
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5));
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0&&Inplace)//配方1是否允许下发配发
{
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe1IssuedFinish = true;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true);
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1)
{
GVL_BigStation.Recipe1DosingStatus = 2;
HKDevice.PlcWrite.Recipe1IssuedFinish = false;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
}
@@ -871,17 +1099,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe2IssuedFinish = true;
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1));
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2));
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3));
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4));
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5));
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 &&Inplace)//配方2是否允许下发配发
{
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true);
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1)
{
GVL_BigStation.Recipe2DosingStatus = 2;
HKDevice.PlcWrite.Recipe2IssuedFinish = false;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
@@ -989,16 +1243,44 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1));
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2));
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3));
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4));
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5));
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发
{
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe3IssuedFinish = true;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true);
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1)
{
GVL_BigStation.Recipe3DosingStatus = 2;

HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
@@ -1106,17 +1388,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发
bool Inplace = false;
switch (trayCode)
{
case 1:
Inplace = HKDevice.PlcRead.Tray1InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1));
break;
case 2:
Inplace = HKDevice.PlcRead.Tray2InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2));
break;
case 3:
Inplace = HKDevice.PlcRead.Tray3InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3));
break;
case 4:
Inplace = HKDevice.PlcRead.Tray4InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4));
break;
case 5:
Inplace = HKDevice.PlcRead.Tray5InPlace;
HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5));
break;
default:
break;
}
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 &&Inplace)//配方4是否允许下发配发
{
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe4IssuedFinish = true;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true);
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1)
{
GVL_BigStation.Recipe4DosingStatus = 2;
HKDevice.PlcWrite.Recipe4IssuedFinish = false;
HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false);
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
@@ -1223,73 +1531,47 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
private void StockBinParReset()
{
HKDevice.PlcWrite.RecipeCode = 0;
HKDevice.PlcWrite.TrayCode = 0;

HKDevice.PlcWrite.Bareel1Bin1SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin2SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin3SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin4SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin5SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin6SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin7SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin8SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin9SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin10SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin11SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin12SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin13SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin14SetWeight = 0;

HKDevice.PlcWrite.Bareel2Bin1SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin2SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin3SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin4SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin5SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin6SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin7SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin8SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin9SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin10SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin11SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin12SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin13SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin14SetWeight = 0;

HKDevice.PlcWrite.Bareel4Bin1SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin2SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin3SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin4SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin5SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin6SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin7SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin8SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin9SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin10SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin11SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin12SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin13SetWeight = 0;
HKDevice.PlcWrite.Bareel4Bin14SetWeight = 0;

HKDevice.PlcWrite.Bareel5Bin1SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin2SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin3SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin4SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin5SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin6SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin7SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin8SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin9SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin10SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin11SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin12SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0;
HKDevice.HK_PLC_S7.Write("DB99.DBW2.0", 0);//
HKDevice.HK_PLC_S7.Write("DB99.DBW4.0", 0);
for (int i = 0; i < 56; i++)
{
string address2 = "DB99.DBD" + (6 + 4 * i);
HKDevice.HK_PLC_S7.Write(address2, 0);
}
}
private void testRawMaterialNameData()
{
RawMaterialsNamePos.Clear();
if (!HKDevice.IsConnected)
RawMaterialsNamePos.Add("0031", 1);
RawMaterialsNamePos.Add("0040", 2);
RawMaterialsNamePos.Add("0007", 3);
RawMaterialsNamePos.Add("0038", 4);
RawMaterialsNamePos.Add("0033", 5);
RawMaterialsNamePos.Add("0005", 6);
RawMaterialsNamePos.Add("0015", 7);
RawMaterialsNamePos.Add("0008", 8);
RawMaterialsNamePos.Add("0010", 9);
RawMaterialsNamePos.Add("0014", 10);
RawMaterialsNamePos.Add("0030", 11);
RawMaterialsNamePos.Add("0012", 12);
if (HKDevice.IsConnected)
{
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName1)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName2)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName2)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName2, 2);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName3)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName3)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName3, 3);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName4)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName4)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName4, 4);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName5)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName5)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName5, 5);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName6)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName6)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName6, 6);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName7)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName7)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName7, 7);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName8)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName8)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName8, 8);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName9)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName9)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName9, 9);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName10)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName10)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName10, 10);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName11)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName11)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName11, 11);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName12)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName12)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName12, 12);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName13)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName13)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName13, 13);
if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName14)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14);
}
/*if (!HKDevice.IsConnected)
{
RawMaterialsNamePos.Add("0005", 1);
RawMaterialsNamePos.Add("0006", 2);
@@ -1323,8 +1605,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RawMaterialsNamePos.Add("0034", 14);
RawMaterialsNamePos.Add("0035", 14);
RawMaterialsNamePos.Add("0040", 14);
}
/*
}*/
/*
HKDevice.StockBinName.RawMaterialName1 = "1";
HKDevice.StockBinName.RawMaterialName2 = "2";
HKDevice.StockBinName.RawMaterialName3 = "3";


+ 2
- 2
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs View File

@@ -10,9 +10,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
public class DL_DataColl_DB
{
[Siemens(16)]
public string RecipeCode { get; set; }
public string RecipeCode { get; set; } = "";
[Siemens(16)]
public string RecipeName { get; set; }
public string RecipeName { get; set; } = "";
/// <summary>
/// 缺料本机
/// </summary>


+ 1
- 1
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Finish_DB
public class DL_Finish_DB
{

/// <summary>


+ 7
- 7
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs View File

@@ -18,12 +18,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
/// </summary>
public bool AGV_Request_Put { get; set; }
public bool AGV_Request_Get { get; set; }
public short AGV_Put_Done { get; set; }
public ushort AGV_Put_Done { get; set; }

public short AGV_Get_Done { get; set; }
public ushort AGV_Get_Done { get; set; }

public short AGV_GetPut_Pos { get; set; }
public short[] Standby { get; set; } = new short[1];
public ushort AGV_GetPut_Pos { get; set; }
public ushort[] Standby { get; set; } = new ushort[1];
[Siemens(16)]
/// <summary>
/// 生产工单
@@ -40,10 +40,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens

public bool Allow_Agv_Get_Empty { get; set; }

public short Pallet_Position_Occ { get; set; }
public ushort Pallet_Position_Occ { get; set; }

public short Dosing_Cancel9 { get; set; }
public ushort Dosing_Cancel9 { get; set; }

public short[] Standby2 { get; set; } = new short[3];
public ushort[] Standby2 { get; set; } = new ushort[3];
}
}

+ 12
- 6
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs View File

@@ -19,14 +19,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
bool a = false;
public void Init()
{
if (IsConnected)
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ThreadManage.GetInstance().StartLong(new Action(() =>
if (IsConnected)
{
var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(2301);
var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2331);
var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(2361);
var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391);
//var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391);
if (res != null && res is DL_Start_DB start)
{
if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request) && GVL_BigStation.SiemensSendRecipeStatus == 0)
@@ -34,7 +34,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
GVL_BigStation.SiemensSendRecipeStatus = 1;
this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true);
}
if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1)
if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1)
{
GVL_BigStation.SiemensSendRecipeStatus = 2;
ActionManage.GetInstance.Send("SiemensSendRecipe", start);
@@ -68,8 +68,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
}
}
Thread.Sleep(10);
}), "监听服务数据");
}
var dataColl = ProcessControl.GetInstance.HKDevice.DataColl;
if (dataColl != null && dataColl is DL_DataColl_DB data)
{
Siemens_PLC_S7.WriteClass<DL_DataColl_DB>(data, 2391);
}
}
Thread.Sleep(10);
}), "监听服务数据");
}
}
}

+ 2
- 1
BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml View File

@@ -17,6 +17,7 @@
<RowDefinition />
</Grid.RowDefinitions>
<!--#region 表格标题栏设置-->
<Grid
Grid.Row="0"
Margin="0,10,0,0"
@@ -126,7 +127,7 @@
<pry:IcoButton
Width="100"
Command="{Binding DataContext.SetValueCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding SetValue}"
CommandParameter="{Binding Address}"
Grid.Column="0"
Margin="50,5,50,5"
Content="设置"


+ 88
- 0
BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml View File

@@ -0,0 +1,88 @@
<UserControl x:Class="BPASmartClient.JXJFoodBigStation.View.ManualFlowView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920">
<UserControl.DataContext>
<vm:ManualFlowViewModel />
</UserControl.DataContext>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<!--#region 表格标题栏设置-->
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="left" VerticalAlignment="Center">
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Tray1InPlace}"
Content="AGV到达工位1"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Tray2InPlace}"
Content="AGV到达工位2"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Tray3InPlace}"
Content="AGV到达工位3"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Tray4InPlace}"
Content="AGV到达工位4"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Tray5InPlace}"
Content="AGV到达工位5"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding ClearTrayInPlace}"
Content="清楚AGV到位信号"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<WrapPanel>
<TextBlock Text="心跳:" Foreground="#FF2AB2E7" FontSize="25" Margin="10,0,5,0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding Heartbeat}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF2AB2E7" FontSize="25" Margin="10"></TextBlock>
</WrapPanel>
</Grid>
</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml.cs View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.JXJFoodBigStation.View
{
/// <summary>
/// HKPlcCommMonitor.xaml 的交互逻辑
/// </summary>
public partial class ManualFlowView : UserControl
{
public ManualFlowView()
{
InitializeComponent();
}
}
}

+ 14
- 17
BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs View File

@@ -17,7 +17,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
public class HKPlcCommMonitorViewModel:ObservableObject
{
HKDeviceStatus DeviceStatus = new HKDeviceStatus();
public HKPlcCommMonitorViewModel()
{
Type type = typeof(DB_Read);
@@ -28,24 +27,23 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
foreach (PropertyInfo mi in properties)
{
PropertyInfo a = DeviceStatus.PlcRead.GetType().GetProperty(mi.Name);
object ab = a.GetValue(DeviceStatus.PlcRead, null);

int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Describe == mi.Name);
PropertyInfo a = GVL_BigStation.HKPlc_Read.GetType().GetProperty(mi.Name);
object ab = a.GetValue(GVL_BigStation.HKPlc_Read, null);
int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Variable == mi.Name);
if (index != -1)
{
PlcInfo.ElementAt(index).NowValue = ab.ToString();
}
}
Thread.Sleep(10);
}), "plc变量读取");
Thread.Sleep(100);
}), "plc变量读取",true);
foreach (PropertyInfo mi in properties)
{
PropertyInfo a = DeviceStatus.PlcRead.GetType().GetProperty(mi.Name);
object ab = a.GetValue(DeviceStatus.PlcRead, null);
PropertyInfo a = GVL_BigStation.HKPlc_Read.GetType().GetProperty(mi.Name);
object ab = a.GetValue(GVL_BigStation.HKPlc_Read, null);
if (mi.PropertyType.Name == "Int16")
{
addressPos = "DBD";
addressPos = "DBW";
Offset = Math.Ceiling(Offset);
if (Offset / 2.0 - Math.Floor(Offset / 2.0) > 0.0)
{
@@ -70,7 +68,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
Offset += 1.0;
}
}
var num = DeviceStatus.PlcRead;
var num = GVL_BigStation.HKPlc_Read;
var res = a.GetCustomAttribute<PlcCommAttribute>();
string describe = "";
if (res != null)
@@ -107,15 +105,16 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel

SetValueCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is String setValue)
/*if (o != null && o is String address)
{
int index = Array.FindIndex(PlcInfo.ToArray(), p => p.SetValue == setValue);
int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Address == address);
if (index != -1)
{
DeviceStatus.HK_PLC_S7.Write(PlcInfo.ElementAt(index).Address, setValue);
if(ProcessControl.GetInstance.HKDevice.IsConnected) ProcessControl.GetInstance.HKDevice.HK_PLC_S7.Write(address , PlcInfo.ElementAt(index).SetValue);
}
}
}*/
});
}
/*public static string GetPropertyValue<T>( T t,string PropertyName)
{
@@ -125,7 +124,5 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
public ObservableCollection<PlcVarMonitor> PlcInfo { get; set; } = new ObservableCollection<PlcVarMonitor>();

public RelayCommand<object> SetValueCommand { get; set; }

public RelayCommand Connect { get; set; }
}
}

+ 61
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs View File

@@ -0,0 +1,61 @@
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
public class ManualFlowViewModel:ObservableObject
{
public ManualFlowViewModel()
{
Tray1InPlace = new RelayCommand(() =>
{
GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(1, true);
});
Tray2InPlace = new RelayCommand(() =>
{
GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(2, true);
});
Tray3InPlace = new RelayCommand(() =>
{
GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(3, true);
});
Tray4InPlace = new RelayCommand(() =>
{
GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(4, true);
});
Tray5InPlace = new RelayCommand(() =>
{
GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(5, true);
});
ClearTrayInPlace = new RelayCommand(() =>
{
GVL_BigStation.AGVPutTray = 0;
});
ThreadManage.GetInstance().StartLong(new Action(() =>
{
Heartbeat = GVL_BigStation.HeartBeatFromPlc;
Thread.Sleep(100);
}), "设备状态读取",true);
}
public RelayCommand Tray1InPlace { get; set; }
public RelayCommand Tray2InPlace { get; set; }
public RelayCommand Tray3InPlace { get; set; }
public RelayCommand Tray4InPlace { get; set; }
public RelayCommand Tray5InPlace { get; set; }
public RelayCommand ClearTrayInPlace { get; set; }
public bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnPropertyChanged(); } }
private bool _mHeartbeat;
}
}

+ 3
- 2
BPASmartClient.JXJFoodSmallStation/App.config View File

@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="HKPlc_IP" value="192.168.0.15"/>
<add key="RawMaterial_IP" value="107.107.2."/>
<add key="HKPlc_IP" value="107.107.2.88"/>
<add key="Siemens_IP" value="107.107.2.200"/>
<add key="WindSend_IP" value="192.168.0.40"/>
<add key="WindSend_IP" value="107.107.2.90"/>
</appSettings>
</configuration>

+ 21
- 2
BPASmartClient.JXJFoodSmallStation/App.xaml.cs View File

@@ -14,6 +14,7 @@ using BPASmartClient.CustomResource.Pages.ViewModel;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
using System.Threading;

namespace BPASmartClient.JXJFoodSmallStation
{
@@ -23,12 +24,22 @@ namespace BPASmartClient.JXJFoodSmallStation
public partial class App : Application
{
public static Window MainWindow;
public EventWaitHandle ProgramStarted { get; set; }
protected override void OnStartup(StartupEventArgs e)
{
bool createNew;
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "SmallStationApp", out createNew);
if (!createNew)
{
MessageBox.Show("程序已启动");
App.Current.Shutdown();
Environment.Exit(0);
}
BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
base.OnStartup(e);
MenuInit();
DataInit();
//DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
MainView mv = new MainView();
ProcessControl.GetInstance.Init();
LoginView lv = new LoginView();
@@ -139,7 +150,15 @@ namespace BPASmartClient.JXJFoodSmallStation
ToggleWindowPath = "View.ManualCommView"

});
ManualControl.Add(new SubMenumodel()
{
SubMenuName = "手动控制流程",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.ManualFlowView"

});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe622;",
@@ -232,7 +251,7 @@ namespace BPASmartClient.JXJFoodSmallStation
UserManager.Add(new SubMenumodel()
{
SubMenuName = "密码修改",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.PasswordChangeView"
});


+ 10
- 0
BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj View File

@@ -19,6 +19,12 @@
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="View\ManualFlowView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
<Page Update="View\ChangeDeviceNameView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
@@ -30,6 +36,10 @@
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\ManualFlowView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\SiemensRecipeReceiveView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>


+ 50
- 31
BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs View File

@@ -14,12 +14,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private volatile static GVL_SmallStation SmallStation;
public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation());
private GVL_SmallStation() { }
/// <summary>
/// 托盘1托盘到位 逻辑完成
/// </summary>
public static bool TrayLogicFinish { get; set; } = false;
/// <summary>
/// 托盘1有货架
/// </summary>
public static bool Station1HaveTray { get; set; }
/// <summary>
/// 托盘2有货架
/// </summary>
public static bool Station2HaveTray { get; set; }

public static bool Station1Sensor { get; set; }
/// <summary>
/// 托盘2传感器信号
/// </summary>
public static bool Station2Sensor { get; set; }
public static bool Station1Cylinder { get; set; }
/// <summary>
/// 托盘2气缸信号
/// </summary>
public static bool Station2Cylinder { get; set; }

public static bool AGV_PutTray1Finish { get; set; }
public static bool AGV_GetTray1Finish { get; set; }
public static bool CylinderReset { get; set; }
/// <summary>
/// 配料站料仓数目
/// </summary>
public const int Max_DosingSotckBinNum = 15;

/// <summary>
/// 风送料仓数目
/// </summary>
@@ -38,43 +63,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// 往输送带下发配方完成
/// </summary>
public bool IssueRecipeFinishStation1 { get; set; } = false;

/// <summary>
/// 往输送带下发配方完成
/// </summary>
public bool IssueRecipeFinishStation2 { get; set; } = false;
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusID { get; set; } = 0;

/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusIDTray2 { get; set; } = 0;

/// <summary>
/// Tray1的柔性味魔方配料标志(下发配方时,若柔性味魔方的状态=3,复位该状态)
/// </summary>
public bool DosingTray1 { get; set; } = true;//默认为true,初始时,判断柔性味魔方的状态。
public bool DosingTray1 { get; set; } = false;//默认为true,初始时,判断柔性味魔方的状态。
/// <summary>
/// Tray2的柔性味魔方配料标志
/// </summary>
public bool DosingTray2 { get; set; } = true;
public bool DosingTray2 { get; set; } = false;

public int DosingTray1Loc { get; set; } = 0;
public int DosingTray2Loc { get; set; } = 0;
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusIDTray2 { get; set; } = 0;
/// <summary>
/// 往输送带下发配方完成
/// </summary>
public bool IssueRecipeFinishStation2 { get; set; } = false;

public bool IsAllow { get; set; } = false;

public bool IsAllowOut { set; get; } = false;
/// <summary>
/// 当前料仓的位置
/// </summary>
public int StockInIsWork { get; set; } = 0;
/// <summary>
/// 单个配方执行完成标志
/// </summary>
public bool RecipeFinish { get; set; } = false;

/// <summary>
/// 记录AGV进站送货的指令顺序
@@ -88,20 +106,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// <summary>
/// 是否使用粉仓
/// </summary>
public bool IsUseWindSend;
public bool IsUseWindSend { get; set; } = false;
/// <summary>
/// 风送配料完成标志
/// </summary>
public bool WindSendDosingFinish;

/// <summary>
/// 是否占用托盘1
/// </summary>
public bool IsOccupationTray1 { get; set; } = true;
/// <summary>
/// 是否占用托盘2
/// </summary>
public bool IsOccupationTray2 { get; set; } = true;
public bool WindSendDosingFinish { get; set; } = false;

/// <summary>
/// 顶升气缸的信号
@@ -118,6 +127,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
public bool IsUseWindSendDosing { get; set; }
public static int test1 = 1;
public DateTime time1;
/// <summary>
/// 风送是否允许AGV到工站
/// </summary>
public static bool WindSendAllowAGVPutGet { get; set; } = false;
/// <summary>
/// 粉料仓配料完成
/// </summary>
public static bool WindSendDosingComple { get; set; } = false;
#endregion
}
}

+ 9
- 9
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -15,20 +15,20 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
public SiemensHelper HK_PLC_S7 = new SiemensHelper();
public bool IsConnected => HK_PLC_S7.IsConnected;
public PlcReadAddressDB45 DeviceStatus = new PlcReadAddressDB45();
public void Init()
{
if (IsConnected)
ThreadManage.GetInstance().StartLong(new Action(() =>
{
/*ThreadManage.GetInstance().StartLong(new Action(() =>
if (IsConnected)
{
if (!IsConnected)
var res = this.HK_PLC_S7.ReadClass<PlcReadAddressDB45>(45);
if ( res != null && res is PlcReadAddressDB45 data)
{
MessageLog.GetInstance.ShowRunLog("海科PLC断开连接");
DeviceStatus = data;
}
Thread.Sleep(10);
}),"信号收发处理");*/
}
}
}),"海科PLC设备状态",true);
}
/// <summary>
/// 单个配料机配料完成
@@ -68,7 +68,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
/// </summary>
/// <param name="BarrelNum">单个桶的编号</param>
/// <param name="StockBinLocation">单个桶对应的料仓位置</param>
public void StockBinPar(uint BarrelNum, ushort StockBinLocation, int TrayNum = 1)
public void StockBinPar(uint BarrelNum, ushort StockBinLocation, int TrayNum = 1)
{
if (IsConnected)
{


+ 58
- 0
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB45.cs View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
public class PlcReadAddressDB45
{
/// <summary>
/// 通信心跳 DB45.DBX0.0
/// </summary>
public bool HeartBeat { get; set; }
/// <summary>
/// 设备运行 DB45.DBX0.1
/// </summary>
public bool DeviceRun { get; set; }
/// <summary>
/// 设备停止 DB45.DBX0.2
/// </summary>
public bool DeviceStop { get; set; }
/// <summary>
/// 设备急停 DB45.DBX0.3
/// </summary>
public bool DeviceEStop { get; set; }
/// <summary>
/// 设备暂停 DB45.DBX0.4
/// </summary>
public bool DevicePause { get; set; }
/// <summary>
/// 设备故障 DB45.DBX0.5
/// </summary>
public bool DeviceAlarm { get; set; }
/// <summary>
/// 料仓缺料 DB45.DBX0.6
/// </summary>
public bool StockBin { get; set; }
/// <summary>
/// 上游缺料 DB45.DBX0.7
/// </summary>
public bool Top { get; set; }
/// <summary>
/// 上游缺料 DB45.DBX1.0
/// </summary>
public bool TopDown { get; set; }
/// <summary>
/// 系统模式
/// </summary>
public short Mode { get; set; }
/// <summary>
/// 报警
/// </summary>
public bool[] Alarm { get; set; } = new bool[24];
public int Standby1 { get; set; }
public int Standby2 { get; set; }
}
}

+ 13
- 0
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
public class PlcWriteAddressDB7
{
}
}

+ 337
- 247
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs View File

@@ -43,7 +43,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// <summary>
/// 风送PLC的DB块
/// </summary>
XL_WindSendData_DB WindSendData = new XL_WindSendData_DB();
WindSend_Write WindSendData = new WindSend_Write();
/// <summary>
/// 接收原料数据
/// </summary>
@@ -51,7 +51,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public void Init()
{
testData();
Json<RemoteRecipeDataColl>.Data.Recipes = Json<LocalRecipeDataColl>.Data.Recipes;
//Json<RemoteRecipeDataColl>.Data.Recipes = Json<LocalRecipeDataColl>.Data.Recipes;
for (int i = 0; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)
@@ -156,11 +156,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}), "SiemensRecipeFinish", true);
ActionManage.GetInstance.CancelRegister("WindSendDosingFinish");
ActionManage.GetInstance.Register(new Action(() =>
{
GVL_SmallStation.GetInstance.WindSendDosingFinish = true;
}),"WindSendDosingFinish",true);
ActionManage.GetInstance.CancelRegister("LocalSimulationRecipeIssue");
ActionManage.GetInstance.Register(new Action<Object>((res) =>
{
@@ -172,11 +167,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
string WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"];
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
//WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200,WindSend_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
if (HKDevice.IsConnected)
{
HKDevice.Init();
@@ -187,16 +183,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
SiemensDevice.Init();
MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功,并初始化完成");
}
if (WindSendDevice.IsConnected)
if (WindSendDevice.IsConnected)
{
WindSendDevice.Init();
MessageNotify.GetInstance.ShowRunLog("风送plc连接成功,并初始化完成");
}
}
catch(Exception ex)
catch (Exception ex)
{
}
ThreadManage.GetInstance().StartLong(new Action(() =>
{
/*if (!HKDevice.IsConnected)
{
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接");
if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功");
}
if (!SiemensDevice.IsConnected)
{
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接");
if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功");
}*/
if (!WindSendDevice.IsConnected)
{
WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功");
}
Thread.Sleep(50);
}), "设备连接", true);
ActionManage.GetInstance.CancelRegister("SystemStart");
ActionManage.GetInstance.Register(new Action(() =>
{
@@ -229,28 +245,38 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.1", true);
}), "SystemDebugMode", true);
RecipeQueue.Clear();
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.3", true);
}), "SystemReset", true);
RecipeQueue.Clear();
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.4", true);
}), "CLearRecipeInfo", true);
RecipeQueue.Clear();
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
HeartHKPlc();
if (HKDevice.IsConnected)
{
GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc;
HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc);
GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read<bool>("DB45.DBX0.0");
}
Thread.Sleep(200);
}), "通信心跳", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
DeviceStatusDispose();
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "西门子配发下发流程处理", true);
/* ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (SiemensDevice.IsConnected && HKDevice.IsConnected)
{
*//*AgvGetInDelivery();
AgvGetInPickUp();*//*
}
Thread.Sleep(10);
}), "AGV进站送取货", true);*/
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (HKDevice.IsConnected)
{
//GetStatus();
ManualOpen();
ManualClose();
}
@@ -266,7 +292,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
for (int i = 0; i < 7; i++)
{
GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
}/*
}
/*
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("M10.0", true);
@@ -579,107 +606,111 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
}
/// <summary>
/// AGV进站送货
/// </summary>
private void AgvGetInDelivery()
{
switch (GVL_SmallStation.GetInstance.AgvDeliveryPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApply) is bool))
{
GVL_SmallStation.GetInstance.AgvDeliveryPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApply)))
{
GVL_SmallStation.GetInstance.AgvDeliveryPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
{
GVL_SmallStation.GetInstance.AgvDeliveryPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApplyJack)))
{
GVL_SmallStation.GetInstance.AgvDeliveryPosition = 4;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true);
}
break;
case 4:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVFinsih) is bool))
{
GVL_SmallStation.GetInstance.AgvDeliveryPosition = 5;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true);
}
break;
case 5:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationHaveCargo)))
{
GVL_SmallStation.GetInstance.AgvDeliveryPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
}
break;
default:
break;
}
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistTray));
}
/// <summary>
/// AGV进站取货
///
/// </summary>
private void AgvGetInPickUp()
private void DeviceStatusDispose()
{
switch (GVL_SmallStation.GetInstance.AgvPickUpPosition)
if (HKDevice.IsConnected)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickAGVApply)))
GVL_SmallStation.Station1HaveTray = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX0.7");//工站1 有货架
GVL_SmallStation.Station2HaveTray = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.0");//工站1 有货架
if (RTrig.GetInstance("WindSendDosingCompleToHKPLC").Start(GVL_SmallStation.WindSendDosingComple))
{
GVL_SmallStation.WindSendDosingComple = false;
HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.7", true);
MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号");
}
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))
{
HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.7", false);
}
if (RTrig.GetInstance("DB3.DBX1.7").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.7")) )//允许下配方1或者允许下配方2
{
GVL_SmallStation.IsAllowSiemensSendRecipe = true;
MessageNotify.GetInstance.ShowRunLog("Plc允许下发配方");
}

GVL_SmallStation.Station1Sensor = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.1");
GVL_SmallStation.Station2Sensor = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.2");
GVL_SmallStation.Station1Cylinder = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.3");
GVL_SmallStation.Station2Cylinder = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX2.4");
if (!GVL_SmallStation.TrayLogicFinish)
{
if (GVL_SmallStation.AGV_PutTray1Finish)
{
GVL_SmallStation.GetInstance.AgvPickUpPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true);
HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true);
GVL_SmallStation.AGV_PutTray1Finish = false;
//MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVIsApply)))
if (GVL_SmallStation.Station1HaveTray)
{
GVL_SmallStation.GetInstance.AgvPickUpPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true);
HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false);
GVL_SmallStation.TrayLogicFinish = true;
MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickCargoAGVFinish)))
else
{
GVL_SmallStation.GetInstance.AgvPickUpPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") == true)
{
if (GVL_SmallStation.CylinderReset)
{
HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.5", true);
}
MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
}
else
{
HKDevice.HK_PLC_S7.Write<bool>("DB4.DBX1.5", false);
}
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVFinish)))
}
else
{
if (GVL_SmallStation.AGV_GetTray1Finish)
{
GVL_SmallStation.GetInstance.AgvPickUpPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true);
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.7") == true)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false);
GVL_SmallStation.TrayLogicFinish = false;
GVL_SmallStation.AGV_GetTray1Finish = false;
}
}
break;
default:
break;
}
}
}
private void HeartHKPlc()
{
if (HKDevice.IsConnected)
if (SiemensDevice.IsConnected)
{
GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc;
HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc);
GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX0.0");
short TrayCylinder = 0;
short TraySensor = 0;
if (GVL_SmallStation.Station1Sensor)
{
TraySensor = SetBitValue(TraySensor, 1, true);
}
else
{
TraySensor = SetBitValue(TraySensor, 0, false);
}
if (!GVL_SmallStation.Station1Cylinder)
{
TrayCylinder = SetBitValue(TrayCylinder, 1, true);
}
else
{
TrayCylinder = SetBitValue(TrayCylinder, 0, false);
}
this.SiemensDevice.Siemens_PLC_S7.Write<bool>("DB2231.DBX28.4", GVL_SmallStation.WindSendAllowAGVPutGet);
this.SiemensDevice.Siemens_PLC_S7.Write<short>("DB2231.DBW190", TraySensor);//添加工位传感器的信号
this.SiemensDevice.Siemens_PLC_S7.Write<short>("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号

if (SiemensDevice.XL_Status.AgvFinishPut == 1)
{
GVL_SmallStation.AGV_PutTray1Finish = true;
}
if (SiemensDevice.XL_Status.AgvFinishGet == 1)
{
GVL_SmallStation.AGV_GetTray1Finish = true;
}
}
}
/// <summary>
@@ -687,85 +718,128 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
private void ReceviceData()
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (RemoteRecipes.Count > 0)
if (!GVL_SmallStation.GetInstance.IsUseLocalRecipe)
{
foreach (var data in RemoteRecipes)
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (RemoteRecipes.Count > 0)
{
if (data.TrayCode == 1)
foreach (var data in RemoteRecipes)
{
if (!(RecipeQueue.Contains(data.RecipeCode)))
if (data.TrayCode == 1)
{
if (SiemensDevice.XL_Status is XL_Status_DB status)
if (!(RecipeQueue.Contains(data.RecipeCode)))
{
if (GVL_SmallStation.SiemensSendRecipeStatus == 3)
{
GVL_SmallStation.SiemensSendRecipeStatus = 4;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode,10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0",true);
}
if (GVL_SmallStation.SiemensSendRecipeStatus == 4)
if (SiemensDevice.XL_Status is XL_Status_DB status)
{
if (SiemensDevice.XL_Status.Dosing_Confirm)
if (GVL_SmallStation.SiemensSendRecipeStatus == 3)
{
GVL_SmallStation.SiemensSendRecipeStatus = 5;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
GVL_SmallStation.SiemensSendRecipeStatus = 4;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
}
}
if (GVL_SmallStation.SiemensSendRecipeStatus == 5)
{
if (SiemensDevice.XL_Status.Dosing_Confirm == false)
if (GVL_SmallStation.SiemensSendRecipeStatus == 4)
{
GVL_SmallStation.SiemensSendRecipeStatus = 6;
RecipeQueue.Enqueue(data.RecipeCode);
if (SiemensDevice.XL_Status.Dosing_Confirm)
{
GVL_SmallStation.SiemensSendRecipeStatus = 5;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
}
}
if (GVL_SmallStation.SiemensSendRecipeStatus == 5)
{
if (SiemensDevice.XL_Status.Dosing_Confirm == false)
{
RecipeQueue.Enqueue(data.RecipeCode);
GVL_SmallStation.SiemensSendRecipeStatus = 6;
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列");
}
}

}

}
}
}
else if (data.TrayCode == 2)
{
if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
else if (data.TrayCode == 2)
{
if (SiemensDevice.XL_Status is XL_Status_DB status)
if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
{
if (GVL_SmallStation.SiemensSendRecipeStatus == 3)
if (SiemensDevice.XL_Status is XL_Status_DB status)
{
GVL_SmallStation.SiemensSendRecipeStatus = 4;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
}
if (GVL_SmallStation.SiemensSendRecipeStatus == 4)
{
if (SiemensDevice.XL_Status.Dosing_Confirm)
if (GVL_SmallStation.SiemensSendRecipeStatus == 3)
{
GVL_SmallStation.SiemensSendRecipeStatus = 5;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
GVL_SmallStation.SiemensSendRecipeStatus = 4;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
}
}
if (GVL_SmallStation.SiemensSendRecipeStatus == 5)
{
if (SiemensDevice.XL_Status.Dosing_Confirm == false)
if (GVL_SmallStation.SiemensSendRecipeStatus == 4)
{
GVL_SmallStation.SiemensSendRecipeStatus = 0;
RecipeQueueTray2.Enqueue(data.RecipeCode);
if (SiemensDevice.XL_Status.Dosing_Confirm)
{
GVL_SmallStation.SiemensSendRecipeStatus = 5;
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
}
}
if (GVL_SmallStation.SiemensSendRecipeStatus == 5)
{
if (SiemensDevice.XL_Status.Dosing_Confirm == false)
{
GVL_SmallStation.SiemensSendRecipeStatus = 0;
RecipeQueueTray2.Enqueue(data.RecipeCode);
}
}
}
}
}
}
}
else
{
RecipeQueue.Clear();
RecipeQueueTray2.Clear();
GVL_SmallStation.GetInstance.RecipeStatusID = 0;
GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
}
}
else
{
RecipeQueue.Clear();
RecipeQueueTray2.Clear();
GVL_SmallStation.GetInstance.RecipeStatusID = 0;
GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (RemoteRecipes.Count > 0)
{
foreach (var data in RemoteRecipes)
{
if (data.TrayCode == 1)
{
if (!(RecipeQueue.Contains(data.RecipeCode)))
{
RecipeQueue.Enqueue(data.RecipeCode);
}
}
else if (data.TrayCode == 2)
{
if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
{

RecipeQueueTray2.Enqueue(data.RecipeCode);
}
}
}
}
else
{
RecipeQueue.Clear();
RecipeQueueTray2.Clear();

GVL_SmallStation.GetInstance.DosingTray1 = false;
GVL_SmallStation.GetInstance.DosingTray1Loc = 0;

GVL_SmallStation.GetInstance.DosingTray2 = false;
GVL_SmallStation.GetInstance.DosingTray2Loc = 0;

GVL_SmallStation.GetInstance.RecipeStatusID = 0;
GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
}
}
}
/// <summary>
@@ -773,7 +847,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
private void RecipeInfoToHKPLC()
{
if (RecipeQueue.Count > 0)
if (RecipeQueue.Count > 0 && GVL_SmallStation.TrayLogicFinish)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
@@ -788,29 +862,29 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (GVL_SmallStation.GetInstance.IsUseWindSend)
{
GVL_SmallStation.GetInstance.IsUseWindSend = false;
WindSendData.TargetRecipeCode = code;
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(0).RawMaterialName == DeviceName.原料1.ToString())
WindSendData.IsAllowDosing = true;
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(0).RawMaterialName == DeviceName.味精.ToString())
{
WindSendData.RawMaterial1_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(0).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(1).RawMaterialName == DeviceName.原料2.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(1).RawMaterialName == DeviceName.白糖.ToString())
{
WindSendData.RawMaterial2_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(1).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(2).RawMaterialName == DeviceName.原料3.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(2).RawMaterialName == DeviceName.食盐.ToString())
{
WindSendData.RawMaterial3_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(2).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(3).RawMaterialName == DeviceName.原料4.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(3).RawMaterialName == DeviceName.芽菜香料粉.ToString())
{
WindSendData.RawMaterial4_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(3).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(4).RawMaterialName == DeviceName.原料5.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(4).RawMaterialName == DeviceName.香料A.ToString())
{
WindSendData.RawMaterial5_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(4).RawMaterialWeight;
}
WindSendDevice.Siemens_PLC_S7.WriteClass<XL_WindSendData_DB>(WindSendData, 5);
WindSendDevice.Siemens_PLC_S7.WriteClass<WindSend_Write>(WindSendData, 5);
}
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
@@ -819,102 +893,102 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
GVL_SmallStation.GetInstance.RecipeStatusID = 1;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true);
GVL_SmallStation.GetInstance.time1 = DateTime.Now;
}
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && GVL_SmallStation.GetInstance.RecipeStatusID == 1)
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
GVL_SmallStation.GetInstance.RecipeStatusID = 2;
MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
}
if (GVL_SmallStation.GetInstance.RecipeStatusID == 2)
{
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
if (GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray1Loc == 0)
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
}
}
else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
}
}
else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight*1000;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
}
}
else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight*1000;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
}
}
if (GVL_SmallStation.GetInstance.DosingTray1 && GVL_SmallStation.GetInstance.DosingTray1Loc > 0 && GVL_SmallStation.GetInstance.DosingTray1Loc < 16)
{
int i = GVL_SmallStation.GetInstance.DosingTray1Loc;
if (RTrig.GetInstance("Tray1StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
{
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
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;
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
if (info)
{
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功");
@@ -936,12 +1010,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
GVL_SmallStation.GetInstance.DosingTray1 = false;
GVL_SmallStation.GetInstance.DosingTray1Loc = 0;
}
}
if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend)) || GVL_SmallStation.GetInstance.RecipeStatusID == 5)
if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))))
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成");
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
}
if (SiemensDevice.IsConnected)
{
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
@@ -959,16 +1036,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
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;
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
}
for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
{
RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
}
if (GVL_SmallStation.SiemensSendRecipeStatus == 6)
{
double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
GVL_SmallStation.SiemensSendRecipeStatus = 7;
RecipeFinishInfo.Ask_For_Finish = true;
RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
}
}
@@ -984,7 +1063,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
if (RecipeQueueTray2.Count > 0)
if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.Station2HaveTray)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
@@ -1004,7 +1083,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 1;
MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成");
HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", true);
}

if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.4") && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 1)
@@ -1021,14 +1099,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
//int decimalNum = Convert.ToInt32(loc.ToString().Substring(loc.ToString().IndexOf(".") + 1));
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 >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
@@ -1047,7 +1123,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
@@ -1066,7 +1141,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
@@ -1085,7 +1159,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
@@ -1099,7 +1172,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
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;
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (info)
{
@@ -1184,7 +1257,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
private void testData()
{
RawMaterialsNamePos.Add("0041", 1);
/*RawMaterialsNamePos.Add("0041", 1);
RawMaterialsNamePos.Add("0042", 2);
RawMaterialsNamePos.Add("0043", 3);
RawMaterialsNamePos.Add("0044", 4);
@@ -1203,7 +1276,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
RawMaterialsNamePos.Add("0057", 15);
RawMaterialsNamePos.Add("0058", 15);
RawMaterialsNamePos.Add("0059", 15);
RawMaterialsNamePos.Add("0060", 15);
RawMaterialsNamePos.Add("0060", 15);*/
RawMaterialsNamePos.Add("0051", 3);
RawMaterialsNamePos.Add("0052", 4);
RawMaterialsNamePos.Add("0054", 5);
RawMaterialsNamePos.Add("0057", 6);
RawMaterialsNamePos.Add("0050", 8);
RawMaterialsNamePos.Add("0048", 13);
}

public short SetBitValue(short data, byte offset, bool val)
{
if (offset > 16 || offset < 1)
{
return data;
}

short num = (short)(1 << offset - 1);
return (short)(val ? (data | num) : (data & ~num));
}
}
}

+ 34
- 22
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs View File

@@ -11,6 +11,7 @@ using System.Linq;
using System.Net.NetworkInformation;
using System.Threading;
using System.Threading.Tasks;
using System.Configuration;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
@@ -20,9 +21,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire());
private DeviceInquire() { }

string IPSegment = "192.168.0.";
string IPSegment = "107.107.2.";

ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>();
ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>();
List<string> InvalidIP = new List<string>();//无效 IP 集合
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合
ConcurrentQueue<string> IPQueues = new ConcurrentQueue<string>();//pincomplete 完成队列
@@ -102,8 +103,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
//AlarmHelper<AlarmInfo>.Init();
//AlarmHelper<AlarmInfo>.Alarm.EStop1 = true;
TestData();
//IPSegment = ConfigurationManager.AppSettings["RawMaterial_IP"];
//TestData();
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -152,13 +153,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
IPLists.Clear();
IPQueues.Clear();
for (int i = 1; i <= 255; i++)
/* for (int i = 1; i <= 255; i++)
{
if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}"))
{
IPLists.Add($"{IPSegment}{i}");
}
}*/
for (int i = 0; i < 15; i++)
{
if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}"))
{
IPLists.Add($"{IPSegment}{i}");
}
IPLists.Add($"{IPSegment}{i + 69}");
}

IPLists.ForEach((item) =>
{
@@ -260,7 +266,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}));
}

if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose();
if (DeviceLists.ContainsKey(ip))
{
DeviceLists[ip].Dispose();
var res11 = DeviceLists[ip];
DeviceLists.TryRemove(ip, out res11);
}
});

Task.Run(new Action(() =>
@@ -317,8 +328,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
// if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
//}
deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态
deviceStatus.WeightFeedback = (Int16)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量
deviceStatus.NowWeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);//获取下料重量
deviceStatus.WeightFeedback = this.modbusTcp.ReadShort(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量
deviceStatus.NowWeightFeedback = this.modbusTcp.GetReal(DeviceAddress.CutWeightFeedback);//获取下料重量
deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1);
@@ -354,16 +365,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (modbusTcp.Connected)
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
bool returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
if (returnValue)
{
MessageNotify.GetInstance.ShowRunLog($"发送成功" + DeviceAddress.Start);
}
else
{
MessageNotify.GetInstance.ShowRunLog($"发送失败" + DeviceAddress.Start);
}
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)
@@ -378,6 +379,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100);
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成");
}
Thread.Sleep(100);
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
bool returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
if (returnValue)
{
MessageNotify.GetInstance.ShowRunLog($"发送成功" + DeviceAddress.Start);
}
else
{
MessageNotify.GetInstance.ShowRunLog($"发送失败" + DeviceAddress.Start);
}
}
}
}


+ 20
- 18
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs View File

@@ -15,7 +15,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;
public XL_Status_DB XL_Status = new XL_Status_DB();
bool test;
public XL_DataColl_DB DataColl = new XL_DataColl_DB();
public void Init()
{
if (IsConnected)
@@ -25,15 +25,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
var Start = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(2201);
var Status = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2231);
var Finish = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(2261);
var DataColl = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291);
//var DataColl = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291);
if (Start != null && Start is XL_Start_DB st)
{
if (RTrig.GetInstance("DB2201.DBX450.0").Start(GVL_SmallStation.IsAllowSiemensSendRecipe) && GVL_SmallStation.SiemensSendRecipeStatus == 0)
if (GVL_SmallStation.IsAllowSiemensSendRecipe && GVL_SmallStation.SiemensSendRecipeStatus == 0)
{
GVL_SmallStation.SiemensSendRecipeStatus = 1;
this.Siemens_PLC_S7.Write("DB2201.DBX450.0", true);
}
if (RTrig.GetInstance("Order_Request_ACK").Start(Start.Order_Request_ACK) && GVL_SmallStation.SiemensSendRecipeStatus == 1)
if (Start.Order_Request_ACK && GVL_SmallStation.SiemensSendRecipeStatus == 1)
{
if (!string.IsNullOrEmpty(st.RecipeCode))
{
@@ -42,16 +42,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
this.Siemens_PLC_S7.Write("DB2201.DBX450.0", false);
}
}
if (TTrig.GetInstance("Order_Request_ACK_").Start(Start.Order_Request_ACK) && GVL_SmallStation.SiemensSendRecipeStatus == 2)
if (Start.Order_Request_ACK == false && GVL_SmallStation.SiemensSendRecipeStatus == 2)
{
GVL_SmallStation.IsAllowSiemensSendRecipe = false;
GVL_SmallStation.SiemensSendRecipeStatus = 3;
//需要等待请求信号复位才能认为接收配方完成
}
}
if (Finish != null && Finish is XL_Finish_DB FinishData)
{
if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(FinishData.Ask_For_Finish_PLC) && GVL_SmallStation.SiemensSendRecipeStatus == 7)
if (FinishData.Ask_For_Finish_PLC && GVL_SmallStation.SiemensSendRecipeStatus == 7)
{
FinishData.Order_No = "";
FinishData.Product_Code = "";
@@ -77,21 +76,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
XL_Status.Powder[i] = new PowderStatus();
}
XL_Status = state;
if (RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut))
{
ActionManage.GetInstance.Send("AGV放货架到位", Status);
Status.AgvRequestPut = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2);
}

}
if (Status != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(Status.AgvRequestGet))

var res = ProcessControl.GetInstance.HKDevice.DeviceStatus;
if (res != null)
{
ActionManage.GetInstance.Send("AGV取货架到位", Status);
Status.AgvRequestGet = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2);
DataColl.HeartBeatWithPLC = res.HeartBeat;
DataColl.SystemStart = res.DeviceRun;
DataColl.SystemStop = res.DeviceStop;
DataColl.SystemPause = res.DevicePause;
DataColl.SystemEStop = res.DeviceEStop;
DataColl.Mode = res.Mode;
DataColl.Alarm = res.Alarm;
this.Siemens_PLC_S7.WriteClass<XL_DataColl_DB>(DataColl, 2291);
}
Thread.Sleep(10);
}),"监听服务数据");
}),"监听服务数据",true);
}
}
}


+ 3
- 3
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs View File

@@ -7,12 +7,12 @@ using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_DataColl_DB
public class XL_DataColl_DB
{
[Siemens(16)]
public string RecipeCode { get; set; }
public string RecipeCode { get; set; } = "";
[Siemens(16)]
public string RecipeName { get; set; }
public string RecipeName { get; set; } = "";
public bool RawMaterialLack { get; set; }
/// <summary>
/// 上游缺料


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs View File

@@ -13,7 +13,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC { get; set; }
public short[] StandbyFinish { get; set; }=new short[4];
public short[] StandbyFinish { get; set; } = new short[4];

[Siemens(16)]
/// <summary>


+ 11
- 6
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs View File

@@ -41,30 +41,35 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// <summary>
/// 生产工单
/// </summary>
public string Order_No { get; set; }
public string Order_No { get; set; } = "";
/// <summary>
/// 配料开始
/// </summary>
public bool Dosing_Start { get; set; }
/// <summary>
/// 工位允许取货架
/// </summary>
public bool StationAllowGet { get; set; }
/// <summary>
/// 工位允许放货架
/// </summary>
public bool StationAllowPut { get; set; }
/// <summary>
/// 工位允许取货架
/// </summary>
public bool StationAllowGet { get; set; }
/// <summary>
/// 工位允许取空货架
/// </summary>
public bool StationAllowGetEmpty { get; set; }

/// <summary>
/// 允许AGV到工站取放粉料
/// </summary>
public bool Allow_AGV_Put_Get_FL { get; set; }
public PowderStatus[] Powder { get; set; } = new PowderStatus[10];
/// <summary>
/// 托盘占用情况
/// </summary>
public short TrayUse { get; set; }
/// <summary>
/// 托盘用情况
/// 托盘使用情况
/// </summary>
public short Permit_Pos { get; set; }
/// <summary>


+ 69
- 15
BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs View File

@@ -17,15 +17,68 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;
public bool test;
public void Init()
{
if (IsConnected)
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ThreadManage.GetInstance().StartLong(new Action(() =>
if (IsConnected)
{
/*var res = this.Siemens_PLC_S7.ReadClass<XL_WindSendData_DB>(5);
if(RTrig.GetInstance("CurrentCompleteSign").Start(res.CurrentCompleteSign))
var res1 = this.Siemens_PLC_S7.ReadClass<WindSend_Read>(94);
/*if (res1 != null && res1 is WindSend_Read readData)
{
GVL_SmallStation.WindSendAllowAGVPutGet = readData.HoodLiftInPlace;
Siemens_PLC_S7.Write<bool>("DB95.DBX38.2", GVL_SmallStation.Station1HaveTray);//工站1有托盘
if (res1.RecipeReceiveFinish)
{
Siemens_PLC_S7.Write<bool>("DB95.DBX38.0", false);
}
if (RTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign))
{
GVL_SmallStation.WindSendDosingComple = true;
Siemens_PLC_S7.Write("DB95.DBX38.1", true);
}
if (TTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign))
{
Siemens_PLC_S7.Write("DB95.DBX38.1", false);
}
}*/
//测试
var res = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95);
if (res != null && res is WindSend_Write write)
{
if (res1.SystemRunStatus == 1 && test)
{
test = false;
write.RawMaterial1_SetWeight = 1.5f;
write.RawMaterial2_SetWeight = 1.5f;
write.RawMaterial3_SetWeight = 1.5f;
write.RawMaterial4_SetWeight = 1.5f;
write.RawMaterial5_SetWeight = 1.5f;
write.TargetRecipeCode = "qwe123";
write.Station1HaveSign = true;
write.IsAllowDosing = true;
Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
}
if (res1.RecipeReceiveFinish)
{
write.IsAllowDosing = false;
Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
}
}
if (res1 != null && res1 is WindSend_Read read)
{
if (RTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
{
Siemens_PLC_S7.Write("DB95.DBX38.1", true);
}
if (TTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
{
Siemens_PLC_S7.Write("DB95.DBX38.1", false);
}
}
/*if (RTrig.GetInstance("CurrentCompleteSign").Start(res.CurrentCompleteSign))
{
ActionManage.GetInstance.Send("WindSendDosingFinish");
}
@@ -34,7 +87,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
float weightAlarmStockBin3 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeightOffset;
float weightAlarmStockBin4 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeightOffset;
float weightAlarmStockBin5 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeightOffset;
if (res.RawMaterial1_StockBinWeight < weightAlarmStockBin1)
if (res.RawMaterial1_StockBinWeight < weightAlarmStockBin1)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓1缺料!");
}
@@ -53,18 +106,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (res.RawMaterial5_StockBinWeight < weightAlarmStockBin5)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓5缺料!");
}*/
Thread.Sleep(10);
}),"监听服务数据");
}
}
Thread.Sleep(10);*/
}
}),"监听服务数据");
}
}
enum DeviceName
{
原料1,
原料2,
原料3,
原料4,
原料5
味精,
白糖,
食盐,
芽菜香料粉,
香料A
}
}

+ 5
- 0
BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs View File

@@ -19,5 +19,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private float _mRawMaterialWeight;
/// <summary>
/// 需要原料重量
/// </summary>
public float DosingCompleWeight { get { return _mDosingCompleWeight; } set { _mDosingCompleWeight = value; OnPropertyChanged(); } }
private float _mDosingCompleWeight;
}
}

BPASmartClient.JXJFoodSmallStation/Model/WindSend/XL_WindSendData_DB.cs → BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs View File

@@ -7,42 +7,29 @@ using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model.WindSend
{
public class XL_WindSendData_DB
internal class WindSend_Read
{
/// <summary>
/// 目标配方编码
/// 吸风罩提升到位
/// </summary>
[Siemens(6)]
public string TargetRecipeCode { get; set; }
public bool HoodLiftInPlace { get; set; }
/// <summary>
/// 当前配方编码
/// 配方接收完成
/// </summary>
[Siemens(6)]
public string CurrentRecipeCode { get; set; }
public bool RecipeReceiveFinish { get; set; }
/// <summary>
/// 当前制作完成信号
/// 制作完成信号
/// </summary>
public bool CurrentCompleteSign { get; set; }
/// <summary>
/// 原料1设定重量
/// </summary>
public float RawMaterial1_SetWeight { get; set; }
/// <summary>
/// 原料2设定重量
/// </summary>
public float RawMaterial2_SetWeight { get; set; }
/// <summary>
/// 原料3设定重量
/// </summary>
public float RawMaterial3_SetWeight { get; set; }
/// <summary>
/// 原料4设定重量
/// 当前配方编码
/// </summary>
public float RawMaterial4_SetWeight { get; set; }
[Siemens(16)]
public string CurrentRecipeCode { get; set; } = "";
/// <summary>
/// 原料5设定重量
/// 系统状态
/// </summary>
public float RawMaterial5_SetWeight { get; set; }
public short SystemRunStatus { get; set; }
/// <summary>
/// 原料1下料完成重量
/// </summary>
@@ -63,45 +50,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.WindSend
/// 原料5下料完成重量
/// </summary>
public float RawMaterial5_FinishWeight { get; set; }

/// <summary>
/// 原料1当前出料重量
/// </summary>
public float RawMaterial1_CurrentWeight { get; set; }
/// <summary>
/// 原料2当前出料重量
/// </summary>
public float RawMaterial2_CurrentWeight { get; set; }
/// <summary>
/// 原料3当前出料重量
/// </summary>
public float RawMaterial3_CurrentWeight { get; set; }
/// <summary>
/// 原料4当前出料重量
/// </summary>
public float RawMaterial4_CurrentWeight { get; set; }
/// <summary>
/// 原料5当前出料重量
/// </summary>
public float RawMaterial5_CurrentWeight { get; set; }
/// <summary>
/// 原料1当前出料重量
/// 原料1料仓重量
/// </summary>
public float RawMaterial1_StockBinWeight { get; set; }
/// <summary>
/// 原料2料仓剩余重量
/// 原料2料仓重量
/// </summary>
public float RawMaterial2_StockBinWeight { get; set; }
/// <summary>
/// 原料3料仓剩余重量
/// 原料3料仓重量
/// </summary>
public float RawMaterial3_StockBinWeight { get; set; }
/// <summary>
/// 原料4料仓剩余重量
/// 原料4料仓重量
/// </summary>
public float RawMaterial4_StockBinWeight { get; set; }
/// <summary>
/// 原料5料仓剩余重量
/// 原料5料仓重量
/// </summary>
public float RawMaterial5_StockBinWeight { get; set; }

}
}

+ 50
- 0
BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Write.cs View File

@@ -0,0 +1,50 @@
using BPASmartClient.S7Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model.WindSend
{
public class WindSend_Write
{
/// <summary>
/// 原料1设定重量
/// </summary>
public float RawMaterial1_SetWeight { get; set; }
/// <summary>
/// 原料2设定重量
/// </summary>
public float RawMaterial2_SetWeight { get; set; }
/// <summary>
/// 原料3设定重量
/// </summary>
public float RawMaterial3_SetWeight { get; set; }
/// <summary>
/// 原料4设定重量
/// </summary>
public float RawMaterial4_SetWeight { get; set; }
/// <summary>
/// 原料5设定重量
/// </summary>
public float RawMaterial5_SetWeight { get; set; }
/// <summary>
/// 目标配方编码
/// </summary>
[Siemens(16)]
public string TargetRecipeCode { get; set; }
/// <summary>
/// 允许配料
/// </summary>
public bool IsAllowDosing { get; set; }
/// <summary>
/// 配方制作完成接收
/// </summary>
public bool RecipeCompleRec { get; set; }
/// <summary>
/// 工位1有信号
/// </summary>
public bool Station1HaveSign { get; set; }
}
}

+ 94
- 0
BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml View File

@@ -0,0 +1,94 @@
<UserControl x:Class="BPASmartClient.JXJFoodSmallStation.View.ManualFlowView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920">
<UserControl.DataContext>
<vm:ManualFlowViewModel />
</UserControl.DataContext>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="100" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<!--#region 表格标题栏设置-->
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="left" VerticalAlignment="Center">
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Test1Command}"
Content="AGV送托盘完成"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Test2Command}"
Content="粉料仓配料完成"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Test3Command}"
Content="AGV取托盘完成"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding Test4Command}"
Content="气缸收紧错位复位"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<StackPanel Orientation="Horizontal" HorizontalAlignment="left" VerticalAlignment="Center">
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding SystemReset}"
Content="系统复位"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
<Button
Width="200"
Height="40"
Margin="5,0,5,0"
Command="{Binding CLearRecipeInfo}"
Content="配方清零"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}"></Button>
</StackPanel>


</Grid>
<Grid Grid.Row="2">
<WrapPanel>
<TextBlock Text="心跳:" Foreground="#FF2AB2E7" FontSize="25" Margin="10,0,5,0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding Heartbeat}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF2AB2E7" FontSize="25" Margin="10"></TextBlock>
</WrapPanel>
</Grid>
</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml.cs View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.JXJFoodSmallStation.View
{
/// <summary>
/// HKPlcCommMonitor.xaml 的交互逻辑
/// </summary>
public partial class ManualFlowView : UserControl
{
public ManualFlowView()
{
InitializeComponent();
}
}
}

+ 1
- 1
BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml View File

@@ -171,7 +171,7 @@
<TextBlock Text="原料桶号" HorizontalAlignment="Center" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="3" Text="原料重量" HorizontalAlignment="Center" />
<TextBlock Grid.Column="3" Text="原料重量(kg)" HorizontalAlignment="Center" />
<Grid Grid.Column="4">
<TextBlock Text="功能操作" HorizontalAlignment="Center" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />


+ 10
- 6
BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml View File

@@ -104,10 +104,12 @@
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock FontSize="16" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top">原料位置</TextBlock>
<TextBlock FontSize="16" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top">原料桶号</TextBlock>
<TextBlock FontSize="16" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top">原料重量</TextBlock>
<TextBlock FontSize="16" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top">原料名称</TextBlock>
<TextBlock FontSize="16" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top">原料位置</TextBlock>
<TextBlock FontSize="16" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top">原料桶号</TextBlock>
<TextBlock FontSize="16" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Top">原料重量</TextBlock>
</Grid>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" >
<ItemsControl ItemsSource="{Binding RawMaterialsInfo}" Width="548" >
@@ -118,10 +120,12 @@
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialLocation}"></TextBlock>
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialWeight}"></TextBlock>
<TextBlock Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialName}"></TextBlock>
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialLocation}"></TextBlock>
<TextBlock Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialWeight}"></TextBlock>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">


+ 5
- 1
BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs View File

@@ -40,12 +40,16 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
Describe = $"托盘2_{i-3}#桶位置反馈",
});
}
}
SetParCommand = new RelayCommand<object>((o) =>
{
});
}
public ObservableCollection<PlcManualComm> PlcInfo { get; set; } = new ObservableCollection<PlcManualComm>();

public RelayCommand<object> SetParCommand { get; set; }

public RelayCommand Connect { get; set; }



+ 64
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using BPASmartClient.JXJFoodSmallStation.Model;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.UserControls;
using System.Diagnostics;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
using System.Threading;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public class ManualFlowViewModel:ObservableObject
{
public ManualFlowViewModel()
{
Test1Command = new RelayCommand(() =>
{
GVL_SmallStation.AGV_PutTray1Finish = true;
});
Test2Command = new RelayCommand(() =>
{
GVL_SmallStation.WindSendDosingComple = true;
});
Test3Command = new RelayCommand(() =>
{
GVL_SmallStation.AGV_GetTray1Finish = true;
});
Test4Command = new RelayCommand(() =>
{
GVL_SmallStation.CylinderReset = true;
});
CLearRecipeInfo = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("CLearRecipeInfo");
});
SystemReset = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("SystemReset");
});
ThreadManage.GetInstance().StartLong(new Action(() =>
{
Heartbeat = GVL_SmallStation.GetInstance.HeartBeatFromPlc;
Thread.Sleep(100);
}), "流程手动设备状态读取",true);
}
public RelayCommand Test1Command { get; set; }
public RelayCommand Test2Command { get; set; }
public RelayCommand Test3Command { get; set; }
public RelayCommand Test4Command { get; set; }
public bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnPropertyChanged(); } }
private bool _mHeartbeat;

public RelayCommand CLearRecipeInfo { get; set; }
public RelayCommand SystemReset { get; set; }
}
}

+ 1
- 1
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs View File

@@ -93,7 +93,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel

}
Thread.Sleep(100);
}), "启动配方下发");
}), "启动配方下发",true);


ThreadManage.GetInstance().StartLong(new Action(() =>


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -110,8 +110,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialName = "原料" + i,
RawMaterialWeight = new Random().Next(200, 300),
RawMaterialBarrelNum = (short)new Random().Next(1, 5),
RawMaterialWeight = (float)Math.Round(new Random().Next(200, 300) * 0.001 ,3),
RawMaterialBarrelNum = (short)new Random().Next(1, 4),
RawMaterialLocation = i,
});
}


+ 138
- 101
BPASmartClient.MorkF/Control_MorkF.cs View File

@@ -19,7 +19,7 @@ namespace BPASmartClient.MorkF
{
public class Control_MorkF : BaseDevice
{
#region 常数定义
/// <summary>
/// while循环最大sleep次数
/// </summary>
@@ -92,6 +92,7 @@ namespace BPASmartClient.MorkF

//当前炒锅,默认为1号炒锅
private int fryIndex = 0;
#endregion

public override DeviceClientType DeviceType => DeviceClientType.MORKCS;
public AutoResetEvent minorReset = new AutoResetEvent(false);
@@ -361,7 +362,7 @@ namespace BPASmartClient.MorkF
{
if(!UpdateMaterialLibraryStock())
{
MessageLog.GetInstance.Show("菜品库检测余量失败");
MessageLog.GetInstance.ShowEx("菜品库检测余量失败");
}
}), "SurplusCheck");
}), "SurplusCheck");
@@ -817,7 +818,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show("菜品库初始化超时");
MessageLog.GetInstance.ShowEx("菜品库初始化超时");
return false;
}
}
@@ -832,7 +833,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("电磁阀启停出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx("电磁阀启停出错,菜品库未初始化");
return;
}

@@ -847,7 +848,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("爪子去到1号位出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx("爪子去到1号位出错,菜品库未初始化");
return false;
}

@@ -858,7 +859,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show("爪子去到1号位超时");
MessageLog.GetInstance.ShowEx("爪子去到1号位超时");
return false;
}
}
@@ -873,7 +874,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("爪子去到2号位出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx("爪子去到2号位出错,菜品库未初始化");
return false;
}

@@ -884,7 +885,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show("爪子去到2号位超时");
MessageLog.GetInstance.ShowEx("爪子去到2号位超时");
return false;
}
}
@@ -899,7 +900,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("爪子去到3号位出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx("爪子去到3号位出错,菜品库未初始化");
return false;
}

@@ -910,7 +911,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show("爪子去到3号位超时");
MessageLog.GetInstance.ShowEx("爪子去到3号位超时");
return false;
}
}
@@ -925,7 +926,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("1号测距出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx("1号测距出错,菜品库未初始化");
return false;
}

@@ -940,7 +941,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("2号测距出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx("2号测距出错,菜品库未初始化");
return false;
}

@@ -955,7 +956,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("3号测距出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx("3号测距出错,菜品库未初始化");
return false;
}

@@ -1008,7 +1009,7 @@ namespace BPASmartClient.MorkF
}
if (!ret)
{
MessageLog.GetInstance.Show($"错误:X轴:{x}获取传感器数据出错");
MessageLog.GetInstance.ShowEx($"错误:X轴:{x}获取传感器数据出错");
}
return ret;
}
@@ -1031,7 +1032,7 @@ namespace BPASmartClient.MorkF
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show($"机械臂移动出错,菜品库未初始化");
MessageLog.GetInstance.ShowEx($"机械臂移动出错,菜品库未初始化");
return false;
}

@@ -1040,7 +1041,7 @@ namespace BPASmartClient.MorkF
y = 0 - Math.Abs(y);
if (x > 0 || y > 0)
{
MessageLog.GetInstance.Show($"机械臂移动到[{x},{y}]非法");
MessageLog.GetInstance.ShowEx($"机械臂移动到[{x},{y}]非法");
return false;
}
MaterailLibrary_Write("VD836", x);
@@ -1070,7 +1071,7 @@ namespace BPASmartClient.MorkF
}
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show("机械臂移动操作超时");
MessageLog.GetInstance.ShowEx("机械臂移动操作超时");
return false;
}
}
@@ -1311,7 +1312,7 @@ namespace BPASmartClient.MorkF

if (MaterialCoordinate.GetInstance().dicNoMaterialCoordinate == null || MaterialCoordinate.GetInstance().dicNoMaterialCoordinate.Count != 27)
{
MessageLog.GetInstance.Show("更新菜品库存量出错,菜品库坐标系数据未建立");
MessageLog.GetInstance.ShowEx("更新菜品库存量出错,菜品库坐标系数据未建立");
return false;
}

@@ -1327,7 +1328,7 @@ namespace BPASmartClient.MorkF
//获取该处的距离
if (!GetDistance(item.Value.X))
{
MessageLog.GetInstance.Show("错误:获取传感器数据出错");
MessageLog.GetInstance.ShowEx("错误:获取传感器数据出错");
return false;
}

@@ -1477,7 +1478,7 @@ namespace BPASmartClient.MorkF
//获取坐标,根据菜品的位置信息
if (!NoMaterial2Coordinate(materialOperation.materialInfo.Loc, out myCoordinate))
{
MessageLog.GetInstance.Show($"炒锅{materialOperation.fryNum}获取菜品[{materialOperation.materialInfo.Name}]失败,找不到对应位置");
MessageLog.GetInstance.ShowEx($"炒锅{materialOperation.fryNum}获取菜品[{materialOperation.materialInfo.Name}]失败,找不到对应位置");
return;
}
lock (lock_Materail)
@@ -1620,7 +1621,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(sleepTime);
if (j >= sleepCount - 1)
{
MessageLog.GetInstance.Show($"炒锅{j}初始化超时");
MessageLog.GetInstance.ShowEx($"炒锅{j}初始化超时");
}
}

@@ -1662,11 +1663,13 @@ namespace BPASmartClient.MorkF
Thread.Sleep(200);
}
//倒菜
public void OutFood(int num,bool isMaterial = false)
public bool OutFood(int num,bool isMaterial = false)
{
bool ret = true;

if (!morkFs.ContainsKey(num))
{
return;
return false;
}
int i = 0;

@@ -1685,8 +1688,8 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show($"炒锅{num}倒菜超时:未能等到取菜完成");
return;
MessageLog.GetInstance.ShowEx($"炒锅{num}倒菜超时:未能等到取菜完成");
ret &= false;
}
}

@@ -1709,7 +1712,8 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show($"炒锅{num}倒菜超时");
MessageLog.GetInstance.ShowEx($"炒锅{num}倒菜超时");
ret &= false;
}
}

@@ -1717,6 +1721,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(200);
MessageLog.GetInstance.Show("倒菜完成");
morkFs[num].GetMaterialComplete = false;
return ret;
}
//搅拌臂去原点位
public void StirArmGoOrigin(int num)
@@ -1734,7 +1739,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(sleepTime);
if (i >= sleepCount - 1)
{
MessageLog.GetInstance.Show($"炒锅{num}搅拌臂去原点位超时");
MessageLog.GetInstance.ShowEx($"炒锅{num}搅拌臂去原点位超时");
}
}

@@ -1744,11 +1749,12 @@ namespace BPASmartClient.MorkF
}

//搅拌臂去炒制位
public void StirArmGoWork(int num)
public bool StirArmGoWork(int num)
{
bool ret = true;
if (!morkFs.ContainsKey(num))
{
return;
return false;
}

if (!morkFs[num].ArmOnWorking/* && morkFs[num].PotOnOrigin*/)
@@ -1761,7 +1767,8 @@ namespace BPASmartClient.MorkF
Thread.Sleep(sleepTime);
if (i >= sleepCount - 1)
{
MessageLog.GetInstance.Show($"炒锅{num}搅拌臂去炒制位超时");
MessageLog.GetInstance.ShowEx($"炒锅{num}搅拌臂去炒制位超时");
ret &= false;
}
}

@@ -1773,8 +1780,11 @@ namespace BPASmartClient.MorkF
FirePot_Write("LB6", false, num);
Thread.Sleep(200);
MessageLog.GetInstance.Show("搅拌臂到达工作位");
return ret;
}

return true;

}
//HBOT放盒子到位
public void HBOTGoWork(int num)
@@ -1788,7 +1798,7 @@ namespace BPASmartClient.MorkF
{
if (!morkFs[num].ArmOnOrigin /*&& morkFs[num].PotOnOrigin*/)
{
MessageLog.GetInstance.Show("搅拌臂不在原点位,无法完成出餐");
MessageLog.GetInstance.ShowEx("搅拌臂不在原点位,无法完成出餐");
return;
}
FirePot_Write("LB4", true, num);
@@ -2055,7 +2065,7 @@ namespace BPASmartClient.MorkF
DeviceProcessLogShow($"接收到{OrderCount}次订单");
Enum.GetNames(typeof(StirFryPotActionEnum));

//var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.RecipeId);//匹配订单对应制作流程
var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.GoodsKey);//匹配订单对应制作流程
if(order.MorkOrder.GoodBatchings.Count <= 0)
{
return;
@@ -2067,26 +2077,26 @@ namespace BPASmartClient.MorkF
}

//var res = LocalstirFryGoods[0];
//if (res != null)
//{
// /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程
// //添加到带炒小炒队列
// if (StirFryGoodsQuenes.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
// {
// lock (lock_MainProcessExcute)
// {
// StirFryGoodsQuenes.Enqueue(new OrderLocInfo()
// {
// SuborderId = order.MorkOrder.SuborderId,
// StirPotActions = res.StirPotActions,
// GoodName = order.MorkOrder.GoodsName
// });
// }
// }
//}
//暂时使用本地菜单
StartLocalOrder();
if (res != null)
{
/* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程
//添加到带炒小炒队列
if (StirFryGoodsQuenes.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
{
lock (lock_MainProcessExcute)
{
StirFryGoodsQuenes.Enqueue(new OrderLocInfo()
{
SuborderId = order.MorkOrder.SuborderId,
StirPotActions = res.StirPotActions,
GoodName = order.MorkOrder.GoodsName
});
}
}
}
////暂时使用本地菜单
//StartLocalOrder();
}

});
@@ -2109,6 +2119,8 @@ namespace BPASmartClient.MorkF
if (/*morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete &&*/
!morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&是否在炒菜中
{
Thread.Sleep(5000);

lock(lock_MainProcessExcute)
{
//待炒小炒队列出队列
@@ -2127,10 +2139,14 @@ namespace BPASmartClient.MorkF
{
try
{
bool ret = true;
MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}");

morkFs[i].GoodName = res.GoodName;

Coordinate myCoordinate = new Coordinate();
int getMaterailNum = 0;
foreach (var potActions in res.StirPotActions)
{
if (ThreadManage.GetInstance().IsCanncel(String.Format(striConst, i.ToString(), nowStirFryGood[i].GoodName)))
@@ -2138,6 +2154,18 @@ namespace BPASmartClient.MorkF
return;
}

if(ret == false)
{
MessageLog.GetInstance.ShowEx("上一步操作未成功");
break;
}

//调试大屏用代码
Thread.Sleep(5000);

//更新
morkFs[i].UpdateProcess(potActions);

switch (potActions.Actions)
{
case nameof(StirFryPotActionEnum.加热开启):
@@ -2205,7 +2233,7 @@ namespace BPASmartClient.MorkF
case nameof(StirFryPotActionEnum.取原料):
//炒锅取菜状态置为未取到
morkFs[i].GetMaterialComplete = false;
if(potActions.MaterialLists != null)
if (potActions.MaterialLists != null)
{
foreach (var item in potActions.MaterialLists)
{
@@ -2213,7 +2241,7 @@ namespace BPASmartClient.MorkF
MaterialInfo materialInfo = MaterialSurplusOperation.GetInstance().GetVailedMaterial(item.MaterialId);
if (materialInfo == null)
{
MessageLog.GetInstance.Show($"炒锅{i}获取菜品[{materialInfo.Name}]失败,库存不足");
MessageLog.GetInstance.ShowEx($"炒锅{i}获取菜品[{item.MaterialId}]失败,库存不足");
continue;
}

@@ -2222,7 +2250,7 @@ namespace BPASmartClient.MorkF
}
else
{
MessageLog.GetInstance.Show($"炒锅{i}获取菜品失败,菜品列表为空");
MessageLog.GetInstance.ShowEx($"炒锅{i}获取菜品失败,菜品列表为空");
}
//if(getMaterailNum == 0)
//{
@@ -2266,7 +2294,7 @@ namespace BPASmartClient.MorkF
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.道菜启动):
OutFood(i, true);
ret = OutFood(i, true);
break;
case nameof(StirFryPotActionEnum.炒制菜品):
Thread.Sleep(potActions.During * 1000);
@@ -2276,7 +2304,7 @@ namespace BPASmartClient.MorkF
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.搅拌臂炒制位):
StirArmGoWork(i);
ret = StirArmGoWork(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.洗锅):
@@ -2294,11 +2322,16 @@ namespace BPASmartClient.MorkF
StirArmGoOrigin(i);

MessageLog.GetInstance.Show($"菜品{res.GoodName}完成");

//菜品统计数量+1
morkFs[i].orderCount++;
}
catch (Exception ex)
{
//异常菜品统计数量+1
morkFs[i].orderAbnormalCount++;
ThreadManage.GetInstance().StopTask($"炒锅{i}{res.GoodName}炒制线程");
MessageLog.GetInstance.Show($"炒锅{i}炒制菜品{res.GoodName}出错,错误信息:" + ex.Message);
MessageLog.GetInstance.ShowEx($"炒锅{i}炒制菜品{res.GoodName}出错,错误信息:" + ex.Message);
}
finally
{
@@ -2306,8 +2339,10 @@ namespace BPASmartClient.MorkF
//炒完后出队列
morkFs[i].StirFryGoodsQuenes.TryDequeue(out var orderQueue);
morkFs[i].FryWorking = false;
//初始化大屏
morkFs[i].ScreenInit();
}
}), String.Format(striConst, i.ToString(), nowStirFryGood[i].GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/);
}), String.Format(striConst, i.ToString(), nowStirFryGood[i].GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/, true);
}
}
break;
@@ -2357,54 +2392,56 @@ namespace BPASmartClient.MorkF
{
List<StatsModel> statsModels = new List<StatsModel>();
statsModels.Add(new StatsModel() { Name = "帝王蟹", Count = 666 });
int i = new Random().Next(0, 100);
List<ProcessModel> processModels= new List<ProcessModel>();
switch ((i / 5) % 6)
{
case 0:
processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
break;
case 1:
processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
break;
case 2:
processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
break;
case 3:
processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
break;
case 4:
processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.正在执行 } };
break;
case 5:
processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.执行完成 } };
break;
default: break;
}
//int i = new Random().Next(0, 100);
//List<ProcessModel> processModels= new List<ProcessModel>();
//switch ((i / 5) % 6)
//{
// case 0:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 1:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 2:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 3:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 4:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.正在执行 } };
// break;
// case 5:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.执行完成 } };
// break;
// default: break;
//}
ScreenModelMinWok maxWok = new ScreenModelMinWok
{
IsRun = new Random().Next(0, 2) == 0 ? IsRun.运行 : IsRun.停止, //设备是否运行
WorkStatus_1 = (WorkStatus)new Random().Next(0, 3), //设备运行状态
WorkStatus_2 = (WorkStatus)new Random().Next(0, 3), //设备运行状态
IsRun = IsHealth ? IsRun.运行 : IsRun.停止,//new Random().Next(0, 2) == 0 ? IsRun.运行 : IsRun.停止, //设备是否运行
WorkStatus_1 = morkFs[0].FryPot1_InitialComplete ? WorkStatus.工作 : WorkStatus.停止,// (WorkStatus)new Random().Next(0, 3), //设备运行状态
WorkStatus_2 = morkFs[1].FryPot1_InitialComplete ? WorkStatus.工作 : WorkStatus.停止,//(WorkStatus)new Random().Next(0, 3), //设备运行状态
RobotStatu = (WorkStatus)new Random().Next(0, 3), //机器人状态 待机 1 正常
Alarm = new List<AlarmModel>(), //告警集合
FailuresCount = 0, //故障数
StatsCount = statsModels, //统计菜品数量
MinWok_Dishes_1 = "满汉全席",//当前炒制菜品名
MinWok_Dishes_2 = "海鲜大餐",
MinWok_Task_1 = "炒制菜品",//当前任务
MinWok_Task_2 = "热油", //当前任务
MinWok_Dishes_1 = morkFs[0].GoodName,//"满汉全席",//当前炒制菜品名
MinWok_Dishes_2 = morkFs[1].GoodName,
MinWok_Task_1 = morkFs[0].Task,//当前任务
MinWok_Task_2 = morkFs[1].Task, //当前任务
//MinWok_Process_1 = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } },
MinWok_Process_1 = processModels, //炒锅当前任务流程
MinWok_Process_2 = new List<ProcessModel>(), //炒锅当前任务流程
MinWok_HeatGear_1 = new Random().Next(0, 5).ToString(), //炒锅加热档位
MinWok_HeatGear_2 = new Random().Next(0, 5).ToString(), //炒锅加热档位
MinWok_StirGear_1 = new Random().Next(0, 5).ToString(), //炒锅搅拌档位
MinWok_StirGear_2 = new Random().Next(0, 5).ToString(), //炒锅搅拌档位
MinWok_OrderCount_1 = 2, //订单数量
MinWok_OrderCount_2 = 2, //订单数量
MinWok_ErrorOrderCount_1 = 0, //异常订单数量
MinWok_ErrorOrderCount_2 = 0, //异常订单数量
MinWok_Process_1 = morkFs[0].processModels, //炒锅当前任务流程
MinWok_Process_2 = morkFs[1].processModels, //炒锅当前任务流程
MinWok_HeatGear_1 = morkFs[0].FireNow, //炒锅加热档位
MinWok_HeatGear_2 = morkFs[1].FireNow, //炒锅加热档位
MinWok_Temp_1 = morkFs[0].TempNow, //炒锅1锅底温度
MinWok_Temp_2 = morkFs[1].TempNow, //炒锅1锅底温度
MinWok_StirGear_1 = morkFs[0].StirNow, //炒锅搅拌档位
MinWok_StirGear_2 = morkFs[1].StirNow, //炒锅搅拌档位
MinWok_OrderCount_1 = morkFs[0].orderCount, //订单数量
MinWok_OrderCount_2 = morkFs[1].orderCount, //订单数量
MinWok_ErrorOrderCount_1 = morkFs[0].orderAbnormalCount, //异常订单数量
MinWok_ErrorOrderCount_2 = morkFs[1].orderAbnormalCount, //异常订单数量

};
LocalMqtt.GetInstance.Publish(maxWok);


+ 169
- 2
BPASmartClient.MorkF/GVL_MorkF.cs View File

@@ -1,4 +1,5 @@
using BPA.Models;
using BPA.Message;
using BPA.Models;
using BPASmartClient.Device;
using System;
using System.Collections.Concurrent;
@@ -14,7 +15,7 @@ namespace BPASmartClient.MorkF
/// <summary>
/// 小炒队列
/// </summary>
public ConcurrentQueue<OrderLocInfo> StirFryGoodsQuenes = new ConcurrentQueue<OrderLocInfo>();
public ConcurrentQueue<OrderLocInfo> StirFryGoodsQuenes { get; set; } = new ConcurrentQueue<OrderLocInfo>();

public bool IsAuto = true;

@@ -88,6 +89,169 @@ namespace BPASmartClient.MorkF

#endregion

#region 炒锅大屏相关

/// <summary>
/// 异常订单数量统计
/// </summary>
public int orderAbnormalCount { get; set; } = 0;

/// <summary>
/// 订单数量统计
/// </summary>
public int orderCount { get; set; } = 0;

/// <summary>
/// 当前炒制菜品
/// </summary>
public string GoodName { get; set; }

/// <summary>
/// 当前任务
/// </summary>
public string Task { get; set; }

/// <summary>
/// 当前加热档位
/// </summary>
public string FireNow { get; set; }

/// <summary>
/// 搅拌档位
/// </summary>
public string StirNow { get; set; }

/// <summary>
/// 炒锅当前锅底温度
/// </summary>
public string TempNow { get; set; }

/// <summary>
/// 当前炒锅进展
/// </summary>
public List<ProcessModel> processModels { get; set; } = new List<ProcessModel>();

public void UpdateProcess(PotActions potActions)
{
switch (potActions.Actions)
{
case nameof(StirFryPotActionEnum.搅拌臂炒制位):
//设置为开始
SetState(0);
Task = "开始";
break;
case nameof(StirFryPotActionEnum.加热开启):
Task = "热油";
//设置为热油
SetState(1);
break;
///以下为不处理,炒制菜品可能为热油阶段,不处理,取原料可能在开启后立即开始
case nameof(StirFryPotActionEnum.取原料):
case nameof(StirFryPotActionEnum.炒制菜品):
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位1):
StirNow = "1";
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位2):
StirNow = "2";
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位3):
StirNow = "3";
break;
case nameof(StirFryPotActionEnum.关闭搅拌):
StirNow = "0";
break;
case nameof(StirFryPotActionEnum.设置加热挡位1):
TempNow = "60";
FireNow = "1";
break;
case nameof(StirFryPotActionEnum.设置加热挡位2):
TempNow = "100";
FireNow = "2";
break;
case nameof(StirFryPotActionEnum.设置加热挡位3):
TempNow = "120";
FireNow = "3";
break;
case nameof(StirFryPotActionEnum.设置加热挡位4):
TempNow = "150";
FireNow = "4";
break;
case nameof(StirFryPotActionEnum.设置加热挡位5):
TempNow = "200";
FireNow = "5";
break;
case nameof(StirFryPotActionEnum.设置加热挡位6):
TempNow = "250";
FireNow = "6";
break;
case nameof(StirFryPotActionEnum.设置加热挡位7):
TempNow = "300";
FireNow = "7";
break;
case nameof(StirFryPotActionEnum.设置加热挡位8):
TempNow = "350";
FireNow = "8";
break;
case nameof(StirFryPotActionEnum.设置加热挡位9):
TempNow = "400";
FireNow = "9";
break;
case nameof(StirFryPotActionEnum.设置加热挡位10):
TempNow = "500";
FireNow = "10";
break;
///以下为待定
case nameof(StirFryPotActionEnum.停止加热):
break;
case nameof(StirFryPotActionEnum.开启搅拌):
break;
case nameof(StirFryPotActionEnum.道菜启动):
case nameof(StirFryPotActionEnum.加调料):
Task = "炒制";
//设置为炒制
SetState(2);
break;
case nameof(StirFryPotActionEnum.出餐启动):
Task = "出餐";
SetState(3);
break;
///设置为结束
case nameof(StirFryPotActionEnum.搅拌臂原点位):
case nameof(StirFryPotActionEnum.洗锅):
Task = "完成";
SetState(4);
break;
default:
break;

}
}

private void SetState(int c)
{
for (int i = 0; i < processModels.Count; i++)
{
if (i == c)
{
processModels[i].Status = ProcessStatus.正在执行;
}
else if (i < c) processModels[i].Status = ProcessStatus.执行完成;
else if (i > c) processModels[i].Status = ProcessStatus.未执行;
}
}

public void ScreenInit()
{
processModels.Clear();
//初始化进度列表
processModels.Add(new ProcessModel() { Id = 1, Name = "开始", Status = ProcessStatus.未执行 });
processModels.Add(new ProcessModel() { Id = 2, Name = "热油", Status = ProcessStatus.未执行 });
processModels.Add(new ProcessModel() { Id = 3, Name = "炒制", Status = ProcessStatus.未执行 });
processModels.Add(new ProcessModel() { Id = 4, Name = "出餐", Status = ProcessStatus.未执行 });
processModels.Add(new ProcessModel() { Id = 5, Name = "完成", Status = ProcessStatus.未执行 });
}
#endregion
#region 调料通道
public bool PassWay1_1Compelete { get; set; }
public bool PassWay1_2Compelete { get; set; }
@@ -122,6 +286,9 @@ namespace BPASmartClient.MorkF
PassWay1_Compelete.Add(12,PassWay1_12Compelete);
PassWay1_Compelete.Add(13,PassWay1_13Compelete);
PassWay1_Compelete.Add(14,PassWay1_14Compelete);

//初始化进度列表
ScreenInit();
}

/// <summary>


+ 6
- 0
BPASmartClient.S7Net/SiemensHelper.cs View File

@@ -117,6 +117,12 @@ namespace BPASmartClient.S7Net
var bytes = S7.Net.Types.S7String.ToByteArray(txt, temp.Length);
myPlc.WriteBytes(DataType.DataBlock, db, startAddress, bytes);

}
public void WriteInt16(int db, short txt, int startAddress = 0)
{
var bytes =BitConverter.GetBytes(txt);
myPlc.WriteBytes(DataType.DataBlock, db, startAddress, bytes);

}
public TResult ReadClass<TResult>(int db, int startByteAdr = 0) where TResult : class, new()
{


+ 1
- 1
BPASmartClient.ScreenALL/App.config View File

@@ -2,7 +2,7 @@
<configuration>
<appSettings>
<!--MQTT配置-->
<add key="MQTTConnection" value="10.2.1.254,1883,admin,public"/>
<add key="MQTTConnection" value="171.221.208.23,11883,admin,public"/>
<!--订阅主题设置:大炒,小炒,分餐机,煮面机-->
<add key="DeviceMC" value="大炒,小炒,分餐机,煮面机"/>
<add key="GgAdder" value="https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4"/>


+ 30
- 5
BPASmartClient.ScreenLib/Helper/Main.cs View File

@@ -1,16 +1,22 @@
using BPA.Communication;
using BPA.Helper;
using BPA.Message;
using IWshRuntimeLibrary;
using Microsoft.Web.WebView2.Wpf;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Shapes;
using System.Xml;

namespace BPASmartClient.ScreenLib
{
@@ -223,7 +229,7 @@ namespace BPASmartClient.ScreenLib
/// </summary>
/// <param name="input"></param>
/// <param name="view2"></param>
public async void InitView2(string input, WebView2 view2, GroupBox group)
public async void InitView2(string input, WebView2 view2, System.Windows.Controls.GroupBox group)
{
var height = 540;
var width = 940;
@@ -231,10 +237,29 @@ namespace BPASmartClient.ScreenLib
StringBuilder sb = new StringBuilder();
sb.Append("<html><style>body {width: " + width + "px;height: " + height + "px;margin: 0;padding:0;}body p {width: " + width + "px;height: " + height + "px;}body p img {width: 100%;height: 100%;}</style><script>function Set(width, height) { var body = document.getElementsByTagName('body')[0]; body.style.width = width + 'px';body.style.height = height + 'px';var p = document.getElementsByTagName('p')[0]; p.style.width = width + 'px';p.style.height = height + 'px';}</script><body>" + input + "</body></html>");
var html = sb.ToString();
await view2.EnsureCoreWebView2Async(null);
view2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
view2.CoreWebView2.Settings.AreDevToolsEnabled = false;
view2.CoreWebView2.NavigateToString(html);

string name = $"{Application.StartupPath}\\Html\\{Name}.html";
if (!System.IO.Directory.Exists($"{Application.StartupPath}\\Html"))
{
System.IO.Directory.CreateDirectory($"{Application.StartupPath}\\Html");//不存在就创建文件夹 }
}
if (!System.IO.File.Exists(name))
{
//----------生成htm文件------------------――
try
{
using (StreamWriter sw = new StreamWriter(name, false, System.Text.Encoding.GetEncoding("UTF-8"))) //保存地址
{
sw.WriteLine(html);
sw.Flush();
sw.Close();
}
}
catch
{
}
}
view2.Source = new Uri(name);
}
/// <summary>
/// 读取配置


+ 1
- 1
BPASmartClient.ScreenMaxWok/App.config View File

@@ -2,7 +2,7 @@
<configuration>
<appSettings>
<!--MQTT配置-->
<add key="MQTTConnection" value="10.2.1.254,1883,admin,public"/>
<add key="MQTTConnection" value="171.221.208.23,11883,admin,public"/>
<!--订阅主题设置:大炒,小炒,分餐机,煮面机-->
<add key="DeviceMC" value="大炒,小炒,分餐机,煮面机"/>
<add key="GgAdder" value="https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4"/>


+ 2
- 1
BPASmartClient.ScreenMinWok/App.config View File

@@ -2,7 +2,8 @@
<configuration>
<appSettings>
<!--MQTT配置-->
<add key="MQTTConnection" value="10.2.1.254,1883,admin,public"/>
<!--<add key="MQTTConnection" value="10.2.1.254,1883,admin,public"/>-->
<add key="MQTTConnection" value="171.221.208.23,11883,emqx_u_block,emqx_p_admin3658765490789"/>
<!--订阅主题设置:大炒,小炒,分餐机,煮面机-->
<add key="DeviceMC" value="大炒,小炒,分餐机,煮面机"/>
<add key="GgAdder" value="https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4"/>


+ 1
- 1
BPASmartClient.ScreenMorks/App.config View File

@@ -2,7 +2,7 @@
<configuration>
<appSettings>
<!--MQTT配置-->
<add key="MQTTConnection" value="10.2.1.254,1883,admin,public"/>
<add key="MQTTConnection" value="171.221.208.23,11883,admin,public"/>
<!--订阅主题设置:大炒,小炒,分餐机,煮面机-->
<add key="DeviceMC" value="大炒,小炒,分餐机,煮面机"/>
<add key="GgAdder" value="https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4"/>


+ 1
- 1
BPASmartClient.ScreenSplitMeals/App.config View File

@@ -2,7 +2,7 @@
<configuration>
<appSettings>
<!--MQTT配置-->
<add key="MQTTConnection" value="10.2.1.254,1883,admin,public"/>
<add key="MQTTConnection" value="171.221.208.23,11883,admin,public"/>
<!--订阅主题设置:大炒,小炒,分餐机,煮面机-->
<add key="DeviceMC" value="大炒,小炒,分餐机,煮面机"/>
<add key="GgAdder" value="https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4"/>


+ 7
- 5
DosingSystem/Model/ConveyerBeltModel.cs View File

@@ -1,4 +1,5 @@
using BPA.Helper;
using BPASmartClient.CustomResource.Pages.Model;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -21,10 +22,10 @@ namespace BPASmartClient.DosingSystem
set
{
_mSpeed = value;
if (Num >= 1 && Num <= 32)
{
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBW{Num * 2 + 132}", value);
}
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBW{Num * 2 + 132}", (short)value);
//SiemensDevice.GetInstance.MySiemens.WriteInt16(4, (short)value, (Num * 2 + 132));
MessageNotify.GetInstance.ShowRunLog($"DB4.DBW{Num * 2 + 132},{value}");
OnPropertyChanged();
}
}
@@ -39,7 +40,8 @@ namespace BPASmartClient.DosingSystem
if (Num >= 1 && Num <= 32)
{
var add = SiemensDevice.GetInstance.GetSiemensBitSingleAdd("DB5.DBX", Num, 6);
SiemensDevice.GetInstance.MySiemens.Write(add, !value);
SiemensDevice.GetInstance.MySiemens.Write(add, value);
MessageNotify.GetInstance.ShowRunLog($"{add},{value}");
}
OnPropertyChanged();
}


+ 1
- 1
DosingSystem/Model/DeviceInquire.cs View File

@@ -114,7 +114,7 @@ namespace BPASmartClient.DosingSystem
{
if (!string.IsNullOrEmpty(Json<DevicePar>.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json<DevicePar>.Data.BaseParModel.NetworkSegAddress;
else Json<DevicePar>.Data.BaseParModel.NetworkSegAddress = IPSegment;
TestData();
//TestData();
IpAddressLines();
SiemensDevice.GetInstance.Connect(Json<DevicePar>.Data.BaseParModel.DeviceAddress);
DeviceDataInit();


+ 3
- 3
DosingSystem/Service/SiemensDevice.cs View File

@@ -19,7 +19,7 @@ namespace BPASmartClient.DosingSystem
public SiemensHelper MySiemens { get; set; } = new SiemensHelper();

private bool IsConnect { get; set; }
bool tempValue = false;
public void Connect(string ip)
{
try
@@ -35,12 +35,11 @@ namespace BPASmartClient.DosingSystem
}
IsConnect = MySiemens.IsConnected;
bool tempValue = false;
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (IsConnect) MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳
tempValue = !tempValue;
Thread.Sleep(1);
Thread.Sleep(100);
}), "设备心跳", true);

ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -55,6 +54,7 @@ namespace BPASmartClient.DosingSystem
}
GlobalDevice.MotorControl = MySiemens.Read<uint>("DB5.DBD6");//获取输送带控制信号
//GlobalDevice.MotorControlFeedback = MySiemens.Read<uint>("DB3.DBD0");//获取当前输送带运行状态
GlobalDevice.MotorControl = (uint)(GlobalDevice.MotorControl.ToBytes(BPA.Helper.DataFormat.ABCD)).ToInt();
Thread.Sleep(50);
}
}), "读取输送线设备数据", true);


+ 1
- 1
DosingSystem/View/NewRecipeView.xaml View File

@@ -8,7 +8,7 @@
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
Title="NewRecipeView"
Width="550"
Height="450"
Height="600"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"


+ 20
- 14
DosingSystem/View/RecipeControlView.xaml View File

@@ -362,23 +362,29 @@
Grid.RowSpan="5"
Source="/BPASmartClient.CustomResource;component/Image/配方背景/竖背景框.png"
Stretch="Fill" />

<TextBlock
Grid.Row="0"
Margin="2,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontSize="18"
Margin="5,0,0,0"
VerticalAlignment="Center"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />

Text="配方信息:" />
<TextBlock
Grid.Row="1"
Margin="5,0,0,0"
VerticalAlignment="Top"
Margin="20,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="12"
Foreground="#FF2AB2E7"
Text="配方信息:" />

Text="配方名称:" />
<TextBlock
Grid.Row="1"
Margin="100,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="12"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />
<ScrollViewer
Grid.Row="2"
VerticalAlignment="Top"
@@ -407,7 +413,7 @@
</ItemsControl.ItemTemplate>
</ItemsControl>

<ItemsControl Grid.Column="1" ItemsSource="{Binding RawMaterials}">
<!--<ItemsControl Grid.Column="1" ItemsSource="{Binding RawMaterials}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
@@ -436,7 +442,7 @@
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ItemsControl>-->

</Grid>

@@ -812,7 +818,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>

<TextBlock


+ 6
- 6
DosingSystem/ViewModel/ManualControlViewModel.cs View File

@@ -103,14 +103,14 @@ namespace BPASmartClient.DosingSystem.ViewModel
SystemStart = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.0", SystemControlText == "停止" ? false : true);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0");
SystemControlText = res ? "停止" : "启动";
/*var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0");
SystemControlText = res ? "停止" : "启动";*/
});
ModelSwitch = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.1", ModelSwitchText == "手动" ? true : false);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1");
ModelSwitchText = res ? "自动" : "手动";
/*var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1");
ModelSwitchText = res ? "自动" : "手动";*/
});

ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -130,8 +130,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
OtherHandCylinders.ElementAt(1).RightTog = GlobalDevice.PlcData.UnderCylinderDetection.HomeSignal;
OtherHandCylinders.ElementAt(1).LeftTog = GlobalDevice.PlcData.UnderCylinderDetection.InPlaceSignal;

//SystemControlText = GlobalDevice.PlcData.SystemStartOrStop ? "停止系统" : "启动系统";
//ModelSwitchText = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动";
SystemControlText = GlobalDevice.PlcData.SystemStartOrStop ? "停止" : "启动";
ModelSwitchText = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动";

Thread.Sleep(100);
}), "手动气缸状态监控");


+ 6
- 4
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -44,7 +44,6 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
await Task.Factory.StartNew(new Action(() =>
{

Recipes.ElementAt(index).IsEnable = true;
Json<LocaPar>.Data.Recipes.ElementAt(index).IsEnable = true;
Recipes.ElementAt(index).Are.Set();
@@ -434,7 +433,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item,2);
MessageNotify.GetInstance.ShowRunLog($"{res}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}
@@ -485,7 +485,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5);
string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5);
MessageNotify.GetInstance.ShowRunLog($"{res}");
//MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
@@ -535,7 +536,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5);
MessageNotify.GetInstance.ShowRunLog($"{res}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}


Loading…
Cancel
Save