终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ManualFlowViewModel.cs 8.6 KiB

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