终端一体化运控平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

88 satır
5.4 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. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  18. {
  19. public class SystemParViewModel : ObservableObject
  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. AxisLoadSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisLoadSpeed;
  27. AxisMidSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed;
  28. AxisUnLoadSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisUnLoadSpeed;
  29. AxisMidSpeed = Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed;
  30. Axis1Speed = Json<DevicePar>.Data.deviceConnectPar.Axis1Speed;
  31. Axis2Speed = Json<DevicePar>.Data.deviceConnectPar.Axis2Speed;
  32. SaveCommand = new RelayCommand(() =>
  33. {
  34. Json<DevicePar>.Data.deviceConnectPar.SiemensConnect = SiemensConnect;
  35. Json<DevicePar>.Data.deviceConnectPar.WindSendConnect = WindSendConnect;
  36. Json<DevicePar>.Data.deviceConnectPar.HKPlcConnect = HKPlcConnect;
  37. Json<DevicePar>.Data.deviceConnectPar.AxisLoadSpeed = AxisLoadSpeed;
  38. Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed;
  39. Json<DevicePar>.Data.deviceConnectPar.AxisUnLoadSpeed = AxisUnLoadSpeed;
  40. Json<DevicePar>.Data.deviceConnectPar.AxisMidSpeed = AxisMidSpeed;
  41. Json<DevicePar>.Data.deviceConnectPar.Axis1Speed = Axis1Speed;
  42. Json<DevicePar>.Data.deviceConnectPar.Axis2Speed = Axis2Speed;
  43. Json<DevicePar>.Save();
  44. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数保存成功!");
  45. });
  46. SetParCommand = new RelayCommand(() =>
  47. {
  48. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD0", PlcVarType = PlcVarType.Real, Value = Axis1Speed });
  49. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBD4", PlcVarType = PlcVarType.Real, Value = Axis2Speed });
  50. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW8", PlcVarType = PlcVarType.Int, Value = AxisLoadSpeed });
  51. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW10", PlcVarType = PlcVarType.Int, Value = AxisMidSpeed });
  52. ActionManage.GetInstance.Send("PLCWrite", new HKDeviceWrite() { Address = "DB47.DBW12", PlcVarType = PlcVarType.Int, Value = AxisUnLoadSpeed });
  53. //ActionManage.GetInstance.Send("AxisLoadSpeedSet", AxisLoadSpeed);
  54. //ActionManage.GetInstance.Send("AxisMidSpeedSet", AxisMidSpeed);
  55. //ActionManage.GetInstance.Send("AxisUnLoadSpeedSet", AxisUnLoadSpeed);
  56. //ActionManage.GetInstance.Send("Axis1SpeedSet", Axis1Speed);
  57. //ActionManage.GetInstance.Send("Axis2SpeedSet", Axis2Speed);
  58. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"参数设置成功!");
  59. });
  60. }
  61. public ConnectParMode CommBaseParModel { get { return Json<DevicePar>.Data.deviceConnectPar; } set { Json<DevicePar>.Data.deviceConnectPar = value; OnPropertyChanged(); } }
  62. public bool SiemensConnect { get { return _mSiemensConnect; } set { _mSiemensConnect = value; OnPropertyChanged(); } }
  63. private bool _mSiemensConnect;
  64. public bool WindSendConnect { get { return _mWindSendConnect; } set { _mWindSendConnect = value; OnPropertyChanged(); } }
  65. private bool _mWindSendConnect;
  66. public bool HKPlcConnect { get { return _mHKPlcConnect; } set { _mHKPlcConnect = value; OnPropertyChanged(); } }
  67. private bool _mHKPlcConnect;
  68. public short AxisLoadSpeed { get { return _mAxisLoadSpeed; } set { _mAxisLoadSpeed = value; OnPropertyChanged(); } }
  69. private short _mAxisLoadSpeed;
  70. public short AxisMidSpeed { get { return _mAxisMidSpeed; } set { _mAxisMidSpeed = value; OnPropertyChanged(); } }
  71. private short _mAxisMidSpeed;
  72. public short AxisUnLoadSpeed { get { return _mAxisUnLoadSpeed; } set { _mAxisUnLoadSpeed = value; OnPropertyChanged(); } }
  73. private short _mAxisUnLoadSpeed;
  74. public float Axis1Speed { get { return _mAxis1Speed; } set { _mAxis1Speed = value; OnPropertyChanged(); } }
  75. private float _mAxis1Speed;
  76. public float Axis2Speed { get { return _mAxis2Speed; } set { _mAxis2Speed = value; OnPropertyChanged(); } }
  77. private float _mAxis2Speed;
  78. public RelayCommand SaveCommand { get; set; }
  79. public RelayCommand SetParCommand { get; set; }
  80. }
  81. }