aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-09 02:27:58 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-09 02:27:58 +0200
commiteb793f20dc078a304a423a481e5bb0eddce71471 (patch)
treeca7b60be7b2d588875017b3885ba3d3cd3f893f9 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands
parent1b5d452cccd3be79c226f1438c3efe7abe786017 (diff)
parentae9cdafa944db884bf878f36a7a328c53a7588a8 (diff)
downloadTango-eb793f20dc078a304a423a481e5bb0eddce71471.tar.gz
Tango-eb793f20dc078a304a423a481e5bb0eddce71471.zip
MERGE
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/HomingMotorCommand.cs80
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseDyeingHeadCommand.cs31
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseLeftLeadingWheelsCommand.cs30
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseMotorCommand.cs158
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseRightLeadingWheelsCommand.cs30
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/ResetThreadLoadingCommand.cs24
6 files changed, 353 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/HomingMotorCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/HomingMotorCommand.cs
new file mode 100644
index 000000000..d3f44fe7e
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/HomingMotorCommand.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.Diagnostics;
+using Tango.PMR.Hardware;
+
+namespace Tango.PPC.Maintenance.Commands
+{
+ public abstract class HomingMotorCommand : MaintenanceCommand<object>
+ {
+ public HardwareMotorType Motor { get; set; }
+
+ public MotorDirection Direction { get; set; }
+
+ public double Speed { get; set; }
+
+ public String HomingMessage { get; set; }
+
+ public String ErrorMessage { get; set; }
+
+ public String SuccessMessage { get; set; }
+
+ public HomingMotorCommand(HardwareMotorType motor,
+ MotorDirection direction,
+ double speed,
+ string homingMessage,
+ string errorMessage,
+ string successMessage)
+ {
+ Motor = motor;
+ Direction = direction;
+ Speed = speed;
+ HomingMessage = homingMessage;
+ ErrorMessage = errorMessage;
+ SuccessMessage = successMessage;
+ }
+
+ protected override void OnExecute()
+ {
+ IsEnabled = false;
+
+ try
+ {
+ NotificationProvider.SetGlobalBusyMessage(HomingMessage);
+
+ MachineProvider.MachineOperator.StartMotorHoming(new PMR.Diagnostics.MotorHomingRequest()
+ {
+ Direction = Direction,
+ MotorType = Motor,
+ Speed = Speed,
+ }).Subscribe((response) =>
+ {
+ //Next
+ }, (ex) =>
+ {
+ //Error
+ IsEnabled = true;
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ LogManager.Log(ex, ErrorMessage);
+ NotificationProvider.ShowError(ex.FlattenMessage());
+ }, () =>
+ {
+ //Complete
+ IsEnabled = true;
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ NotificationProvider.ShowSuccess(SuccessMessage);
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, ErrorMessage);
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ NotificationProvider.ShowError(ex.FlattenMessage());
+ IsEnabled = true;
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseDyeingHeadCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseDyeingHeadCommand.cs
new file mode 100644
index 000000000..794274e21
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseDyeingHeadCommand.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Integration.Operation;
+using Tango.PMR.Diagnostics;
+using Tango.PMR.Hardware;
+
+namespace Tango.PPC.Maintenance.Commands
+{
+ public class OpenCloseDyeingHeadCommand : OpenCloseMotorCommand
+ {
+ public OpenCloseDyeingHeadCommand() : base(
+ HardwareMotorType.MotoDhLid,
+ MotorDirection.Backward,
+ 400,
+ 400,
+ MotorState.Closed,
+ "Opening dyeing head lead...",
+ "Closing dyeing head lead...",
+ "Error opening dyeing head lead.",
+ "Error closing dyeing head lead.",
+ "The dyeing head lead is now opened.",
+ "The dyeing head lead is now closed."
+ )
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseLeftLeadingWheelsCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseLeftLeadingWheelsCommand.cs
new file mode 100644
index 000000000..b0d8c1dc5
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseLeftLeadingWheelsCommand.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.Diagnostics;
+using Tango.PMR.Hardware;
+
+namespace Tango.PPC.Maintenance.Commands
+{
+ public class OpenCloseLeftLeadingWheelsCommand : OpenCloseMotorCommand
+ {
+ public OpenCloseLeftLeadingWheelsCommand() : base(
+ HardwareMotorType.MotoLloading,
+ MotorDirection.Backward,
+ 250,
+ 250,
+ MotorState.Closed,
+ "Opening left leading wheels...",
+ "Closing left leading wheels...",
+ "Error opening left leading wheels.",
+ "Error closing left leading wheels.",
+ "The left leading wheels are now opened.",
+ "The left leading wheels are now closed."
+ )
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseMotorCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseMotorCommand.cs
new file mode 100644
index 000000000..149c3675d
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseMotorCommand.cs
@@ -0,0 +1,158 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.Diagnostics;
+using Tango.PMR.Hardware;
+
+namespace Tango.PPC.Maintenance.Commands
+{
+ public abstract class OpenCloseMotorCommand : MaintenanceCommand<OpenCloseMotorCommand.MotorState>
+ {
+ public enum MotorState
+ {
+ Closed,
+ Opened,
+ }
+
+ public HardwareMotorType Motor { get; set; }
+
+ public MotorDirection OpenDirection { get; set; }
+
+ public MotorDirection CloseDirection
+ {
+ get
+ {
+ return OpenDirection == MotorDirection.Forward ? MotorDirection.Backward : MotorDirection.Forward;
+ }
+ }
+
+ public double OpeningSpeed { get; set; }
+
+ public double ClosingSpeed { get; set; }
+
+ public String OpeningMessage { get; set; }
+
+ public String ClosingMessage { get; set; }
+
+ public String OpeningErrorMessage { get; set; }
+
+ public String ClosingErrorMessage { get; set; }
+
+ public String OpeningSuccessMessage { get; set; }
+
+ public String ClosingSuccessMessage { get; set; }
+
+ public OpenCloseMotorCommand(
+ HardwareMotorType motor,
+ MotorDirection openDirection,
+ double openingSpeed,
+ double closingSpeed,
+ MotorState defaultState,
+ String openingMessage,
+ String closingMessage,
+ String openingErrorMessage,
+ String closingErrorMessage,
+ String openingSuccessMessage,
+ String closingSuccessMessage)
+ {
+
+ Motor = motor;
+ OpenDirection = openDirection;
+ OpeningSpeed = openingSpeed;
+ ClosingSpeed = closingSpeed;
+ State = defaultState;
+ OpeningMessage = openingMessage;
+ ClosingMessage = closingMessage;
+ OpeningErrorMessage = openingErrorMessage;
+ ClosingErrorMessage = closingErrorMessage;
+ OpeningSuccessMessage = openingSuccessMessage;
+ ClosingSuccessMessage = closingSuccessMessage;
+ }
+
+ protected override void OnExecute()
+ {
+ if (State == MotorState.Closed)
+ {
+ IsEnabled = false;
+
+ try
+ {
+ NotificationProvider.SetGlobalBusyMessage(OpeningMessage);
+
+ MachineProvider.MachineOperator.StartMotorHoming(new PMR.Diagnostics.MotorHomingRequest()
+ {
+ Direction = OpenDirection,
+ MotorType = Motor,
+ Speed = OpeningSpeed,
+ }).Subscribe((response) =>
+ {
+ //Next
+ }, (ex) =>
+ {
+ //Error
+ IsEnabled = true;
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ LogManager.Log(ex, OpeningErrorMessage);
+ NotificationProvider.ShowError(ex.FlattenMessage());
+ }, () =>
+ {
+ //Complete
+ IsEnabled = true;
+ State = MotorState.Opened;
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ NotificationProvider.ShowSuccess(OpeningSuccessMessage);
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, OpeningErrorMessage);
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ NotificationProvider.ShowError(ex.FlattenMessage());
+ IsEnabled = true;
+ }
+ }
+ else
+ {
+ IsEnabled = false;
+
+ try
+ {
+ NotificationProvider.SetGlobalBusyMessage(ClosingMessage);
+
+ MachineProvider.MachineOperator.StartMotorHoming(new PMR.Diagnostics.MotorHomingRequest()
+ {
+ Direction = CloseDirection,
+ MotorType = Motor,
+ Speed = ClosingSpeed,
+ }).Subscribe((response) =>
+ {
+ //Next
+ }, (ex) =>
+ {
+ //Error
+ IsEnabled = true;
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ LogManager.Log(ex, ClosingErrorMessage);
+ NotificationProvider.ShowError(ex.FlattenMessage());
+ }, () =>
+ {
+ //Complete
+ IsEnabled = true;
+ State = MotorState.Closed;
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ NotificationProvider.ShowSuccess(ClosingSuccessMessage);
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, ClosingErrorMessage);
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ NotificationProvider.ShowError(ex.FlattenMessage());
+ IsEnabled = true;
+ }
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseRightLeadingWheelsCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseRightLeadingWheelsCommand.cs
new file mode 100644
index 000000000..ced9eea60
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/OpenCloseRightLeadingWheelsCommand.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.Diagnostics;
+using Tango.PMR.Hardware;
+
+namespace Tango.PPC.Maintenance.Commands
+{
+ public class OpenCloseRightLeadingWheelsCommand : OpenCloseMotorCommand
+ {
+ public OpenCloseRightLeadingWheelsCommand() : base(
+ HardwareMotorType.MotoRloading,
+ MotorDirection.Backward,
+ 250,
+ 250,
+ MotorState.Closed,
+ "Opening right leading wheels...",
+ "Closing right leading wheels...",
+ "Error opening right leading wheels.",
+ "Error closing right leading wheels.",
+ "The right leading wheels are now opened.",
+ "The right leading wheels are now closed."
+ )
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/ResetThreadLoadingCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/ResetThreadLoadingCommand.cs
new file mode 100644
index 000000000..0078cd546
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Commands/ResetThreadLoadingCommand.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PMR.Diagnostics;
+using Tango.PMR.Hardware;
+
+namespace Tango.PPC.Maintenance.Commands
+{
+ public class ResetThreadLoadingCommand : HomingMotorCommand
+ {
+ public ResetThreadLoadingCommand() : base(
+ HardwareMotorType.MotoDryerLoadarm,
+ MotorDirection.Backward,
+ 200,
+ "Resetting thread loading arm...",
+ "Error resetting thread loading arm.",
+ "Thread loading arm in now in place.")
+ {
+
+ }
+ }
+}