blob: ae4f7432eeee6da962158ea3d20bcba9b0ba6119 (
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
41
42
43
44
45
46
47
48
49
50
|
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;
SignalRConfiguration.Enabled = true;
if (Environment.CommandLine.Contains("-webDebug"))
{
SignalRConfiguration.Address = "http://localhost:1111/"; //settings.DeploymentSlot.ToAddress();
}
else
{
SignalRConfiguration.Address = settings.DeploymentSlot.ToAddress();
}
SignalRConfiguration.Hub = "ExternalBridgeHub";
Enabled = settings.EnableExternalBridge;
};
}
}
}
|