001package jmri.jmrix.pi;
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;
011
012import org.slf4j.Logger;
013import org.slf4j.LoggerFactory;
014
015/**
016 * Lightweight class to denote that a system is active
017 * and provide general information.
018 * <p>
019 * Objects of specific subtypes are registered in the 
020 * instance manager to activate their particular system.
021 *
022 * @author   Paul Bender Copyright (C) 2015
023 */
024public class RaspberryPiSystemConnectionMemo extends DefaultSystemConnectionMemo implements ConfiguringSystemConnectionMemo {
025
026    public RaspberryPiSystemConnectionMemo(@Nonnull String prefix, @Nonnull String name) {
027        super(prefix, name); // NOI18N
028
029        InstanceManager.store(this, RaspberryPiSystemConnectionMemo.class);
030        log.debug("Created RaspberryPiSystemConnectionMemo");
031    }
032
033    public RaspberryPiSystemConnectionMemo(){
034        this("P", "RaspberryPi");
035    }
036
037    /*
038     * Provides access to the SensorManager for this particular connection.
039     * NOTE: SensorManager defaults to NULL
040     */
041    public SensorManager getSensorManager(){
042        return get(SensorManager.class);
043
044    }
045    public void setSensorManager(SensorManager s){
046         InstanceManager.setSensorManager(s);
047         store(s,SensorManager.class);
048    }
049
050    /*
051     * Provides access to the TurnoutManager for this particular connection.
052     * NOTE: TurnoutManager defaults to NULL
053     */
054    public TurnoutManager getTurnoutManager(){
055        return get(TurnoutManager.class);
056    }
057
058    public void setTurnoutManager(TurnoutManager t){
059         InstanceManager.setTurnoutManager(t);
060         store(t,TurnoutManager.class);
061    }
062
063    /*
064     * Provides access to the LightManager for this particular connection.
065     * NOTE: Light manager defaults to NULL
066     */
067    public LightManager getLightManager(){
068        return get(LightManager.class);
069
070    }
071    public void setLightManager(LightManager l){
072         InstanceManager.setLightManager(l);
073         store(l,LightManager.class);
074    }
075
076    public void configureManagers(){
077       setTurnoutManager(new RaspberryPiTurnoutManager(this));
078       setSensorManager(new RaspberryPiSensorManager(this));
079       register();
080    }
081    
082    @Override
083    protected ResourceBundle getActionModelResourceBundle(){
084        return ResourceBundle.getBundle("jmri.jmrix.pi.RaspberryPiActionListBundle");
085    }
086
087    @Override
088    public <B extends NamedBean> Comparator<B> getNamedBeanComparator(Class<B> type) {
089        return new NamedBeanComparator<>();
090    }
091
092    @Override
093    public void dispose() {
094        InstanceManager.deregister(this, RaspberryPiSystemConnectionMemo.class);
095        super.dispose();
096    }
097
098    private final static Logger log = LoggerFactory.getLogger(RaspberryPiSystemConnectionMemo.class);
099
100}