终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

97 líneas
5.9 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BPA.Helper;
  7. using System.Collections.ObjectModel;
  8. using BPASmartClient.JXJFoodSmallStation.Model;
  9. using BPA.Helper;
  10. using BPASmartClient.CustomResource.UserControls.MessageShow;
  11. using BPASmartClient.CustomResource.UserControls;
  12. using System.Diagnostics;
  13. using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
  14. using BPASmartClient.JXJFoodSmallStation.Model.Par;
  15. using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
  16. using BPASmartClient.CustomResource.Pages.Model;
  17. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  18. {
  19. public class SystemParViewModel : NotifyBase
  20. {
  21. public SystemParViewModel()
  22. {
  23. SiemensConnect = Json<DevicePar>.Data.deviceConnectPar.SiemensConnect;
  24. WindSendConnect = Json<DevicePar>.Data.deviceConnectPar.WindSendConnect;
  25. HKPlcConnect = Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect;
  26. ShieldStockbinAlarm = Json<DevicePar>.Data.deviceConnectPar.ShieldStockbinAlarm;
  27. AxisLoadSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisLoadSpeed;
  28. AxisMidSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed;
  29. AxisUnLoadSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisUnLoadSpeed;
  30. AxisMidSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed;
  31. Axis1Speed = Json<DevicePar>.Data.deviceConnectPar.Axis1Speed;
  32. Axis2Speed = Json<DevicePar>.Data.deviceConnectPar.Axis2Speed;
  33. SaveCommand = new BPARelayCommand(() =>
  34. {
  35. Json<DevicePar>.Data.deviceConnectPar.SiemensConnect = SiemensConnect;
  36. Json<DevicePar>.Data.deviceConnectPar.WindSendConnect = WindSendConnect;
  37. Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect = HKPlcConnect;
  38. Json<DevicePar>.Data.deviceConnectPar.ShieldStockbinAlarm = ShieldStockbinAlarm;
  39. Json<DevicePar>.Data.deviceConnectPar.AxisLoadSpeed = AxisLoadSpeed;
  40. Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed;
  41. Json<DevicePar>.Data.deviceConnectPar.AxisUnLoadSpeed = AxisUnLoadSpeed;
  42. Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed;
  43. Json<DevicePar>.Data.deviceConnectPar.Axis1Speed = Axis1Speed;
  44. Json<DevicePar>.Data.deviceConnectPar.Axis2Speed = Axis2Speed;
  45. Json<DevicePar>.Save();
  46. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"系统设置参数保存成功!");
  47. MessageNotify.GetInstance.ShowUserLog("保存系统设置参数。");
  48. });
  49. SetParCommand = new BPARelayCommand(() =>
  50. {
  51. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD0", PlcVarType = PlcVarType.Real, Value = Axis1Speed });
  52. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD4", PlcVarType = PlcVarType.Real, Value = Axis2Speed });
  53. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW8", PlcVarType = PlcVarType.Int, Value = AxisLoadSpeed });
  54. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW10", PlcVarType = PlcVarType.Int, Value = AxisMidSpeed });
  55. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW12", PlcVarType = PlcVarType.Int, Value = AxisUnLoadSpeed });
  56. //ActionManage.GetInstance.Send("AxisLoadSpeedSet", AxisLoadSpeed);
  57. //ActionManage.GetInstance.Send("AxisMidSpeedSet", AxisMidSpeed);
  58. //ActionManage.GetInstance.Send("AxisUnLoadSpeedSet", AxisUnLoadSpeed);
  59. //ActionManage.GetInstance.Send("Axis1SpeedSet", Axis1Speed);
  60. //ActionManage.GetInstance.Send("Axis2SpeedSet", Axis2Speed);
  61. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"电机参数设置成功!");
  62. MessageNotify.GetInstance.ShowUserLog("电机设置参数下发成功。");
  63. });
  64. }
  65. public ConnectParMode CommBaseParModel { get { return Json<DevicePar>.Data.deviceConnectPar; } set { Json<DevicePar>.Data.deviceConnectPar = value; OnPropertyChanged(); } }
  66. public bool SiemensConnect { get { return _mSiemensConnect; } set { _mSiemensConnect = value; OnPropertyChanged(); } }
  67. private bool _mSiemensConnect;
  68. public bool WindSendConnect { get { return _mWindSendConnect; } set { _mWindSendConnect = value; OnPropertyChanged(); } }
  69. private bool _mWindSendConnect;
  70. public bool HKPlcConnect { get { return _mHKPlcConnect; } set { _mHKPlcConnect = value; OnPropertyChanged(); } }
  71. private bool _mHKPlcConnect;
  72. public bool ShieldStockbinAlarm { get { return _mShieldStockbinAlarm; } set { _mShieldStockbinAlarm = value; OnPropertyChanged(); } }
  73. private bool _mShieldStockbinAlarm;
  74. public short AxisLoadSpeed { get { return _mAxisLoadSpeed; } set { _mAxisLoadSpeed = value; OnPropertyChanged(); } }
  75. private short _mAxisLoadSpeed;
  76. public short AxisMidSpeed { get { return _mAxisMidSpeed; } set { _mAxisMidSpeed = value; OnPropertyChanged(); } }
  77. private short _mAxisMidSpeed;
  78. public short AxisUnLoadSpeed { get { return _mAxisUnLoadSpeed; } set { _mAxisUnLoadSpeed = value; OnPropertyChanged(); } }
  79. private short _mAxisUnLoadSpeed;
  80. public float Axis1Speed { get { return _mAxis1Speed; } set { _mAxis1Speed = value; OnPropertyChanged(); } }
  81. private float _mAxis1Speed;
  82. public float Axis2Speed { get { return _mAxis2Speed; } set { _mAxis2Speed = value; OnPropertyChanged(); } }
  83. private float _mAxis2Speed;
  84. public BPARelayCommand SaveCommand { get; set; }
  85. public BPARelayCommand SetParCommand { get; set; }
  86. }
  87. }