aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy <Roy.mail.net@gmail.com>2023-06-27 13:15:28 +0300
committerRoy <Roy.mail.net@gmail.com>2023-06-27 13:15:28 +0300
commit0f150c98978332377ee6aad3eac8c8a08553a8e7 (patch)
treedcfd17fb1c3495e74273cb618c03cd7538a9873d /Software/Visual_Studio
parent304735006580cb2f6728bedeb3393dbefc2e14f5 (diff)
downloadTango-0f150c98978332377ee6aad3eac8c8a08553a8e7.tar.gz
Tango-0f150c98978332377ee6aad3eac8c8a08553a8e7.zip
Added support for external emulator on PPC/Eureka over TCP.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs23
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs12
-rw-r--r--Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs45
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml2
-rw-r--r--Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml2
5 files changed, 56 insertions, 28 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 93fde75a5..9e15abbe0 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs
@@ -265,16 +265,25 @@ namespace Tango.PPC.Common.Connection
{
LogManager.Log("Application in demo mode!");
- var emulator_channel_name = "emulator-" + Guid.NewGuid().ToString();
+ if (settings.EmulatorMode == EmulatorMode.InMemory)
+ {
+ var emulator_channel_name = "emulator-" + Guid.NewGuid().ToString();
+ LogManager.Log("Starting embedded emulator...");
+ MachineEmulator emulator = new MachineEmulator(new BasicTransporter(new MemoryTransportAdapter(emulator_channel_name)));
+ await emulator.Start();
- LogManager.Log("Starting embedded emulator...");
- MachineEmulator emulator = new MachineEmulator(new BasicTransporter(new MemoryTransportAdapter(emulator_channel_name)));
- await emulator.Start();
+ LogManager.Log("Emulator started. Connecting to emulator...");
- LogManager.Log("Emulator started. Connecting to emulator...");
+ MemoryTransportAdapter adapter = new MemoryTransportAdapter(emulator_channel_name);
+ MachineOperator.Adapter = adapter;
+ }
+ else
+ {
+ LogManager.Log("Connecting to external emulator over TCP...");
+ TcpTransportAdapter adapter = new TcpTransportAdapter("127.0.0.1", 30000);
+ MachineOperator.Adapter = adapter;
+ }
- MemoryTransportAdapter adapter = new MemoryTransportAdapter(emulator_channel_name);
- MachineOperator.Adapter = adapter;
MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp;
LogManager.Log("Connecting machine operator...");
await MachineOperator.Connect();
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs
index 41e103ca0..ae6e4bc47 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs
@@ -16,6 +16,12 @@ using Tango.Web;
namespace Tango.PPC.Common
{
+ public enum EmulatorMode
+ {
+ InMemory,
+ ExternalTCP,
+ }
+
/// <summary>
/// Represents the main PPC settings.
/// </summary>
@@ -365,6 +371,11 @@ namespace Tango.PPC.Common
public bool ForceTouchMode { get; set; }
/// <summary>
+ /// Gets or sets the emulator mode.
+ /// </summary>
+ public EmulatorMode EmulatorMode { get; set; }
+
+ /// <summary>
/// Gets the machine service address.
/// </summary>
/// <returns></returns>
@@ -378,6 +389,7 @@ namespace Tango.PPC.Common
/// </summary>
public PPCSettings()
{
+ EmulatorMode = EmulatorMode.InMemory;
LubricationLevels = new List<RmlLubricationLevel>();
JobUploadStrategy = JobUploadStrategy.JobDescriptionFile;
FineTuningTrialLengthMeters = 200;
diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
index 3543b8b3a..f873dbece 100644
--- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
+++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
@@ -1739,34 +1739,41 @@ namespace Tango.Emulations.Emulators
private async void HandleStartPowerUpRequest(TangoMessage<StartPowerUpRequest> request)
{
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Power up started...", ProgressPercentage = 10, State = PowerUpState.BuiltInTest }, request.Container.Token);
- Thread.Sleep(1000);
+ try
+ {
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Power up started...", ProgressPercentage = 10, State = PowerUpState.BuiltInTest }, request.Container.Token);
+ Thread.Sleep(1000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Testing dispensers...", ProgressPercentage = 20, State = PowerUpState.DispenserPressureBuildupTest }, request.Container.Token);
- Thread.Sleep(1000);
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Testing dispensers...", ProgressPercentage = 20, State = PowerUpState.DispenserPressureBuildupTest }, request.Container.Token);
+ Thread.Sleep(1000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Heating started...", ProgressPercentage = 30, State = PowerUpState.HeatingStarted }, request.Container.Token);
- Thread.Sleep(1000);
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Heating started...", ProgressPercentage = 30, State = PowerUpState.HeatingStarted }, request.Container.Token);
+ Thread.Sleep(1000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Heating started...", ProgressPercentage = 40, State = PowerUpState.HwConfig }, request.Container.Token);
- Thread.Sleep(1000);
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Heating started...", ProgressPercentage = 40, State = PowerUpState.HwConfig }, request.Container.Token);
+ Thread.Sleep(1000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Hardware configuration...", ProgressPercentage = 50, State = PowerUpState.HwConfig }, request.Container.Token);
- Thread.Sleep(1000);
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Hardware configuration...", ProgressPercentage = 50, State = PowerUpState.HwConfig }, request.Container.Token);
+ Thread.Sleep(1000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Initializing blower...", ProgressPercentage = 60, State = PowerUpState.InitialBlowerActivation }, request.Container.Token);
- Thread.Sleep(1000);
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Initializing blower...", ProgressPercentage = 60, State = PowerUpState.InitialBlowerActivation }, request.Container.Token);
+ Thread.Sleep(1000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Thread detection...", ProgressPercentage = 70, State = PowerUpState.ThreadDetection }, request.Container.Token);
- Thread.Sleep(1000);
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Thread detection...", ProgressPercentage = 70, State = PowerUpState.ThreadDetection }, request.Container.Token);
+ Thread.Sleep(1000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Waiting for cooler...", ProgressPercentage = 80, State = PowerUpState.WaitForCooler }, request.Container.Token);
- Thread.Sleep(4000);
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Waiting for cooler...", ProgressPercentage = 80, State = PowerUpState.WaitForCooler }, request.Container.Token);
+ Thread.Sleep(4000);
- await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Ready to dye...", ProgressPercentage = 90, State = PowerUpState.MachineReadyToDye }, request.Container.Token, new TransportResponseConfig()
+ await Transporter.SendResponse(new StartPowerUpResponse() { Message = "Ready to dye...", ProgressPercentage = 90, State = PowerUpState.MachineReadyToDye }, request.Container.Token, new TransportResponseConfig()
+ {
+ Completed = true
+ });
+ }
+ catch (Exception ex)
{
- Completed = true
- });
+ LogManager.Log(ex);
+ }
}
private void HandleStartInkFillingStatusRequest(TangoMessage<StartInkFillingStatusRequest> request)
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml
index 8f066800e..875072faa 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml
+++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml
@@ -9,7 +9,7 @@
xmlns:local="clr-namespace:Tango.MachineEM.UI"
xmlns:views="clr-namespace:Tango.MachineEM.UI.Views"
mc:Ignorable="d"
- Title="Tango Embedded Emulator" Height="820" Width="1300" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}">
+ Title="Firmware Emulator" Height="820" Width="1300" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
<views:MainView DataContext="{StaticResource MainViewVM}"></views:MainView>
</Grid>
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml
index c0c4b7b97..c3c086065 100644
--- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml
@@ -40,7 +40,7 @@
</Grid.Background>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20 15">
<Image Source="/Images/embedded-device.png" RenderOptions.BitmapScalingMode="Fant"></Image>
- <TextBlock Text="Tango Embedded Emulator" VerticalAlignment="Center" Margin="20 0 0 0" FontSize="36" Foreground="Red">
+ <TextBlock Text="Firmware Emulator" VerticalAlignment="Center" Margin="20 0 0 0" FontSize="36" Foreground="Red">
<TextBlock.Effect>
<DropShadowEffect/>
</TextBlock.Effect>