aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs23
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs125
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs4
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs44
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs64
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs87
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs107
7 files changed, 31 insertions, 423 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs
index dbc99fa87..97bae6f5b 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs
@@ -4,9 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
-//using Tango.PPC.Browser;
-//using Tango.PPC.Browser.Navigation;
-//using Tango.PPC.Browser.Views;
using Tango.PPC.Common;
namespace Tango.PPC.Technician.ViewModels
@@ -19,22 +16,16 @@ namespace Tango.PPC.Technician.ViewModels
public RelayCommand<String> NavigationCommand { get; set; }
/// <summary>
- /// Gets or sets the browser command.
- /// </summary>
- public RelayCommand BrowserCommand { get; set; }
-
- /// <summary>
/// Initializes a new instance of the <see cref="CatalogViewVM"/> class.
/// </summary>
public CatalogViewVM()
{
NavigationCommand = new RelayCommand<string>(NavigateToView);
- BrowserCommand = new RelayCommand(OpenBrowserModule);
}
public override void OnApplicationStarted()
{
-
+
}
/// <summary>
@@ -45,17 +36,5 @@ namespace Tango.PPC.Technician.ViewModels
{
NavigationManager.NavigateTo<TechnicianModule>(view);
}
-
- /// <summary>
- /// Opens the browser module.
- /// </summary>
- private void OpenBrowserModule()
- {
- //NavigationManager.NavigateWithObject<BrowserModule, BrowserView, BrowserNavigationRequest>(new BrowserNavigationRequest()
- //{
- // Address = "https://twine-s.com/",
- // DisplayAddressBar = true,
- //}, true);
- }
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs
index 2aee7f561..6ca693af6 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs
@@ -8,11 +8,8 @@ using System.Threading.Tasks;
using System.Windows.Data;
using Tango.Core;
using Tango.Core.Commands;
-using Tango.Integration.Logging;
-using Tango.Integration.Operation;
using Tango.Logging;
using Tango.PPC.Common;
-using Tango.PPC.Common.Helpers;
using Tango.PPC.Technician.Dialogs;
namespace Tango.PPC.Technician.ViewModels
@@ -20,28 +17,12 @@ namespace Tango.PPC.Technician.ViewModels
public class LoggingViewVM : PPCViewModel
{
private const int MAX_LOGS = 1000;
-
private List<LogItemBase> paused_logs;
- private List<LogItemBase> paused_embedded_logs;
public SynchronizedObservableCollection<LogItemBase> ApplicationLogs { get; set; }
public SynchronizedObservableCollection<LogItemBase> EmbeddedLogs { get; set; }
- private ICollectionView _applicationLogsViewSource;
- public ICollectionView ApplicationLogsViewSource
- {
- get { return _applicationLogsViewSource; }
- set { _applicationLogsViewSource = value; RaisePropertyChangedAuto(); }
- }
-
- private ICollectionView _embeddedLogsViewSource;
- public ICollectionView EmbeddedLogsViewSource
- {
- get { return _embeddedLogsViewSource; }
- set { _embeddedLogsViewSource = value; RaisePropertyChangedAuto(); }
- }
-
private LogItemBase _selectedLog;
public LogItemBase SelectedLog
{
@@ -49,6 +30,13 @@ namespace Tango.PPC.Technician.ViewModels
set { _selectedLog = value; RaisePropertyChangedAuto(); OnSelectedLogChanged(); }
}
+ private ICollectionView _applicationLogsViewSource;
+ public ICollectionView ApplicationLogsViewSource
+ {
+ get { return _applicationLogsViewSource; }
+ set { _applicationLogsViewSource = value; RaisePropertyChangedAuto(); }
+ }
+
private String _filter;
public String Filter
{
@@ -58,7 +46,6 @@ namespace Tango.PPC.Technician.ViewModels
_filter = value;
RaisePropertyChangedAuto();
ApplicationLogsViewSource.Refresh();
- EmbeddedLogsViewSource.Refresh();
}
}
@@ -69,13 +56,6 @@ namespace Tango.PPC.Technician.ViewModels
set { _isPaused = value; RaisePropertyChangedAuto(); OnIsPausedChanged(); }
}
- private bool _processDebugLogs;
- public bool ProcessDebugLogs
- {
- get { return _processDebugLogs; }
- set { _processDebugLogs = value; RaisePropertyChangedAuto(); OnProcessDebugLogsChanged(); }
- }
-
public RelayCommand ClearCommand { get; set; }
public LoggingViewVM()
@@ -83,19 +63,8 @@ namespace Tango.PPC.Technician.ViewModels
ApplicationLogs = new SynchronizedObservableCollection<LogItemBase>();
EmbeddedLogs = new SynchronizedObservableCollection<LogItemBase>();
ApplicationLogsViewSource = CollectionViewSource.GetDefaultView(ApplicationLogs);
- EmbeddedLogsViewSource = CollectionViewSource.GetDefaultView(EmbeddedLogs);
paused_logs = new List<LogItemBase>();
- paused_embedded_logs = new List<LogItemBase>();
-
- var appStartLogs = LogsHelper.GetLogSafe().EmptyAndDispose();
-
- foreach (var log in appStartLogs)
- {
- ApplicationLogs.Insert(0, log);
- }
-
LogManager.NewLog += LogManager_NewLog;
- MachineOperator.EmbeddedLogManager.NewLog += EmbeddedLogManager_NewLog;
ClearCommand = new RelayCommand(ClearLogs);
Filter = "error";
@@ -112,31 +81,6 @@ namespace Tango.PPC.Technician.ViewModels
return false;
}
};
-
- EmbeddedLogsViewSource.Filter = (x) =>
- {
- try
- {
- LogItemBase log = x as LogItemBase;
- return String.IsNullOrWhiteSpace(Filter) || log.Category.ToString().ToLower().Contains(Filter.ToLower()) || log.Message.ToLower().Contains(Filter.ToLower());
- }
- catch
- {
- return false;
- }
- };
- }
-
- private void OnProcessDebugLogsChanged()
- {
- if (ProcessDebugLogs)
- {
- LogManager.Categories.Add(LogCategory.Debug);
- }
- else
- {
- LogManager.Categories.RemoveAll(x => x == LogCategory.Debug);
- }
}
private void OnIsPausedChanged()
@@ -147,14 +91,6 @@ namespace Tango.PPC.Technician.ViewModels
}
paused_logs.Clear();
-
-
- foreach (var log in paused_embedded_logs)
- {
- EmbeddedLogManager_NewLog(this, log);
- }
-
- paused_embedded_logs.Clear();
}
private void LogManager_NewLog(object sender, LogItemBase log)
@@ -184,59 +120,22 @@ namespace Tango.PPC.Technician.ViewModels
}
}
- private void EmbeddedLogManager_NewLog(object sender, LogItemBase log)
- {
- if (!IsPaused)
- {
- InvokeUI(() =>
- {
- EmbeddedLogs.Insert(0, log);
-
- try
- {
- if (EmbeddedLogs.Count > MAX_LOGS)
- {
- EmbeddedLogs.Remove(EmbeddedLogs.Last());
- }
- }
- catch
- {
- //I don't know if this will cause an exception but I'm tired.
- }
- });
- }
- else
- {
- paused_embedded_logs.Add(log);
- }
- }
-
private void ClearLogs()
{
ApplicationLogs.Clear();
- EmbeddedLogs.Clear();
paused_logs.Clear();
- paused_embedded_logs.Clear();
}
private async void OnSelectedLogChanged()
{
if (SelectedLog != null)
{
- if (SelectedLog.GetType() == typeof(EmbeddedLogItem))
- {
- await NotificationProvider.ShowDialog<EmbeddedLogItemDetailsViewVM>(new EmbeddedLogItemDetailsViewVM()
- {
- Log = SelectedLog as EmbeddedLogItem,
- });
- }
- else
+ await NotificationProvider.ShowDialog<LogItemDetailsViewVM>(new LogItemDetailsViewVM()
{
- await NotificationProvider.ShowDialog<LogItemDetailsViewVM>(new LogItemDetailsViewVM()
- {
- Log = SelectedLog,
- });
- }
+ Log = SelectedLog,
+ });
+
+ SelectedLog = null;
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs
index 4f8aba952..d63a89f3b 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs
@@ -12,13 +12,13 @@ namespace Tango.PPC.Technician.ViewModels
{
public override void OnApplicationStarted()
{
-
+
}
public override void OnNavigatedTo()
{
base.OnNavigatedTo();
- NavigationManager.NavigateTo<TechnicianModule>(nameof(CatalogView), false);
+ NavigationManager.NavigateTo<TechnicianModule>(nameof(CatalogView));
}
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs
deleted file mode 100644
index 1d7e1780a..000000000
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Core.DI;
-using Tango.PPC.Common;
-using Tango.PPC.Common.UpdatePackages;
-using Tango.PPC.Shared.Updates;
-
-namespace Tango.PPC.Technician.ViewModels
-{
- public class PackagesViewVM : PPCViewModel
- {
- [TangoInject(TangoInjectMode.WhenAvailable)]
- public IPackageRunner PackageRunner { get; set; }
-
- private List<PackageInstallation> _packages;
- public List<PackageInstallation> Packages
- {
- get { return _packages; }
- set { _packages = value; RaisePropertyChangedAuto(); }
- }
-
- public override void OnApplicationStarted()
- {
-
- }
-
- public async override void OnApplicationReady()
- {
- base.OnApplicationReady();
-
- try
- {
- Packages = (await PackageRunner.GetPackagesFile()).PackageInstallations;
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "An error occurred while trying to list the installed update packages.");
- }
- }
- }
-}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs
deleted file mode 100644
index 2d8857329..000000000
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/RemoteConnectionsViewVM.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Core.Commands;
-using Tango.Integration.ExternalBridge;
-using Tango.PPC.Common;
-
-namespace Tango.PPC.Technician.ViewModels
-{
- public class RemoteConnectionsViewVM : PPCViewModel
- {
- public RelayCommand DisconnectCommand { get; set; }
-
- private ExternalBridgeReceiver _selectedReceiver;
- public ExternalBridgeReceiver SelectedReceiver
- {
- get { return _selectedReceiver; }
- set
- {
- if (value != null)
- {
- _selectedReceiver = value;
- InvalidateRelayCommands();
- }
- }
- }
-
- public RemoteConnectionsViewVM()
- {
- DisconnectCommand = new RelayCommand(DisconnectReceiver, () => SelectedReceiver != null);
- }
-
- private async void DisconnectReceiver()
- {
- if (SelectedReceiver != null)
- {
- try
- {
- await Task.Factory.StartNew(() =>
- {
- SelectedReceiver.Disconnect().Wait();
- });
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error disconnecting the specified receiver.");
- }
- finally
- {
- _selectedReceiver = null;
- RaisePropertyChanged(nameof(SelectedReceiver));
- InvalidateRelayCommands();
- }
- }
- }
-
- public override void OnApplicationStarted()
- {
-
- }
- }
-}
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 452907366..444c1d09e 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
@@ -8,20 +8,16 @@ using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
-using Tango.BL;
using Tango.Core.Commands;
using Tango.PPC.Common;
using Tango.PPC.Common.OS;
using Tango.Settings;
-using System.Data.Entity;
-using Tango.PPC.Common.UWF;
namespace Tango.PPC.Technician.ViewModels
{
public class SystemViewVM : PPCViewModel
{
private IOperationSystemManager _os;
- private IUnifiedWriteFilterManager _uwf;
private Timer _statsTimer;
private bool _resettingDevice;
@@ -60,20 +56,6 @@ namespace Tango.PPC.Technician.ViewModels
set { _ipAddress = value; RaisePropertyChangedAuto(); }
}
- private String _totalDyeTime;
- public String TotalDyeTime
- {
- get { return _totalDyeTime; }
- set { _totalDyeTime = value; RaisePropertyChangedAuto(); }
- }
-
- private String _totalDyeMeters;
- public String TotalDyeMeters
- {
- get { return _totalDyeMeters; }
- set { _totalDyeMeters = value; RaisePropertyChangedAuto(); }
- }
-
public RelayCommand ResetDeviceCommand { get; set; }
public RelayCommand RestartCommand { get; set; }
@@ -84,10 +66,9 @@ namespace Tango.PPC.Technician.ViewModels
public RelayCommand ExitToExplorerCommand { get; set; }
- public SystemViewVM(IOperationSystemManager os, IUnifiedWriteFilterManager uwf)
+ public SystemViewVM(IOperationSystemManager os)
{
_os = os;
- _uwf = uwf;
CPU = 0;
RAM = 0;
@@ -105,7 +86,7 @@ namespace Tango.PPC.Technician.ViewModels
{
_resettingDevice = true;
ResetDeviceCommand.RaiseCanExecuteChanged();
- await MachineProvider.MachineOperator.Reset();
+ await MachineProvider.MachineOperator.ResetDFU();
await NotificationProvider.ShowInfo("Embedded device has been reset successfully.");
}
catch (Exception ex)
@@ -121,30 +102,11 @@ namespace Tango.PPC.Technician.ViewModels
private async void FactoryReset()
{
- if (await NotificationProvider.ShowQuestion("Are you sure you want to reset this device back to factory settings?"))
+ if (await NotificationProvider.ShowQuestion("Are you sure you want to reset this device and back to factory settings?"))
{
Settings.ApplicationState = ApplicationStates.FactoryRestore;
Settings.Save();
- try
- {
- NotificationProvider.SetGlobalBusyMessage("Disabling write filter protection...");
- await _uwf.Disable();
- await Task.Delay(2000);
- NotificationProvider.ReleaseGlobalBusyMessage();
- await NavigationManager.NavigateTo(Common.Navigation.NavigationView.RestartingSystemView);
- await Task.Delay(4000);
- _os.Restart();
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error executing factory reset.");
- NotificationProvider.ReleaseGlobalBusyMessage();
- await NotificationProvider.ShowError($"Error executing factory reset.\n{ex.FlattenMessage()}");
- }
- finally
- {
- NotificationProvider.ReleaseGlobalBusyMessage();
- }
+ ApplicationManager.Restart();
}
}
@@ -160,8 +122,6 @@ namespace Tango.PPC.Technician.ViewModels
{
if (await NotificationProvider.ShowQuestion("Are you sure you want to restart the device?"))
{
- await NavigationManager.NavigateTo(Common.Navigation.NavigationView.RestartingSystemView);
- await Task.Delay(4000);
_os.Restart();
}
}
@@ -170,7 +130,12 @@ namespace Tango.PPC.Technician.ViewModels
{
if (await NotificationProvider.ShowQuestion("Close the application and start OS shell?"))
{
- _os.OpenShell();
+ Process.Start(new ProcessStartInfo()
+ {
+ UseShellExecute = true,
+ FileName = "explorer.exe",
+ });
+
ApplicationManager.ShutDown();
}
}
@@ -183,6 +148,12 @@ namespace Tango.PPC.Technician.ViewModels
_statsTimer.Start();
}
+ public override void OnApplicationReady()
+ {
+ base.OnApplicationReady();
+ IPAddress = GetIpv4Address();
+ }
+
private void _statsTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (IsVisible)
@@ -273,31 +244,5 @@ namespace Tango.PPC.Technician.ViewModels
return "N/A";
}
}
-
- public async override void OnNavigatedTo()
- {
- base.OnNavigatedTo();
-
- IPAddress = GetIpv4Address();
-
- try
- {
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- var jobRuns = await db.JobRuns.Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToListAsync();
-
- TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToStringUnlimitedHours();
-
- int meters = (int)jobRuns.Select(x => x.EndPosition).Sum();
- TotalDyeMeters = $"{meters.ToString("N0")} meters";
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error loading machine counters.");
- TotalDyeTime = "error!";
- TotalDyeMeters = "error!";
- }
- }
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs
deleted file mode 100644
index 3f4232252..000000000
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/UpdatesViewVM.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.BL;
-using Tango.BL.Entities;
-using Tango.BL.Enumerations;
-using Tango.Core.Commands;
-using Tango.PPC.Common;
-using System.Data.Entity;
-using Tango.PPC.Technician.Dialogs;
-using Tango.PPC.Common.Synchronization;
-
-namespace Tango.PPC.Technician.ViewModels
-{
- public class UpdatesViewVM : PPCViewModel
- {
- public RelayCommand SynchronizeCommand { get; set; }
-
- private List<TangoUpdate> _updates;
- public List<TangoUpdate> Updates
- {
- get { return _updates; }
- set { _updates = value; RaisePropertyChangedAuto(); }
- }
-
- private TangoUpdate _selectedUpdate;
- public TangoUpdate SelectedUpdate
- {
- get { return _selectedUpdate; }
- set { _selectedUpdate = value; OnSelectedUpdateChanged(); }
- }
-
- private SynchronizationStatus _selectedSynchronization;
- public SynchronizationStatus SelectedSynchronization
- {
- get { return _selectedSynchronization; }
- set { _selectedSynchronization = value; OnSelectedSynchronizationChanged(); }
- }
-
- public UpdatesViewVM()
- {
- Updates = new List<TangoUpdate>();
- SynchronizeCommand = new RelayCommand(Synchronize, () => !MachineDataSynchronizer.IsSynchronizing);
- }
-
- public override void OnApplicationStarted()
- {
-
- }
-
- public override void OnApplicationReady()
- {
- base.OnApplicationReady();
- MachineDataSynchronizer.SynchronizationStarted += (_, __) => InvalidateRelayCommands();
- MachineDataSynchronizer.SynchronizationEnded += (_, __) => InvalidateRelayCommands();
- }
-
- private async void Synchronize()
- {
- try
- {
- await MachineDataSynchronizer.Synchronize();
- }
- catch { }
- }
-
- public async override void OnNavigatedTo()
- {
- base.OnNavigatedTo();
-
- try
- {
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- Updates = await db.TangoUpdates.Where(x =>
- x.Status != (int)TangoUpdateStatuses.SynchronizationCompleted &&
- x.Status != (int)TangoUpdateStatuses.SynchronizationFailed &&
- x.Status != (int)TangoUpdateStatuses.SynchronizationStarted
- ).OrderByDescending(x => x.StartDate).ToListAsync();
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex, "Error loading update history.");
- }
- }
-
- private async void OnSelectedUpdateChanged()
- {
- if (SelectedUpdate != null)
- {
- await NotificationProvider.ShowDialog<UpdateDetailsViewVM>(new UpdateDetailsViewVM() { Update = SelectedUpdate });
- }
- }
-
- private async void OnSelectedSynchronizationChanged()
- {
- if (SelectedSynchronization != null)
- {
- await NotificationProvider.ShowDialog<SynchronizationDetailsViewVM>(new SynchronizationDetailsViewVM() { Status = SelectedSynchronization });
- }
- }
- }
-}