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 { /// /// WagoView.xaml 的交互逻辑 /// 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 DONameItems { get; set; } public ObservableCollection DINameItems { get; set; } public ObservableCollection AONameItems { get; set; } public ObservableCollection AINameItems { get; set; } public ObservableCollection 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") { SetDICommand = new DelegateCommand(SetDIAction); SetDOCommand = new DelegateCommand(SetDOAction); SetAICommand = new DelegateCommand(SetAIAction); SetAOCommand = new DelegateCommand(SetAOAction); int.TryParse(str, out int port); _sim = new WagoSocketSimulator(port); Init(_sim); InitData(port); } 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(int port) { DigitalInputSelected = new ObservableCollection { 0, 1 }; DONameItems = new ObservableCollection { "c_System_Alarm", "c_Pole_Red", "c_Pole_Amber", "c_Pole_Green", "c_Pole_Blue", "c_System_Alarm2", "c_BACKSIDE_PRESSURE_TEST", "c_VACUUM_TEST", "DO8", "DO9", "DO10", "DO11", "DO12", "DO13", "DO14", "DO15", "DO16", "DO17", "DO18", "DO19", "DO20", "DO21"}; DINameItems = new ObservableCollection { "r_Cassette_1_150", "r_Cassette_1_100", "r_Cassette_1_200", "r_Cassette_2_150", "r_Cassette_2_100", "r_Cassette_2_200", "r_Cassette_3_150", "r_Cassette_3_100", "r_Cassette_3_200", "r_Dummy_1_150", "r_Dummy_1_100", "r_Dummy_1_200", "r_Dummy_2_150", "r_Dummy_2_100", "r_Dummy_2_100", "D15", "r_LoaderA_Wafer_Present", "r_LoaderB_Wafer_Present", "r_Cathode_Present", "DI19", "DI20", "DI21", "DI22", "DI23", "DI24", "DI25", "r_LOADERA_CRS_CURTAIN_1", "r_LOADERA_CRS_CURTAIN_2", "r_LOADERA_CRS_CURTAIN_3", "r_LOADERA_CRS_CURTAIN_4", "r_LOADERA_CRS_CURTAIN_5", "r_LOADERA_CRS_CURTAIN_6",}; AONameItems = new ObservableCollection { "AO1", "AO2", "AO3", "AO4", "AO5", "AO6", "AO7", "AO8", "AO9", "AO10", "AO11", "AO12", "AO13", "AO14", "AO15", "AO16"}; AINameItems = new ObservableCollection { "AI1", "AI2", "AI3", "r_LoaderA_LS_Vacuum_anlg", "r_LoaderB_LS_Vacuum_anlg", "AI6", "r_LOADER_GasFlowSensor_FLOW", "r_LOADERA_BERNOULLI_PRESSURE", "r_LOADERB_BERNOULLI_PRESSURE", "r_LOADERA_CHUCK_BLADDER", "r_LOADERB_CHUCK_BLADDER", "r_LOADERA_WS_BLADDER_PRESSURE", "r_LOADERB_WS_BLADDER_PRESSURE", "r_SPUF_VAC", "r_LOADER_GasFlowSensor_VACUUM",}; } } }