From 5a06b997b7ef29c566bad2bc65f927e9443c3888 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 8 Jan 2020 13:53:48 +0200 Subject: Implemented maintenance mid-tank graphics. Implemented session file logger. --- .../Converters/LiquidTypeToBrushConverter.cs | 52 ++++++++++ .../MidTankLevelToElementHeightConverter.cs | 6 +- .../Tango.PPC.Maintenance/Images/cl-full.png | Bin 0 -> 3454 bytes .../Tango.PPC.Maintenance/Images/cone-empty.png | Bin 0 -> 2174 bytes .../Tango.PPC.Maintenance/Images/cone-full.png | Bin 0 -> 1752 bytes .../Tango.PPC.Maintenance/Images/l-full.png | Bin 0 -> 19717 bytes .../Tango.PPC.Maintenance/Images/lubricant2.png | Bin 0 -> 194234 bytes .../Tango.PPC.Maintenance.csproj | 12 ++- .../Views/MaintenanceView.xaml | 113 +++++++++++---------- 9 files changed, 125 insertions(+), 58 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cl-full.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-empty.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-full.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/l-full.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/lubricant2.png (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs new file mode 100644 index 000000000..c7e828148 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/LiquidTypeToBrushConverter.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Tango.BL.Entities; +using Tango.SharedUI.Helpers; + +namespace Tango.PPC.Maintenance.Converters +{ + public class LiquidTypeToBrushConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is LiquidType) + { + LiquidType type = value as LiquidType; + if (type.Type == BL.Enumerations.LiquidTypes.Lubricant) + { + ImageBrush lubricantBrush = new ImageBrush() { Stretch = Stretch.None, TileMode = TileMode.Tile, ViewportUnits = BrushMappingMode.Absolute }; + lubricantBrush.ImageSource = ResourceHelper.GetImageFromResources(@"Images/lubricant2.png"); + lubricantBrush.Viewport = new System.Windows.Rect(lubricantBrush.ImageSource.Width/3, lubricantBrush.ImageSource.Height/3, lubricantBrush.ImageSource.Width, lubricantBrush.ImageSource.Height); + return lubricantBrush; + } + if (type.Type == BL.Enumerations.LiquidTypes.Cleaner) + { + ImageBrush cleanerBrush = new ImageBrush(){ Stretch = Stretch.None, TileMode = TileMode.Tile, ViewportUnits = BrushMappingMode.Absolute }; + cleanerBrush.ImageSource = ResourceHelper.GetImageFromResources(@"Images/cl-full.png"); + cleanerBrush.Viewport = new System.Windows.Rect(5, 5, cleanerBrush.ImageSource.Width, cleanerBrush.ImageSource.Height); + return cleanerBrush; + } + else + { + return new SolidColorBrush(type.LiquidTypeColor); ; + } + } + return null; + + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + } +} + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/MidTankLevelToElementHeightConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/MidTankLevelToElementHeightConverter.cs index 5cf3f535c..94d1ed8b8 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/MidTankLevelToElementHeightConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Converters/MidTankLevelToElementHeightConverter.cs @@ -16,9 +16,9 @@ namespace Tango.PPC.Maintenance.Converters try { double parentActualHeight = (double)values[0]; - double midTankLevel = (double)values[1]; - - return (midTankLevel / MachineOperator.MAX_MIDTANK_LITERS) * parentActualHeight; + double midTankLevel = Math.Min((double)values[1], MachineOperator.MAX_MIDTANK_LITERS); + //var test = (parentActualHeight - (midTankLevel / MachineOperator.MAX_MIDTANK_LITERS) * parentActualHeight); + return (parentActualHeight - (midTankLevel / MachineOperator.MAX_MIDTANK_LITERS) * parentActualHeight); } catch { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cl-full.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cl-full.png new file mode 100644 index 000000000..5aaea8e6c Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cl-full.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-empty.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-empty.png new file mode 100644 index 000000000..d65b8f793 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-empty.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-full.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-full.png new file mode 100644 index 000000000..c42abf56e Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/cone-full.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/l-full.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/l-full.png new file mode 100644 index 000000000..2607f4a26 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/l-full.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/lubricant2.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/lubricant2.png new file mode 100644 index 000000000..554c16305 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Images/lubricant2.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj index a43fc2dc3..3f9f7c7b9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj @@ -102,6 +102,7 @@ GlobalVersionInfo.cs + @@ -255,10 +256,19 @@ + + + + + + + + + - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml index c843daffc..e71a1827e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml @@ -15,6 +15,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -88,67 +144,16 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Temperature Inks -- cgit v1.3.1 From d8b3bbece9ee09b68b6707c276ce4101f91e2943 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 12 Jan 2020 15:56:17 +0200 Subject: Add session log to TFS PPC and Machine Studio. Related Work Items: #2306 --- .../ViewModels/MainViewVM.cs | 2 +- .../TFS/TeamFoundationServiceExtendedClient.cs | 14 +++++++ .../TFS/TeamFoundationServicePPCClient.cs | 14 +++++++ .../ExternalBridge/ExternalBridgeTcpClient.cs | 6 +++ .../Tango.Integration/Operation/MachineOperator.cs | 25 ++++++++++++ .../Tango.Logging/SessionFileLogger.cs | 46 ++++++++++++++++++++-- 6 files changed, 103 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs index e9f2404e0..ea6584556 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs @@ -21,7 +21,7 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels { public class MainViewVM : StudioViewModel { - #region properties + #region Properties private DateTime _startSelectedDate; public DateTime StartSelectedDate diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index b3e121253..bfd5b0557 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -241,6 +241,20 @@ namespace Tango.MachineStudio.UI.TFS } } + //Add session log file.. + if (MachineOperator.EnableSessionLogFile) + { + var file = MachineOperator.SessionLogger.LogFile; + var sessionLogFile = _tempFolder.CreateImaginaryFile(); + File.Copy(file, sessionLogFile.Path); + item.Attachments.Add(new Attachment() + { + Description = "Session Log File", + FilePath = sessionLogFile.Path, + Name = Path.GetFileName(file), + }); + } + SystemInformationModel sysModel = new SystemInformationModel(); sysModel.ApplicationVersion = app.Version.ToString(); sysModel.EmbeddedVersion = "N/A"; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs index c28c5fcba..eb5b8f283 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs @@ -134,6 +134,20 @@ namespace Tango.PPC.BugReporting.TFS } } + //Add session log file.. + if (MachineOperator.EnableSessionLogFile) + { + var file = MachineOperator.SessionLogger.LogFile; + var sessionLogFile = tempFolder.CreateImaginaryFile(); + File.Copy(file, sessionLogFile.Path); + item.Attachments.Add(new Attachment() + { + Description = "Session Log File", + FilePath = sessionLogFile.Path, + Name = Path.GetFileName(file), + }); + } + SystemInformationModel sysModel = new SystemInformationModel(); sysModel.ApplicationVersion = _applicationManager.Version.ToString(); sysModel.EmbeddedVersion = "N/A"; diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs index d3344aa16..61a0c5238 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs @@ -107,6 +107,9 @@ namespace Tango.Integration.ExternalBridge LogRequestSent(login); var response = await SendRequest(login); + + SessionLogger.CreateSession(); + DeviceInformation = response.Message.DeviceInformation; if (!response.Message.Authenticated) { @@ -235,6 +238,9 @@ namespace Tango.Integration.ExternalBridge } State = TransportComponentState.Disconnected; + + SessionLogger.EndSession(); + if (Adapter != null) { await Adapter.Disconnect(); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 6d9a987cb..a0ba31b40 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -77,6 +77,8 @@ namespace Tango.Integration.Operation public static String EmbeddedLogsFolder { get; private set; } public static String EmbeddedLogsTag { get; private set; } + public static SessionFileLogger SessionLogger { get; set; } + #region Constructors /// @@ -94,6 +96,12 @@ namespace Tango.Integration.Operation FileLogger fileLogger = new FileLogger(EmbeddedLogsFolder, EmbeddedLogsTag) { Enabled = true }; EmbeddedLogManager.RegisterLogger(fileLogger); } + + if (SessionLogger == null) + { + SessionLogger = new SessionFileLogger(); + LogManager.Default.RegisterLogger(SessionLogger); + } } /// @@ -249,6 +257,18 @@ namespace Tango.Integration.Operation #endregion #region Properties + /// + /// Gets or sets a value indicating whether to create a new designated session log file each successful connection. + /// This log file will contain standard logs that have occurred between the last connection and disconnection states. + /// + public static bool EnableSessionLogFile + { + get { return SessionLogger.Enabled; } + set + { + SessionLogger.Enabled = value; + } + } /// /// Gets or sets the job handling mode. @@ -1154,6 +1174,8 @@ namespace Tango.Integration.Operation { if (Status == MachineStatuses.Upgrading) return; + SessionLogger.EndSession(); + if (State == TransportComponentState.Connected) { DisconnectRequest request = new DisconnectRequest(); @@ -1206,6 +1228,9 @@ namespace Tango.Integration.Operation try { var response = await SendRequest(request); + + SessionLogger.CreateSession(); + LogResponseReceived(response.Message); if (Status != MachineStatuses.Upgrading) diff --git a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs index f3c23ca25..f4ce9c2fb 100644 --- a/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/SessionFileLogger.cs @@ -10,12 +10,22 @@ namespace Tango.Logging { public class SessionFileLogger : ILogger { + #region Properties private bool _inInSession; - public const string FILE_SESSION_EXTENSION = "_session"; + private int _writeCount; + public const string FILE_SESSION_EXTENSION = "_session"; + public static String DefaultLogsFolder { get; private set; } + private const int FILE_SIZE_CHECK_COUNT = 100; + + /// + /// Gets or sets the maximum file size limit. + /// + public static long MaxFileSizeLimit { get; set; } + public bool Enabled { get; set; } public String Folder { get; private set; } @@ -24,9 +34,15 @@ namespace Tango.Logging public String Tag { get; private set; } + #endregion + #region Constructors + /// + /// Initializes the static members of the class. + /// static SessionFileLogger() { - DefaultLogsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Logs", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName), "session"); + DefaultLogsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Logs", Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName), "Session"); + MaxFileSizeLimit = 1000000 * 10; //10 MB } public SessionFileLogger(String folder, String tag) @@ -35,13 +51,17 @@ namespace Tango.Logging Tag = tag; Directory.CreateDirectory(Folder); Enabled = true; + _writeCount = 0; } public SessionFileLogger() : this(DefaultLogsFolder, Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName)) { } - + #endregion + /// + /// Creates the session. Only one file should be for session log, so removed old file and create a new file. + /// public void CreateSession() { RemoveOldLogFile(); @@ -49,16 +69,26 @@ namespace Tango.Logging _inInSession = true; } + /// + /// Ends the session. Set flag _inInSession to false. + /// public void EndSession() { _inInSession = false; } + /// + /// Creates the name of the log file. + /// + /// private String CreateLogFileName() { return Path.Combine(Folder, string.Format("{1}-{0:dd-MM-yyyy_HH-mm-ss}{2}.log", DateTime.Now, Tag, FILE_SESSION_EXTENSION)); } + /// + /// Delete the old log file if is existed. + /// private void RemoveOldLogFile() { try @@ -85,12 +115,22 @@ namespace Tango.Logging } } + /// + /// Called when write to session log file. + /// + /// The output. public void OnLog(LogItemBase output) { if (_inInSession) { try { + if(++_writeCount > FILE_SIZE_CHECK_COUNT && new FileInfo(LogFile).Length > MaxFileSizeLimit) + { + _writeCount = 0; + CreateSession(); + File.AppendAllText(LogFile, "### This log file is a continuation of a previous log file ###" + Environment.NewLine + Environment.NewLine); + } File.AppendAllText(LogFile, output.ToString() + Environment.NewLine); } catch -- cgit v1.3.1 From 9949e351e152a929da696ef2f0a1f8b1668e83fa Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 12 Jan 2020 15:56:50 +0200 Subject: Merged Beta+ fixes to master. --- .../Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs | 1 + .../Tango.PPC.Jobs/Views/JobProgressView.xaml | 2 + .../ViewModels/SystemViewVM.cs | 2 +- .../PPC/Tango.PPC.UI/MainWindow.xaml.cs | 20 +++++- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 53 +++++++++++++- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 26 +++++-- .../Tango.AdvancedInstaller/InstallerBuilder.cs | 27 +++++++- Software/Visual_Studio/Tango.BL/Entities/Job.cs | 2 +- .../ExternalBridge/ExternalBridgeTcpClient.cs | 3 +- .../Tango.Integration/Operation/JobHandler.cs | 23 +++++-- .../Tango.Integration/Operation/MachineOperator.cs | 80 ++++++++++++++-------- Software/Visual_Studio/Tango.Logging/FileLogger.cs | 23 +++---- .../Tango.Touch/Styles/TouchButton.xaml | 5 ++ .../Tango.Transport/Tango.Transport.csproj | 3 +- .../Tango.Transport/TransportMessage.cs | 8 +++ .../Tango.Transport/TransporterBase.cs | 15 ++++ .../TransporterDisconnectedException.cs | 16 +++++ .../Utilities/Tango.JobRunsGenerator/Program.cs | 22 +++++- 18 files changed, 267 insertions(+), 64 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Transport/TransporterDisconnectedException.cs (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs index 1de54b784..a2f67b2ba 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs @@ -178,6 +178,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (_handler != null) { + _stop_job_btn.Pop(); _handler.Cancel(); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml index 2a21f772e..6bc1337b9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml @@ -38,6 +38,8 @@ + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs index 13aeeb671..f3ffcda14 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs @@ -265,7 +265,7 @@ namespace Tango.PPC.Technician.ViewModels { using (ObservablesContext db = ObservablesContext.CreateDefault()) { - var jobRuns = await db.JobRuns.Where(x => x.MachineGuid == MachineProvider.Machine.Guid).ToListAsync(); + var jobRuns = await db.JobRuns.ToListAsync(); TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToString(@"hh\:mm\:ss"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs index b90a1afff..dec58f336 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs @@ -61,6 +61,12 @@ namespace Tango.PPC.UI has_touch = true; } } + +#if !DEBUG + ForceTouch(); + has_touch = true; +#endif + #endif if (!has_touch) @@ -72,7 +78,7 @@ namespace Tango.PPC.UI gridMain.Height = 1280; viewBox.Child = gridMain; LockAspectRatio(); - this.SizeChanged += (x, y) => + this.SizeChanged += (x, y) => { LockAspectRatio(); }; @@ -81,6 +87,18 @@ namespace Tango.PPC.UI Closing += MainWindow_Closing; } + private void ForceTouch() + { + WindowStyle = WindowStyle.None; + ResizeMode = ResizeMode.NoResize; + WindowStartupLocation = WindowStartupLocation.Manual; + Topmost = false; // sure? + Left = 0; + Top = 0; + Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; + Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; + } + protected override void OnSourceInitialized(EventArgs e) { //var hwndSource = PresentationSource.FromVisual(this) as HwndSource; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index d7717e6db..2bb4e9286 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -23,6 +23,7 @@ namespace Tango.PPC.UI.ViewModels public class LayoutViewVM : PPCViewModel { private JobHandler _jobHandler; + private bool _resettingDevice; /// /// Gets or sets the module loader. @@ -127,6 +128,11 @@ namespace Tango.PPC.UI.ViewModels /// public RelayCommand PowerOffCommand { get; set; } + /// + /// Gets or sets the reset command. + /// + public RelayCommand ResetCommand { get; set; } + #endregion #region Constructors @@ -152,7 +158,8 @@ namespace Tango.PPC.UI.ViewModels PowerCommand = new RelayCommand(() => IsPowerOpened = true); RestartApplicationCommand = new RelayCommand(RestartApplication); - PowerOffCommand = new RelayCommand(PowerOffMachine); + PowerOffCommand = new RelayCommand(PowerOffMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected); + ResetCommand = new RelayCommand(ResetMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected); } #endregion @@ -252,6 +259,7 @@ namespace Tango.PPC.UI.ViewModels private async void PowerOffMachine() { IsMenuOpened = false; + if (await NotificationProvider.ShowQuestion("Are you sure you wish to turn off the machine?")) { try @@ -261,10 +269,38 @@ namespace Tango.PPC.UI.ViewModels catch (Exception ex) { LogManager.Log(ex, "Error triggering power down."); + await NotificationProvider.ShowError(ex.FlattenMessage()); } } } + /// + /// Resets the machine. + /// + private async void ResetMachine() + { + IsMenuOpened = false; + + if (!await NotificationProvider.ShowQuestion("Are you sure you want to reset the machine?")) return; + + try + { + _resettingDevice = true; + ResetCommand.RaiseCanExecuteChanged(); + await MachineProvider.MachineOperator.Reset(); + await NotificationProvider.ShowInfo("Machine was successfully restarted."); + } + catch (Exception ex) + { + await NotificationProvider.ShowError(ex.FlattenMessage()); + } + finally + { + _resettingDevice = false; + ResetCommand.RaiseCanExecuteChanged(); + } + } + #endregion #region Override Methods @@ -286,6 +322,21 @@ namespace Tango.PPC.UI.ViewModels } + public override void OnApplicationReady() + { + base.OnApplicationReady(); + MachineProvider.MachineOperator.StatusChanged += MachineOperator_StatusChanged; + } + + private void MachineOperator_StatusChanged(object sender, MachineStatuses e) + { + InvokeUI(() => + { + PowerOffCommand.RaiseCanExecuteChanged(); + ResetCommand.RaiseCanExecuteChanged(); + }); + } + #endregion #region Public Methods diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index b4f93fd0a..1700749c2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -130,6 +130,21 @@ + + +