001package jmri.jmrix.sprog; 002 003import jmri.AddressedProgrammer; 004import jmri.Programmer; 005import jmri.jmrix.sprog.SprogConstants.SprogMode; 006import jmri.managers.DefaultProgrammerManager; 007 008/** 009 * Extend DefaultProgrammerManager to provide programmers for SPROG systems. 010 * 011 * @see jmri.managers.DefaultProgrammerManager 012 * @author Andrew crosland Copyright (C) 2001 013 */ 014public class SprogProgrammerManager extends DefaultProgrammerManager { 015 016 //private Programmer localProgrammer; 017 private SprogMode mode; 018 private SprogSystemConnectionMemo adapterMemo = null; 019 020 public SprogProgrammerManager(Programmer serviceModeProgrammer, SprogSystemConnectionMemo memo) { 021 super(serviceModeProgrammer, memo); 022 //localProgrammer = serviceModeProgrammer; 023 this.mode = SprogMode.SERVICE; 024 adapterMemo = memo; 025 } 026 027 public SprogProgrammerManager(Programmer serviceModeProgrammer, SprogMode mode, SprogSystemConnectionMemo memo) { 028 super(serviceModeProgrammer, memo); 029 //localProgrammer = serviceModeProgrammer; 030 this.mode = mode; 031 adapterMemo = memo; 032 } 033 034 /** 035 * Classic SPROG is service mode only. SPROG Command Station is Ops mode only. 036 * 037 * @return true for SPROG Command Station 038 */ 039 @Override 040 public boolean isAddressedModePossible() { 041 if (mode == SprogMode.OPS) { 042 return true; 043 } else { 044 return false; 045 } 046 } 047 048 @Override 049 public boolean isGlobalProgrammerAvailable() { 050 if (mode == SprogMode.SERVICE) { 051 return true; 052 } else { 053 return false; 054 } 055 } 056 057 @Override 058 public AddressedProgrammer getAddressedProgrammer(boolean pLongAddress, int pAddress) { 059 return new SprogOpsModeProgrammer(pAddress, pLongAddress, adapterMemo); 060 } 061 062 @Override 063 public AddressedProgrammer reserveAddressedProgrammer(boolean pLongAddress, int pAddress) { 064 return null; 065 } 066 067}