|
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPA.Helper;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using BPASmartClient.SmallBatchingSystem.Views;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.CustomResource.UserControls;
-
- namespace BPASmartClient.SmallBatchingSystem.ViewModels
- {
- public class RecipeControlViewModel : ObservableObject
- {
- public RecipeControlViewModel()
- {
- Recipes = Json<ConfigInfoModel>.Data.Recipes;
- StartCommand = new RelayCommand<object>((o) =>
- {
- Task.Factory.StartNew(() =>
- {
- if (PlcDataModel.RecipeBatchingComplete)
- {
- if (!string.IsNullOrEmpty(o?.ToString()))
- {
- int index = Array.FindIndex(Json<ConfigInfoModel>.Data.Recipes.ToArray(), p => p.RecipeName == o.ToString());
- if (index >= 0 && index < Json<ConfigInfoModel>.Data.Recipes.Count)
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- var data = Json<ConfigInfoModel>.Data.Recipes.ElementAt(index);
- Control.GetInstance.RunLog($"下发配方:{data.RecipeName}");
- GrindArenaceousView grindArenaceousView = new GrindArenaceousView();
- ActionManage.GetInstance.Send("OpenRecipeStatusMotion", data);
- Control.GetInstance.MakeOrderQueue.Enqueue(data);
- Control.GetInstance.NotifyPrompt("配方下发成功!");
- grindArenaceousView.ShowDialog();
- });
- }
- }
- }
- else
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", "配方下发失败,硬件设备状态未装备就绪!");
- });
- Control.GetInstance.RunLog("配方下发失败,硬件设备状态未装备就绪!");
- }
- });
- });
-
- DeviceInitCommand = new RelayCommand(() => { PlcServer.GetInstance.WriteData("M10.3", true); });
- }
-
- public RelayCommand DeviceInitCommand { get; set; }
-
- public ObservableCollection<RecipeInfo> Recipes { get; set; }
-
- public RelayCommand<object> StartCommand { get; set; }
-
- }
- }
|