IoViewModel.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows;
  7. using System.Windows.Input;
  8. using Aitex.Core.Common.DeviceData;
  9. using Aitex.Core.UI.MVVM;
  10. using Aitex.Core.Util;
  11. using MECF.Framework.Common.IOCore;
  12. using Xceed.Wpf.Toolkit;
  13. namespace Aitex.Sorter.UI.ViewModel
  14. {
  15. public class IoViewModel : UIViewModelBase
  16. {
  17. public ObservableCollection<NotifiableIoItem> Card1DiList { get; set; }
  18. public ObservableCollection<NotifiableIoItem> Card2DiList { get; set; }
  19. public ObservableCollection<NotifiableIoItem> Card1DoList { get; set; }
  20. public ObservableCollection<NotifiableIoItem> Card2DoList { get; set; }
  21. private List<NotifiableIoItem> _di;
  22. [Subscription("DI", SystemStateModule)]
  23. public List<NotifiableIoItem> DiListData
  24. {
  25. get
  26. {
  27. return _di;
  28. }
  29. set
  30. {
  31. _di = value;
  32. Application.Current.Dispatcher.Invoke(new Action(() =>
  33. {
  34. Card1DiList.Clear();
  35. Card2DiList.Clear();
  36. _di.ForEach(x=>
  37. {
  38. if (x.Provider.ToLower()=="system.dio000")
  39. Card1DiList.Add(x);
  40. if (x.Provider.ToLower() == "system.dio001")
  41. Card2DiList.Add(x);
  42. });
  43. }));
  44. }
  45. }
  46. private List<NotifiableIoItem> _do;
  47. [Subscription("DO", SystemStateModule)]
  48. public List<NotifiableIoItem> DoListData
  49. {
  50. get
  51. {
  52. return _do;
  53. }
  54. set
  55. {
  56. _do = value;
  57. Application.Current.Dispatcher.Invoke(new Action(() =>
  58. {
  59. Card1DoList.Clear();
  60. Card2DoList.Clear();
  61. _do.ForEach(x=>
  62. {
  63. if (x.Provider.ToLower()== "system.dio000")
  64. Card1DoList.Add(x);
  65. if (x.Provider.ToLower() == "system.dio001")
  66. Card2DoList.Add(x);
  67. });
  68. }));
  69. }
  70. }
  71. public ICommand SetDoCommand
  72. {
  73. get; set;
  74. }
  75. public IoViewModel() : base("IoViewModel")
  76. {
  77. Card1DiList = new ObservableCollection<NotifiableIoItem>();
  78. Card2DiList = new ObservableCollection<NotifiableIoItem>();
  79. Card1DoList = new ObservableCollection<NotifiableIoItem>();
  80. Card2DoList = new ObservableCollection<NotifiableIoItem>();
  81. SetDoCommand = new DelegateCommand<string>(PerformSetDo);
  82. }
  83. private void PerformSetDo(string ioName)
  84. {
  85. }
  86. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  87. {
  88. //data[UIKey(UnitName.System.ToString(), ParamName.WaferInfoRobotAligner01)] = new WaferInfo("dummy", WaferStatus.Normal);
  89. }
  90. }
  91. }