blob: d3f44fe7e01bc17717b6bd16ff6f5f841d4d6502 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;
}
}
}
}
|