Signal Functions

Aus EEP Handbuch
Wechseln zu: Navigation, Suche
EEPSetSignal() EEPSetSignal(ID,Aspect,Callback)
type: function
    -- switch signal 0023 to 1 (aspect depends on signal)
    EEPSetSignal(23, 1)

    -- switch signal 0045 to 1 and call 
    EEPOnSignal_45()
    EEPSetSignal(45, 1, 1)
                
caller: script
defined in: EEP
parameters: two or three
returns: one
requires: EEP 10.2 plug-in 2
purpose: Switches a signal
notes:
  • First argument is a numeric value representing the signal’s ID.
  • Second argument is the signal’s aspect.
  • If a 1 is entered as a third (optional) argument, the EEPOnSignal_x() function for this signal is called when the signal’s aspect has changed.
  • Use with care! The signal must be registerd and the corresponding function must be declared. (see next page). Careless use of this function may result in infinite loops.
  • The function returns a 1 if the signal and the demanded aspect exist. It returns a 0 if either one of the two could not be found.


EEPGetSignal() EEPGetSignal(ID)
type: function
    currentAspect = EEPGetSignal(1)
    if currentAspect == 0 then
        print("Signal 1 doesn’t exist")
    elseif currentAspect == 1 then
        print("Signal 1 set to Danger")
    elseif currentAspect == 2 then
        print("Signal 1 set to Clear")
    end
                
caller: script
defined in: EEP
parameters: one
returns: one
requires: EEP 10.2 plug-in 2
purpose: Provides the current state of a signal.
notes:
  • Argument is the signal’s ID.
  • Return value is a numeric representation of the signal’s current aspect. The value reflects the aspect’s position in the effects list of the signal’s properties.
  • The return value is 0 if the signal doesn’t exist.


EEPRegisterSignal() EEPRegisterSignal(ID)
type: function
    EEPRegisterSignal(1)
    function EEPOnSignal_1(newAspect)
        print("Signal 1 switched to ", newAspect)
    end
                
caller: script
defined in: EEP
parameters: one
returns: one
requires: EEP 10.2 plug-in 2
purpose: Registers a signal for the callback function EEPOnSignal_x(). The requirement of a registration prevents signals from triggering a callback when no appropriate function was declared.
notes:
  • The registration is mandatory for those signals which you want to trigger the EEPOnSignal_x() function whenever the aspect changes.
  • Argument is the signal’s ID.
  • Return value is 1, if the signal exists or 0 if it doesn’t exist.


EEPOnSignal_x() EEPOnSignal_x(Aspect)
type: function
    EEPRegisterSignal(1)
    function EEPOnSignal_1(newAspect)
        print("Signal 1 switched to ", newAspect)
    end
                
caller: EEP
defined in: script
parameters: one
returns: none
requires: EEP 10.2 plug-in 2
purpose: Every aspect change induced by a contact or by manual operation (directly or in a link chain) triggers this callback function if the signal has been registerd for callbacks.However: Changing this or a linked signal’s state by Lua function will not trigger thecallback, unless the third argument in that function was a 1.
notes:
  • The name of the function must not end in _x but with the signal’s ID. For signal 0012 the correct name of the function would be EEPOnSignal_12().
  • Please note: The leading zeroes must be omitted in the function’s name!
  • The function is called with the new signal aspect as an argument. The number matches the position in the signal’s aspect list as found in the signal’s properties. Use a variable of your choosing to store this value.
  • EEP requires no return value when calling this function.


EEPGetSignalTrainsCount() EEPGetSignalTrainsCount(ID)
type: function
    EEPGetSignalTrainsCount(3)
                
caller: script
defined in: EEP
parameters: one
returns: one
requires: EEP 13.2 plug-in 2
purpose: Returns the number of consists waiting at the specified signal.
notes:
  • Argument is the signal ID.
  • Return value ist he number of trains (cars, trams etc.) held by the signal.


EEPGetSignalTrainName() EEPGetSignalTrainName(ID,Positionsnr.)
type: function
    EEPGetSignalTrainName(3 , 1)
                
caller: script
defined in: EEP
parameters: two
returns: one
requires: EEP 13.2 plug-in 2
purpose: Returns the name oft he specified consist waiting at the specified signal.
notes:
  • First argument is the signal ID.
  • Second argument ist the position of the train (car, tram ...) in the queue.
  • Return value ist the name of the specified consist.