001package jmri.jmrix.can; 002 003import java.util.Arrays; 004import java.util.ResourceBundle; 005import org.slf4j.Logger; 006import org.slf4j.LoggerFactory; 007 008/** 009 * Does configuration for various CAN-based communications implementations. 010 * <p> 011 * TODO It would be good to replace this with properties-based method for redirecting 012 * to classes in particular subpackages. 013 * 014 * @author Bob Jacobsen Copyright (C) 2009 015 */ 016abstract public class ConfigurationManager { 017 018 final public static String SPROGCBUS = "SPROG CBUS"; 019 final public static String MERGCBUS = "MERG CBUS"; 020 final public static String OPENLCB = "OpenLCB"; 021 final public static String RAWCAN = "Raw CAN"; // TODO I18N 022 final public static String TEST = "Test - do not use"; 023 024 public enum SubProtocol { 025 NONE, 026 CBUS 027 } 028 029 /** 030 * Enumerate support for switching programming modes in connected hardware 031 */ 032 public enum ProgModeSwitch { 033 NONE, // No support for switching programming modes, or no programmer, 034 // or unknown CBUS attached command station/programmer 035 EITHER, // Service mode or ops mode, but not both at the same time 036 SPROG3PLUS // Specific hardware choice 037 } 038 039 private static String[] options = new String[]{SPROGCBUS, MERGCBUS, OPENLCB, RAWCAN, TEST}; 040 041 /** 042 * Create a new ConfigurationManager 043 * @param memo System Connection 044 */ 045 public ConfigurationManager(CanSystemConnectionMemo memo) { 046 adapterMemo = memo; 047 } 048 049 /** 050 * Provide the current set of "Option1" values 051 * @return Copy of System Options Array 052 */ 053 static public String[] getSystemOptions() { 054 return Arrays.copyOf(options, options.length); 055 } 056 057 /** 058 * Set the list of protocols to start with OpenLCB. 059 */ 060 static public void setOpenLCB() { 061 log.debug("setOpenLCB"); 062 options = new String[]{OPENLCB, MERGCBUS, RAWCAN, TEST}; 063 } 064 065 /** 066 * Set the list of protocols to start with MERG. 067 */ 068 static public void setMERG() { 069 log.debug("setMERG"); 070 options = new String[]{MERGCBUS, OPENLCB, RAWCAN, TEST}; 071 } 072 073 /** 074 * Set the list of protocols to start with SPROG. 075 */ 076 static public void setSPROG() { 077 log.debug("setSPROG"); 078 options = new String[]{SPROGCBUS}; 079 } 080 081 protected CanSystemConnectionMemo adapterMemo; 082 083 abstract public void configureManagers(); 084 085 /** 086 * Get which managers this class provides. 087 * @param type class to query. 088 * @return true if provided, else false. 089 */ 090 abstract public boolean provides(Class<?> type); 091 092 abstract public <T> T get(Class<?> T); 093 094 /** 095 * Dispose of the ConfigurationManager 096 */ 097 abstract public void dispose(); 098 099 abstract protected ResourceBundle getActionModelResourceBundle(); 100 101 private final static Logger log = LoggerFactory.getLogger(ConfigurationManager.class); 102 103}