PlcSettingViewModel.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using MvvmScaffoldFrame48.DLL.CommunicationTools;
  2. using MvvmScaffoldFrame48.DLL.ThreadManager;
  3. using MvvmScaffoldFrame48.Model.StorageModel.PlcParameter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Input;
  10. namespace MvvmScaffoldFrame48.ViewModel.ViewModel
  11. {
  12. public class PlcSettingViewModel:BaseViewModel
  13. {
  14. #region 界面绑定属性
  15. private string _ShowValue;
  16. public string ShowValue
  17. {
  18. get { return _ShowValue; }
  19. set
  20. {
  21. _ShowValue = value;
  22. OnPropertyChanged(nameof(ShowValue));
  23. }
  24. }
  25. #endregion
  26. #region 界面绑定事件
  27. public ICommand CheckTestCommand { get; set; }
  28. #endregion
  29. #region 属性
  30. private PlcCommunManager PlcCommunManager = null;
  31. #endregion
  32. #region 绑定用Action方法
  33. private void CheckTest(object e)
  34. {
  35. PlcCommunManager.RegisterMap.TryGetValue("test3", out PlcParameterModel Result);
  36. if (Result != null)
  37. {
  38. ShowValue = PlcCommunManager.ReadParameter(Result).ToString();
  39. }
  40. }
  41. #endregion
  42. #region 绑定用Predicate方法
  43. private bool CanTrue(object obj)
  44. {
  45. return true;
  46. }
  47. private bool CanFalse(object obj)
  48. {
  49. return false;
  50. }
  51. #endregion
  52. #region 其他方法
  53. public PlcSettingViewModel()
  54. {
  55. PlcCommunManager = PlcCommunManager.Instance;
  56. CheckTestCommand = new RelayCommand(CheckTest,CanTrue);
  57. }
  58. #endregion
  59. }
  60. }