终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

78 wiersze
4.8 KiB

  1. using BPASmartClient.CustomResource.UserControls;
  2. using BPASmartClient.CustomResource.UserControls.MessageShow;
  3. using BPASmartClient.FoodStationTest.Model;
  4. using BPASmartClient.FoodStationTest.Model.HK_PLC;
  5. using BPASmartClient.FoodStationTest.Model.Par;
  6. using BPASmartClient.Helper;
  7. using Microsoft.Toolkit.Mvvm.ComponentModel;
  8. using Microsoft.Toolkit.Mvvm.Input;
  9. namespace BPASmartClient.FoodStationTest.ViewModel
  10. {
  11. public class SystemParViewModel : ObservableObject
  12. {
  13. public SystemParViewModel()
  14. {
  15. HKPlcConnect = Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect;
  16. ShieldStockbinAlarm = Json<DevicePar>.Data.deviceConnectPar.ShieldStockbinAlarm;
  17. AxisLoadSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisLoadSpeed;
  18. AxisMidSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed;
  19. AxisUnLoadSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisUnLoadSpeed;
  20. AxisMidSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed;
  21. Axis1Speed = Json<DevicePar>.Data.deviceConnectPar.Axis1Speed;
  22. Axis2Speed = Json<DevicePar>.Data.deviceConnectPar.Axis2Speed;
  23. SaveCommand = new RelayCommand(() =>
  24. {
  25. Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect = HKPlcConnect;
  26. Json<DevicePar>.Data.deviceConnectPar.ShieldStockbinAlarm = ShieldStockbinAlarm;
  27. Json<DevicePar>.Data.deviceConnectPar.AxisLoadSpeed = AxisLoadSpeed;
  28. Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed;
  29. Json<DevicePar>.Data.deviceConnectPar.AxisUnLoadSpeed = AxisUnLoadSpeed;
  30. Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed;
  31. Json<DevicePar>.Data.deviceConnectPar.Axis1Speed = Axis1Speed;
  32. Json<DevicePar>.Data.deviceConnectPar.Axis2Speed = Axis2Speed;
  33. Json<DevicePar>.Save();
  34. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数保存成功!");
  35. });
  36. SetParCommand = new RelayCommand(() =>
  37. {
  38. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD0", PlcVarType = PlcVarType.Real, Value = Axis1Speed });
  39. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD4", PlcVarType = PlcVarType.Real, Value = Axis2Speed });
  40. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW8", PlcVarType = PlcVarType.Int, Value = AxisLoadSpeed });
  41. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW10", PlcVarType = PlcVarType.Int, Value = AxisMidSpeed });
  42. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW12", PlcVarType = PlcVarType.Int, Value = AxisUnLoadSpeed });
  43. //ActionManage.GetInstance.Send("AxisLoadSpeedSet", AxisLoadSpeed);
  44. //ActionManage.GetInstance.Send("AxisMidSpeedSet", AxisMidSpeed);
  45. //ActionManage.GetInstance.Send("AxisUnLoadSpeedSet", AxisUnLoadSpeed);
  46. //ActionManage.GetInstance.Send("Axis1SpeedSet", Axis1Speed);
  47. //ActionManage.GetInstance.Send("Axis2SpeedSet", Axis2Speed);
  48. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数设置成功!");
  49. });
  50. }
  51. public ConnectParMode CommBaseParModel { get { return Json<DevicePar>.Data.deviceConnectPar; } set { Json<DevicePar>.Data.deviceConnectPar = value; OnPropertyChanged(); } }
  52. public bool HKPlcConnect { get { return _mHKPlcConnect; } set { _mHKPlcConnect = value; OnPropertyChanged(); } }
  53. private bool _mHKPlcConnect;
  54. public bool ShieldStockbinAlarm { get { return _mShieldStockbinAlarm; } set { _mShieldStockbinAlarm = value; OnPropertyChanged(); } }
  55. private bool _mShieldStockbinAlarm;
  56. public short AxisLoadSpeed { get { return _mAxisLoadSpeed; } set { _mAxisLoadSpeed = value; OnPropertyChanged(); } }
  57. private short _mAxisLoadSpeed;
  58. public short AxisMidSpeed { get { return _mAxisMidSpeed; } set { _mAxisMidSpeed = value; OnPropertyChanged(); } }
  59. private short _mAxisMidSpeed;
  60. public short AxisUnLoadSpeed { get { return _mAxisUnLoadSpeed; } set { _mAxisUnLoadSpeed = value; OnPropertyChanged(); } }
  61. private short _mAxisUnLoadSpeed;
  62. public float Axis1Speed { get { return _mAxis1Speed; } set { _mAxis1Speed = value; OnPropertyChanged(); } }
  63. private float _mAxis1Speed;
  64. public float Axis2Speed { get { return _mAxis2Speed; } set { _mAxis2Speed = value; OnPropertyChanged(); } }
  65. private float _mAxis2Speed;
  66. public RelayCommand SaveCommand { get; set; }
  67. public RelayCommand SetParCommand { get; set; }
  68. }
  69. }