From afca405892ace809c498c010a2d4484bec5adf11 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 24 Apr 2019 14:01:40 +0300 Subject: Implemented USB adapter finalizer. Added exception logging for USB adapter disconnection error. Added Volume color space icon to PPC. Implemented KeepAlive suppression on StorageAPI. Suppressed KeepAlive when uploading job. Implemented keep alive skipping when arrived responses queue is busy. --- .../ViewModels/MainViewVM.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 4d8ec954e..e03c64a54 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1307,6 +1307,8 @@ namespace Tango.MachineStudio.Developer.ViewModels /// private async void StartJob(Func resumeFunc = null) { + SettingsManager.Default.Save(); + LogManager.Log(String.Format("Starting job {0}...", ActiveJob.Name)); if (MachineOperator == null || MachineOperator.State != TransportComponentState.Connected) { @@ -1766,6 +1768,11 @@ namespace Tango.MachineStudio.Developer.ViewModels InvalidateRelayCommands(); _disable_gamut_check = false; + + _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; + _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + + _settings.Save(); }); SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments); @@ -2003,6 +2010,11 @@ namespace Tango.MachineStudio.Developer.ViewModels SelectedSegments.ToList().ForEach(x => { + if (ActiveJob.Segments.Count == 1) + { + _notification.ShowInfo("A job must contain at least one segment."); + return; + } ActiveJob.Segments.Remove(x); x.DefferedDelete(_activeJobDbContext); }); @@ -2130,12 +2142,17 @@ namespace Tango.MachineStudio.Developer.ViewModels { if (SelectedBrushStop != null && SelectedSegment != null) { - if (_notification.ShowQuestion("Are you sure you want to delete the selected colors?")) + if (_notification.ShowQuestion("Are you sure you want to delete the selected brush stops?")) { LogManager.Log(String.Format("Removing {0} brush stops...", SelectedBrushStops.Count)); SelectedBrushStops.ToList().ForEach(x => { + if (SelectedSegment.BrushStops.Count == 1) + { + _notification.ShowInfo("A job segment must contain at least one brush stop."); + return; + } SelectedSegment.BrushStops.Remove(x); x.DefferedDelete(_activeJobDbContext); }); @@ -2422,8 +2439,7 @@ namespace Tango.MachineStudio.Developer.ViewModels public override void OnShuttingDown() { - _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + } #endregion -- cgit v1.3.1 From b3251faca81119a951c176291cec428646500b17 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 30 Apr 2019 09:09:16 +0300 Subject: General bug fixes. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes .../Machine Studio Installer.aip | 18 +-- .../Advanced Installer Projects/PPC Installer.aip | 108 ++------------- .../ViewModels/MainViewVM.cs | 14 +- .../Properties/AssemblyInfo.cs | 2 +- .../Tango.PPC.Events/ViewModels/MainViewVM.cs | 13 +- .../Controls/DispenserController.xaml | 2 +- .../Tango.PPC.Technician.csproj | 12 ++ .../Tango.PPC.Technician/ViewModelLocator.cs | 12 ++ .../ViewModels/SystemViewVM.cs | 150 +++++++++++++++++++++ .../Tango.PPC.Technician/Views/CatalogView.xaml | 2 +- .../Tango.PPC.Technician/Views/DispensersView.xaml | 2 +- .../Tango.PPC.Technician/Views/MainView.xaml | 1 + .../Tango.PPC.Technician/Views/SystemView.xaml | 56 ++++++++ .../Tango.PPC.Technician/Views/SystemView.xaml.cs | 28 ++++ .../Connection/DefaultMachineProvider.cs | 7 +- .../MachineUpdate/MachineUpdateManager.cs | 4 +- .../OS/DefaultOperationSystemManager.cs | 8 ++ .../Tango.PPC.Common/OS/IOperationSystemManager.cs | 6 + .../PPC/Tango.PPC.Common/PPCSettings.cs | 6 + .../PPCApplication/DefaultPPCApplicationManager.cs | 11 +- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 5 +- .../Tango.Integration/Operation/MachineOperator.cs | 2 + .../Discovery/UsbCommunicationScanner.cs | 46 +++++-- .../Tango.Transport/TransportMessage.cs | 64 +++++---- .../Tango.Transport/TransportMessageBase.cs | 3 +- 30 files changed, 417 insertions(+), 167 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 872d8ac1b..8848eced3 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index c0b0daa9f..2062993f9 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 032683b9d..a82e50d7e 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index c016fe931..5b81a70e8 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip index 4b88dab01..de4d79c45 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip @@ -15,10 +15,10 @@ - + - + @@ -103,6 +103,7 @@ + @@ -319,9 +320,6 @@ - - - @@ -329,7 +327,7 @@ - + @@ -764,14 +762,11 @@ - - - - + @@ -787,7 +782,7 @@ - + @@ -864,6 +859,7 @@ + diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index 27458976f..074e21f8a 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip @@ -18,10 +18,10 @@ - + - + @@ -73,17 +73,9 @@ - - - - - - - - @@ -110,11 +102,11 @@ - + @@ -129,46 +121,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -204,22 +170,15 @@ - - - - - - - + - - + @@ -254,21 +213,12 @@ - - - - - - - - - @@ -312,14 +262,12 @@ - - @@ -339,23 +287,12 @@ - - - - - - - - - - - @@ -369,28 +306,13 @@ - - - - - - - - - - - - - - - @@ -446,7 +368,7 @@ - + @@ -484,23 +406,9 @@ - - - - - - - - - - - - - - @@ -512,7 +420,7 @@ - + @@ -579,6 +487,8 @@ + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index e03c64a54..4ce8ab39d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1081,13 +1081,13 @@ namespace Tango.MachineStudio.Developer.ViewModels { _speech.SpeakError(events.Last().EventType.Name); - if (events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.StopJob))) - { - if (JobHandler != null) - { - InvokeUI(StopJob); - } - } + //if (events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.StopJob))) + //{ + // if (JobHandler != null) + // { + // InvokeUI(StopJob); + // } + //} } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index a1601d9de..fb9d1472b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("4.0.13.0")] +[assembly: AssemblyVersion("4.0.15.0")] [assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs index 49e0763d9..dcf6afb97 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs @@ -22,7 +22,7 @@ namespace Tango.PPC.Events.ViewModels /// public class MainViewVM : PPCViewModel { - private Dictionary _notifications; + private List> _notifications; private EventsSource _selectedEventsSource; public EventsSource SelectedEventsSource @@ -78,7 +78,7 @@ namespace Tango.PPC.Events.ViewModels public MainViewVM() { CurrentEvents = new ObservableCollection(); - _notifications = new Dictionary(); + _notifications = new List>(); } /// @@ -157,7 +157,7 @@ namespace Tango.PPC.Events.ViewModels } NotificationProvider.PushNotification(notificationItem); - _notifications.Add(ev.EventType.Type, notificationItem); + _notifications.Add(new KeyValuePair(ev.EventType.Type, notificationItem)); } }); @@ -172,11 +172,10 @@ namespace Tango.PPC.Events.ViewModels CurrentEvents.Remove(ev); HistoryEvents.Insert(0, ev); - if (_notifications.ContainsKey(ev.EventType.Type)) + foreach (var item in _notifications.ToList().Where(x => x.Key == ev.EventType.Type)) { - var notification = _notifications[ev.EventType.Type]; - _notifications.Remove(ev.EventType.Type); - NotificationProvider.PopNotification(notification); + _notifications.Remove(item); + NotificationProvider.PopNotification(item.Value); } } }); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml index 3fc7c607e..18636704a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml @@ -46,7 +46,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj index 212ab6f16..e524c44cb 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -86,6 +86,7 @@ + CatalogView.xaml @@ -98,6 +99,9 @@ MainView.xaml + + SystemView.xaml + ResXFileCodeGenerator Resources.Designer.cs @@ -130,6 +134,10 @@ {e4927038-348d-4295-aaf4-861c58cb3943} Tango.PMR + + {D8F1AD85-526A-4F50-B6DC-D437AF63D8D8} + Tango.Settings + {8491D07B-C1F6-4B62-A412-41B9FD2D6538} Tango.SharedUI @@ -172,6 +180,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs index 9460578c8..ae4678e60 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs @@ -19,6 +19,7 @@ namespace Tango.PPC.Technician TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } /// @@ -64,5 +65,16 @@ namespace Tango.PPC.Technician return TangoIOC.Default.GetInstance(); } } + + /// + /// Gets the system view VM. + /// + public static SystemViewVM SystemViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } 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 new file mode 100644 index 000000000..5f7002e78 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Timers; +using Tango.Core.Commands; +using Tango.PPC.Common; +using Tango.PPC.Common.OS; +using Tango.Settings; + +namespace Tango.PPC.Technician.ViewModels +{ + public class SystemViewVM : PPCViewModel + { + private IOperationSystemManager _os; + private Timer _statsTimer; + + private float _cpu; + public float CPU + { + get { return _cpu; } + set { _cpu = value; RaisePropertyChangedAuto(); } + } + + private long _ram; + public long RAM + { + get { return _ram; } + set { _ram = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand RestartCommand { get; set; } + + public RelayCommand ShutdownCommand { get; set; } + + public RelayCommand FactoryResetCommand { get; set; } + + public RelayCommand ExitToExplorerCommand { get; set; } + + public SystemViewVM(IOperationSystemManager os) + { + _os = os; + + CPU = 0; + RAM = 0; + + RestartCommand = new RelayCommand(RestartSystem); + ShutdownCommand = new RelayCommand(ShutdownSystem); + FactoryResetCommand = new RelayCommand(FactoryReset); + ExitToExplorerCommand = new RelayCommand(ExitToExplorer); + } + + private async void FactoryReset() + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to reset this device and back to factory settings?")) + { + Settings.ApplicationState = ApplicationStates.PreSetup; + Settings.Save(); + ApplicationManager.Restart(); + } + } + + private async void ShutdownSystem() + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to shutdown the device?")) + { + _os.Shutdown(); + } + } + + private async void RestartSystem() + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to restart the device?")) + { + _os.Restart(); + } + } + + private async void ExitToExplorer() + { + if (await NotificationProvider.ShowQuestion("Close the application and start OS shell?")) + { + Process.Start(new ProcessStartInfo() + { + UseShellExecute = true, + FileName = "explorer.exe", + }); + + ApplicationManager.ShutDown(); + } + } + + public override void OnApplicationStarted() + { + _statsTimer = new Timer(); + _statsTimer.Interval = 2000; + _statsTimer.Elapsed += _statsTimer_Elapsed; + _statsTimer.Start(); + } + + private void _statsTimer_Elapsed(object sender, ElapsedEventArgs e) + { + if (IsVisible) + { + CPU = GetAppCPU(); + RAM = GetAppRam(); + } + } + + public float GetTotalCPU() + { + PerformanceCounter cpuCounter = new PerformanceCounter(); + cpuCounter.CategoryName = "Processor"; + cpuCounter.CounterName = "% Processor Time"; + cpuCounter.InstanceName = "_Total"; + + // will always start at 0 + float firstValue = cpuCounter.NextValue(); + System.Threading.Thread.Sleep(1000); + // now matches task manager reading + float secondValue = cpuCounter.NextValue(); + + return secondValue; + } + + public float GetAppCPU() + { + PerformanceCounter cpuCounter = new PerformanceCounter(); + cpuCounter.CategoryName = "Process"; + cpuCounter.CounterName = "% Processor Time"; + cpuCounter.InstanceName = Process.GetCurrentProcess().ProcessName; + + // will always start at 0 + float firstValue = cpuCounter.NextValue(); + System.Threading.Thread.Sleep(1000); + // now matches task manager reading + float secondValue = cpuCounter.NextValue(); + + return secondValue / Environment.ProcessorCount; + } + + public long GetAppRam() + { + Process proc = Process.GetCurrentProcess(); + return proc.PrivateMemorySize64; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml index 4571f99de..58c88324f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml @@ -32,7 +32,7 @@ - + System diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml index c8fc038f1..58600df3c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml @@ -27,7 +27,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml index e697696c2..08f9a335a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml @@ -16,6 +16,7 @@ + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml new file mode 100644 index 000000000..dc13b2918 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + System + + + + + + + + CPU Usage: + % + + + + RAM Usage: + + + + + + Restart Device + Shutdown Device + Factory Reset + Exit To Shell + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml.cs new file mode 100644 index 000000000..f4a672407 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml.cs @@ -0,0 +1,28 @@ +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.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Technician.Views +{ + /// + /// Interaction logic for SystemView.xaml + /// + public partial class SystemView : UserControl + { + public SystemView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 61ddfdb2b..ab42de712 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -79,6 +79,7 @@ namespace Tango.PPC.Common.Connection MachineOperator.UseKeepAlive = true; MachineOperator.EnableDiagnostics = false; MachineOperator.EnableEmbeddedDebugging = false; + MachineOperator.FirmwareUpgradeMode = Integration.Upgrade.FirmwareUpgradeModes.DFU | Integration.Upgrade.FirmwareUpgradeModes.TFP_PACKAGE; var settings = SettingsManager.Default.GetOrCreate(); @@ -96,6 +97,8 @@ namespace Tango.PPC.Common.Connection { try { + Thread.Sleep(2000); + LogManager.Log("Starting machine connection procedure...", LogCategory.Debug); var settings = SettingsManager.Default.GetOrCreate(); @@ -108,7 +111,7 @@ namespace Tango.PPC.Common.Connection LogManager.Log("Scanning for machine on available serial ports...", LogCategory.Debug); Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_115200); - var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, timeout); + var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, settings.EmbeddedDeviceHint, timeout); LogManager.Log("Machine discovered on port: " + response.Adapter.Address, LogCategory.Debug); LogManager.Log("Device Information:", LogCategory.Debug); @@ -132,6 +135,7 @@ namespace Tango.PPC.Common.Connection await Task.Delay(1000); await MachineOperator.UploadHardwareConfiguration(Machine.Configuration.HardwareVersion, Machine.Configuration); + MachineOperator.UseKeepAlive = true; } else { @@ -152,6 +156,7 @@ namespace Tango.PPC.Common.Connection await Task.Delay(1000); await MachineOperator.UploadHardwareConfiguration(Machine.Configuration.HardwareVersion, Machine.Configuration); + MachineOperator.UseKeepAlive = true; } } else diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index b64b624fe..3061b9506 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -119,9 +119,9 @@ namespace Tango.PPC.Common.MachineUpdate { throw LogManager.Log(new InvalidOperationException("Could not perform an update while the machine is not connected.")); } - if (op.Status != MachineStatuses.ReadyToDye) + if (op.IsPrinting) { - throw LogManager.Log(new InvalidOperationException($"Could not perform an update while the machine is in a {op.Status} status.")); + throw LogManager.Log(new InvalidOperationException($"Could not perform an update while the machine is in {op.Status} status.")); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index cfbc6d752..d0c8567a1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -160,5 +160,13 @@ namespace Tango.PPC.Common.OS { Process.Start("shutdown.exe", "-r -t 0"); } + + /// + /// Shutdown the system. + /// + public void Shutdown() + { + Process.Start("shutdown.exe", "-s -t 0"); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs index 0cdf85927..f3ec398fc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs @@ -49,5 +49,11 @@ namespace Tango.PPC.Common.OS /// /// void Restart(); + + /// + /// Shutdown the system. + /// + /// + void Shutdown(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 050f1615c..a14d5ede7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -42,6 +42,11 @@ namespace Tango.PPC.Common /// public String EmbeddedComPort { get; set; } + /// + /// Gets or sets the embedded device scanning hint. + /// + public String EmbeddedDeviceHint { get; set; } + /// /// Gets or sets a value indicating whether [enable external bridge]. /// @@ -132,6 +137,7 @@ namespace Tango.PPC.Common MachineScanningTimeoutSeconds = 20; LoggingCategories = new List(); EmbeddedComPort = null; + EmbeddedDeviceHint = "Tango USB Serial Port"; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; LockScreenTimeout = TimeSpan.FromMinutes(10); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index ef2b8aeee..7aeb6760e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -182,7 +182,7 @@ namespace Tango.PPC.UI.PPCApplication //Start watchdog _watchdogServer = new WatchDogServer(Application.Current.Dispatcher); #if !DEBUG - + if (settings.EnableWatchDog) { _watchdogServer.Start(); @@ -425,6 +425,15 @@ namespace Tango.PPC.UI.PPCApplication } catch { } + try + { + if (_machineProvider.MachineOperator.State == Transport.TransportComponentState.Connected) + { + _machineProvider.MachineOperator.Adapter.Disconnect().Wait(); + } + } + catch { } + Process.Start(Application.ResourceAssembly.Location); Environment.Exit(0); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index 8a23fd4f2..62916369e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("1.0.13.0")] +[assembly: AssemblyVersion("1.0.17.0")] 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 56b4c2283..18c8cc7ae 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -38,7 +38,10 @@ Machine S/N: - + + | + Version: + diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 4e42f2b7f..e8e76839a 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -857,6 +857,8 @@ namespace Tango.Integration.Operation bool responseLogged = false; + Thread.Sleep(500); //Just wait maybe Shlomo is getting this message to fast after restart ? + SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => { if (!responseLogged) diff --git a/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs b/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs index 32876e44e..10628da27 100644 --- a/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs +++ b/Software/Visual_Studio/Tango.Transport/Discovery/UsbCommunicationScanner.cs @@ -54,6 +54,18 @@ namespace Tango.Transport.Discovery /// The timeout. /// public Task> Scan(TRequest request, TimeSpan timeout) + { + return Scan(request, null, timeout); + } + + /// + /// Scans the environment with the specified request while expecting the type of response. + /// + /// The request. + /// The expected device name. + /// The timeout. + /// + public Task> Scan(TRequest request, String hint, TimeSpan timeout) { var logManager = LogManager.Default; @@ -71,6 +83,24 @@ namespace Tango.Transport.Discovery logManager.Log("Enumerating com ports..."); var comPorts = ComPortEnumerator.EnumerateComPorts(); + if (!String.IsNullOrWhiteSpace(hint)) + { + logManager.Log($"Device hint is '{hint}'."); + + var expected_port = comPorts.FirstOrDefault(x => x.Description.Contains(hint)); + + if (expected_port != null) + { + logManager.Log($"Device found by hint on port {expected_port.Port}. Sorting ports..."); + comPorts.Remove(expected_port); + comPorts.Insert(0, expected_port); + } + else + { + logManager.Log("Device could not be found by hint."); + } + } + while (!found && DateTime.Now < startTime.Add(timeout)) { foreach (var port in comPorts) @@ -84,15 +114,15 @@ namespace Tango.Transport.Discovery ScanningPort?.Invoke(port.Port); - SafeFileHandle hFile = UsbComPortWin32.CreateFile(@"\\.\" + port.Port, -1073741824, 0, IntPtr.Zero, 3, UsbComPortWin32.dwFlagsAndAttributes, IntPtr.Zero); - if (hFile.IsInvalid) - { - logManager.Log(String.Format("Port {0} is already open or invalid.", port.Port)); - hFile.Close(); - continue; - } + //SafeFileHandle hFile = UsbComPortWin32.CreateFile(@"\\.\" + port.Port, -1073741824, 0, IntPtr.Zero, 3, UsbComPortWin32.dwFlagsAndAttributes, IntPtr.Zero); + //if (hFile.IsInvalid) + //{ + // logManager.Log(String.Format("Port {0} is already open or invalid.", port.Port)); + // hFile.Close(); + // continue; + //} - hFile.Close(); + //hFile.Close(); SerialPort serialPort = new SerialPort(port.Port); diff --git a/Software/Visual_Studio/Tango.Transport/TransportMessage.cs b/Software/Visual_Studio/Tango.Transport/TransportMessage.cs index 18f130d7b..73bf3b1e0 100644 --- a/Software/Visual_Studio/Tango.Transport/TransportMessage.cs +++ b/Software/Visual_Studio/Tango.Transport/TransportMessage.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Reactive.Subjects; using System.Text; using System.Threading.Tasks; +using Tango.Logging; using Tango.PMR; using Tango.PMR.Common; @@ -50,45 +51,60 @@ namespace Tango.Transport Task.Factory.StartNew(() => { - if (!IsContinuous) + try { - if (!_completionSource.Task.IsCompleted) + if (!IsContinuous) + { + if (!_completionSource.Task.IsCompleted) + { + if (_completionSource.GetType() == typeof(TaskCompletionSource)) + { + _completionSource.SetResult((T)result.GetType().GetProperty("Message").GetValue(result)); + } + else if (_completionSource.GetType() == typeof(TaskCompletionSource)) + { + _completionSource.SetResult((T)result.GetType().GetProperty("Container").GetValue(result)); + } + else + { + _completionSource.SetResult((T)result); + } + } + } + else { - if (_completionSource.GetType() == typeof(TaskCompletionSource)) + LastResponseTime = DateTime.Now; + AtLeastOneResponseReceived = true; + + if (ContinuesResponseSubject.GetType() == typeof(Subject)) { - _completionSource.SetResult((T)result.GetType().GetProperty("Message").GetValue(result)); + ContinuesResponseSubject.OnNext((T)result.GetType().GetProperty("Message").GetValue(result)); } - else if (_completionSource.GetType() == typeof(TaskCompletionSource)) + else if (ContinuesResponseSubject.GetType() == typeof(Subject)) { - _completionSource.SetResult((T)result.GetType().GetProperty("Container").GetValue(result)); + ContinuesResponseSubject.OnNext((T)result.GetType().GetProperty("Container").GetValue(result)); } else { - _completionSource.SetResult((T)result); + ContinuesResponseSubject.OnNext((T)result); + } + + if (completed) + { + ContinuesResponseSubject.OnCompleted(); } } } - else + catch (Exception ex) { - LastResponseTime = DateTime.Now; - AtLeastOneResponseReceived = true; - - if (ContinuesResponseSubject.GetType() == typeof(Subject)) - { - ContinuesResponseSubject.OnNext((T)result.GetType().GetProperty("Message").GetValue(result)); - } - else if (ContinuesResponseSubject.GetType() == typeof(Subject)) + LogManager.Log(ex, $"Error while settings result for message."); + try { - ContinuesResponseSubject.OnNext((T)result.GetType().GetProperty("Container").GetValue(result)); + SetException(ex); } - else - { - ContinuesResponseSubject.OnNext((T)result); - } - - if (completed) + catch (Exception e) { - ContinuesResponseSubject.OnCompleted(); + LogManager.Log(e, $"Error while settings exception for message."); } } }); diff --git a/Software/Visual_Studio/Tango.Transport/TransportMessageBase.cs b/Software/Visual_Studio/Tango.Transport/TransportMessageBase.cs index 4e80dc2e6..7736a2752 100644 --- a/Software/Visual_Studio/Tango.Transport/TransportMessageBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransportMessageBase.cs @@ -4,13 +4,14 @@ using System.Linq; using System.Reactive.Subjects; using System.Text; using System.Threading.Tasks; +using Tango.Core; namespace Tango.Transport { /// /// Represents a base transport message. /// - internal abstract class TransportMessageBase + internal abstract class TransportMessageBase : ExtendedObject { /// /// Gets or sets a value indicating whether this instance is multi response. -- cgit v1.3.1