@@ -48,7 +48,6 @@ public BatterySwitch(MSTSWagon wagon)
48
48
Wagon = wagon ;
49
49
50
50
Timer = new Timer ( Wagon ) ;
51
- Timer . Setup ( DelayS ) ;
52
51
}
53
52
54
53
public virtual void Parse ( string lowercasetoken , STFReader stf )
@@ -91,6 +90,7 @@ public void Copy(BatterySwitch other)
91
90
92
91
public virtual void Initialize ( )
93
92
{
93
+ Timer . Setup ( DelayS ) ;
94
94
}
95
95
96
96
/// <summary>
@@ -235,47 +235,47 @@ public virtual void HandleEvent(PowerSupplyEvent evt)
235
235
switch ( evt )
236
236
{
237
237
case PowerSupplyEvent . CloseBatterySwitch :
238
- if ( Mode == ModeType . Switch )
238
+ if ( Mode == ModeType . Switch && ! CommandSwitch )
239
239
{
240
240
CommandSwitch = true ;
241
241
Wagon . SignalEvent ( Event . BatterySwitchCommandOn ) ;
242
242
}
243
243
break ;
244
244
245
245
case PowerSupplyEvent . OpenBatterySwitch :
246
- if ( Mode == ModeType . Switch )
246
+ if ( Mode == ModeType . Switch && CommandSwitch )
247
247
{
248
248
CommandSwitch = false ;
249
249
Wagon . SignalEvent ( Event . BatterySwitchCommandOff ) ;
250
250
}
251
251
break ;
252
252
253
253
case PowerSupplyEvent . CloseBatterySwitchButtonPressed :
254
- if ( Mode == ModeType . PushButtons )
254
+ if ( Mode == ModeType . PushButtons && ! CommandButtonOn )
255
255
{
256
256
CommandButtonOn = true ;
257
257
Wagon . SignalEvent ( Event . BatterySwitchCommandOn ) ;
258
258
}
259
259
break ;
260
260
261
261
case PowerSupplyEvent . CloseBatterySwitchButtonReleased :
262
- if ( Mode == ModeType . PushButtons )
262
+ if ( Mode == ModeType . PushButtons && CommandButtonOn )
263
263
{
264
264
CommandButtonOn = false ;
265
265
Wagon . SignalEvent ( Event . BatterySwitchCommandOff ) ;
266
266
}
267
267
break ;
268
268
269
269
case PowerSupplyEvent . OpenBatterySwitchButtonPressed :
270
- if ( Mode == ModeType . PushButtons )
270
+ if ( Mode == ModeType . PushButtons && ! CommandButtonOff )
271
271
{
272
272
CommandButtonOff = true ;
273
273
Wagon . SignalEvent ( Event . BatterySwitchCommandOn ) ;
274
274
}
275
275
break ;
276
276
277
277
case PowerSupplyEvent . OpenBatterySwitchButtonReleased :
278
- if ( Mode == ModeType . PushButtons )
278
+ if ( Mode == ModeType . PushButtons && CommandButtonOff )
279
279
{
280
280
CommandButtonOff = false ;
281
281
Wagon . SignalEvent ( Event . BatterySwitchCommandOff ) ;
0 commit comments