aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs138
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs17
2 files changed, 155 insertions, 0 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
new file mode 100644
index 000000000..0c818483c
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
@@ -0,0 +1,138 @@
+using Microsoft.WindowsAPICodePack.Net;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+using Tango.Core.DI;
+using Tango.Integration.ExternalBridge;
+using Tango.PPC.Common.Application;
+using Tango.PPC.Common.Connectivity;
+using Tango.PPC.Common.ExternalBridge;
+using Tango.PPC.Shared.Information;
+using Tango.Settings;
+using Tango.SystemInfo;
+
+namespace Tango.PPC.Common.SystemInfo
+{
+ [TangoCreateWhenRegistered]
+ public class DefaultSystemInfoService : ExtendedObject, ISystemInfoService, IExternalBridgeRequestHandler
+ {
+ public bool Enabled { get; set; } = true;
+
+ private List<SystemObjectsCollection> _baseSystemInfo;
+ private IPPCApplicationManager _applicationManager;
+ private IConnectivityProvider _connectivityProvider;
+
+ public DefaultSystemInfoService(IPPCExternalBridgeService externalBridge, IPPCApplicationManager applicationManager, IConnectivityProvider connectivityProvider)
+ {
+ _applicationManager = applicationManager;
+ _connectivityProvider = connectivityProvider;
+ externalBridge.RegisterRequestHandler(this);
+ }
+
+ [ExternalBridgeRequestHandlerMethod(typeof(GetMachineInformationRequest), RequestHandlerLoggingMode.LogRequestName)]
+ public async Task OnGetMachineInformationRequest(GetMachineInformationRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ if (_baseSystemInfo == null) //Create hardware info just once.
+ {
+ _baseSystemInfo = new List<SystemObjectsCollection>();
+
+ if (!Debugger.IsAttached)
+ {
+ _baseSystemInfo = SystemObjectsCollection.Create();
+ }
+ }
+
+ //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 },
+ 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() },
+ },
+ });
+
+
+ //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() },
+ new SystemObjectProperty() { Name = "Type", Value = connectedNetwork.Connectivity.ToString() },
+ new SystemObjectProperty() { Name = "Domain", Value = connectedNetwork.DomainType.ToString() },
+ new SystemObjectProperty() { Name = "Connected Time", Value = connectedNetwork.ConnectedTime.ToString() },
+ new SystemObjectProperty() { Name = "Internet Connection", Value = connectedNetwork.IsConnectedToInternet.ToStringYesNo() },
+ },
+ });
+ }
+
+ //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() },
+ new SystemObjectProperty() { Name = "Auto Update Interval", Value = settings.AutoUpdateCheckInterval.ToString() },
+ new SystemObjectProperty() { Name = "Automatic Thread Loading", Value = settings.EnableAutomaticThreadLoading.ToStringYesNo() },
+ new SystemObjectProperty() { Name = "Firmware Logs Enabled", Value = settings.EnableEmbeddedDebugLogs.ToStringYesNo() },
+ new SystemObjectProperty() { Name = "Emergency Switch Enabled", Value = settings.EnableEmergencyNotifications.ToStringYesNo() },
+ new SystemObjectProperty() { Name = "Liquid Quantity Validation Enabled", Value = settings.EnableJobLiquidQuantityValidation.ToStringYesNo() },
+ new SystemObjectProperty() { Name = "Remote Assistance Enabled", Value = settings.EnableRemoteAssistance.ToStringYesNo() },
+ new SystemObjectProperty() { Name = "Remote Desktop Enabled", Value = settings.EnableRemoteDesktop.ToStringYesNo() },
+ new SystemObjectProperty() { Name = "Start in Technician Mode", Value = settings.EnableTechnicianModeByDefault.ToStringYesNo() },
+ 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.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(),
+ });
+
+ await receiver.SendGenericResponse(new GetMachineInformationResponse()
+ {
+ Package = new InformationPackage()
+ {
+ System = system,
+ }
+ }, token);
+ }
+
+ public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs
new file mode 100644
index 000000000..47ea7bd4b
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/ISystemInfoService.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Common.SystemInfo
+{
+ /// <summary>
+ /// Represents a PPC system information service.
+ /// </summary>
+ /// <seealso cref="Tango.PPC.Common.IPPCService" />
+ public interface ISystemInfoService : IPPCService
+ {
+
+ }
+}