001package jmri.jmrix.pi;
002
003import javax.annotation.Nonnull;
004import jmri.Sensor;
005
006/**
007 * Manage the RaspberryPi specific Sensor implementation.
008 *
009 * System names are "PSnnn", where P is the user configurable system prefix,
010 * nnn is the sensor number without padding.
011 *
012 * @author   Paul Bender Copyright (C) 2015
013 */
014public class RaspberryPiSensorManager extends jmri.managers.AbstractSensorManager {
015
016    // ctor has to register for RaspberryPi events
017    public RaspberryPiSensorManager(RaspberryPiSystemConnectionMemo memo) {
018        super(memo);
019    }
020
021    /**
022     * {@inheritDoc}
023     */
024    @Override
025    @Nonnull
026    public RaspberryPiSystemConnectionMemo getMemo() {
027        return (RaspberryPiSystemConnectionMemo) memo;
028    }
029
030    /**
031     * {@inheritDoc}
032     */
033    @Override
034    @Nonnull
035    protected Sensor createNewSensor(@Nonnull String systemName, String userName) throws IllegalArgumentException {
036        return new RaspberryPiSensor(systemName, userName);
037    }
038
039    /**
040     * Do the sensor objects provided by this manager support configuring
041     * an internal pullup or pull down resistor?
042     * <p>
043     * For Raspberry Pi systems, it is possible to set the pullup or 
044     * pulldown resistor, so return true.
045     *
046     * @return true if pull up/pull down configuration is supported.
047     */
048    @Override
049    public boolean isPullResistanceConfigurable(){
050       return true;
051    }
052    
053    /**
054     * Validates to Integer Format 0-999 with valid prefix.
055     * eg. PS0 to PS999
056     * {@inheritDoc}
057     */
058    @Override
059    @Nonnull
060    public String validateSystemNameFormat(@Nonnull String name, @Nonnull java.util.Locale locale) throws jmri.NamedBean.BadSystemNameException {
061        return this.validateIntegerSystemNameFormat(name, 0, 999, locale);
062    }
063
064}