-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriveevent.cpp
More file actions
188 lines (135 loc) · 3.96 KB
/
driveevent.cpp
File metadata and controls
188 lines (135 loc) · 3.96 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include "driveevent.h"
DriveEvent::DriveEvent()
{
}
DriveEvent::DriveEvent(const DriveEvent &event)
{
event_impl = event.event_impl;
}
DriveEvent::DriveEvent(const drive_event_t &drive_event)
{
event_impl = QSharedPointer<drive_event_t>(new drive_event_t());
memcpy(event_impl.data(), &drive_event, sizeof(drive_event_t));
}
bool DriveEvent::isValid() const
{
return !event_impl.isNull();
}
drive_event_id_t DriveEvent::id() const
{
if(!isValid()) return 0;
return event_impl->id;
}
drive_event_type_t DriveEvent::type() const
{
if(!isValid()) return static_cast<drive_event_type_t>(0);
return static_cast<drive_event_type_t>(event_impl->type);
}
drive_state_t DriveEvent::state() const
{
if(!isValid()) return static_cast<drive_state_t>(0);
return static_cast<drive_state_t>(event_impl->state);
}
drive_dir_t DriveEvent::direction() const
{
if(!isValid()) return static_cast<drive_dir_t>(0);
return static_cast<drive_dir_t>(event_impl->direction);
}
drive_init_state_t DriveEvent::initState() const
{
if(!isValid()) return static_cast<drive_init_state_t>(0);
return static_cast<drive_init_state_t>(event_impl->init_state);
}
drive_power_calibration_t DriveEvent::calibrationState() const
{
if(!isValid()) return static_cast<drive_power_calibration_t>(0);
return static_cast<drive_power_calibration_t>(event_impl->calibration_state);
}
drive_starting_t DriveEvent::startingState() const
{
if(!isValid()) return static_cast<drive_starting_t>(0);
return static_cast<drive_starting_t>(event_impl->starting_state);
}
drive_stopping_t DriveEvent::stoppingState() const
{
if(!isValid()) return static_cast<drive_stopping_t>(0);
return static_cast<drive_stopping_t>(event_impl->stopping_state);
}
drive_err_stopping_t DriveEvent::errStoppingState() const
{
if(!isValid()) return static_cast<drive_err_stopping_t>(0);
return static_cast<drive_err_stopping_t>(event_impl->err_stopping_state);
}
reference_t DriveEvent::reference() const
{
if(!isValid()) return static_cast<reference_t>(0);
return event_impl->reference;
}
drive_flags_t DriveEvent::flags() const
{
if(!isValid()) return static_cast<drive_flags_t>(0);
return event_impl->flags;
}
drive_warnings_t DriveEvent::warnings() const
{
if(!isValid()) return static_cast<drive_warnings_t>(0);
return event_impl->warnings;
}
drive_errors_t DriveEvent::errors() const
{
if(!isValid()) return static_cast<drive_errors_t>(0);
return event_impl->errors;
}
drive_power_warnings_t DriveEvent::powerWarnings() const
{
if(!isValid()) return static_cast<drive_power_warnings_t>(0);
return event_impl->power_warnings;
}
drive_power_errors_t DriveEvent::powerErrors() const
{
if(!isValid()) return static_cast<drive_power_errors_t>(0);
return event_impl->power_errors;
}
drive_phase_errors_t DriveEvent::phaseErrors() const
{
if(!isValid()) return static_cast<drive_phase_errors_t>(0);
return event_impl->phase_errors;
}
#ifdef USE_ZERO_SENSORS
phase_time_t DriveEvent::phaseTimeA() const
{
if(!isValid()) return static_cast<phase_time_t>(0);
return event_impl->phase_a_time;
}
phase_time_t DriveEvent::phaseTimeB() const
{
if(!isValid()) return static_cast<phase_time_t>(0);
return event_impl->phase_b_time;
}
phase_time_t DriveEvent::phaseTimeC() const
{
if(!isValid()) return static_cast<phase_time_t>(0);
return event_impl->phase_c_time;
}
#else
int16_t DriveEvent::phaseAngleA() const
{
if(!isValid()) return static_cast<int16_t>(0);
return event_impl->phase_a_angle;
}
int16_t DriveEvent::phaseAngleB() const
{
if(!isValid()) return static_cast<int16_t>(0);
return event_impl->phase_b_angle;
}
int16_t DriveEvent::phaseAngleC() const
{
if(!isValid()) return static_cast<int16_t>(0);
return event_impl->phase_c_angle;
}
#endif //USE_ZERO_SENSORS
uint32_t DriveEvent::time() const
{
if(!isValid()) return static_cast<uint32_t>(0);
return event_impl->time;
}