001package jmri.jmrix.dcc4pc;
002
003import jmri.implementation.AbstractSensor;
004
005/**
006 * Implement a Sensor via Dcc4Pc communications.
007 * <p>
008 * This object doesn't listen to the Dcc4Pc communications. This is because it
009 * should be the only object that is sending messages for this sensor; more than
010 * one Sensor object pointing to a single device is not allowed.
011 *
012 * @author Bob Jacobsen Copyright (C) 2001
013 * @author Kevin Dickerson (C) 2012
014 */
015public class Dcc4PcSensor extends AbstractSensor {
016
017    public Dcc4PcSensor(String systemName, String userName) {
018        super(systemName, userName);
019        init(systemName);
020    }
021
022    public Dcc4PcSensor(String systemName) {
023        super(systemName);
024        init(systemName);
025    }
026
027    //private int boardAddress;
028    private int inputLine;
029
030    private void init(String id) {
031    }
032
033    @Override
034    public void requestUpdateFromLayout() {
035    }
036
037    @Override
038    public void setOwnState(int state) {
039        int stateConvert = UNKNOWN;
040        realState = state;
041        switch (state) {
042            case INACTIVE:
043                stateConvert = INACTIVE;
044                break; //"UnOccupied"
045            case ACTIVE:
046                stateConvert = ACTIVE;
047                break; //"Occupied No RailComm Data"
048            case ORIENTA:
049                stateConvert = ACTIVE;
050                break; //"Occupied RailComm Orientation A"
051            case ORIENTB:
052                stateConvert = ACTIVE;
053                break; //"Occupied RailComm Orientation B"
054            default:
055                stateConvert = UNKNOWN;
056                break;
057        }
058        super.setOwnState(stateConvert);
059    }
060
061    final public static int ORIENTA = 0x10;
062    final public static int ORIENTB = 0x20;
063    int realState = UNKNOWN;
064
065    public int getRailCommState() {
066        return realState;
067    }
068
069    public void notifyReply(Dcc4PcReply r) {
070    }
071
072    public void notifyMessage(Dcc4PcMessage m) {
073    }
074
075    boolean enabled = false;
076
077    public void setEnabled(boolean enable) {
078        enabled = enable;
079    }
080
081    public boolean getEnabled() {
082        return enabled;
083    }
084
085    public void setInput(int i) {
086        inputLine = i;
087    }
088
089    public int getInput() {
090        return inputLine;
091    }
092}