001package jmri.jmrix.roco.z21;
002
003import jmri.AddressedProgrammer;
004import jmri.Programmer;
005import jmri.jmrix.lenz.XNetSystemConnectionMemo;
006import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
007
008/**
009 * Extend XNetProgrammerManager for Z21.
010 * @see jmri.jmrix.lenz.XNetProgrammerManager
011 * @author Paul Bender Copyright (C) 2018
012 * @navassoc 1 - 1 jmri.jmrix.roco.z21.Z21XNetProgrammer
013 * @navassoc 1 - * jmri.jmrix.roco.z21.Z21XNetOpsModeProgrammer
014 */
015public class Z21XNetProgrammerManager extends jmri.jmrix.lenz.XNetProgrammerManager {
016
017    private LocoNetSystemConnectionMemo lnMemo = null;
018
019    public Z21XNetProgrammerManager(Programmer pProgrammer, XNetSystemConnectionMemo memo) {
020        this(pProgrammer, memo, null);
021    }
022
023    public Z21XNetProgrammerManager(Programmer pProgrammer, XNetSystemConnectionMemo xnetMemo,LocoNetSystemConnectionMemo loconetMemo) {
024        super(pProgrammer, xnetMemo);
025        setLocoNetMemo(loconetMemo);
026    }
027
028    /**
029     * Z21 Command stations do provide Ops Mode.
030     * @return true
031     */
032    @Override
033    public boolean isAddressedModePossible() {
034        return true; 
035    }
036
037    @Override
038    public AddressedProgrammer getAddressedProgrammer(boolean pLongAddress, int pAddress) {
039        if(lnMemo!=null) {
040           return new Z21XNetOpsModeProgrammer(pAddress, tc, lnMemo.getLnTrafficController()); 
041        } else {
042           return new Z21XNetOpsModeProgrammer(pAddress, tc );
043        }
044    }
045
046    public void setLocoNetMemo(LocoNetSystemConnectionMemo loconetMemo) {
047        lnMemo = loconetMemo;
048    }
049
050}