终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

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