aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/ExternalBridge/PPCExternalBridgeService.cs
blob: c50202e8653c67fb1053e85d7af9792274328415 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.Core.DI;
using Tango.Integration.ExternalBridge;
using Tango.Integration.Operation;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Connection;
using Tango.PPC.Common.Messages;
using Tango.Settings;

namespace Tango.PPC.Common.ExternalBridge
{
    /// <summary>
    /// Represents the PPC external bridge service capable of exposing a remote API for communicating and controlling the machine through the PPC.
    /// </summary>
    /// <seealso cref="Tango.Integration.ExternalBridge.ExternalBridgeService" />
    /// <seealso cref="Tango.PPC.Common.ExternalBridge.IPPCExternalBridgeService" />
    public class PPCExternalBridgeService : ExternalBridgeService, IPPCExternalBridgeService
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PPCExternalBridgeService"/> class.
        /// </summary>
        /// <param name="applicationManager">The application manager.</param>
        /// <param name="machineProvider">The machine provider.</param>
        public PPCExternalBridgeService(IPPCApplicationManager applicationManager, IMachineProvider machineProvider)
        {
            applicationManager.ApplicationReady += (_, __) => 
            {
                var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
                MachineOperator = machineProvider.MachineOperator;
                Machine = machineProvider.Machine;
                Enabled = settings.EnableExternalBridge;
            };
        }
    }
}