1 using System.Xml.Serialization;
19 private int _MaxRuntimeMs = 300000;
29 public int MaxRunTimeMs
31 get {
return _MaxRuntimeMs; }
32 set { _MaxRuntimeMs = value.Limit(0,
int.MaxValue); }
38 private int _KickstartPower = 255;
50 public int KickstartPower
52 get {
return _KickstartPower; }
53 set { _KickstartPower = value.Limit(0, 255); }
56 private int _KickstartDurationMs = 100;
66 public int KickstartDurationMs
68 get {
return _KickstartDurationMs; }
69 set { _KickstartDurationMs = value.Limit(0, 5000); }
72 private int _MinPower = 1;
82 get {
return _MinPower; }
83 set { _MinPower = value.Limit(0, 255); }
87 private int _MaxPower = 255;
97 get {
return _MaxPower; }
98 set { _MaxPower = value.Limit(0, 255); }
118 int CurrentMotorPower = 0;
119 int TargetMotorPower = 0;
120 bool KickstartActive =
false;
121 bool TurnedOffAfterMaxRunTime =
false;
130 int P = FadingCurve.MapValue(GetResultingValue().Limit(0, 255));
134 P = ((int)((
double)(MaxPower >= MinPower ? MaxPower - MinPower : MinPower - MaxPower) / 255 * P) + MinPower).Limit(MinPower, MaxPower);
142 TurnedOffAfterMaxRunTime =
false;
145 if (!TurnedOffAfterMaxRunTime)
147 if (CurrentMotorPower == 0)
154 if (KickstartDurationMs > 0 && KickstartPower > 0 && P <= KickstartPower)
158 TargetMotorPower = P;
160 if (!KickstartActive)
162 CurrentMotorPower = KickstartPower;
163 Output.Value = (byte)CurrentMotorPower;
164 KickstartActive =
true;
172 CurrentMotorPower = P;
173 TargetMotorPower = P;
174 Output.Value = (byte)P;
175 KickstartActive =
false;
179 if (MaxRunTimeMs > 0)
187 else if (KickstartActive)
193 TargetMotorPower = P;
200 TargetMotorPower = 0;
201 CurrentMotorPower = 0;
213 TargetMotorPower = 0;
214 CurrentMotorPower = 0;
217 else if (P != CurrentMotorPower)
220 CurrentMotorPower = P;
221 TargetMotorPower = P;
222 Output.Value = (byte)P;
230 private void MaxRunTimeMotorStop()
233 KickstartActive =
false;
234 CurrentMotorPower = 0;
235 TargetMotorPower = 0;
237 TurnedOffAfterMaxRunTime =
true;
241 private void KickStartEnd()
243 KickstartActive =
false;
244 CurrentMotorPower = TargetMotorPower;
245 Output.Value = (byte)CurrentMotorPower;
261 AlarmHandler = Cabinet.
Alarms;
270 if (AlarmHandler != null)
The AlarmHandler classed is used to execute scheduled events (e.g. regular updates on a effect) in th...
The Cabinet object describes the parts of a pinball cabinet (toys, outputcontrollers, outputs and more).
The namespace DirectOutput.Cab.Toys contains all toy related classes.
override void Finish()
Finishes the Motor toy and releases used references.
void RegisterAlarm(int DurationMs, Action AlarmHandler, bool DontUnregister=false)
Registers the specied AlarmHandler for a alarm after the specified duration.
Motor toy supporting max. and min. power, max. runtime and kickstart settings. The settings of this ...
override void UpdateOutputs()
Updates the output of the toy.
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
void UnregisterAlarm(Action AlarmHandler)
Unregisters all alarm for the specified alarm handler.
This toy handles analog values (0-255) in a layer structure including alpha value (0=completely trans...
void Finish()
Finishes the object. Clears all alarm lists.
Namespace for objects dealing with layers
override void Init(Cabinet Cabinet)
Initalizes the Motor toy.
AlarmHandler Alarms
Gets the AlarmHandler object for the cabinet object.
Support classes used by the Pinball object.