@@ -48,7 +48,6 @@ public BatterySwitch(MSTSWagon wagon)
4848 Wagon = wagon ;
4949
5050 Timer = new Timer ( Wagon ) ;
51- Timer . Setup ( DelayS ) ;
5251 }
5352
5453 public virtual void Parse ( string lowercasetoken , STFReader stf )
@@ -91,6 +90,7 @@ public void Copy(BatterySwitch other)
9190
9291 public virtual void Initialize ( )
9392 {
93+ Timer . Setup ( DelayS ) ;
9494 }
9595
9696 /// <summary>
@@ -235,47 +235,47 @@ public virtual void HandleEvent(PowerSupplyEvent evt)
235235 switch ( evt )
236236 {
237237 case PowerSupplyEvent . CloseBatterySwitch :
238- if ( Mode == ModeType . Switch )
238+ if ( Mode == ModeType . Switch && ! CommandSwitch )
239239 {
240240 CommandSwitch = true ;
241241 Wagon . SignalEvent ( Event . BatterySwitchCommandOn ) ;
242242 }
243243 break ;
244244
245245 case PowerSupplyEvent . OpenBatterySwitch :
246- if ( Mode == ModeType . Switch )
246+ if ( Mode == ModeType . Switch && CommandSwitch )
247247 {
248248 CommandSwitch = false ;
249249 Wagon . SignalEvent ( Event . BatterySwitchCommandOff ) ;
250250 }
251251 break ;
252252
253253 case PowerSupplyEvent . CloseBatterySwitchButtonPressed :
254- if ( Mode == ModeType . PushButtons )
254+ if ( Mode == ModeType . PushButtons && ! CommandButtonOn )
255255 {
256256 CommandButtonOn = true ;
257257 Wagon . SignalEvent ( Event . BatterySwitchCommandOn ) ;
258258 }
259259 break ;
260260
261261 case PowerSupplyEvent . CloseBatterySwitchButtonReleased :
262- if ( Mode == ModeType . PushButtons )
262+ if ( Mode == ModeType . PushButtons && CommandButtonOn )
263263 {
264264 CommandButtonOn = false ;
265265 Wagon . SignalEvent ( Event . BatterySwitchCommandOff ) ;
266266 }
267267 break ;
268268
269269 case PowerSupplyEvent . OpenBatterySwitchButtonPressed :
270- if ( Mode == ModeType . PushButtons )
270+ if ( Mode == ModeType . PushButtons && ! CommandButtonOff )
271271 {
272272 CommandButtonOff = true ;
273273 Wagon . SignalEvent ( Event . BatterySwitchCommandOn ) ;
274274 }
275275 break ;
276276
277277 case PowerSupplyEvent . OpenBatterySwitchButtonReleased :
278- if ( Mode == ModeType . PushButtons )
278+ if ( Mode == ModeType . PushButtons && CommandButtonOff )
279279 {
280280 CommandButtonOff = false ;
281281 Wagon . SignalEvent ( Event . BatterySwitchCommandOff ) ;
0 commit comments