终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ManualFlowViewModel.cs 17 KiB

1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
1 ano atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.CustomResource.UserControls;
  3. using BPASmartClient.CustomResource.UserControls.MessageShow;
  4. using BPASmartClient.FoodStationTest.Model;
  5. using BPASmartClient.FoodStationTest.Model.HK_PLC;
  6. using BPA.Helper;
  7. using BPA.Helper;
  8. using System;
  9. using System.ComponentModel;
  10. using System.Linq;
  11. using System.Runtime.CompilerServices;
  12. using System.Threading;
  13. using System.Windows;
  14. namespace BPASmartClient.FoodStationTest.ViewModel
  15. {
  16. public class ManualFlowViewModel : NotifyBase
  17. {
  18. public ManualFlowViewModel()
  19. {
  20. time = GVL_SmallStation.GetInstance.Time;
  21. Test4Command = new BPARelayCommand(() =>
  22. {
  23. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX1.5", PlcVarType = PlcVarType.Bool, Value = true });
  24. //GVL_SmallStation.GetInstance.CylinderReset = true;
  25. MessageNotify.GetInstance.ShowUserLog("手动点击按钮,气缸收紧错位复位");
  26. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,气缸收紧错位复位");
  27. });
  28. CLearRecipeInfo = new BPARelayCommand(() =>
  29. {
  30. App.Current.Dispatcher.Invoke(() =>
  31. {
  32. if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【PLC配方清零】操作"))
  33. {
  34. ActionManage.GetInstance.Send("CLearRecipeInfo");
  35. MessageNotify.GetInstance.ShowUserLog("手动点击按钮,PLC配方清零");
  36. }
  37. });
  38. });
  39. SystemReset = new BPARelayCommand(() =>
  40. {
  41. App.Current.Dispatcher.Invoke(() =>
  42. {
  43. if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【PLC系统复位】操作"))
  44. {
  45. ActionManage.GetInstance.Send("ManualSystemReset");
  46. MessageNotify.GetInstance.ShowUserLog("手动点击按钮,PLC系统复位");
  47. }
  48. });
  49. });
  50. BPAResetCommand = new BPARelayCommand(() =>
  51. {
  52. App.Current.Dispatcher.Invoke(() =>
  53. {
  54. if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【上位机初始化】操作"))
  55. {
  56. ActionManage.GetInstance.Send("BPASystemReset");
  57. MessageNotify.GetInstance.ShowUserLog("手动点击按钮,上位机初始化");
  58. }
  59. });
  60. });
  61. StockbinDosingComple = new BPARelayCommand(() =>
  62. {
  63. int loc = StockbinDosingCompleNum;
  64. if (loc >= 1 && loc <= 8)
  65. {
  66. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX12." + (loc - 1), PlcVarType = PlcVarType.Bool, Value = true });
  67. MessageNotify.GetInstance.ShowUserLog($"手动点击按钮,给plc料仓{loc}配料完成信号");
  68. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,手动设置料仓{loc}配料完成");
  69. }
  70. else if (loc >= 9 && loc <= 15)
  71. {
  72. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX13." + (loc - 9), PlcVarType = PlcVarType.Bool, Value = true });
  73. MessageNotify.GetInstance.ShowUserLog($"手动点击按钮,给plc料仓{loc}配料完成信号");
  74. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,手动设置料仓{loc}配料完成");
  75. }
  76. else
  77. {
  78. MessageNotify.GetInstance.ShowUserLog("料仓编号不正确");
  79. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,手动设置料仓{loc}配料,料仓编号不正确");
  80. }
  81. });
  82. StockbinDosingCompleClear = new BPARelayCommand(() =>
  83. {
  84. });
  85. CancelRecipeCommand = new BPARelayCommand(() =>
  86. {
  87. string cancelRecipeCode = CancelRecipeCode.Trim();
  88. if (!String.IsNullOrEmpty(cancelRecipeCode) && MessageNotify.GetInstance.ShowDialog($"请确认,是否进行删除订单【{cancelRecipeCode}】操作?"))
  89. {
  90. if (Json<RemoteRecipeDataColl>.Data.Recipes != null)
  91. {
  92. int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == cancelRecipeCode);
  93. if (index >= 0)
  94. {
  95. GVL_SmallStation.GetInstance.Order_Cancel = true;
  96. GVL_SmallStation.GetInstance.Order_CancelRecipeCode = cancelRecipeCode;
  97. MessageNotify.GetInstance.ShowUserLog($"手动删除订单【{cancelRecipeCode}】。");
  98. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"删除订单【{cancelRecipeCode}】成功!");
  99. return;
  100. }
  101. NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"删除订单【{cancelRecipeCode}】失败,未找到该订单。");
  102. }
  103. }
  104. });
  105. CompletedNumResetCommand = new BPARelayCommand(() =>
  106. {
  107. if (MessageNotify.GetInstance.ShowDialog("请确认,是否将配方完成数目清零?", DialogType.Warning))
  108. {
  109. GVL_SmallStation.GetInstance.RecipeDosingCompleNum = 0;
  110. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", "配方完成数目清零成功!");
  111. MessageNotify.GetInstance.ShowUserLog("手动清零配方完成数目。");
  112. }
  113. });
  114. TaskManage.GetInstance.StartLong(new Action(() =>
  115. {
  116. RecipeDosingCompleNum = GVL_SmallStation.GetInstance.RecipeDosingCompleNum;
  117. Recipe1DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[0].ToBinString();
  118. Recipe2DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[1].ToBinString();
  119. Recipe3DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[2].ToBinString();
  120. Recipe4DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[3].ToBinString();
  121. Recipe5DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[4].ToBinString();
  122. Heartbeat = GVL_SmallStation.GetInstance.HeartBeatFromPlc;
  123. switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
  124. {
  125. case 0:
  126. OrderStatus = IssueRecipeCondition.等待小料站PLC允许下配方.ToString();
  127. break;
  128. case 1:
  129. OrderStatus = IssueRecipeCondition.等待西门子下发配方.ToString();
  130. break;
  131. case 2:
  132. OrderStatus = IssueRecipeCondition.等待西门子下发配方信号复位.ToString();
  133. break;
  134. case 3:
  135. OrderStatus = IssueRecipeCondition.等待上位机请求配料.ToString();
  136. break;
  137. case 4:
  138. OrderStatus = IssueRecipeCondition.等待西门子确认配料.ToString();
  139. break;
  140. case 5:
  141. OrderStatus = IssueRecipeCondition.等待西门子确认配料信号复位.ToString();
  142. break;
  143. case 6:
  144. OrderStatus = "上位机将配方添加到队列中";
  145. break;
  146. default:
  147. OrderStatus = "无意义";
  148. break;
  149. }
  150. switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[0])
  151. {
  152. case 0:
  153. Recipe1DosingStatus = ProcessCondition.等待AGV到位.ToString();
  154. break;
  155. case 1:
  156. Recipe1DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
  157. break;
  158. case 2:
  159. Recipe1DosingStatus = ProcessCondition.等待配方配料完成.ToString();
  160. break;
  161. default:
  162. break;
  163. }
  164. switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[1])
  165. {
  166. case 0:
  167. Recipe2DosingStatus = ProcessCondition.等待AGV到位.ToString();
  168. break;
  169. case 1:
  170. Recipe2DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
  171. break;
  172. case 2:
  173. Recipe2DosingStatus = ProcessCondition.等待配方配料完成.ToString();
  174. break;
  175. default:
  176. break;
  177. }
  178. switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[2])
  179. {
  180. case 0:
  181. Recipe3DosingStatus = ProcessCondition.等待AGV到位.ToString();
  182. break;
  183. case 1:
  184. Recipe3DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
  185. break;
  186. case 2:
  187. Recipe3DosingStatus = ProcessCondition.等待配方配料完成.ToString();
  188. break;
  189. default:
  190. break;
  191. }
  192. switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[3])
  193. {
  194. case 0:
  195. Recipe4DosingStatus = ProcessCondition.等待AGV到位.ToString();
  196. break;
  197. case 1:
  198. Recipe4DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
  199. break;
  200. case 2:
  201. Recipe4DosingStatus = ProcessCondition.等待配方配料完成.ToString();
  202. break;
  203. default:
  204. break;
  205. }
  206. switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[4])
  207. {
  208. case 0:
  209. Recipe5DosingStatus = ProcessCondition.等待AGV到位.ToString();
  210. break;
  211. case 1:
  212. Recipe5DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
  213. break;
  214. case 2:
  215. Recipe5DosingStatus = ProcessCondition.等待配方配料完成.ToString();
  216. break;
  217. default:
  218. break;
  219. }
  220. Thread.Sleep(100);
  221. }), "流程手动设备状态读取", true);
  222. TimeSet = new BPARelayCommand(() =>
  223. {
  224. GVL_SmallStation.GetInstance.Time = time;
  225. MessageNotify.GetInstance.ShowUserLog($"设置柔性味魔方复位时间:{time}s");
  226. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{time.ToString()}:设置成功!");
  227. });
  228. HKPlcIsConnect = ProcessControl.GetInstance.HKDevice.IsConnected;
  229. }
  230. public BPARelayCommand Test4Command { get; set; }
  231. public BPARelayCommand TimeSet { get; set; }
  232. public BPARelayCommand CompletedNumResetCommand { get; set; }
  233. public static bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnStaticPropertyChanged(); } }
  234. private static bool _mHeartbeat;
  235. public int time { get { return _mtime; } set { _mtime = value; OnStaticPropertyChanged(); } }
  236. private int _mtime;
  237. public static string OrderStatus { get { return _mOrderStatus; } set { _mOrderStatus = value; OnStaticPropertyChanged(); } }
  238. private static string _mOrderStatus = "无意义";
  239. public static string Recipe1DosingStatus { get { return _mRecipe1DosingStatus; } set { _mRecipe1DosingStatus = value; OnStaticPropertyChanged(); } }
  240. private static string _mRecipe1DosingStatus = "无意义";
  241. public static string Recipe2DosingStatus { get { return _mRecipe2DosingStatus; } set { _mRecipe2DosingStatus = value; OnStaticPropertyChanged(); } }
  242. private static string _mRecipe2DosingStatus = "无意义";
  243. public static string Recipe3DosingStatus { get { return _mRecipe3DosingStatus; } set { _mRecipe3DosingStatus = value; OnStaticPropertyChanged(); } }
  244. private static string _mRecipe3DosingStatus = "无意义";
  245. public static string Recipe4DosingStatus { get { return _mRecipe4DosingStatus; } set { _mRecipe4DosingStatus = value; OnStaticPropertyChanged(); } }
  246. private static string _mRecipe4DosingStatus = "无意义";
  247. public static string Recipe5DosingStatus { get { return _mRecipe5DosingStatus; } set { _mRecipe5DosingStatus = value; OnStaticPropertyChanged(); } }
  248. private static string _mRecipe5DosingStatus = "无意义";
  249. public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
  250. public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
  251. {
  252. StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
  253. }
  254. public BPARelayCommand CLearRecipeInfo { get; set; }
  255. public BPARelayCommand SystemReset { get; set; }
  256. public BPARelayCommand BPAResetCommand { get; set; }
  257. private bool _SiemensIsConnect { get; set; }
  258. public bool SiemensIsConnect { get { return _SiemensIsConnect; } set { _SiemensIsConnect = value; OnPropertyChanged(); } }
  259. private bool _HKPlcIsConnect { get; set; }
  260. public bool HKPlcIsConnect { get { return _HKPlcIsConnect; } set { _HKPlcIsConnect = value; OnPropertyChanged(); } }
  261. private bool _WindSendIsConnect { get; set; }
  262. public bool WindSendIsConnect { get { return _WindSendIsConnect; } set { _WindSendIsConnect = value; OnPropertyChanged(); } }
  263. private static string _Recipe1DosingComplete { get; set; }
  264. public static string Recipe1DosingComplete { get { return _Recipe1DosingComplete; } set { _Recipe1DosingComplete = value; OnStaticPropertyChanged(); } }
  265. private static string _Recipe2DosingComplete { get; set; }
  266. public static string Recipe2DosingComplete { get { return _Recipe2DosingComplete; } set { _Recipe2DosingComplete = value; OnStaticPropertyChanged(); } }
  267. private static string _Recipe3DosingComplete { get; set; }
  268. public static string Recipe3DosingComplete { get { return _Recipe3DosingComplete; } set { _Recipe3DosingComplete = value; OnStaticPropertyChanged(); } }
  269. private static string _Recipe4DosingComplete { get; set; }
  270. public static string Recipe4DosingComplete { get { return _Recipe4DosingComplete; } set { _Recipe4DosingComplete = value; OnStaticPropertyChanged(); } }
  271. private static string _Recipe5DosingComplete { get; set; }
  272. public static string Recipe5DosingComplete { get { return _Recipe5DosingComplete; } set { _Recipe5DosingComplete = value; OnStaticPropertyChanged(); } }
  273. public BPARelayCommand StockbinDosingComple { get; set; }
  274. public BPARelayCommand StockbinDosingCompleClear { get; set; }
  275. public BPARelayCommand CancelRecipeCommand { get; set; }
  276. private static int _StockbinDosingCompleNum { get; set; }
  277. public static int StockbinDosingCompleNum { get { return _StockbinDosingCompleNum; } set { _StockbinDosingCompleNum = value; OnStaticPropertyChanged(); } }
  278. private static int _RecipeDosingCompleNum { get; set; }
  279. public static int RecipeDosingCompleNum { get { return _RecipeDosingCompleNum; } set { _RecipeDosingCompleNum = value; OnStaticPropertyChanged(); } }
  280. public string CancelRecipeCode { get { return _CancelRecipeCode; } set { _CancelRecipeCode = value; OnPropertyChanged(); } }
  281. public string _CancelRecipeCode { get; set; }
  282. }
  283. }