-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathG422_AUX.cpp
More file actions
179 lines (139 loc) · 2.74 KB
/
Copy pathG422_AUX.cpp
File metadata and controls
179 lines (139 loc) · 2.74 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
#include "G422.h"
#include "G422_DVC.h"
//
//
int MovingPart::toggle()
{
if(mp_status == MP_REVERSING || mp_status == MP_LOW_DETENT)
{
mp_status = MP_MOVING;
sysReset = false;
vsl->clbkGeneric(VMSG_MPSTRT, sysID, this);
}
else if(mp_status == MP_MOVING || mp_status == MP_HI_DETENT)
{
mp_status = MP_REVERSING;
sysReset = false;
vsl->clbkGeneric(VMSG_MPSTRT, sysID, this);
}
return mp_status;
}
int MovingPart::toggle(bool b)
{
if(b && (mp_status == MP_REVERSING || mp_status == MP_LOW_DETENT))
{
mp_status = MP_MOVING;
sysReset = false;
vsl->clbkGeneric(VMSG_MPSTRT, sysID, this);
}
else if(!b && (mp_status == MP_MOVING || mp_status == MP_HI_DETENT))
{
mp_status = MP_REVERSING;
sysReset = false;
vsl->clbkGeneric(VMSG_MPSTRT, sysID, this);
}
return mp_status;
}
void MovingPart::toDetent(int p)
{
if (p == MP_HI_DETENT)
{
mp_status = MP_HI_DETENT;
pos = 1;
} else
{
mp_status = MP_LOW_DETENT;
pos = 0;
}
vsl->SetAnimation (anim_idx, pos);
sysReset = false;
vsl->clbkGeneric(VMSG_MPSTRT, sysID, this);
}
bool MovingPart::getToggleState()
{
if ((mp_status == MP_REVERSING || mp_status == MP_LOW_DETENT))
{
return false;
}
if((mp_status == MP_MOVING || mp_status == MP_HI_DETENT))
{
return true;
}
return false;
}
//
//
// not sure where else to put these....
bool VCSwitch::flick(bool upDn, VESSEL3 *vslRef) // true = "up" | false = "down"
{
//
switch (pos)
{
case SW2_DOWN:
if (upDn)
{
vslRef->SetAnimation(anID, 1.0);
pos = SW2_UP;
return true;
}
break;
case SW2_UP:
if (!upDn)
{
vslRef->SetAnimation(anID, 0.0);
pos = SW2_DOWN;
return true;
}
break;
case SW3_DOWN:
if (upDn)
{
vslRef->SetAnimation(anID, 0.5);
pos = SW3_MID;
return true;
}
break;
case SW3_MID:
if (upDn)
{
vslRef->SetAnimation(anID, 1.0);
pos = SW3_UP;
return true;
} else
{
vslRef->SetAnimation(anID, 0.0);
pos = SW3_DOWN;
return true;
}
break;
case SW3_UP:
if (!upDn)
{
vslRef->SetAnimation(anID, 0.5);
pos = SW3_MID;
return true;
}
break;
}
return false; // false is returned when the switch cannot be flipped to that position
}
void VCSwitch::setPos(VCSwitchState newPos, VESSEL3 *vslRef)
{
//
if (pos == newPos) return;
pos = newPos;
switch (newPos)
{
case SW2_UP:
case SW3_UP:
vslRef->SetAnimation(anID, 1.0);
return;
case SW3_MID:
vslRef->SetAnimation(anID, 0.5);
return;
case SW2_DOWN:
case SW3_DOWN:
vslRef->SetAnimation(anID, 0.0);
return;
}
}