1 using System.Xml.Serialization;
2 using DirectOutput.PinballSupport;
4 namespace DirectOutput.Cab.Toys.Basic
15 private int _MaxRuntimeMs = 300000;
25 public int MaxRunTimeMs
27 get {
return _MaxRuntimeMs; }
28 set { _MaxRuntimeMs = value.Limit(0,
int.MaxValue); }
32 private int _MinPower = 10;
44 get {
return _MinPower; }
45 set { _MinPower = value.Limit(0, 255); }
48 private int _MaxPower = 255;
59 get {
return _MaxPower; }
60 set { _MaxPower = value.Limit(0, 255); }
64 private int _KickstartPower = 128;
76 public int KickstartPower
78 get {
return _KickstartPower; }
79 set { _KickstartPower = value.Limit(0, 255); }
82 private int _KickstartDurationMs = 100;
92 public int KickstartDurationMs
94 get {
return _KickstartDurationMs; }
95 set { _KickstartDurationMs = value.Limit(0, 5000); }
110 return (
int)((Value - MinPower) * ((
double)(MaxPower - MinPower) / 255));
116 bool KickstartActive =
false;
122 public void SetPower(
int Power)
125 if (this.Power != Power)
130 if (!KickstartActive)
133 if (KickstartPower > 0 && Power<KickstartPower && KickstartDurationMs > 0)
135 KickstartActive =
true;
136 SetValue(KickstartPower);
149 private void StartMotor()
151 KickstartActive =
false;
158 SetMotorPower(MotorPower);
159 if (MaxRunTimeMs > 0)
167 private void SetMotorPower(
int Power)
169 int ScaledPower = (int)(MinPower + (MaxPower - MinPower) / 255 * (double)MotorPower).Limit(MinPower, MaxPower);
170 SetValue(ScaledPower);
173 private void StopMotor()
175 KickstartActive =
false;
199 public override void Finish()