| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 | 
							- using Aitex.Common.Util;
 
- using Aitex.Core.UI.MVVM;
 
- using Aitex.Core.Util;
 
- using Aitex.Core.Utilities;
 
- using PunkHPX8_Simulator.Devices;
 
- using MECF.Framework.Common.Device.Festo;
 
- using MECF.Framework.Simulator.Core.Commons;
 
- using System.Collections.ObjectModel;
 
- using System.IO;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Input;
 
- using System.Xml.Linq;
 
- namespace PunkHPX8_Simulator.Views
 
- {
 
-     /// <summary>
 
-     /// FestoView.xaml 的交互逻辑
 
-     /// </summary>
 
-     public partial class FestoView : UserControl
 
-     {
 
-         public FestoView()
 
-         {
 
-             InitializeComponent();
 
-             this.Loaded += OnViewLoaded;
 
-         }
 
-         private void OnViewLoaded(object sender, RoutedEventArgs e)
 
-         {
 
-             (DataContext as TimerViewModelBase)?.Start();
 
-         }        
 
-     }
 
-     class FestoViewModel : SocketDeviceViewModel
 
-     {
 
-         #region 属性
 
-         public string Title
 
-         {
 
-             get { return "Festo Simulator"; }
 
-         }
 
-         private string _DOSelectedItem;
 
-         [IgnorePropertyChange]
 
-         public string DOSelectedItem
 
-         {
 
-             get
 
-             {
 
-                 return _DOSelectedItem;
 
-             }
 
-             set
 
-             {
 
-                 _DOSelectedItem = value;
 
-             }
 
-         }
 
-         private int _DOInputValue;
 
-         [IgnorePropertyChange]
 
-         public int DOInputValue
 
-         {
 
-             get
 
-             {
 
-                 return _DOInputValue;
 
-             }
 
-             set
 
-             {
 
-                 _DOInputValue = value;
 
-             }
 
-         }
 
-         private int _DOCurrentValue;
 
-         [IgnorePropertyChange]
 
-         public int DOCurrentValue
 
-         {
 
-             get
 
-             {
 
-                 return _DOCurrentValue;
 
-             }
 
-             set
 
-             {
 
-                 _DOCurrentValue = value;
 
-             }
 
-         }
 
-         public ObservableCollection<string> DONameItems { get; set; }
 
-         public ObservableCollection<int> DigitalOutputSelected { get; set; }
 
-         #endregion
 
-         public ICommand SetDOCommand { get; set; }
 
-         public ICommand DOSelectionChangedCommand { get; set; }
 
-         private FestoSocketSimulator _sim;
 
-         public FestoViewModel(string str) : base("FestoViewModel")
 
-         {
 
-             int.TryParse(str, out int port);
 
-             _sim = new FestoSocketSimulator(port);
 
-             Init(_sim);
 
-             InitData(port);
 
-             SetDOCommand = new DelegateCommand<object>(SetDOAction);
 
-             DOSelectionChangedCommand = new DelegateCommand<object>(DOSelectionChangedAction);
 
-         }
 
-         private void InitData(int port)
 
-         {
 
-             DigitalOutputSelected = new ObservableCollection<int> { 0, 1 };
 
-             DONameItems = new ObservableCollection<string>();
 
-             foreach (var item in _sim.FestoNameIndexDic.Keys)
 
-             {
 
-                 DONameItems.Add(item);
 
-             }    
 
-         }
 
-         private void SetDOAction(object obj)
 
-         {
 
-             _sim.UpdataDOBytes(DOSelectedItem, DOInputValue);
 
-             DOSelectionChangedAction("");
 
-         }
 
-         private void DOSelectionChangedAction(object obj)
 
-         {
 
-             DOCurrentValue = _sim.GetDOData(DOSelectedItem);
 
-         }
 
-     }
 
- }
 
 
  |