From e47e602cd61bcca8eb7fbef40dc4aa8798510ccc Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 16 Aug 2020 17:05:56 +0300 Subject: Working on insights... --- .../Insights/DefaultInsightsService.cs | 45 ++++++++++++++++++++++ .../Tango.PPC.Common/Insights/IInsightsService.cs | 13 +++++++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 8 +++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/IInsightsService.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs new file mode 100644 index 000000000..e5148cfe5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.DI; +using Tango.Insights; +using Tango.PPC.Common.Application; +using Tango.PPC.Common.Connection; + +namespace Tango.PPC.Common.Insights +{ + [TangoCreateWhenRegistered] + public class DefaultInsightsService : ExtendedObject, IInsightsService + { + private InsightsListener _listener; + public bool Enabled { get; set; } + + private IMachineProvider MachineProvider { get; set; } + + public DefaultInsightsService(IMachineProvider machineProvider, IPPCApplicationManager applicationManager) + { + MachineProvider = machineProvider; + + applicationManager.ApplicationStarted += ApplicationManager_ApplicationStarted; + } + + private void ApplicationManager_ApplicationStarted(object sender, EventArgs e) + { + Task.Factory.StartNew(() => + { + try + { + _listener = new InsightsListener(MachineProvider.MachineOperator); + _listener.Start(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error initializing insights listener."); + } + }); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/IInsightsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/IInsightsService.cs new file mode 100644 index 000000000..d7c5497d6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/IInsightsService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Insights +{ + public interface IInsightsService: IPPCService + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index b15ca60bd..08e49621c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -163,6 +163,8 @@ + + @@ -389,6 +391,10 @@ {c6ebbbbe-2123-44dc-aef7-a0d47d736ac0} Tango.FileSystem + + {4a55c185-3f8d-41b0-8815-c15f6213a14a} + Tango.Insights + {4206ac58-3b57-4699-8835-90bf6db01a61} Tango.Integration @@ -477,7 +483,7 @@ - + \ No newline at end of file -- cgit v1.3.1