|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System.Collections.ObjectModel;
- using BPASmartClient.JXJFoodSmallStation.Model;
- using BPASmartClient.Helper;
- using Microsoft.Toolkit.Mvvm.Input;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.CustomResource.UserControls;
- using System.Diagnostics;
- using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
- using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
- using System.Threading;
- using System.ComponentModel;
- using System.Runtime.CompilerServices;
- using BPASmartClient.CustomResource.Pages.Model;
- using System.Windows;
-
- namespace BPASmartClient.JXJFoodSmallStation.ViewModel
- {
- public class ManualFlowViewModel : ObservableObject
- {
- public ManualFlowViewModel()
- {
- time = GVL_SmallStation.GetInstance.Time;
- Test1Command = new RelayCommand(() =>
- {
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX8.0", PlcVarType = PlcVarType.Bool, Value = true });
- Thread.Sleep(200);
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX8.0", PlcVarType = PlcVarType.Bool, Value = false });
- //GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true;
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,AGV送托盘完成");
-
- VisibilityBtn1 = Visibility.Hidden;
- VisibilityBtn2 = Visibility.Visible;
- VisibilityBtn3 = Visibility.Hidden;
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,AGV送托盘完成");
- });
- Test2Command = new RelayCommand(() =>
- {
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX4.0", PlcVarType = PlcVarType.Bool, Value = true });
- //Thread.Sleep(200);
- //ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX4.0", PlcVarType = PlcVarType.Bool, Value = false });
- //GVL_SmallStation.GetInstance.WindSendDosingComple = true;
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,粉料仓配料完成");
-
- VisibilityBtn1 = Visibility.Hidden;
- VisibilityBtn2 = Visibility.Hidden;
- VisibilityBtn3 = Visibility.Visible;
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,粉料仓配料完成");
- });
- Test3Command = new RelayCommand(() =>
- {
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX10.0", PlcVarType = PlcVarType.Bool, Value = true });
- Thread.Sleep(200);
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX10.0", PlcVarType = PlcVarType.Bool, Value = false });
- //GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true;
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,AGV取托盘完成");
-
- VisibilityBtn1 = Visibility.Visible;
- VisibilityBtn2 = Visibility.Hidden;
- VisibilityBtn3 = Visibility.Hidden;
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,AGV取托盘完成");
- });
- Test4Command = new RelayCommand(() =>
- {
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX1.5", PlcVarType = PlcVarType.Bool, Value = true });
- //GVL_SmallStation.GetInstance.CylinderReset = true;
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,气缸收紧错位复位");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,气缸收紧错位复位");
- });
- Test5Command = new RelayCommand(() =>
- {
- GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet = true;
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,粉料仓提升到位");
- });
- Test6Command = new RelayCommand(() =>
- {
- ActionManage.GetInstance.Send("AGVPutTrayFinish");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,AGV放货架流程完成");
- });
- CLearRecipeInfo = new RelayCommand(() =>
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【PLC配方清零】操作"))
- {
- ActionManage.GetInstance.Send("CLearRecipeInfo");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,PLC配方清零");
- }
- });
- });
- SystemReset = new RelayCommand(() =>
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【PLC系统复位】操作"))
- {
- ActionManage.GetInstance.Send("ManualSystemReset");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,PLC系统复位");
- }
- });
- });
- BPAResetCommand = new RelayCommand(() =>
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【上位机初始化】操作"))
- {
- ActionManage.GetInstance.Send("BPASystemReset");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,上位机初始化");
- }
- });
- });
- StockbinDosingComple = new RelayCommand(() =>
- {
- int loc = StockbinDosingCompleNum;
- if (loc >= 1 && loc <= 8)
- {
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX12." + (loc - 1), PlcVarType = PlcVarType.Bool, Value = true });
-
- MessageNotify.GetInstance.ShowUserLog($"手动点击按钮,给plc料仓{loc}配料完成信号");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,手动设置料仓{loc}配料完成");
- }
- else if (loc >= 9 && loc <= 15)
- {
- ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB4.DBX13." + (loc - 9), PlcVarType = PlcVarType.Bool, Value = true });
-
- MessageNotify.GetInstance.ShowUserLog($"手动点击按钮,给plc料仓{loc}配料完成信号");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,手动设置料仓{loc}配料完成");
- }
- else
- {
- MessageNotify.GetInstance.ShowUserLog("料仓编号不正确");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"手动点击按钮,手动设置料仓{loc}配料,料仓编号不正确");
- }
- });
- StockbinDosingCompleClear = new RelayCommand(() =>
- {
- //for (int i = 0; i < GVL_SmallStation.GetInstance.StockInDosingComple.Length; i++)
- //{
- // GVL_SmallStation.GetInstance.StockInDosingComple[i] = false;
- //}
- //MessageNotify.GetInstance.ShowUserLog($"手动点击按钮,清除所有手动配料完成信号");
- //NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"清除所有手动配料完成信号");
- });
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- Recipe1DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[0].ToBinString();
- Recipe2DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[1].ToBinString();
- Recipe3DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[2].ToBinString();
- Recipe4DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[3].ToBinString();
- Recipe5DosingComplete = GVL_SmallStation.GetInstance.RecipeStockBinDosing[4].ToBinString();
- Heartbeat = GVL_SmallStation.GetInstance.HeartBeatFromPlc;
- switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
- {
- case 0:
- OrderStatus = IssueRecipeCondition.等待小料站PLC允许下配方.ToString();
- break;
- case 1:
- OrderStatus = IssueRecipeCondition.等待西门子下发配方.ToString();
- break;
- case 2:
- OrderStatus = IssueRecipeCondition.等待西门子下发配方信号复位.ToString();
- break;
- case 3:
- OrderStatus = IssueRecipeCondition.等待上位机请求配料.ToString();
- break;
- case 4:
- OrderStatus = IssueRecipeCondition.等待西门子确认配料.ToString();
- break;
- case 5:
- OrderStatus = IssueRecipeCondition.等待西门子确认配料信号复位.ToString();
- break;
- case 6:
- OrderStatus = "上位机将配方添加到队列中";
- break;
- default:
- OrderStatus = "无意义";
- break;
- }
- switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[0])
- {
- case 0:
- Recipe1DosingStatus = ProcessCondition.等待AGV到位.ToString();
- break;
- case 1:
- Recipe1DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
- break;
- case 2:
- Recipe1DosingStatus = ProcessCondition.等待配方配料完成.ToString();
- break;
- default:
- break;
- }
- switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[1])
- {
- case 0:
- Recipe2DosingStatus = ProcessCondition.等待AGV到位.ToString();
- break;
- case 1:
- Recipe2DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
- break;
- case 2:
- Recipe2DosingStatus = ProcessCondition.等待配方配料完成.ToString();
- break;
- default:
- break;
- }
- switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[2])
- {
- case 0:
- Recipe3DosingStatus = ProcessCondition.等待AGV到位.ToString();
- break;
- case 1:
- Recipe3DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
- break;
- case 2:
- Recipe3DosingStatus = ProcessCondition.等待配方配料完成.ToString();
- break;
- default:
- break;
- }
- switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[3])
- {
- case 0:
- Recipe4DosingStatus = ProcessCondition.等待AGV到位.ToString();
- break;
- case 1:
- Recipe4DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
- break;
- case 2:
- Recipe4DosingStatus = ProcessCondition.等待配方配料完成.ToString();
- break;
- default:
- break;
- }
- switch (GVL_SmallStation.GetInstance.RecipeProcessStatus[4])
- {
- case 0:
- Recipe5DosingStatus = ProcessCondition.等待AGV到位.ToString();
- break;
- case 1:
- Recipe5DosingStatus = ProcessCondition.等待小料站PLC接受配方完成.ToString();
- break;
- case 2:
- Recipe5DosingStatus = ProcessCondition.等待配方配料完成.ToString();
- break;
- default:
- break;
- }
- Thread.Sleep(100);
- }), "流程手动设备状态读取", true);
- TimeSet = new RelayCommand(() =>
- {
- GVL_SmallStation.GetInstance.Time = time;
- MessageNotify.GetInstance.ShowUserLog($"设置柔性味魔方复位时间:{time}s");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{time.ToString()}:设置成功!");
- });
- SiemensIsConnect = ProcessControl.GetInstance.SiemensDevice.IsConnected;
- HKPlcIsConnect = ProcessControl.GetInstance.HKDevice.IsConnected;
- WindSendIsConnect = ProcessControl.GetInstance.WindSendDevice.IsConnected;
- }
- public RelayCommand Test1Command { get; set; }
- public RelayCommand Test2Command { get; set; }
- public RelayCommand Test3Command { get; set; }
- public RelayCommand Test4Command { get; set; }
- public RelayCommand Test5Command { get; set; }
- public RelayCommand Test6Command { get; set; }
- public RelayCommand TimeSet { get; set; }
- public static bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnStaticPropertyChanged(); } }
- private static bool _mHeartbeat;
-
- public int time { get { return _mtime; } set { _mtime = value; OnStaticPropertyChanged(); } }
- private int _mtime;
- public static string OrderStatus { get { return _mOrderStatus; } set { _mOrderStatus = value; OnStaticPropertyChanged(); } }
- private static string _mOrderStatus = "无意义";
- public static string Recipe1DosingStatus { get { return _mRecipe1DosingStatus; } set { _mRecipe1DosingStatus = value; OnStaticPropertyChanged(); } }
- private static string _mRecipe1DosingStatus = "无意义";
- public static string Recipe2DosingStatus { get { return _mRecipe2DosingStatus; } set { _mRecipe2DosingStatus = value; OnStaticPropertyChanged(); } }
- private static string _mRecipe2DosingStatus = "无意义";
- public static string Recipe3DosingStatus { get { return _mRecipe3DosingStatus; } set { _mRecipe3DosingStatus = value; OnStaticPropertyChanged(); } }
- private static string _mRecipe3DosingStatus = "无意义";
- public static string Recipe4DosingStatus { get { return _mRecipe4DosingStatus; } set { _mRecipe4DosingStatus = value; OnStaticPropertyChanged(); } }
- private static string _mRecipe4DosingStatus = "无意义";
- public static string Recipe5DosingStatus { get { return _mRecipe5DosingStatus; } set { _mRecipe5DosingStatus = value; OnStaticPropertyChanged(); } }
- private static string _mRecipe5DosingStatus = "无意义";
-
-
- public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
- public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
- {
- StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
- }
- public RelayCommand CLearRecipeInfo { get; set; }
- public RelayCommand SystemReset { get; set; }
- public RelayCommand BPAResetCommand { get; set; }
- private bool _SiemensIsConnect { get; set; }
- public bool SiemensIsConnect { get { return _SiemensIsConnect; } set { _SiemensIsConnect = value; OnPropertyChanged(); } }
- private bool _HKPlcIsConnect { get; set; }
- public bool HKPlcIsConnect { get { return _HKPlcIsConnect; } set { _HKPlcIsConnect = value; OnPropertyChanged(); } }
- private bool _WindSendIsConnect { get; set; }
- public bool WindSendIsConnect { get { return _WindSendIsConnect; } set { _WindSendIsConnect = value; OnPropertyChanged(); } }
-
-
- private static string _Recipe1DosingComplete { get; set; }
- public static string Recipe1DosingComplete { get { return _Recipe1DosingComplete; } set { _Recipe1DosingComplete = value; OnStaticPropertyChanged(); } }
-
- private static string _Recipe2DosingComplete { get; set; }
- public static string Recipe2DosingComplete { get { return _Recipe2DosingComplete; } set { _Recipe2DosingComplete = value; OnStaticPropertyChanged(); } }
-
- private static string _Recipe3DosingComplete { get; set; }
- public static string Recipe3DosingComplete { get { return _Recipe3DosingComplete; } set { _Recipe3DosingComplete = value; OnStaticPropertyChanged(); } }
- private static string _Recipe4DosingComplete { get; set; }
- public static string Recipe4DosingComplete { get { return _Recipe4DosingComplete; } set { _Recipe4DosingComplete = value; OnStaticPropertyChanged(); } }
- private static string _Recipe5DosingComplete { get; set; }
- public static string Recipe5DosingComplete { get { return _Recipe5DosingComplete; } set { _Recipe5DosingComplete = value; OnStaticPropertyChanged(); } }
-
-
- public RelayCommand StockbinDosingComple { get; set; }
- public RelayCommand StockbinDosingCompleClear { get; set; }
- private static int _StockbinDosingCompleNum { get; set; }
- public static int StockbinDosingCompleNum { get { return _StockbinDosingCompleNum; } set { _StockbinDosingCompleNum = value; OnStaticPropertyChanged(); } }
-
-
- public static Visibility VisibilityBtn1 { get { return _VisibilityBtn1; } set { _VisibilityBtn1 = value; OnStaticPropertyChanged(); } }
- private static Visibility _VisibilityBtn1 = Visibility.Visible;
- public static Visibility VisibilityBtn2 { get { return _VisibilityBtn2; } set { _VisibilityBtn2 = value; OnStaticPropertyChanged(); } }
- private static Visibility _VisibilityBtn2 = Visibility.Hidden;
- public static Visibility VisibilityBtn3 { get { return _VisibilityBtn3; } set { _VisibilityBtn3 = value; OnStaticPropertyChanged(); } }
- private static Visibility _VisibilityBtn3 = Visibility.Hidden;
- }
- }
|