From 00a491d93733d4625ad329b2ba8237f445364b3f Mon Sep 17 00:00:00 2001 From: Mirta Date: Wed, 30 Dec 2020 16:39:52 +0200 Subject: merge --- .../Controls/InkFillingStatusView.xaml | 51 ------ .../Controls/InkFillingStatusView.xaml.cs | 29 ---- .../Converters/EventTypeToStringConverter.cs | 29 ---- .../Utilities/Tango.MachineEM.UI/InputWindow.xaml | 25 --- .../Tango.MachineEM.UI/InputWindow.xaml.cs | 56 ------ .../Utilities/Tango.MachineEM.UI/MainWindow.xaml | 2 +- .../Tango.MachineEM.UI/Tango.MachineEM.UI.csproj | 15 -- .../Tango.MachineEM.UI/ViewModels/MainViewVM.cs | 186 -------------------- .../Tango.MachineEM.UI/Views/MainView.xaml | 191 +++++++-------------- 9 files changed, 59 insertions(+), 525 deletions(-) delete mode 100644 Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml delete mode 100644 Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml.cs delete mode 100644 Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Converters/EventTypeToStringConverter.cs delete mode 100644 Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml delete mode 100644 Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml.cs (limited to 'Software/Visual_Studio/Utilities/Tango.MachineEM.UI') diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml deleted file mode 100644 index 22468a052..000000000 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml.cs deleted file mode 100644 index 575e12210..000000000 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Controls/InkFillingStatusView.xaml.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -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 Tango.MachineEM.UI.Controls -{ - /// - /// Interaction logic for MainView.xaml - /// - public partial class InkFillingStatusView : UserControl - { - public InkFillingStatusView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Converters/EventTypeToStringConverter.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Converters/EventTypeToStringConverter.cs deleted file mode 100644 index de771f2a8..000000000 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Converters/EventTypeToStringConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Google.Protobuf.Reflection; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Data; -using Tango.PMR.Diagnostics; - -namespace Tango.MachineEM.UI.Converters -{ - public class EventTypeToStringConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - EventType eventType = (EventType)value; - FieldInfo fi = value.GetType().GetField(eventType.ToString()); - String name = fi.GetCustomAttribute().Name; - return $"{(int)eventType} {name}"; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml deleted file mode 100644 index 05a4b33cd..000000000 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml.cs deleted file mode 100644 index 191b53072..000000000 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -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.Shapes; - -namespace Tango.MachineEM.UI -{ - /// - /// Interaction logic for InputWindow.xaml - /// - public partial class InputWindow : Window - { - public String Value { get; set; } - public String Message { get; set; } - - public InputWindow() - { - InitializeComponent(); - - btnOK.Click += BtnOK_Click; - btnCancel.Click += BtnCancel_Click; - Loaded += InputWindow_Loaded; - } - - private void InputWindow_Loaded(object sender, RoutedEventArgs e) - { - txtValue.Text = Value; - txtMessage.Text = Message; - - txtValue.Focus(); - Keyboard.Focus(txtValue); - } - - private void BtnCancel_Click(object sender, RoutedEventArgs e) - { - DialogResult = false; - Close(); - } - - private void BtnOK_Click(object sender, RoutedEventArgs e) - { - Value = txtValue.Text; - DialogResult = true; - Close(); - } - } -} diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml index 8f066800e..7bfc7f0fd 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml @@ -9,7 +9,7 @@ xmlns:local="clr-namespace:Tango.MachineEM.UI" xmlns:views="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - Title="Tango Embedded Emulator" Height="820" Width="1300" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> + Title="Tango Embedded Emulator" Height="720" Width="1300" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj index c6f382afe..bce166287 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj @@ -80,25 +80,10 @@ GlobalVersionInfo.cs - - InkFillingStatusView.xaml - - - - InputWindow.xaml - MainView.xaml - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - MSBuild:Compile Designer 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 /// public RelayCommand ValidateCartridgeCommand { get; set; } - /// - /// Gets or sets the start thread loading sequence command. - /// - public RelayCommand StartThreadLoadingCommand { get; set; } - - /// - /// Gets or sets the finalize thread loading command. - /// - public RelayCommand FinalizeThreadLoadingCommand { get; set; } - - /// - /// Gets or sets the abort job. - /// - 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() { @@ -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("Get Data Store Item", "Enter collection name", String.Empty); - if (!result.Confirmed) return; - var collectionName = result.Value; - - result = GetUserInput("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("Put Data Store Item", "Enter collection name", String.Empty); - if (!result.Confirmed) return; - var collectionName = result.Value; - - result = GetUserInput("Put Data Store Item", "Enter item key", String.Empty); - if (!result.Confirmed) return; - var key = result.Value; - - result = GetUserInput("Put Data Store Item", "Enter data type", "Int32"); - if (!result.Confirmed) return; - DataType dataType = (DataType)Enum.Parse(typeof(DataType), result.Value); - - result = GetUserInput("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 - { - public bool Confirmed { get; set; } - public T Value { get; set; } - } - - private InputResult GetUserInput(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() { Confirmed = true, Value = (T)Convert.ChangeType(window.Value, typeof(T)) }; - } - else - { - return new InputResult(); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error parsing input."); - throw ex; - } - } - #endregion } } diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index c0c4b7b97..036fec7dc 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -3,23 +3,19 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:controls="clr-namespace:Tango.MachineEM.UI.Controls" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:vm="clr-namespace:Tango.MachineEM.UI.ViewModels" xmlns:pmr="clr-namespace:Tango.PMR.MachineStatus;assembly=Tango.PMR" - xmlns:threadLoading="clr-namespace:Tango.PMR.ThreadLoading;assembly=Tango.PMR" - xmlns:localConverters="clr-namespace:Tango.MachineEM.UI.Converters" xmlns:local="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - d:DesignHeight="780" d:DesignWidth="1300" Foreground="Gainsboro" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" > + d:DesignHeight="720" d:DesignWidth="1300" Foreground="Gainsboro" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" > - @@ -57,141 +53,17 @@ - - - - - - - - - - MACHINE STATUS - - - - - - - - IDS Packs Levels - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MACHINE STATE - - - - OVERALL TEMPERATURE - - - - - SPOOL STATE - - - - - - - - - INK FILLING STATUS - - - - - - - - - - - - - - - - - - Thread Loading State - - - - - + - + HARDWARE EVENTS - +