using BPASmartClient.CustomResource.UserControls; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.FoodStationTest.Model; using BPASmartClient.FoodStationTest.Model.HK_PLC; using BPASmartClient.FoodStationTest.Model.Par; using BPA.Helper; using BPA.Helper; namespace BPASmartClient.FoodStationTest.ViewModel { public class SystemParViewModel : NotifyBase { public SystemParViewModel() { HKPlcConnect = Json.Data.deviceConnectPar.HKPlcConnect; ShieldStockbinAlarm = Json.Data.deviceConnectPar.ShieldStockbinAlarm; AxisLoadSpeed = Json.Data.deviceConnectPar.AxisLoadSpeed; AxisMidSpeed = Json.Data.deviceConnectPar.AxisMidSpeed; AxisUnLoadSpeed = Json.Data.deviceConnectPar.AxisUnLoadSpeed; AxisMidSpeed = Json.Data.deviceConnectPar.AxisMidSpeed; Axis1Speed = Json.Data.deviceConnectPar.Axis1Speed; Axis2Speed = Json.Data.deviceConnectPar.Axis2Speed; SaveCommand = new BPARelayCommand(() => { Json.Data.deviceConnectPar.HKPlcConnect = HKPlcConnect; Json.Data.deviceConnectPar.ShieldStockbinAlarm = ShieldStockbinAlarm; Json.Data.deviceConnectPar.AxisLoadSpeed = AxisLoadSpeed; Json.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed; Json.Data.deviceConnectPar.AxisUnLoadSpeed = AxisUnLoadSpeed; Json.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed; Json.Data.deviceConnectPar.Axis1Speed = Axis1Speed; Json.Data.deviceConnectPar.Axis2Speed = Axis2Speed; Json.Save(); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数保存成功!"); }); SetParCommand = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD0", PlcVarType = PlcVarType.Real, Value = Axis1Speed }); ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD4", PlcVarType = PlcVarType.Real, Value = Axis2Speed }); ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW8", PlcVarType = PlcVarType.Int, Value = AxisLoadSpeed }); ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW10", PlcVarType = PlcVarType.Int, Value = AxisMidSpeed }); ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW12", PlcVarType = PlcVarType.Int, Value = AxisUnLoadSpeed }); //ActionManage.GetInstance.Send("AxisLoadSpeedSet", AxisLoadSpeed); //ActionManage.GetInstance.Send("AxisMidSpeedSet", AxisMidSpeed); //ActionManage.GetInstance.Send("AxisUnLoadSpeedSet", AxisUnLoadSpeed); //ActionManage.GetInstance.Send("Axis1SpeedSet", Axis1Speed); //ActionManage.GetInstance.Send("Axis2SpeedSet", Axis2Speed); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数设置成功!"); }); } public ConnectParMode CommBaseParModel { get { return Json.Data.deviceConnectPar; } set { Json.Data.deviceConnectPar = value; OnPropertyChanged(); } } public bool HKPlcConnect { get { return _mHKPlcConnect; } set { _mHKPlcConnect = value; OnPropertyChanged(); } } private bool _mHKPlcConnect; public bool ShieldStockbinAlarm { get { return _mShieldStockbinAlarm; } set { _mShieldStockbinAlarm = value; OnPropertyChanged(); } } private bool _mShieldStockbinAlarm; public short AxisLoadSpeed { get { return _mAxisLoadSpeed; } set { _mAxisLoadSpeed = value; OnPropertyChanged(); } } private short _mAxisLoadSpeed; public short AxisMidSpeed { get { return _mAxisMidSpeed; } set { _mAxisMidSpeed = value; OnPropertyChanged(); } } private short _mAxisMidSpeed; public short AxisUnLoadSpeed { get { return _mAxisUnLoadSpeed; } set { _mAxisUnLoadSpeed = value; OnPropertyChanged(); } } private short _mAxisUnLoadSpeed; public float Axis1Speed { get { return _mAxis1Speed; } set { _mAxis1Speed = value; OnPropertyChanged(); } } private float _mAxis1Speed; public float Axis2Speed { get { return _mAxis2Speed; } set { _mAxis2Speed = value; OnPropertyChanged(); } } private float _mAxis2Speed; public BPARelayCommand SaveCommand { get; set; } public BPARelayCommand SetParCommand { get; set; } } }