终端一体化运控平台
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

150 řádky
8.7 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPASmartClient.Helper;
  5. using BPASmartClient.JXJFoodBigStation.Model;
  6. using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
  7. using BPASmartClient.JXJFoodBigStation.Model.Siemens;
  8. using Microsoft.Toolkit.Mvvm.ComponentModel;
  9. using Microsoft.Toolkit.Mvvm.Input;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Collections.ObjectModel;
  13. using System.ComponentModel;
  14. using System.Linq;
  15. using System.Reflection;
  16. using System.Runtime.CompilerServices;
  17. using System.Text;
  18. using System.Threading;
  19. using System.Threading.Tasks;
  20. namespace BPASmartClient.JXJFoodBigStation.ViewModel
  21. {
  22. public class ManualFlowViewModel:ObservableObject
  23. {
  24. public ManualFlowViewModel()
  25. {
  26. TrayInPlace = new RelayCommand<object>((o) =>
  27. {
  28. if (o != null)
  29. {
  30. byte loc = Convert.ToByte(o);
  31. GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(loc, true);
  32. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"操作成功");
  33. MessageNotify.GetInstance.ShowUserLog($"手动点击AGV到达工位{loc}。");
  34. }
  35. });
  36. TrayLeave = new RelayCommand<object>((o) =>
  37. {
  38. if (o!=null)
  39. {
  40. byte loc = Convert.ToByte(o);
  41. GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(loc, false);
  42. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"操作成功");
  43. MessageNotify.GetInstance.ShowUserLog($"手动点击AGV离开工位{loc}。");
  44. }
  45. });
  46. ClearTrayInPlace = new RelayCommand(() =>
  47. {
  48. GVL_BigStation.AGVPutTray = 0;
  49. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"操作成功");
  50. MessageNotify.GetInstance.ShowUserLog($"手动点击清除AGV到位信号按钮。");
  51. });
  52. ClearAllRecipe = new RelayCommand(() =>
  53. {
  54. if (!MessageNotify.GetInstance.ShowDialog($"请确认,是否清除所有西门子配方?",DialogType.Warning))
  55. {
  56. return;
  57. }
  58. Json<RemoteRecipe>.Data.Recipes.Clear();
  59. GVL_BigStation.SiemensSendRecipeStatus = 0;
  60. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"清除所有配方完成");
  61. MessageNotify.GetInstance.ShowUserLog($"手动清除所有西门子配方。");
  62. });
  63. CancelRecipeCommand = new RelayCommand(() =>
  64. {
  65. if (!MessageNotify.GetInstance.ShowDialog($"请确认,是否取消订单【{CancelRecipeCode}】?", DialogType.Warning))
  66. {
  67. return;
  68. }
  69. if (Json<RemoteRecipe>.Data.Recipes != null)
  70. {
  71. int index = Array.FindIndex(Json<RemoteRecipe>.Data.Recipes.ToArray(), p => p.RecipeCode == CancelRecipeCode);
  72. if (index >= 0)
  73. {
  74. GVL_BigStation.Order_Cancel = true;
  75. GVL_BigStation.Order_CancelRecipeCode = CancelRecipeCode;
  76. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"订单取消完成");
  77. MessageNotify.GetInstance.ShowUserLog($"手动取消订单【{CancelRecipeCode}】。");
  78. }
  79. }
  80. });
  81. ThreadManage.GetInstance().StartLong(new Action(() =>
  82. {
  83. Heartbeat = GVL_BigStation.HeartBeatFromPlc;
  84. Thread.Sleep(100);
  85. StockBin1Name = GVL_BigStation.stockBinName.RawMaterialName1;
  86. StockBin2Name = GVL_BigStation.stockBinName.RawMaterialName2;
  87. StockBin3Name = GVL_BigStation.stockBinName.RawMaterialName3;
  88. StockBin4Name = GVL_BigStation.stockBinName.RawMaterialName4;
  89. StockBin5Name = GVL_BigStation.stockBinName.RawMaterialName5;
  90. StockBin6Name = GVL_BigStation.stockBinName.RawMaterialName6;
  91. StockBin7Name = GVL_BigStation.stockBinName.RawMaterialName7;
  92. StockBin8Name = GVL_BigStation.stockBinName.RawMaterialName8;
  93. StockBin9Name = GVL_BigStation.stockBinName.RawMaterialName9;
  94. StockBin10Name = GVL_BigStation.stockBinName.RawMaterialName10;
  95. StockBin11Name = GVL_BigStation.stockBinName.RawMaterialName11;
  96. StockBin12Name = GVL_BigStation.stockBinName.RawMaterialName12;
  97. StockBin13Name = GVL_BigStation.stockBinName.RawMaterialName13;
  98. StockBin14Name = GVL_BigStation.stockBinName.RawMaterialName14;
  99. }), "设备状态读取",true);
  100. }
  101. public RelayCommand<object> TrayInPlace { get; set; }
  102. public RelayCommand<object> TrayLeave { get; set; }
  103. public RelayCommand ClearTrayInPlace { get; set; }
  104. public RelayCommand ClearAllRecipe { get; set; }
  105. public static bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnStaticPropertyChanged(); } }
  106. private static bool _mHeartbeat;
  107. public string CancelRecipeCode { get { return _CancelRecipeCode; } set { _CancelRecipeCode = value; OnPropertyChanged(); } }
  108. public string _CancelRecipeCode { get; set; }
  109. public static string StockBin1Name { get { return _StockBin1Name; } set { _StockBin1Name = value; OnStaticPropertyChanged(); } }
  110. private static string _StockBin1Name { get; set; }
  111. public static string StockBin2Name { get { return _StockBin2Name; } set { _StockBin2Name = value; OnStaticPropertyChanged(); } }
  112. private static string _StockBin2Name { get; set; }
  113. public static string StockBin3Name { get { return _StockBin3Name; } set { _StockBin3Name = value; OnStaticPropertyChanged(); } }
  114. private static string _StockBin3Name { get; set; }
  115. public static string StockBin4Name { get { return _StockBin4Name; } set { _StockBin4Name = value; OnStaticPropertyChanged(); } }
  116. private static string _StockBin4Name { get; set; }
  117. public static string StockBin5Name { get { return _StockBin5Name; } set { _StockBin5Name = value; OnStaticPropertyChanged(); } }
  118. private static string _StockBin5Name { get; set; }
  119. public static string StockBin6Name { get { return _StockBin6Name; } set { _StockBin6Name = value; OnStaticPropertyChanged(); } }
  120. private static string _StockBin6Name { get; set; }
  121. public static string StockBin7Name { get { return _StockBin7Name; } set { _StockBin7Name = value; OnStaticPropertyChanged(); } }
  122. private static string _StockBin7Name { get; set; }
  123. public static string StockBin8Name { get { return _StockBin8Name; } set { _StockBin8Name = value; OnStaticPropertyChanged(); } }
  124. private static string _StockBin8Name { get; set; }
  125. public static string StockBin9Name { get { return _StockBin9Name; } set { _StockBin9Name = value; OnStaticPropertyChanged(); } }
  126. private static string _StockBin9Name { get; set; }
  127. public static string StockBin10Name { get { return _StockBin10Name; } set { _StockBin10Name = value; OnStaticPropertyChanged(); } }
  128. private static string _StockBin10Name { get; set; }
  129. public static string StockBin11Name { get { return _StockBin11Name; } set { _StockBin11Name = value; OnStaticPropertyChanged(); } }
  130. private static string _StockBin11Name { get; set; }
  131. public static string StockBin12Name { get { return _StockBin12Name; } set { _StockBin12Name = value; OnStaticPropertyChanged(); } }
  132. private static string _StockBin12Name { get; set; }
  133. public static string StockBin13Name { get { return _StockBin13Name; } set { _StockBin13Name = value; OnStaticPropertyChanged(); } }
  134. private static string _StockBin13Name { get; set; }
  135. public static string StockBin14Name { get { return _StockBin14Name; } set { _StockBin14Name = value; OnStaticPropertyChanged(); } }
  136. private static string _StockBin14Name { get; set; }
  137. public RelayCommand CancelRecipeCommand { get; set; }
  138. public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
  139. public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
  140. {
  141. StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
  142. }
  143. }
  144. }