diff options
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs | 186 |
1 files changed, 0 insertions, 186 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs index c993be2d7..1662a3ede 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs @@ -12,9 +12,6 @@ using Tango.Transport.Servers; using Tango.Transport.Transporters; using Tango.Core; using Tango.Settings; -using Tango.PMR.ThreadLoading; -using Tango.PMR.DataStore; -using System.Windows; namespace Tango.MachineEM.UI.ViewModels { @@ -23,7 +20,6 @@ namespace Tango.MachineEM.UI.ViewModels private TcpServer TcpServer; private bool _running; private LogManager logManager = LogManager.Default; - private bool _isThreadLoading; #region Properties @@ -67,30 +63,10 @@ namespace Tango.MachineEM.UI.ViewModels set { _selectedPort = value; RaisePropertyChanged(nameof(SelectedPort)); } } - private ThreadLoadingState _threadLoadingState; - public ThreadLoadingState ThreadLoadingState - { - get { return _threadLoadingState; } - set { _threadLoadingState = value; OnThreadLoadingStateChanged(); } - } - - #endregion #region Private Methods - private void OnThreadLoadingStateChanged() - { - try - { - Emulator?.SetThreadLoadingState(ThreadLoadingState); - } - catch (Exception ex) - { - LogManager.Log(ex); - } - } - #endregion #region Commands @@ -125,27 +101,6 @@ namespace Tango.MachineEM.UI.ViewModels /// </summary> public RelayCommand ValidateCartridgeCommand { get; set; } - /// <summary> - /// Gets or sets the start thread loading sequence command. - /// </summary> - public RelayCommand StartThreadLoadingCommand { get; set; } - - /// <summary> - /// Gets or sets the finalize thread loading command. - /// </summary> - public RelayCommand FinalizeThreadLoadingCommand { get; set; } - - /// <summary> - /// Gets or sets the abort job. - /// </summary> - public RelayCommand AbortJobCommand { get; set; } - - public RelayCommand GetDataStoreItemCommand { get; set; } - - public RelayCommand PutDataStoreItemCommand { get; set; } - - public RelayCommand PerformDataStoreTestCommand { get; set; } - #endregion #region Constructors @@ -176,9 +131,6 @@ namespace Tango.MachineEM.UI.ViewModels CancelCommand = new RelayCommand(Cancel, (x) => _running); ClearCommand = new RelayCommand(() => Log = String.Empty); ValidateCartridgeCommand = new RelayCommand(ValidateCartridge, (x) => Emulator.IsStarted); - StartThreadLoadingCommand = new RelayCommand(StartThreadLoading, (x) => Emulator.IsStarted && !_isThreadLoading); - FinalizeThreadLoadingCommand = new RelayCommand(FinalizeThreadLoading, (x) => Emulator.IsStarted && _isThreadLoading); - AbortJobCommand = new RelayCommand(() => Emulator?.AbortJob(), (x) => Emulator.IsStarted); Ports = new List<string>() { @@ -195,10 +147,6 @@ namespace Tango.MachineEM.UI.ViewModels }; SelectedPort = Ports.First(); - - PerformDataStoreTestCommand = new RelayCommand(Emulator.PerformDataStoreTest); - GetDataStoreItemCommand = new RelayCommand(GetDataStoreItem); - PutDataStoreItemCommand = new RelayCommand(PutDataStoreItem); } #endregion @@ -270,140 +218,6 @@ namespace Tango.MachineEM.UI.ViewModels } } - private async void StartThreadLoading() - { - LogManager.Log("Starting thread loading sequence..."); - Emulator.StartThreadLoading(); - _isThreadLoading = true; - InvalidateRelayCommands(); - - await Task.Delay(10000); - _isThreadLoading = false; - InvalidateRelayCommands(); - } - - private void FinalizeThreadLoading() - { - LogManager.Log("Finalizing thread loading sequence..."); - Emulator.FinalizeThreadLoading(); - _isThreadLoading = false; - InvalidateRelayCommands(); - } - - private void GetDataStoreItem() - { - try - { - var result = GetUserInput<String>("Get Data Store Item", "Enter collection name", String.Empty); - if (!result.Confirmed) return; - var collectionName = result.Value; - - result = GetUserInput<String>("Get Data Store Item", "Enter item key", String.Empty); - if (!result.Confirmed) return; - var key = result.Value; - - Emulator.GetDataStoreItem(new PMR.DataStore.GetDataStoreItemRequest() - { - Collection = collectionName, - Key = key - }); - } - catch { } - } - - private void PutDataStoreItem() - { - try - { - var result = GetUserInput<String>("Put Data Store Item", "Enter collection name", String.Empty); - if (!result.Confirmed) return; - var collectionName = result.Value; - - result = GetUserInput<String>("Put Data Store Item", "Enter item key", String.Empty); - if (!result.Confirmed) return; - var key = result.Value; - - result = GetUserInput<String>("Put Data Store Item", "Enter data type", "Int32"); - if (!result.Confirmed) return; - DataType dataType = (DataType)Enum.Parse(typeof(DataType), result.Value); - - result = GetUserInput<String>("Put Data Store Item", "Enter value", "10"); - if (!result.Confirmed) return; - var value = result.Value; - - DataStoreItem item = new DataStoreItem(); - item.DataType = dataType; - - switch (dataType) - { - case DataType.Int32: - item.Int32Value = int.Parse(value); - break; - case DataType.Float: - item.FloatValue = float.Parse(value); - break; - case DataType.Double: - item.DoubleValue = double.Parse(value); - break; - case DataType.Boolean: - item.BooleanValue = bool.Parse(value); - break; - case DataType.String: - item.StringValue = value; - break; - default: - LogManager.Log("Data type not supported by this emulator."); - throw new NotSupportedException(); - } - - Emulator.PutDataStoreItem(new PutDataStoreItemRequest() - { - Collection = collectionName, - Key = key, - Item = item - }); - } - catch { } - } - - #endregion - - #region Private Methods - - private class InputResult<T> - { - public bool Confirmed { get; set; } - public T Value { get; set; } - } - - private InputResult<T> GetUserInput<T>(String title, String message, T defaultValue) - { - InputWindow window = new InputWindow(); - window.Title = title; - window.Message = message; - window.Value = defaultValue.ToStringSafe(); - window.Owner = Application.Current.MainWindow; - window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; - window.WindowStyle = WindowStyle.ToolWindow; - - try - { - if (window.ShowDialog().Value) - { - return new InputResult<T>() { Confirmed = true, Value = (T)Convert.ChangeType(window.Value, typeof(T)) }; - } - else - { - return new InputResult<T>(); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error parsing input."); - throw ex; - } - } - #endregion } } |
