001package jmri.jmrix.debugthrottle; 002 003import java.util.EnumSet; 004import jmri.DccLocoAddress; 005import jmri.DccThrottle; 006import jmri.LocoAddress; 007import jmri.SpeedStepMode; 008import jmri.jmrix.AbstractThrottleManager; 009 010/** 011 * Implementation of a ThrottleManager for debugging. 012 * 013 * @author Bob Jacobsen Copyright (C) 2003, 2005 014 */ 015public class DebugThrottleManager extends AbstractThrottleManager { 016 017 @Deprecated( since="5.13.3", forRemoval=true) 018 public DebugThrottleManager() { 019 this(jmri.InstanceManager.getDefault(jmri.jmrix.internal.InternalSystemConnectionMemo.class)); 020 } 021 022 /** 023 * Constructor. 024 * @param memo system connection. 025 */ 026 public DebugThrottleManager(jmri.SystemConnectionMemo memo) { 027 super(memo); 028 } 029 030 @Override 031 public void requestThrottleSetup(LocoAddress a, boolean control) { 032 if (a instanceof DccLocoAddress) { 033 // Immediately trigger the callback. 034 DccLocoAddress address = (DccLocoAddress) a; 035 log.debug("new debug throttle for {}", address); 036 notifyThrottleKnown(new DebugThrottle(address, adapterMemo), a); 037 } 038 else { 039 log.error("LocoAddress {} is not a DccLocoAddress",a); 040 } 041 } 042 043 /** 044 * Address 1 and above can be a long address 045 * 046 */ 047 @Override 048 public boolean canBeLongAddress(int address) { 049 return (address >= 1); 050 } 051 052 /** 053 * Address 127 and below can be a short address 054 * 055 */ 056 @Override 057 public boolean canBeShortAddress(int address) { 058 return (address <= 127); 059 } 060 061 /** 062 * Are there any ambiguous addresses (short vs long) on this system? 063 */ 064 @Override 065 public boolean addressTypeUnique() { 066 return false; 067 } 068 069 @Override 070 public boolean disposeThrottle(DccThrottle t, jmri.ThrottleListener l) { 071 log.debug("disposeThrottle called for {}", t); 072 if (super.disposeThrottle(t, l)) { 073 if (t instanceof DebugThrottle) { 074 DebugThrottle lnt = (DebugThrottle) t; 075 lnt.throttleDispose(); 076 return true; 077 } 078 else { 079 log.error("DccThrottle {} is not a DebugThrottle",t); 080 } 081 } 082 return false; 083 } 084 085 /** 086 * What speed modes are supported by this system? 087 * {@inheritDoc } 088 */ 089 @Override 090 public EnumSet<SpeedStepMode> supportedSpeedModes() { 091 return EnumSet.allOf(SpeedStepMode.class); 092 } 093 094 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(DebugThrottleManager.class); 095 096}