aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-20 06:24:09 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-05-20 06:24:09 +0300
commited0c073eae5358b509c68e3051c489bd25be30c9 (patch)
tree2dd9f25649fbb6357791b39f5c3cedb415f8f2c9 /Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo
parentb40bfa0f652ec194f2c4d05ae02f0a9c420b50fc (diff)
downloadTango-ed0c073eae5358b509c68e3051c489bd25be30c9.tar.gz
Tango-ed0c073eae5358b509c68e3051c489bd25be30c9.zip
Several fixes and improvements after first real test against PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs98
1 files changed, 52 insertions, 46 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
index f80a8be1e..0c818483c 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
@@ -22,7 +22,7 @@ namespace Tango.PPC.Common.SystemInfo
{
public bool Enabled { get; set; } = true;
- private GetMachineInformationResponse response;
+ private List<SystemObjectsCollection> _baseSystemInfo;
private IPPCApplicationManager _applicationManager;
private IConnectivityProvider _connectivityProvider;
@@ -36,44 +36,52 @@ namespace Tango.PPC.Common.SystemInfo
[ExternalBridgeRequestHandlerMethod(typeof(GetMachineInformationRequest), RequestHandlerLoggingMode.LogRequestName)]
public async Task OnGetMachineInformationRequest(GetMachineInformationRequest request, String token, ExternalBridgeReceiver receiver)
{
- if (response == null)
+ if (_baseSystemInfo == null) //Create hardware info just once.
{
- //Get the networks that are currently connected to
- var connectedNetwork = NetworkListManager.GetNetworks(NetworkConnectivityLevels.Connected).FirstOrDefault();
-
- var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
-
- List<SystemObjectsCollection> system = new List<SystemObjectsCollection>();
+ _baseSystemInfo = new List<SystemObjectsCollection>();
if (!Debugger.IsAttached)
{
- system = SystemObjectsCollection.Create();
+ _baseSystemInfo = SystemObjectsCollection.Create();
}
+ }
- //Add custom information..
- system.Insert(0, new SystemObjectsCollection()
- {
- Name = "Application",
- Objects = new List<SystemObject>()
- {
- new SystemObject()
- {
- Name = "Tango PPC",
- Properties = new List<SystemObjectProperty>()
+ //Now always update the latest custom objects..
+ var system = _baseSystemInfo.ToList();
+
+ //Get the networks that are currently connected to
+ var connectedNetwork = NetworkListManager.GetNetworks(NetworkConnectivityLevels.Connected).FirstOrDefault();
+
+ var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
+
+ var applicationCollection = new SystemObjectsCollection();
+ applicationCollection.Name = "Application";
+ system.Insert(0, applicationCollection);
+
+ //Application.
+ applicationCollection.Objects.Add(new SystemObject()
+ {
+ Name = "Tango PPC",
+ Properties = new List<SystemObjectProperty>()
{
new SystemObjectProperty() { Name = "Version", Value = _applicationManager.Version.ToString(3) },
- new SystemObjectProperty() { Name = "Build Date", Value = _applicationManager.BuildDate.ToString() },
- new SystemObjectProperty() { Name = "Previous Version", Value = settings.PreviousApplicationVersion.ToString() },
- new SystemObjectProperty() { Name = "Firmware Version", Value = _applicationManager.FirmwareVersion.ToString() },
+ new SystemObjectProperty() { Name = "Build Date", Value = _applicationManager.BuildDate },
+ new SystemObjectProperty() { Name = "Previous Version", Value = settings.PreviousApplicationVersion },
+ new SystemObjectProperty() { Name = "Firmware Version", Value = _applicationManager.FirmwareVersion.ToStringSafe() },
new SystemObjectProperty() { Name = "Technician Mode", Value = _applicationManager.IsInTechnicianMode.ToStringYesNo() },
new SystemObjectProperty() { Name = "After Update", Value = _applicationManager.IsAfterUpdate.ToStringYesNo() },
new SystemObjectProperty() { Name = "Startup Date", Value = _applicationManager.StartUpDate.ToString() },
},
- },
- new SystemObject()
- {
- Name = "Network",
- Properties = new List<SystemObjectProperty>()
+ });
+
+
+ //Network.
+ if (connectedNetwork != null)
+ {
+ applicationCollection.Objects.Add(new SystemObject()
+ {
+ Name = "Network",
+ Properties = new List<SystemObjectProperty>()
{
new SystemObjectProperty() { Name = "Network Name", Value = connectedNetwork.Name },
new SystemObjectProperty() { Name = "Category", Value = connectedNetwork.Category.ToString() },
@@ -82,11 +90,14 @@ namespace Tango.PPC.Common.SystemInfo
new SystemObjectProperty() { Name = "Connected Time", Value = connectedNetwork.ConnectedTime.ToString() },
new SystemObjectProperty() { Name = "Internet Connection", Value = connectedNetwork.IsConnectedToInternet.ToStringYesNo() },
},
- },
- new SystemObject()
- {
- Name = "Settings",
- Properties = new List<SystemObjectProperty>()
+ });
+ }
+
+ //Settings.
+ applicationCollection.Objects.Add(new SystemObject()
+ {
+ Name = "Settings",
+ Properties = new List<SystemObjectProperty>()
{
new SystemObjectProperty() { Name = "Application State", Value = settings.ApplicationState.ToString() },
new SystemObjectProperty() { Name = "Auto Update Check", Value = settings.AutoCheckForUpdates.ToStringYesNo() },
@@ -101,27 +112,22 @@ namespace Tango.PPC.Common.SystemInfo
new SystemObjectProperty() { Name = "Watchdog Enabled", Value = settings.EnableWatchDog.ToStringYesNo() },
new SystemObjectProperty() { Name = "Job Units Method", Value = settings.JobUnitsMethod.ToString() },
new SystemObjectProperty() { Name = "PowerUp Screen Enabled", Value = settings.DisplayPowerUpScreen.ToStringYesNo() },
- new SystemObjectProperty() { Name = "Firmware COM Port", Value = settings.EmbeddedComPort.ToString() },
- new SystemObjectProperty() { Name = "Emergency COM Port", Value = settings.EmergencyComPort.ToString() },
+ new SystemObjectProperty() { Name = "Firmware COM Port", Value = settings.EmbeddedComPort.ToStringOrEmpty() },
+ new SystemObjectProperty() { Name = "Emergency COM Port", Value = settings.EmergencyComPort.ToStringOrEmpty() },
new SystemObjectProperty() { Name = "Job Upload Method", Value = settings.JobUploadStrategy.ToString() },
new SystemObjectProperty() { Name = "Diagnostics Synchronization", Value = settings.SynchronizeDiagnostics.ToStringYesNo() },
new SystemObjectProperty() { Name = "Jobs Synchronization", Value = settings.SynchronizeJobs.ToStringYesNo() },
new SystemObjectProperty() { Name = "TCP Write Mode", Value = settings.TcpTransportAdapterWriteMode.ToString() },
}.OrderBy(x => x.Name).ToList(),
- },
- },
- });
+ });
- response = new GetMachineInformationResponse()
+ await receiver.SendGenericResponse(new GetMachineInformationResponse()
+ {
+ Package = new InformationPackage()
{
- Package = new InformationPackage()
- {
- System = system,
- }
- };
- }
-
- await receiver.SendGenericResponse(response, token);
+ System = system,
+ }
+ }, token);
}
public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)