aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-11-08 12:03:06 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-11-08 12:03:06 +0200
commit5da415d6935bd6faa8c49db66f11015a8050bf4d (patch)
treed2b124a77b4e46f8c7ea92fa2e15151fe4d0d6e5 /Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
parent65115888c2d2fd03522dd4b5243a6657e15a62f0 (diff)
downloadTango-5da415d6935bd6faa8c49db66f11015a8050bf4d.tar.gz
Tango-5da415d6935bd6faa8c49db66f11015a8050bf4d.zip
Moved android project and new project.
Visual Studio Timeout Task!
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs43
1 files changed, 29 insertions, 14 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
index b87773e1f..a4932eafc 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
@@ -17,6 +17,7 @@ using Tango.Core.DI;
using Tango.PPC.Common.Messages;
using Tango.Emulations.Emulators;
using Tango.Transport.Transporters;
+using Tango.Integration;
namespace Tango.PPC.Common.Connection
{
@@ -125,26 +126,40 @@ namespace Tango.PPC.Common.Connection
{
LogManager.Log("Starting machine connection procedure...");
- var demo = SettingsManager.Default.GetOrCreate<PPCSettings>().DemoMode;
+ var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
+
+ var demo = settings.DemoMode;
if (!demo)
{
- TimeSpan timeout = TimeSpan.FromSeconds(SettingsManager.Default.GetOrCreate<PPCSettings>().MachineScanningTimeoutSeconds);
+ if (String.IsNullOrWhiteSpace(settings.EmbeddedComPort))
+ {
+ TimeSpan timeout = TimeSpan.FromSeconds(SettingsManager.Default.GetOrCreate<PPCSettings>().MachineScanningTimeoutSeconds);
- LogManager.Log("Scanning for machine on available serial ports...");
- Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse> scanner = new Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse>(UsbSerialBaudRates.BR_9600);
- var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, timeout);
+ LogManager.Log("Scanning for machine on available serial ports...");
+ Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse> scanner = new Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse>(UsbSerialBaudRates.BR_115200);
+ var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, timeout);
- LogManager.Log("Machine discovered on port: " + response.Adapter.Address);
- LogManager.Log("Device Information:");
- LogManager.Log(response.Response.DeviceInformation.ToJsonString());
+ LogManager.Log("Machine discovered on port: " + response.Adapter.Address);
+ LogManager.Log("Device Information:");
+ LogManager.Log(response.Response.DeviceInformation.ToJsonString());
- LogManager.Log("Disconnecting machine operator...");
- await MachineOperator.Disconnect();
- MachineOperator.Adapter = response.Adapter;
- MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp;
- LogManager.Log("Connecting machine operator...");
- await MachineOperator.Connect();
+ LogManager.Log("Disconnecting machine operator...");
+ await MachineOperator.Disconnect();
+ MachineOperator.Adapter = response.Adapter;
+ MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp;
+ LogManager.Log("Connecting machine operator...");
+ await MachineOperator.Connect();
+ }
+ else
+ {
+ LogManager.Log($"Connecting to machine on {settings.EmbeddedComPort}...");
+
+ UsbTransportAdapter adapter = new UsbTransportAdapter(settings.EmbeddedComPort, UsbSerialBaudRates.BR_115200);
+ MachineOperator.Adapter = adapter;
+ MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp;
+ await MachineOperator.Connect();
+ }
}
else
{