Skip to content

Customizing the Interface

A customization of the interface is possible through an API (application programming interface). The API is based on the scripting language lua.org. If LUA is already installed on the system the system parameters are extended within SXMLIF by the following:

  • The default of package cpath is extended by SIHOT-HOME\lua\bin.
  • The default package path is extended by SIHOT-HOME\lua\lua.

The name of the script has to exactly match the name of the XMLinterface process in SIHOT; e.g. if the name of process is “SXMLIF2”, the name of the Lua script has to be “sxmlif2.lua”.

The extension file must be located under: SIHOT-HOME\lua\main\protocol\sxmlif\

Concerning the purpose of the extension the Lua script has to implement whether the public function is send or receive. The function send is called by the interface every time prior to sending information to an external system. The function receive is called every time information was sent to the interface. Both functions are called with the XML string as parameter and have to implement two return values. The first value is the XML string that should be used for further operations in the interface; the second value is a boolean value that tells the interface if the XML string still needs to be processed by the interface. The complete structure of the lua extension is shown below.

-- This function is invoked when the interface is shutdown
function shutdown()
    return "", true
end

-- This function is invoked prior to processing with the data received
function receive(data)
    -- return true if the data is still to be processed
    -- return false if the data should not be processed
    return data, true
end  

-- This function is invoked periodically before the OC:LA is being sent  
function alive(data)
    return data, true
end

-- This function is invoked prior to sending with the data to be sent  
function send(data)
    -- return true if the data is still to be sent
    -- return false if the data should not be sent
    return  data, true
end

Structure of the lua extension

The simplest implementation of the send-function is shown below. The script file just receives the data, transfers nothing back and tells the following code to not send anything.

function send( data )
    return "", false
end