IoViewModel.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.ObjectModel;
  2. using Aitex.Core.UI.MVVM;
  3. using MECF.Framework.Common.IOCore;
  4. using MECF.Framework.Simulator.Core.IoProviders;
  5. using EfemDualSimulator.Instances;
  6. namespace EfemDualSimulator.Views
  7. {
  8. public class IoViewModel : TimerViewModelBase
  9. {
  10. public SimulatorModulePlc PlcModule { get; set; }
  11. public SimulatorIO PlcSystem { get; set; }
  12. public ObservableCollection<NotifiableIoItem> DIs { get; set; }
  13. public ObservableCollection<NotifiableIoItem> DOs { get; set; }
  14. public ObservableCollection<NotifiableIoItem> AIs { get; set; }
  15. public ObservableCollection<NotifiableIoItem> AOs { get; set; }
  16. public IoViewModel(int port, string source, string ioMapPathFile, string module) : base(nameof(IoViewModel))
  17. {
  18. if (string.IsNullOrEmpty(module) )
  19. {
  20. PlcSystem = new SimulatorIO(port, source, ioMapPathFile);
  21. DIs = PlcSystem.DiItemList;
  22. DOs = PlcSystem.DoItemList;
  23. AIs = PlcSystem.AiItemList;
  24. AOs = PlcSystem.AoItemList;
  25. }
  26. else
  27. {
  28. PlcModule = new SimulatorModulePlc(port, source, ioMapPathFile, module);
  29. DIs = PlcModule.DiItemList;
  30. DOs = PlcModule.DoItemList;
  31. AIs = PlcModule.AiItemList;
  32. AOs = PlcModule.AoItemList;
  33. }
  34. }
  35. protected override void Poll()
  36. {
  37. }
  38. }
  39. }