001package jmri.jmrix.loconet;
002
003import java.util.ArrayList;
004import java.util.List;
005import jmri.AddressedProgrammer;
006import jmri.ProgrammingMode;
007import jmri.managers.DefaultProgrammerManager;
008
009import javax.annotation.Nonnull;
010
011/**
012 * Extend DefaultProgrammerManager to provide programmers on LocoNet.
013 *
014 * @see jmri.managers.DefaultProgrammerManager
015 * @author Bob Jacobsen Copyright (C) 2002
016 */
017public class LnProgrammerManager extends DefaultProgrammerManager {
018
019    public LnProgrammerManager(LocoNetSystemConnectionMemo memo) {
020        super(new LnDeferProgrammer(memo), memo);
021        this.memo = memo;
022     }
023
024    LocoNetSystemConnectionMemo memo;
025
026    /**
027     * {@inheritDoc}
028     * LocoNet command station does provide Ops Mode
029     *
030     * @return true always
031     */
032    @Override
033    public boolean isAddressedModePossible() {
034        return true;
035    }
036
037    /**
038     * {@inheritDoc}
039     */
040    @Override
041    public AddressedProgrammer getAddressedProgrammer(boolean pLongAddress, int pAddress) {
042        return new LnOpsModeProgrammer(memo, pAddress, pLongAddress);
043    }
044
045    /**
046     * {@inheritDoc}
047     */
048    @Override
049    public AddressedProgrammer reserveAddressedProgrammer(boolean pLongAddress, int pAddress) {
050        return null;
051    }
052
053    /**
054     * Programming in Ops mode via the LocoNet cable.
055     */
056    public static final ProgrammingMode LOCONETOPSBOARD    = new ProgrammingMode("LOCONETOPSBOARD", Bundle.getMessage("LOCONETOPSBOARD"));
057
058    /**
059     * Programming for LocoNet System Variables using version 1 of the protocol.
060     */
061    static final ProgrammingMode LOCONETSV1MODE    = new ProgrammingMode("LOCONETSV1MODE", Bundle.getMessage("LOCONETSV1MODE"));
062
063    /**
064     * Programming for LocoNet System Variables using version 2 of the protocol.
065     */
066    public static final ProgrammingMode LOCONETSV2MODE    = new ProgrammingMode("LOCONETSV2MODE", Bundle.getMessage("LOCONETSV2MODE"));
067
068    /**
069     * Programming for Uhlenbrock (LocoNet) LNCV protocol.
070     */
071    public static final ProgrammingMode LOCONETLNCVMODE    = new ProgrammingMode("LOCONETLNCVMODE", Bundle.getMessage("LOCONETLNCVMODE"));
072
073
074    /**
075     * Programming via LocoNet messages for Digitrax DS*, PM*, BDL*, SE* boards
076     */
077    static final ProgrammingMode LOCONETBDOPSWMODE = new ProgrammingMode("LOCONETBDOPSWMODE", Bundle.getMessage("LOCONETBDOPSWMODE"));
078
079    /**
080     * Programming via LocoNet messages for Digitrax Command Station op switches
081     */
082    static final ProgrammingMode LOCONETCSOPSWMODE = new ProgrammingMode("LOCONETCSOPSWMODE", Bundle.getMessage("LOCONETCSOPSWMODE"));
083
084    /**
085     * Programming via LocoNet messages for Series 7* op switches
086     */
087    static final ProgrammingMode LOCONETBD7OPSWMODE = new ProgrammingMode("LOCONETBD7OPSWMODE", Bundle.getMessage("LOCONETBD7OPSWMODE"));
088
089    /**
090     * Types implemented here.
091     */
092    @Override
093    @Nonnull
094    public List<ProgrammingMode> getDefaultModes() {
095        List<ProgrammingMode> ret = new ArrayList<ProgrammingMode>();
096        ret.add(ProgrammingMode.OPSBYTEMODE);
097        ret.add(LOCONETBD7OPSWMODE);
098        ret.add(LOCONETOPSBOARD);
099        ret.add(LOCONETSV2MODE);
100        ret.add(LOCONETSV1MODE); // they show in the interface in the order listed here
101        ret.add(LOCONETLNCVMODE);
102        return ret;
103    }
104
105}