123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- using Aitex.Core.UI.MVVM;
- using Aitex.Core.Utilities;
- using CyberX8_Simulator.Devices;
- using MECF.Framework.Simulator.Core.Commons;
- using MECF.Framework.Simulator.Core.Driver;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace CyberX8_Simulator.Views
- {
- /// <summary>
- /// WagoView.xaml 的交互逻辑
- /// </summary>
- public partial class WagoView : UserControl
- {
- public WagoView()
- {
- InitializeComponent();
- this.Loaded += OnViewLoaded;
- }
- private void OnViewLoaded(object sender, RoutedEventArgs e)
- {
- (DataContext as TimerViewModelBase)?.Start();
- }
- }
- class WagoViewModel : SocketDeviceViewModel
- {
- #region 属性
- public string Title
- {
- get { return "Wago 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 string _DISelectedItem;
- [IgnorePropertyChange]
- public string DISelectedItem
- {
- get
- {
- return _DISelectedItem;
- }
- set
- {
- _DISelectedItem = value;
- }
- }
- private int _DIInputValue;
- [IgnorePropertyChange]
- public int DIInputValue
- {
- get
- {
- return _DIInputValue;
- }
- set
- {
- _DIInputValue = value;
- }
- }
- private string _AOSelectedItem;
- [IgnorePropertyChange]
- public string AOSelectedItem
- {
- get
- {
- return _AOSelectedItem;
- }
- set
- {
- _AOSelectedItem = value;
- }
- }
- private short _AOInputValue;
- [IgnorePropertyChange]
- public short AOInputValue
- {
- get
- {
- return _AOInputValue;
- }
- set
- {
- _AOInputValue = value;
- }
- }
- private string _AISelectedItem;
- [IgnorePropertyChange]
- public string AISelectedItem
- {
- get
- {
- return _AISelectedItem;
- }
- set
- {
- _AISelectedItem = value;
- }
- }
- private short _AIInputValue;
- [IgnorePropertyChange]
- public short AIInputValue
- {
- get
- {
- return _AIInputValue;
- }
- set
- {
- _AIInputValue = value;
- }
- }
- #endregion
- public ObservableCollection<string> DONameItems { get; set; }
- public ObservableCollection<string> DINameItems { get; set; }
- public ObservableCollection<string> AONameItems { get; set; }
- public ObservableCollection<string> AINameItems { get; set; }
- public ObservableCollection<int> DigitalInputSelected { get; set; }
-
-
- private WagoSocketSimulator _sim;
- public ICommand SetDICommand { get; set; }
- public ICommand SetDOCommand { get; set; }
- public ICommand SetAICommand { get; set; }
- public ICommand SetAOCommand { get; set; }
- public WagoViewModel(string str) : base("WagoViewModel")
- {
- InitData();
-
- SetDICommand = new DelegateCommand<object>(SetDIAction);
- SetDOCommand = new DelegateCommand<object>(SetDOAction);
- SetAICommand = new DelegateCommand<object>(SetAIAction);
- SetAOCommand = new DelegateCommand<object>(SetAOAction);
-
- int.TryParse(str, out int port);
- _sim = new WagoSocketSimulator(port);
- Init(_sim);
- }
- private void SetDIAction(object obj)
- {
- _sim.UpdataDIBytes(DISelectedItem, DIInputValue);
- }
- private void SetDOAction(object obj)
- {
- _sim.UpdataDOBytes(DOSelectedItem, DOInputValue);
- }
- private void SetAIAction(object obj)
- {
- _sim.UpdataAIShorts(AISelectedItem, AIInputValue);
- }
- private void SetAOAction(object obj)
- {
- _sim.UpdataAOShorts(AOSelectedItem, AOInputValue);
- }
- private void InitData()
- {
- DigitalInputSelected = new ObservableCollection<int> { 0, 1 };
- DONameItems = new ObservableCollection<string>
- { "DO1","DO2","DO3","c_LoaderA_LS_Vacuum","DO4","DO5","DO6","DO7","DO8"
- ,"DO9","DO10","DO11","DO12","DO12","DO13","DO14","DO15","DO16","DO17","DO18",
- "c_LOADERA_DOOR_UNLOCK","DO20","DO21"};
-
- DINameItems = new ObservableCollection<string>
- { "r_Cassette_1_150","r_Cassette_1_100","r_DRIP_TRAY_FLUID_DETECTION"};
- AONameItems = new ObservableCollection<string> { "AO0", "AO1" };
- AINameItems = new ObservableCollection<string> { "r_LoaderA_LS_Vacuum_anlg", "AI1" };
- }
- }
- }
|