终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

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