001package jmri.jmrix.secsi; 002 003import java.util.Comparator; 004import java.util.ResourceBundle; 005import javax.annotation.Nonnull; 006 007import jmri.*; 008import jmri.jmrix.ConfiguringSystemConnectionMemo; 009import jmri.jmrix.DefaultSystemConnectionMemo; 010import jmri.util.NamedBeanComparator; 011import org.slf4j.Logger; 012import org.slf4j.LoggerFactory; 013 014/** 015 * Minimum required implementation. 016 * 017 * @author Randall Wood randall.h.wood@alexandriasoftware.com 018 */ 019public class SecsiSystemConnectionMemo extends DefaultSystemConnectionMemo implements ConfiguringSystemConnectionMemo { 020 021 public SecsiSystemConnectionMemo(@Nonnull String prefix, @Nonnull String name) { 022 super(prefix, name); 023 InstanceManager.store(this, SecsiSystemConnectionMemo.class); 024 025 // create and register the ComponentFactory 026 InstanceManager.store(new jmri.jmrix.secsi.swing.SecsiComponentFactory(this), 027 jmri.jmrix.swing.ComponentFactory.class); 028 029 log.debug("Created SecsiSystemConnectionMemo with prefix {}", prefix); 030 } 031 032 public SecsiSystemConnectionMemo() { 033 this("V", "SECSI"); 034 log.debug("Created nameless SecsiSystemConnectionMemo"); 035 } 036 037 private SerialTrafficController tc = null; 038 039 /** 040 * Set the traffic controller instance associated with this connection memo. 041 * 042 * @param s jmri.jmrix.secsi.SerialTrafficController object to use. 043 */ 044 public void setTrafficController(SerialTrafficController s){ 045 tc = s; 046 } 047 048 /** 049 * Get the traffic controller instance associated with this connection memo. 050 * @return traffic controller, new TC provided if null. 051 */ 052 public SerialTrafficController getTrafficController() { 053 if (tc == null) { 054 setTrafficController(new SerialTrafficController(this)); 055 log.debug("Auto create of SerialTrafficController for initial configuration"); 056 } 057 return tc; 058 } 059 060 @Override 061 protected ResourceBundle getActionModelResourceBundle() { 062 return null; 063 } 064 065 @Override 066 public <B extends NamedBean> Comparator<B> getNamedBeanComparator(Class<B> type) { 067 return new NamedBeanComparator<>(); 068 } 069 070 @Override 071 public void configureManagers() { 072 setTurnoutManager(new SerialTurnoutManager(this)); 073 InstanceManager.setTurnoutManager(getTurnoutManager()); 074 075 setLightManager(new SerialLightManager(this)); 076 InstanceManager.setLightManager(getLightManager()); 077 078 setSensorManager(new SerialSensorManager(this)); 079 InstanceManager.setSensorManager(getSensorManager()); 080 081 register(); 082 } 083 084 /** 085 * Provide access to the SensorManager for this particular connection. 086 * <p> 087 * NOTE: SensorManager defaults to NULL 088 * @return sensor manager. 089 */ 090 public SensorManager getSensorManager() { 091 return get(SensorManager.class); 092 } 093 094 public void setSensorManager(SerialSensorManager s) { 095 store(s,SensorManager.class); 096 getTrafficController().setSensorManager(s); 097 } 098 099 /** 100 * Provide access to the TurnoutManager for this particular connection. 101 * <p> 102 * NOTE: TurnoutManager defaults to NULL 103 * @return turnout manager. 104 */ 105 public TurnoutManager getTurnoutManager() { 106 return get(TurnoutManager.class); 107 108 } 109 110 public void setTurnoutManager(SerialTurnoutManager t) { 111 store(t,TurnoutManager.class); 112 } 113 114 /** 115 * Provide access to the LightManager for this particular connection. 116 * <p> 117 * NOTE: LightManager defaults to NULL 118 * @return light manager. 119 */ 120 public LightManager getLightManager() { 121 return get(LightManager.class); 122 123 } 124 125 public void setLightManager(SerialLightManager l) { 126 store(l,LightManager.class); 127 } 128 129 private final static Logger log = LoggerFactory.getLogger(SecsiSystemConnectionMemo.class); 130 131}