终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

97 linhas
6.0 KiB

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