终端一体化运控平台
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.
 
 
 

70 rivejä
3.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using BPA.Helper;
  8. using BPA.Helper;
  9. using BPASmartClient.SmallBatchingSystem.Views;
  10. using BPASmartClient.CustomResource.UserControls.MessageShow;
  11. using BPASmartClient.CustomResource.UserControls;
  12. using BPASmartClient.CustomResource.Pages.Model;
  13. namespace BPASmartClient.SmallBatchingSystem.ViewModels
  14. {
  15. public class RecipeControlViewModel : NotifyBase
  16. {
  17. public RecipeControlViewModel()
  18. {
  19. Recipes = Json<ConfigInfoModel>.Data.Recipes;
  20. StartCommand = new BPARelayCommand<object>((o) =>
  21. {
  22. Task.Factory.StartNew(() =>
  23. {
  24. if (PlcDataModel.RecipeBatchingComplete)
  25. {
  26. if (!string.IsNullOrEmpty(o?.ToString()))
  27. {
  28. int index = Array.FindIndex(Json<ConfigInfoModel>.Data.Recipes.ToArray(), p => p.RecipeName == o.ToString());
  29. if (index >= 0 && index < Json<ConfigInfoModel>.Data.Recipes.Count)
  30. {
  31. App.Current.Dispatcher.Invoke(() =>
  32. {
  33. var data = Json<ConfigInfoModel>.Data.Recipes.ElementAt(index);
  34. Control.GetInstance.RunLog($"下发配方:{data.RecipeName}");
  35. GrindArenaceousView grindArenaceousView = new GrindArenaceousView();
  36. ActionManage.GetInstance.Send("OpenRecipeStatusMotion", data);
  37. Control.GetInstance.MakeOrderQueue.Enqueue(data);
  38. Control.GetInstance.NotifyPrompt("配方下发成功!");
  39. grindArenaceousView.ShowDialog();
  40. });
  41. }
  42. }
  43. }
  44. else
  45. {
  46. //App.Current.Dispatcher.Invoke(() =>
  47. //{
  48. // NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", "配方下发失败,硬件设备状态未装备就绪!");
  49. //});
  50. MessageNotify.GetInstance.ShowDialog($"配方下发失败,硬件设备状态未装备就绪!", DialogType.Error);
  51. Control.GetInstance.RunLog("配方下发失败,硬件设备状态未装备就绪!");
  52. }
  53. });
  54. });
  55. DeviceInitCommand = new BPARelayCommand(() => { PlcServer.GetInstance.WriteData("M10.4", true); });
  56. }
  57. public BPARelayCommand DeviceInitCommand { get; set; }
  58. public ObservableCollection<RecipeInfo> Recipes { get; set; }
  59. public BPARelayCommand<object> StartCommand { get; set; }
  60. }
  61. }