Search in sources :

Example 1 with AbstractSensor

use of jmri.implementation.AbstractSensor in project JMRI by JMRI.

the class BlockManagerXmlTest method testStore.

/**
     * This test checks that the store operation runs, but doesn't check the
     * output for correctness.
     */
public void testStore() throws jmri.JmriException {
    JUnitUtil.resetInstanceManager();
    JUnitUtil.initConfigureManager();
    JUnitUtil.initInternalTurnoutManager();
    JUnitUtil.initInternalLightManager();
    JUnitUtil.initInternalSensorManager();
    JUnitUtil.initMemoryManager();
    JUnitUtil.initLayoutBlockManager();
    Block b1 = InstanceManager.getDefault(jmri.BlockManager.class).createNewBlock("SystemNameb1", "");
    Block b2 = InstanceManager.getDefault(jmri.BlockManager.class).createNewBlock("SystemNameb2", "");
    Sensor s2 = new AbstractSensor("IS2") {

        @Override
        public void requestUpdateFromLayout() {
        }
    };
    b2.setSensor("IS2");
    s2.setState(Sensor.ACTIVE);
    b2.setValue("b2 contents");
    Path p21 = new Path();
    p21.setBlock(b1);
    p21.setFromBlockDirection(Path.RIGHT);
    p21.setToBlockDirection(Path.LEFT);
    p21.addSetting(new BeanSetting(new jmri.implementation.AbstractTurnout("IT1") {

        @Override
        public void turnoutPushbuttonLockout(boolean b) {
        }

        @Override
        public void forwardCommandChangeToLayout(int i) {
        }
    }, jmri.Turnout.THROWN));
    b2.addPath(p21);
//BlockManagerXml tb = new BlockManagerXml();
}
Also used : Path(jmri.Path) BeanSetting(jmri.BeanSetting) Block(jmri.Block) AbstractSensor(jmri.implementation.AbstractSensor) Sensor(jmri.Sensor) AbstractSensor(jmri.implementation.AbstractSensor)

Example 2 with AbstractSensor

use of jmri.implementation.AbstractSensor in project JMRI by JMRI.

the class InternalSensorManager method createNewSensor.

/**
     * Create an internal (dummy) sensor object
     *
     * @return new null
     */
@Override
protected Sensor createNewSensor(String systemName, String userName) {
    Sensor sen = new AbstractSensor(systemName, userName) {

        @Override
        public void requestUpdateFromLayout() {
        }
    };
    try {
        sen.setKnownState(getDefaultStateForNewSensors());
    } catch (jmri.JmriException ex) {
        log.error("An error occured while trying to set initial state for sensor " + sen.getDisplayName());
        log.error(ex.toString());
    }
    log.debug("Internal Sensor \"{}\", \"{}\" created", systemName, userName);
    return sen;
}
Also used : AbstractSensor(jmri.implementation.AbstractSensor) Sensor(jmri.Sensor) AbstractSensor(jmri.implementation.AbstractSensor)

Aggregations

Sensor (jmri.Sensor)2 AbstractSensor (jmri.implementation.AbstractSensor)2 BeanSetting (jmri.BeanSetting)1 Block (jmri.Block)1 Path (jmri.Path)1