1 using System.Xml.Serialization;
2 using DirectOutput.PinballSupport;
3 using DirectOutput.Cab.Toys.Layer;
5 namespace DirectOutput.Cab.Toys.Hardware
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;
126 public override void UpdateOutputs()
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;
268 public override void Finish()