From 0c664ab02889ac34b568ccd9a1d4aff5985f9d7a Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Mon, 7 Oct 2019 11:05:59 +0300 Subject: Refactoring - added app.xaml files to view in designer VS --- .../MachineStudio/Modules/Tango.MachineStudio.RML/App.xaml | 12 ++++++++++++ .../Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/App.xaml (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/App.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/App.xaml new file mode 100644 index 000000000..787e83d72 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/App.xaml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index 6741a1dff..2ff9ab0a3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -191,6 +191,10 @@ + + Designer + MSBuild:Compile + Designer MSBuild:Compile -- cgit v1.3.1 From 20b54cfc2b40bb69d1d6558c7fac6cc412c98da0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 7 Oct 2019 14:42:44 +0300 Subject: Implemented RML import/export. Fixed issue with MS in 1920x1080. Added IP Address & Up Time to PPC. Added ExternalBridge Icon IsInSession Indication. Fixed issue with ExternalBridgeService disconnection. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../PPC Installer-cache/cacheIndex.txt | Bin 52 -> 52 bytes .../Advanced Installer Projects/PPC Installer.aip | 6 +- .../ViewModels/MainViewVM.cs | 2 +- .../ViewModels/MainViewVM.cs | 91 +++++++++++++++++++++ .../Tango.MachineStudio.RML/Views/RmlsView.xaml | 76 ++++++++++------- .../Tango.MachineStudio.UI/MainWindow.xaml | 4 +- .../Tango.MachineStudio.UI/MainWindow.xaml.cs | 7 +- .../ViewModels/SystemViewVM.cs | 43 ++++++++++ .../Tango.PPC.Technician/Views/SystemView.xaml | 41 +++++++--- .../Application/IPPCApplicationManager.cs | 5 ++ .../PPCApplication/DefaultPPCApplicationManager.cs | 7 ++ .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../PPC/Tango.PPC.UI/Views/MainView.xaml | 13 ++- Software/Visual_Studio/Tango.BL/Entities/Rml.cs | 45 ++++++++++ .../Tango.Transport/TransporterBase.cs | 2 +- 19 files changed, 293 insertions(+), 51 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index e689d3860..44cb41149 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 dbc33c2eb..a08ddfca9 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 6b4ec2038..1e370f3c3 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 9aea78ecc..be04f47f6 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt index a603ff06b..6d87e9201 100644 Binary files a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt and b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index 61e14fbe8..5daca3dcb 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 @@ - + - + @@ -400,7 +400,7 @@ - + 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 27d43bd20..4ab3bb1bb 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 @@ -2565,7 +2565,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private async void ImportJobFile() { OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Import Job File"; + dlg.Title = "Import Job Files"; dlg.Filter = "Twine Job Files|*.job"; dlg.Multiselect = true; if (dlg.ShowDialog().Value) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index a76799881..ee21b9ac3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -181,6 +181,10 @@ namespace Tango.MachineStudio.RML.ViewModels public RelayCommand CloneRmlCommand { get; set; } + public RelayCommand ExportRMLFileCommand { get; set; } + + public RelayCommand ImportRMLFileCommand { get; set; } + public MainViewVM(INotificationProvider notificationProvider) { _notification = notificationProvider; @@ -199,6 +203,9 @@ namespace Tango.MachineStudio.RML.ViewModels ImportForwardDataCommand = new RelayCommand(ImportCCTData, () => ActiveRML != null && IsFree); ExportForwardDataCommand = new RelayCommand(ExportCCTData, () => ActiveRML != null && SelectedCCT != null && IsFree); + + ExportRMLFileCommand = new RelayCommand(ExportRmlFile, () => SelectedRML != null && IsFree); + ImportRMLFileCommand = new RelayCommand(ImportRmlFile, () => IsFree); } public override void OnApplicationReady() @@ -769,5 +776,89 @@ namespace Tango.MachineStudio.RML.ViewModels } #endregion + + #region RML Import / Export + + private async void ImportRmlFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Import Thread Files"; + dlg.Filter = "Twine Thread Files|*.rml"; + dlg.Multiselect = true; + + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Importing thread files...")) + { + try + { + IsFree = false; + + LogManager.Log($"Importing thread files..."); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + foreach (var file in dlg.FileNames) + { + var json = File.ReadAllText(file); + var rmlFile = await Rml.FromRmlFile(db, json); + + db.Rmls.Add(rmlFile); + } + + await db.SaveChangesAsync(); + } + + IsFree = true; + + _notification.ShowInfo($"Threads imported successfully."); + + LoadRmls(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing thread file."); + _notification.ShowError($"An error occurred while trying to import the selected thread file.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } + } + + private async void ExportRmlFile() + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Export Thread File"; + dlg.Filter = "Twine Thread Files|*.rml"; + dlg.DefaultExt = ".rml"; + dlg.FileName = SelectedRML.Name; + + if (dlg.ShowDialog().Value) + { + using (_notification.PushTaskItem($"Exporting Thread '{SelectedRML.Name}'...")) + { + try + { + LogManager.Log($"Exporting Thread file {SelectedRML.Name}"); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var rmlJsonFile = await SelectedRML.ToRmlFile(db); + File.WriteAllText(dlg.FileName, rmlJsonFile); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting Thread file."); + _notification.ShowError($"An error occurred while trying to export thread '{SelectedRML.Name}'.\n{ex.FlattenMessage()}"); + } + } + } + } + + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml index fdfc00ba6..288f00a3d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml @@ -19,38 +19,58 @@ - + - - + + - - - - - - - + + + + + + + @@ -63,11 +83,11 @@ - + - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml index eecbcf8ad..a76749b05 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml @@ -15,8 +15,8 @@ - - + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs index d0eec65e2..915deb484 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs @@ -105,19 +105,24 @@ namespace Tango.MachineStudio.UI switch (ratio) { case 16d / 9d: - grid.Height = 1000; + grid.Height = 1145; + grid.Width = 2000; break; case 16d / 10d: grid.Height = 1145; + grid.Width = 1920; break; case 4d / 3d: grid.Height = 1280; + grid.Width = 1920; break; case 1366d / 768d: grid.Height = 1100; + grid.Width = 1920; break; default: grid.Height = 1145; + grid.Width = 1920; break; } } 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 e01003c0b..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 @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Management; +using System.Net; +using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using System.Timers; @@ -40,6 +42,20 @@ namespace Tango.PPC.Technician.ViewModels set { _temperature = value; RaisePropertyChangedAuto(); } } + private TimeSpan _upTime; + public TimeSpan UpTime + { + get { return _upTime; } + set { _upTime = value; RaisePropertyChangedAuto(); } + } + + private String _ipAddress; + public String IPAddress + { + get { return _ipAddress; } + set { _ipAddress = value; RaisePropertyChangedAuto(); } + } + public RelayCommand ResetDeviceCommand { get; set; } public RelayCommand RestartCommand { get; set; } @@ -132,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) @@ -139,6 +161,7 @@ namespace Tango.PPC.Technician.ViewModels CPU = GetAppCPU(); RAM = GetAppRam(); //Temperature = GetTemperature(); + UpTime = DateTime.Now - ApplicationManager.StartUpDate; } } @@ -201,5 +224,25 @@ namespace Tango.PPC.Technician.ViewModels return 0; } } + + public String GetIpv4Address() + { + try + { + var host = Dns.GetHostEntry(Dns.GetHostName()); + foreach (var ip in host.AddressList) + { + if (ip.AddressFamily == AddressFamily.InterNetwork) + { + return ip.ToString(); + } + } + return "N/A"; + } + catch (Exception ex) + { + return "N/A"; + } + } } } 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 index f6e6370c1..f2bfcdf7d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/SystemView.xaml @@ -49,19 +49,34 @@ - - - - - - - Restart Device - Shutdown Device - Factory Reset - Exit To Shell - + + + + + UP TIME: + + + + + IP ADDRESS: + + + + + + + + + + + Restart Device + Shutdown Device + Factory Reset + Exit To Shell + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs index 5f58be48b..7c67ac1a3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -95,6 +95,11 @@ namespace Tango.PPC.Common.Application /// String BuildDate { get; } + /// + /// Gets the application startup date. + /// + DateTime StartUpDate { get; } + /// /// Gets or sets a value indicating whether the screen is currently locked. /// 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 6a9e42ce5..c7351aa4a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -120,6 +120,11 @@ namespace Tango.PPC.UI.PPCApplication } } + /// + /// Gets the application startup date. + /// + public DateTime StartUpDate { get; private set; } + private bool _isScreenLocked; /// /// Gets or sets a value indicating whether the screen is currently locked. @@ -171,6 +176,8 @@ namespace Tango.PPC.UI.PPCApplication bool initialized = false; bool isAfterSetup = false; + StartUpDate = DateTime.Now; + await Task.Factory.StartNew(() => { try 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 db8540db7..a572fe23e 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.47.0")] +[assembly: AssemblyVersion("1.0.48.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 5accd8ff3..0ee8058c0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -63,7 +63,18 @@ - + + + + + diff --git a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs index 63c0a9dbe..b9224a6d6 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Media; +using Tango.BL.Builders; +using Tango.BL.Serialization; namespace Tango.BL.Entities { @@ -57,5 +59,48 @@ namespace Tango.BL.Entities { return ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); } + + public Task ToRmlFile(ObservablesContext context) + { + return Task.Factory.StartNew(() => + { + var rml = new RmlBuilder(context).Set(Guid).WithActiveParametersGroup().WithCCT().WithLiquidFactors().Build(); + + String result = rml.ToJson(new EntitySerializationStrategy() + .Include(() => rml.Cct) + .Include(() => rml.LiquidTypesRmls) + .Include(() => rml.ProcessParametersTablesGroups) + .Include(typeof(ProcessParametersTablesGroup).GetProperty(nameof(ProcessParametersTablesGroup.ProcessParametersTables))), + EntitySerializationFlags.IgnoreCollections | EntitySerializationFlags.IgnoreReferenceTypes | EntitySerializationFlags.Indented); + + return result; + }); + } + + public static Task FromRmlFile(ObservablesContext context, String json) + { + return Task.Factory.StartNew(() => + { + Rml rml = Rml.FromJson(json,new EntitySerializationStrategy(),EntitySerializationFlags.Indented); + + if (context.Rmls.Any(x => x.Guid == rml.Guid || x.Name == rml.Name)) + { + throw new InvalidOperationException($"Thread {rml.Name} already exist."); + } + + if (rml.Cct != null) + { + if (context.Ccts.Any(x => x.Guid == rml.Cct.Guid)) + { + rml.Cct = null; + } + } + + rml.LastUpdated = DateTime.UtcNow; + rml.Code = context.Rmls.Max(x => x.Code) + 1; + + return rml; + }); + } } } diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 443f5f7cb..2824ed26a 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -1191,7 +1191,7 @@ namespace Tango.Transport } catch (Exception ex) when (ex is TimeoutException || ex is AggregateException) { - if (State != TransportComponentState.Connected || aborted || Adapter.State == TransportComponentState.Failed) return; + if (State != TransportComponentState.Connected || aborted || (Adapter.State == TransportComponentState.Failed && FailsWithAdapter)) return; if (UseKeepAlive) { -- cgit v1.3.1