diff --git a/BPASmartClient.CustomResource/Themes/GenricStyle.xaml b/BPASmartClient.CustomResource/Themes/GenricStyle.xaml index 6f3f53a9..b34e41aa 100644 --- a/BPASmartClient.CustomResource/Themes/GenricStyle.xaml +++ b/BPASmartClient.CustomResource/Themes/GenricStyle.xaml @@ -11,13 +11,13 @@ - - - - - - - + + + + + + + - - + + - - - + \ No newline at end of file diff --git a/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml b/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml index b30d09af..419a45bf 100644 --- a/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml +++ b/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml @@ -22,15 +22,26 @@ - 14:48:30 + + 14:48:30 + - 星期一 + + 星期一 + 2021-11-13 diff --git a/BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml b/BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml index d1c7d721..37a5336b 100644 --- a/BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml +++ b/BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml @@ -12,7 +12,7 @@ mc:Ignorable="d"> + + + + + + + + + + + + 咖啡机状态 + + 应用状态 + + 告警信息 + + 故障信息 + + + + + 饮品 + + + + + + + + + + + + + + + + + + + DI输入 + + + + + + + + + + + + + + + DI0 + + + DI1 + + + DI2 + + + DI3 + + + DI4 + + + DI5 + + + DI6 + + + DI7 + + + + + + + + + + + + + + + + + + DO输出 + + + + DO0 + DO1 + DO2 + DO3 + DO4 + DO5 + DO6 + DO7 + + + + + + + True + false + + + + + + diff --git a/BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml.cs b/BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml.cs new file mode 100644 index 00000000..aa18d11e --- /dev/null +++ b/BPASmartClient.MorkT.Lebai.JC/View/DebugView.xaml.cs @@ -0,0 +1,37 @@ +using BPASmartClient.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.MorkTJAKAJC.View +{ + /// + /// DebugView.xaml 的交互逻辑 + /// + public partial class DebugView : UserControl + { + public DebugView() + { + InitializeComponent(); + } + + private void Dubug_Unloaded(object sender, RoutedEventArgs e) + { + ThreadManage.GetInstance().StopTask("MorkT-状态刷新"); + ThreadManage.GetInstance().StopTask("MorkT-传感器监视"); + + } + } + +} diff --git a/BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs new file mode 100644 index 00000000..6b6c242c --- /dev/null +++ b/BPASmartClient.MorkT.Lebai.JC/ViewModel/DebugViewModel.cs @@ -0,0 +1,235 @@ +using BPASmartClient.Business; +using BPASmartClient.Device; +using BPASmartClient.DRCoffee; +using BPASmartClient.EventBus; +using BPASmartClient.GSIceCream; +using BPASmartClient.Helper; +using BPASmartClient.LebaiRobot; +using BPASmartClient.Message; +using BPASmartClient.Model; +using BPASmartClient.Model.乐白机器人; +using BPASmartClient.Model.冰淇淋.Enum; +using BPASmartClient.Model.单片机; +using BPASmartClient.Model.单片机.Enum; +using BPASmartClient.Model.咖啡机.Enum; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +namespace BPASmartClient.MorkTLebaiJC.ViewModel; + public class DebugViewModel : ObservableObject + { + + #region 乐白机器人 + /// + /// 乐白机器人连接状态 + /// + public string RobotConnected { get { return _robotConnected; } set { _robotConnected = value; OnPropertyChanged(); } } + private string _robotConnected { get; set; } + /// + /// 乐白机器人的模式状态 + /// + public string RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } } + private string _robotMode { get; set; } + /// + /// 机器人控制指令 + /// + public RelayCommand Button_RobotControlCommand { get; set; } + /// + /// 机器人控制 + /// + /// + private void Button_RobotControl(object o) + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiControlEvent { DeviceId = DeviceId, LebaiControl = o.ToString() }); + } + + #endregion + + #region 果汁机 + /// + /// 果汁机的连接状态 + /// + public string JuicerConnected { get { return _JuicerConnected; } set { _JuicerConnected = value; OnPropertyChanged(); } } + private string _JuicerConnected { get; set; } + + /// + /// 果汁机的状态 + /// + public string JuicerState { get { return _JuicerState; } set { _JuicerState = value; OnPropertyChanged(); } } + private string _JuicerState { get; set; } + + #endregion + + #region 咖啡机 + /// + /// 咖啡机连接状态 + /// + public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } } + private string _coffeeConnected { get; set; } + /// + /// 咖啡机状态 + /// + public string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } } + private string _coffeeStatus { get; set; } + /// + /// 应用状态 + /// + public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } } + private string _appStatus { get; set; } + /// + /// 告警 + /// + public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } } + public string _warning { get; set; } + /// + /// 故障信息 + /// + public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } } + public string _caffeeFault { get; set; } + + public List Coffees { get; set; } = new List(); + public string SelectedCoffee { get; set; } + + public List CoffeeCmds { get; set; } = new List(); + public string SelectedCoffeeCmd { get; set; } + /// + /// 制作咖啡 + /// + public RelayCommand Button_MakeCoffeeCommand { get; set; } + /// + /// 停止制作咖啡 + /// + public RelayCommand Button_StopMakeCoffeCommand { get; set; } + /// + /// 咖啡模式设置 + /// + public RelayCommand Button_CoffeeModeSetCommand { get; set; } + + private void Button_MakeCoffee() + { + EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)}); + } + private void Button_StopMakeCoffe() + { + EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId }); + } + private void Button_CoffeeModeSet() + { + EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)}); + } + #endregion + + #region 单片机 + public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } } + private string _mcuConnected { get; set; } + + public RelayCommand Button_MCUOuputCommand { get; set; } + public RelayCommand Button_MCUDOuputCommand { get; set; } + public RelayCommand Button_LebaiDOuputCommand { get; set; } + + public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } } + private int _pwmInputNumber = 1; + + public int MCU_PWM_CH { get { return _choosePWM; } set { _choosePWM = value; OnPropertyChanged(); } } + private int _choosePWM = 1; + + public int MCU_DO_CH { get { return _mcuDO_CH; } set { _mcuDO_CH = value; OnPropertyChanged(); } } + private int _mcuDO_CH = 1; + + public int Lebai_DO_CH { get { return _lebaiDO_CH; } set { _lebaiDO_CH = value; OnPropertyChanged(); } } + private int _lebaiDO_CH = 1; + + public int Lebai_DO_Value { get { return _lebaiDO_Value; } set { _lebaiDO_Value = value; OnPropertyChanged(); } } + private int _lebaiDO_Value = 1; + + private int[] DICH { get { return _diCH; } set { _diCH = value; OnPropertyChanged(); } } + private int[] _diCH = new int[8]; + + public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } } + private bool _mcu_DO_Valuer = true; + + private void Button_McuOutput() + { + string sChoosePWM =Convert.ToString(MCU_PWM_CH+1); + new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish(); + } + private void Button_McuDOutput() + { + string sChooseDO = Convert.ToString(MCU_DO_CH + 1); + new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish(); + } + private void Button_LebaiDOutput() + { + string sChooseDO = Convert.ToString(Lebai_DO_CH + 1); + + } + #endregion + + /// + /// 设备ID + /// + public int DeviceId { get; set; } + /// + /// 设备数据 + /// + public ObservableCollection variableMonitors { get; set; } + + public DebugViewModel() + { + Button_RobotControlCommand = new RelayCommand(Button_RobotControl); + Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee); + Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe); + Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet); + + Button_MCUOuputCommand = new RelayCommand(Button_McuOutput); + Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput); + Button_LebaiDOuputCommand = new RelayCommand(Button_LebaiDOutput); + foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) + { + Coffees.Add(code.ToString()); + } + SelectedCoffee = Coffees[0]; + foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd))) + { + CoffeeCmds.Add(code.ToString()); + } + SelectedCoffeeCmd = CoffeeCmds[0]; + + Plugin.GetInstance()?.GetPlugin()?.GetDevices().ForEach(device => + { + if (device.Name == "MorkT") DeviceId = device.DeviceId + ; + }); + + + + ThreadManage.GetInstance().StartLong(new Action(() => + { + + variableMonitors = Plugin.GetInstance()?.GetPlugin()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors; + + if (variableMonitors != null && variableMonitors.Count > 0) + { + RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + JuicerConnected = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + MCUConnected = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + + RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue; + + CoffeeStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机状态").CurrentValue; + AppStatus = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机应用状态").CurrentValue; + Warning = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机告警").CurrentValue; + CaffeeFault = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机故障").CurrentValue; + + + } + Thread.Sleep(500); + }), "MorkT-状态刷新"); + } + } + diff --git a/BPASmartClient.MorkT.Lebai.JC/ViewModel/MonitorViewModel.cs b/BPASmartClient.MorkT.Lebai.JC/ViewModel/MonitorViewModel.cs new file mode 100644 index 00000000..2a61a967 --- /dev/null +++ b/BPASmartClient.MorkT.Lebai.JC/ViewModel/MonitorViewModel.cs @@ -0,0 +1,94 @@ +using BPASmartClient.Business; +using BPASmartClient.Helper; +using BPASmartClient.Model.乐白机器人; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace BPASmartClient.MorkTLebaiJC.ViewModel +{ + + public class MonitorViewModel: ObservableObject + { + #region 传感器 + /// + /// 机器人夹爪传感器 + /// + public bool RobotSenser { get { return _robotSenser; } set { _robotSenser = value; OnPropertyChanged(); } } + private bool _robotSenser; + /// + /// 冰淇淋出口传感器 + /// + public bool IceCreamSenser { get { return _iceCreamSenser; } set { _iceCreamSenser = value; OnPropertyChanged(); } } + private bool _iceCreamSenser; + /// + /// 取餐口检测传感器 + /// + public bool TakeMealSenser { get { return _takeMealSenser; } set { _takeMealSenser = value; OnPropertyChanged(); } } + private bool _takeMealSenser; + + #endregion + + + /// + /// 设备ID + /// + int DeviceId; + public MonitorViewModel() + { + Plugin.GetInstance()?.GetPlugin()?.GetDevices().ForEach(device => + { + if (device.Name == "MorkT") DeviceId = device.DeviceId; + + }); + ThreadManage.GetInstance().StartLong(new Action(() => + { + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 1 },(res)=> + { + if(res != null&& res.Length>0&& res[0] is bool b) + { + RobotSenser = b; + } + }); + + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (res) => + { + if (res != null && res.Length > 0 && res[0] is bool b) + { + TakeMealSenser = b; + } + }); + + EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 3 }, (res) => + { + if (res != null && res.Length > 0 && res[0] is bool b) + { + IceCreamSenser = b; + } + }); + Thread.Sleep(500); + }), "MorkT-传感器监视"); + } + } + + public class BoolToColorConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return (bool) value? new SolidColorBrush(Color.FromRgb(144, 238, 144)) : new SolidColorBrush(Color.FromRgb(178, 34, 34)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + +} diff --git a/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml b/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml index a1e6ee6b..5cbc00e6 100644 --- a/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml +++ b/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml @@ -79,11 +79,11 @@ + - - 1 + + @@ -330,7 +332,7 @@ - DI0 + DI0 DI1 @@ -372,7 +374,7 @@ DO输出 - + DO0 DO1 DO2 @@ -384,10 +386,10 @@ - + - True + True false diff --git a/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs b/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs index 9a5f1480..aa18d11e 100644 --- a/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs +++ b/BPASmartClient.Morkt.JAKA.JC/View/DebugView.xaml.cs @@ -30,6 +30,8 @@ namespace BPASmartClient.MorkTJAKAJC.View { ThreadManage.GetInstance().StopTask("MorkT-状态刷新"); ThreadManage.GetInstance().StopTask("MorkT-传感器监视"); + } } + } diff --git a/BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs b/BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs index 9b0c3763..35951331 100644 --- a/BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs +++ b/BPASmartClient.Morkt.JAKA.JC/ViewModel/DebugViewModel.cs @@ -19,7 +19,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading; - namespace BPASmartClient.MorkTJAKAJC.ViewModel; public class DebugViewModel : ObservableObject { @@ -65,109 +64,104 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel; public string JuicerState { get { return _JuicerState; } set { _JuicerState = value; OnPropertyChanged(); } } private string _JuicerState { get; set; } - #endregion + #endregion #region 咖啡机 - /// - /// 咖啡机连接状态 - /// - public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } } - private string _coffeeConnected { get; set; } - /// - /// 咖啡机状态 - /// - public string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } } - private string _coffeeStatus { get; set; } - /// - /// 应用状态 - /// - public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } } - private string _appStatus { get; set; } - /// - /// 告警 - /// - public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } } - public string _warning { get; set; } - /// - /// 故障信息 - /// - public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } } - public string _caffeeFault { get; set; } - - public List Coffees { get; set; } = new List(); - public string SelectedCoffee { get; set; } - - public List CoffeeCmds { get; set; } = new List(); - public string SelectedCoffeeCmd { get; set; } - /// - /// 制作咖啡 - /// - public RelayCommand Button_MakeCoffeeCommand { get; set; } - /// - /// 停止制作咖啡 - /// - public RelayCommand Button_StopMakeCoffeCommand { get; set; } - /// - /// 咖啡模式设置 + /// + /// 咖啡机连接状态 /// - public RelayCommand Button_CoffeeModeSetCommand { get; set; } - - private void Button_MakeCoffee() - { - EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)}); - } - private void Button_StopMakeCoffe() - { - EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId }); - } - private void Button_CoffeeModeSet() - { - EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)}); - } - #endregion - - #region 单片机 + public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } } + private string _coffeeConnected { get; set; } + /// + /// 咖啡机状态 + /// + public string CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } } + private string _coffeeStatus { get; set; } + /// + /// 应用状态 + /// + public string AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } } + private string _appStatus { get; set; } /// - /// 咖啡杯或冰淇淋杯落杯 + /// 告警 /// - public RelayCommand Button_CupControlCommand { get; set; } + public string Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } } + public string _warning { get; set; } /// - /// 单片机冰淇淋机器制冷 + /// 故障信息 /// - public RelayCommand Button_SCChipRefrigerationCommand { get; set; } + public string CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } } + public string _caffeeFault { get; set; } + + public List Coffees { get; set; } = new List(); + public string SelectedCoffee { get; set; } + + public List CoffeeCmds { get; set; } = new List(); + public string SelectedCoffeeCmd { get; set; } /// - /// 单片机冰淇淋机器打料 + /// 制作咖啡 /// - public RelayCommand Button_SCChipDischargeCommand { get; set; } + public RelayCommand Button_MakeCoffeeCommand { get; set; } /// - /// 模拟测试 + /// 停止制作咖啡 /// - public RelayCommand Button_SCChipTestCommand { get; set; } + public RelayCommand Button_StopMakeCoffeCommand { get; set; } + /// + /// 咖啡模式设置 + /// + public RelayCommand Button_CoffeeModeSetCommand { get; set; } - private void Button_CupControl(object CupType) + private void Button_MakeCoffee() { - EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent() { DeviceId = DeviceId, Cup = (IC_CUP)Enum.Parse(typeof(IC_CUP), CupType.ToString()) }); + EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)}); } - - private void Button_SCChipRefrigeration() + private void Button_StopMakeCoffe() { - EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = true }); - Thread.Sleep(500); - EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = false }); - + EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId }); } - - private void Button_SCChipDischarge() + private void Button_CoffeeModeSet() { - EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 }); + EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)}); } - #endregion - /// - /// 设备ID - /// - public int DeviceId { get; set; } + #region 单片机 + public string MCUConnected { get { return _mcuConnected; } set { _mcuConnected = value; OnPropertyChanged(); } } + private string _mcuConnected { get; set; } + + public RelayCommand Button_MCUOuputCommand { get; set; } + public RelayCommand Button_MCUDOuputCommand { get; set; } + public int PWMInputNumber { get { return _pwmInputNumber; } set { _pwmInputNumber = value; OnPropertyChanged(); } } + private int _pwmInputNumber = 1; + + public int MCU_PWM_CH { get { return _choosePWM; } set { _choosePWM = value; OnPropertyChanged(); } } + private int _choosePWM = 1; + + public int MCU_DO_CH { get { return _mcuDO_CH; } set { _mcuDO_CH = value; OnPropertyChanged(); } } + private int _mcuDO_CH = 1; + + private int[] DICH { get { return _diCH; } set { _diCH = value; OnPropertyChanged(); } } + private int[] _diCH = new int[8]; + + public bool MCU_DO_Value { get { return _mcu_DO_Valuer; } set { _mcu_DO_Valuer = value; OnPropertyChanged(); } } + private bool _mcu_DO_Valuer = true; + + private void Button_McuOutput() + { + string sChoosePWM =Convert.ToString(MCU_PWM_CH+1); + new WriteMcu() { TagName = "ServoControl", Address = sChoosePWM, Value = PWMInputNumber }.Publish(); + } + private void Button_McuDOutput() + { + string sChooseDO = Convert.ToString(MCU_DO_CH + 1); + new WriteMcu() { TagName = "OutputControl", Address = sChooseDO, Value = MCU_DO_Value }.Publish(); + } + #endregion + + /// + /// 设备ID + /// + public int DeviceId { get; set; } /// /// 设备数据 /// @@ -180,15 +174,8 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel; Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe); Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet); - Button_CupControlCommand = new RelayCommand(Button_CupControl); - Button_SCChipRefrigerationCommand = new RelayCommand(Button_SCChipRefrigeration); - Button_SCChipDischargeCommand = new RelayCommand(Button_SCChipDischarge); - Button_SCChipTestCommand = new RelayCommand(() => - { - Button_SCChipRefrigeration(); - Thread.Sleep(50); - Button_SCChipDischarge(); - }); + Button_MCUOuputCommand = new RelayCommand(Button_McuOutput); + Button_MCUDOuputCommand = new RelayCommand(Button_McuDOutput); foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) { @@ -216,9 +203,10 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel; if (variableMonitors != null && variableMonitors.Count > 0) { - RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + RobotConnected = variableMonitors.FirstOrDefault(p=>p.Notes == "机器人连接状态").CurrentValue == "True" ? "已连接" : "未连接"; CoffeeConnected = variableMonitors.FirstOrDefault(p => p.Notes == "咖啡机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; JuicerConnected = variableMonitors.FirstOrDefault(p => p.Notes == "果汁机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; + MCUConnected = variableMonitors.FirstOrDefault(p => p.Notes == "单片机连接状态").CurrentValue == "True" ? "已连接" : "未连接"; RobotMode = variableMonitors.FirstOrDefault(p => p.Notes == "机器人状态").CurrentValue; @@ -229,7 +217,6 @@ namespace BPASmartClient.MorkTJAKAJC.ViewModel; } - Thread.Sleep(500); }), "MorkT-状态刷新"); } diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config index fc532a83..4e21d83c 100644 --- a/BPASmartClient/App.config +++ b/BPASmartClient/App.config @@ -7,14 +7,14 @@ - + - + diff --git a/DosingSystem/DosingSystem.csproj b/DosingSystem/DosingSystem.csproj index e2f57fa2..7dff77c7 100644 --- a/DosingSystem/DosingSystem.csproj +++ b/DosingSystem/DosingSystem.csproj @@ -5,10 +5,18 @@ net6.0-windows enable true + app.manifest + hbl.ico + + + + + + @@ -16,4 +24,10 @@ + + + $(DefaultXamlRuntime) + + + diff --git a/DosingSystem/Model/ActionMenu.cs b/DosingSystem/Model/ActionMenu.cs new file mode 100644 index 00000000..1313a488 --- /dev/null +++ b/DosingSystem/Model/ActionMenu.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; + +namespace DosingSystem.Model +{ + public class ActionMenu : ObservableObject + { + public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } } + private string _mCommandParameter; + + public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } + private Permission[] _mpermission; + + public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } + private string _mMenuName; + + } +} diff --git a/DosingSystem/Model/Config.cs b/DosingSystem/Model/Config.cs new file mode 100644 index 00000000..607e43f8 --- /dev/null +++ b/DosingSystem/Model/Config.cs @@ -0,0 +1,49 @@ +using BPA.Message; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DosingSystem.Model +{ + public class Config + { + + private volatile static Config _Instance; + public static Config GetInstance => _Instance ?? (_Instance = new Config()); + private Config() { } + + + public void Init() + { + if (File.Exists("up.hbl")) + { + var result = JsonConvert.DeserializeObject(File.ReadAllText("up.hbl").AESDecrypt()); + if (result == null || (result != null && result.userInfos.Count <= 0)) + { + AddData(); + } + else + { + Global.userManager = result; + } + } + else + { + AddData(); + } + } + + private void AddData() + { + Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.管理员, UserName = "admin", Password = "admin" }); + Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.操作员, UserName = "czy", Password = "123456" }); + Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.观察员, UserName = "gcy", Password = "654321" }); + Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.技术员, UserName = "jsy", Password = "88888888" }); + File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); + } + } +} diff --git a/DosingSystem/Model/Global.cs b/DosingSystem/Model/Global.cs new file mode 100644 index 00000000..d068c78a --- /dev/null +++ b/DosingSystem/Model/Global.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DosingSystem.Model +{ + public class Global + { + public static UserManager userManager { get; set; } = new UserManager(); + } +} diff --git a/DosingSystem/Model/UserManager.cs b/DosingSystem/Model/UserManager.cs new file mode 100644 index 00000000..6c2fc247 --- /dev/null +++ b/DosingSystem/Model/UserManager.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DosingSystem.Model +{ + public class UserManager + { + public List userInfos { get; set; } = new List(); + } + + public class UserInfo + { + public Permission permission { get; set; } + public string UserName { get; set; } + public string Password { get; set; } + + } + + public enum Permission : int + { + 管理员 = 1, + 操作员 = 2, + 观察员 = 3, + 技术员=4 + } + +} diff --git a/DosingSystem/View/AdminstratorsView.xaml b/DosingSystem/View/AdminstratorsView.xaml new file mode 100644 index 00000000..208b641a --- /dev/null +++ b/DosingSystem/View/AdminstratorsView.xaml @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +