|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPA.Helper;
- using System.Collections.ObjectModel;
- using BPASmartClient.JXJFoodSmallStation.Model;
- using BPA.Helper;
-
- 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 : NotifyBase
- {
- public ManualFlowViewModel()
- {
- time = GVL_SmallStation.GetInstance.Time;
- Test1Command = new BPARelayCommand(() =>
- {
- if (DateTime.Now.Subtract(GVL_SmallStation.GetInstance.LatestIssueRecipe).TotalSeconds<=10)
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"最后一次手动下发订单间隔不足10秒,请稍后再点击。");
- return;
- }
-
- 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 BPARelayCommand(() =>
- {
- 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 BPARelayCommand(() =>
- {
- 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 BPARelayCommand(() =>
- {
- 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 BPARelayCommand(() =>
- //{
- // GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet = true;
- // MessageNotify.GetInstance.ShowUserLog("手动点击按钮,粉料仓提升到位");
- //});
- Test6Command = new BPARelayCommand(() =>
- {
- ActionManage.GetInstance.Send("AGVPutTrayFinish");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,AGV放货架流程完成");
- });
- CLearRecipeInfo = new BPARelayCommand(() =>
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【PLC配方清零】操作"))
- {
- ActionManage.GetInstance.Send("CLearRecipeInfo");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,PLC配方清零");
- }
- });
- });
- SystemReset = new BPARelayCommand(() =>
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【PLC系统复位】操作"))
- {
- ActionManage.GetInstance.Send("ManualSystemReset");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,PLC系统复位");
- }
- });
- });
- BPAResetCommand = new BPARelayCommand(() =>
- {
- App.Current.Dispatcher.Invoke(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认,是否进行【上位机初始化】操作"))
- {
- ActionManage.GetInstance.Send("BPASystemReset");
- MessageNotify.GetInstance.ShowUserLog("手动点击按钮,上位机初始化");
- }
- });
- });
- StockbinDosingComple = new BPARelayCommand(() =>
- {
- 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 BPARelayCommand(() =>
- {
- //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, "提示", $"清除所有手动配料完成信号");
- });
- CancelRecipeCommand = new BPARelayCommand(() =>
- {
- string cancelRecipeCode = CancelRecipeCode.Trim();
- if (!String.IsNullOrEmpty(cancelRecipeCode) && MessageNotify.GetInstance.ShowDialog($"请确认,是否进行删除订单【{cancelRecipeCode}】操作?"))
- {
- if (Json<RemoteRecipeDataColl>.Data.Recipes != null)
- {
- int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == cancelRecipeCode);
- if (index >= 0)
- {
- GVL_SmallStation.GetInstance.Order_Cancel = true;
- GVL_SmallStation.GetInstance.Order_CancelRecipeCode = cancelRecipeCode;
- MessageNotify.GetInstance.ShowUserLog($"手动删除订单【{cancelRecipeCode}】。");
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"删除订单【{cancelRecipeCode}】成功!");
- return;
- }
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"删除订单【{cancelRecipeCode}】失败,未找到该订单。");
-
- }
- }
-
- });
- CompletedNumResetCommand = new BPARelayCommand(() =>
- {
- if (MessageNotify.GetInstance.ShowDialog("请确认,是否将配方完成数目清零?", DialogType.Warning))
- {
- GVL_SmallStation.GetInstance.RecipeDosingCompleNum = 0;
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", "配方完成数目清零成功!");
- MessageNotify.GetInstance.ShowUserLog("手动清零配方完成数目。");
- }
- });
- TaskManage.GetInstance.StartLong(new Action(() =>
- {
- RecipeDosingCompleNum = GVL_SmallStation.GetInstance.RecipeDosingCompleNum;
- 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 BPARelayCommand(() =>
- {
- 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 BPARelayCommand Test1Command { get; set; }
- public BPARelayCommand Test2Command { get; set; }
- public BPARelayCommand Test3Command { get; set; }
- public BPARelayCommand Test4Command { get; set; }
- public BPARelayCommand Test5Command { get; set; }
- public BPARelayCommand Test6Command { get; set; }
- public BPARelayCommand TimeSet { get; set; }
- public BPARelayCommand CompletedNumResetCommand { 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 BPARelayCommand CLearRecipeInfo { get; set; }
- public BPARelayCommand SystemReset { get; set; }
- public BPARelayCommand 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 BPARelayCommand StockbinDosingComple { get; set; }
- public BPARelayCommand StockbinDosingCompleClear { get; set; }
- public BPARelayCommand CancelRecipeCommand { get; set; }
- private static int _StockbinDosingCompleNum { get; set; }
- public static int StockbinDosingCompleNum { get { return _StockbinDosingCompleNum; } set { _StockbinDosingCompleNum = value; OnStaticPropertyChanged(); } }
-
-
- private static int _RecipeDosingCompleNum { get; set; }
- public static int RecipeDosingCompleNum { get { return _RecipeDosingCompleNum; } set { _RecipeDosingCompleNum = 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(); } }
-
- public string CancelRecipeCode { get { return _CancelRecipeCode; } set { _CancelRecipeCode = value; OnPropertyChanged(); } }
- public string _CancelRecipeCode { get; set; }
-
- private static Visibility _VisibilityBtn3 = Visibility.Hidden;
-
-
- }
- }
|