001/*
002 *  @author Gregory J. Bedlek Copyright (C) 2018, 2019
003 */
004package jmri.jmrit.ctc;
005
006import jmri.Sensor;
007
008public class SwitchDirectionLever {
009    private NBHSensor _mSwitchLeverSensor;
010    public SwitchDirectionLever(String userIdentifier,
011                                NBHSensor switchLeverSensor) {
012        _mSwitchLeverSensor = switchLeverSensor;
013        if (_mSwitchLeverSensor.getKnownState() == Sensor.UNKNOWN) {
014            _mSwitchLeverSensor.setKnownState(Sensor.ACTIVE);
015        }
016    }
017
018    public void removeAllListeners() {}   // None done.
019    public NBHSensor getSwitchLeverSensor() { return _mSwitchLeverSensor; }
020
021    public int getPresentState() {
022        int presentState =  _mSwitchLeverSensor.getKnownState();
023        if (presentState == Sensor.ACTIVE) return CTCConstants.SWITCHNORMAL;
024        if (presentState == Sensor.INACTIVE) return CTCConstants.SWITCHREVERSED;
025        return CTCConstants.OUTOFCORRESPONDENCE;    // HUH?
026    }
027}