|
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPA.Helper;
- using BPA.Helper;
-
- using BPASmartClient.SmallBatchingSystem.Views;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.Pages.Model;
-
- namespace BPASmartClient.SmallBatchingSystem.ViewModels
- {
- public class RecipeControlViewModel : NotifyBase
- {
- public RecipeControlViewModel()
- {
- Recipes = Json<ConfigInfoModel>.Data.Recipes;
- StartCommand = new BPARelayCommand<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, "错误", "配方下发失败,硬件设备状态未装备就绪!");
- //});
- MessageNotify.GetInstance.ShowDialog($"配方下发失败,硬件设备状态未装备就绪!", DialogType.Error);
-
- Control.GetInstance.RunLog("配方下发失败,硬件设备状态未装备就绪!");
- }
- });
- });
-
- DeviceInitCommand = new BPARelayCommand(() => { PlcServer.GetInstance.WriteData("M10.4", true); });
- }
-
- public BPARelayCommand DeviceInitCommand { get; set; }
-
- public ObservableCollection<RecipeInfo> Recipes { get; set; }
-
- public BPARelayCommand<object> StartCommand { get; set; }
-
- }
- }
|