Search in sources :

Example 16 with Memory

use of jmri.Memory in project JMRI by JMRI.

the class DefaultConditional method getMemory.

/**
     * for backward compatibility with config files having system names in lower
     * case
     */
private static Memory getMemory(String name) {
    Memory m = InstanceManager.memoryManagerInstance().getMemory(name);
    if (m == null) {
        // N11N
        String sName = name.toUpperCase().trim();
        m = InstanceManager.memoryManagerInstance().getMemory(sName);
    }
    return m;
}
Also used : Memory(jmri.Memory)

Example 17 with Memory

use of jmri.Memory in project JMRI by JMRI.

the class DefaultConditionalAction method getIndirectBean.

/**
     * If this is an indirect reference return the Memory bean
     *
     */
private Memory getIndirectBean(String devName) {
    if (devName != null && devName.length() > 0 && devName.charAt(0) == '@') {
        String memName = devName.substring(1);
        Memory m = InstanceManager.memoryManagerInstance().getMemory(memName);
        if (m != null) {
            _indirectAction = true;
            return m;
        }
        log.error("\"" + devName + "\" invalid indirect memory name in action " + _actionString + " of type " + _type);
    } else {
        _indirectAction = false;
    }
    return null;
}
Also used : Memory(jmri.Memory)

Example 18 with Memory

use of jmri.Memory in project JMRI by JMRI.

the class DefaultConditionalAction method getNamedBean.

@Override
public NamedBeanHandle<?> getNamedBean() {
    if (_indirectAction) {
        Memory m = (Memory) (_namedBean.getBean());
        String actionName = (String) m.getValue();
        NamedBean bean = getActionBean(actionName);
        if (bean != null) {
            return nbhm.getNamedBeanHandle(actionName, bean);
        } else {
            return null;
        }
    }
    return _namedBean;
}
Also used : NamedBean(jmri.NamedBean) Memory(jmri.Memory)

Example 19 with Memory

use of jmri.Memory in project JMRI by JMRI.

the class DefaultConditional method getActionString.

private String getActionString(ConditionalAction action) {
    String devAction = action.getActionString();
    if (devAction != null && devAction.length() > 0 && devAction.charAt(0) == '@') {
        String memName = devAction.substring(1);
        Memory m = getMemory(memName);
        if (m == null) {
            log.error(getDisplayName() + " action \"" + action.getDeviceName() + "\" has invalid memory name in actionString - " + action.getActionString());
            return "";
        }
        devAction = (String) m.getValue();
    }
    return devAction;
}
Also used : Memory(jmri.Memory)

Example 20 with Memory

use of jmri.Memory in project JMRI by JMRI.

the class DefaultConditional method getDeviceName.

private String getDeviceName(ConditionalAction action) {
    String devName = action.getDeviceName();
    if (devName != null && devName.length() > 0 && devName.charAt(0) == '@') {
        String memName = devName.substring(1);
        Memory m = getMemory(memName);
        if (m == null) {
            log.error(getDisplayName() + " invalid memory name in action - " + devName);
            return null;
        }
        devName = (String) m.getValue();
    }
    return devName;
}
Also used : Memory(jmri.Memory)

Aggregations

Memory (jmri.Memory)31 MemoryManager (jmri.MemoryManager)7 Sensor (jmri.Sensor)5 JsonException (jmri.server.json.JsonException)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 Element (org.jdom2.Element)4 Conditional (jmri.Conditional)3 JmriException (jmri.JmriException)3 SignalHead (jmri.SignalHead)3 Turnout (jmri.Turnout)3 Editor (jmri.jmrit.display.Editor)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 IOException (java.io.IOException)2 Block (jmri.Block)2 ConfigureManager (jmri.ConfigureManager)2 Light (jmri.Light)2 Logix (jmri.Logix)2 NamedBean (jmri.NamedBean)2 Path (jmri.Path)2