001package jmri.jmrit.logixng;
002
003import jmri.NamedBean;
004import jmri.jmrit.logixng.util.LogixNG_Thread;
005
006/**
007 * ConditionalNG.
008 *
009 * @author Daniel Bergqvist Copyright 2019
010 */
011public interface ConditionalNG extends Base, NamedBean {
012
013    /**
014     * Get the thread that this conditionalNG executes on.
015     * @return the thread
016     */
017    LogixNG_Thread getCurrentThread();
018
019    /**
020     * Get the thread id that this conditionalNG should execute on when JMRI
021     * starts next time.
022     * It's not currently possible to move a ConditionalNG from one thread to
023     * another without restarting JMRI.
024     * @return the thread ID
025     */
026    int getStartupThreadId();
027
028    /**
029     * Set the thread id that this conditionalNG should execute on when JMRI
030     * starts next time.
031     * It's not currently possible to move a ConditionalNG from one thread to
032     * another without restarting JMRI.
033     * @param threadId the thread ID
034     */
035    void setStartupThreadId(int threadId);
036
037    /**
038     * Get the female socket of this ConditionalNG.
039     * @return the female socket
040     */
041    FemaleDigitalActionSocket getFemaleSocket();
042
043    void setSocketSystemName(String systemName);
044
045    String getSocketSystemName();
046
047    /**
048     * Set whenether this ConditionalNG is enabled or disabled.
049     * <P>
050     * This method must call registerListeners() / unregisterListeners().
051     *
052     * @param enable true if this ConditionalNG should be enabled, false otherwise
053     */
054    void setEnabled(boolean enable);
055
056    /**
057     * Determines whether this ConditionalNG is enabled.
058     *
059     * @return true if the ConditionalNG is enabled, false otherwise
060     */
061    @Override
062    boolean isEnabled();
063
064    /**
065     * Set whenether this ConditionalNG should be executed at startup or at
066     * panel load.
067     *
068     * @param value true if this ConditionalNG should be executed at startup
069     * or at panel load.
070     */
071    void setExecuteAtStartup(boolean value);
072
073    /**
074     * Determines whenether this ConditionalNG should be executed at startup
075     * or at panel load.
076     *
077     * @return true if this ConditionalNG should be executed at startup or at
078     * panel load.
079     */
080    boolean isExecuteAtStartup();
081
082    /**
083     * Set whenether execute() should run on the LogixNG thread at once or
084     * should dispatch the call until later.
085     * Most tests turns off the delay to simplify the tests.
086     *
087     * @param value true if execute() should run on LogixNG thread delayed,
088     *              false otherwise.
089     */
090    void setRunDelayed(boolean value);
091
092    /**
093     * Get whenether execute() should run on the LogixNG thread at once or
094     * should dispatch the call until later.
095     * Most tests turns off the delay to simplify the tests.
096     * @return true if execute() should run on LogixNG thread delayed,
097     * false otherwise.
098     */
099    boolean getRunDelayed();
100
101    /**
102     * Execute the ConditionalNG.
103     */
104    void execute();
105
106    /**
107     * Execute the ConditionalNG.
108     * @param allowRunDelayed true if it's ok to run delayed, false otherwise
109     */
110    void execute(boolean allowRunDelayed);
111
112    /**
113     * Execute the female socket.
114     * @param socket the female socket
115     */
116    void execute(FemaleDigitalActionSocket socket);
117
118    /**
119     * Are listeners registered?
120     * @return true if listeners are registered, otherwise return false
121     */
122    boolean isListenersRegistered();
123
124    /**
125     * Get the stack
126     * @return the stack
127     */
128    Stack getStack();
129
130    /**
131     * Get the current symbol table
132     * @return the symbol table
133     */
134    SymbolTable getSymbolTable();
135
136    /**
137     * Set the current symbol table
138     * @param symbolTable the symbol table
139     */
140    void setSymbolTable(SymbolTable symbolTable);
141
142    /**
143     * Set the current ConditionalNG.
144     * @param conditionalNG the current ConditionalNG
145     */
146    void setCurrentConditionalNG(ConditionalNG conditionalNG);
147
148}