Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

All LUA functions that are invoked by server tasks as well as all predefined event callbacks (cf. Section 4.6.11) are called in the same thread context. This means that these functions are not executed independent of each other – they are executed one by one. Especially if a lot of functionality is implemented in a LUA function i.e. if it contains a lot of LUA code, this may be a disadvantage because a long execution of a LUA function may block other LUA function.
In order to be able to implement time consuming tasks, so called LUA Apps are available. LUA Apps are executed
within a separate thread within the LUA engine. This means that LUA Apps are executed to some extend in parallel without block each other.
LUA Apps are invoked using the following LUA function:
<file name="nxa.StartApp">
<h1>Description</h1>
<h1>Signature</h1> nxa.StartApp (LUA file, LUA function) <p> Start a LUA App in a separate thread context.
</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>LUA file</td><td>M</td><td>name of the LUA file where the function is defined</td></tr>
<tr><td></td><td>LUA function</td><td>M</td><td>LUA worker function that is invoked within a separate thread</td></tr>
</tbody>
</table>
<h1>Return</h1> None.
</file>
After calling the "nxa.StartApp", the given function is executed as App. If the function is returns, the App is automatically terminated. This means if a LUA App shall be able to do some periodic task, an event loop has to be included.
Since LUA Apps are invoke to some extent in parallel, the implemented functionality and the used resource must be thread-safe i.e. critical operations must be protected. Therefore, only the following functions can be used within LUA Apps:

  • nxa.LogInfo
  • nxa.LogWarning
  • nxa.LogError
  • nxa.IsInitialized
  • nxa.IsRunning
  • nxa.IsSimulation
  • nxa.IsActiveServer
  • nxa.IsMainServer
  • nxa.IsBackupServer
  • nxa.GetValue | nxa.Value
  • nxa.SetValue
  • nxa.SetItemData
  • nxa.WriteValue
  • nxa.ReadValue
  • nxa.IsValidValue
  • nxa.WorkspaceName
  • nxa.RootPath
  • nxa.WorkspacePath
  • nxa.ScriptFilesPath
  • nxa.DataFilesPath
  • nxa.LogFilesPath
  • nxa.ProjectFilesPath
  • nxa.EventFilesPath
  • nxa.ConfigFilesPath
  • nxa.GetItemID
  • nxa.Sleep (only available inside a LUA App)
  • nxa.Now
  • nxa.TimeOnly
  • nxa.DateOnly
  • nxa.Year
  • nxa.Month
  • nxa.Day
  • nxa.Hour
  • nxa.Minute
  • nxa.Second
  • nxa.DayOfWeek
  • nxa.MakeDate
  • nxa.MakeTimeOnly
  • nxa.AddDate
  • nxa.DiffDate
  • nxa.DateToString
  • nxa.SetDate
  • nxa.SetTimeOnly
  • nxa.GetVar
  • nxa.SetVar
  • nxa.ClearVar
  • nxa.AddVarTask
  • nxa.SourceVar
  • nxa.GetPropertyValue | nxa.PropertyValue | nxa.Property
  • nxa.SetPropertyValue | nxa.SetProperty
  • nxa.GetLastErrorText
  • nxa.GetLastErrorCode
  • nxa.LowByte
  • nxa.HiByte
  • nxa.LowWord
  • nxa.HiWord
  • nxa.IsBitSet
  • nxa.SetBit
  • nxa.ResetBit
  • nxa.SetLowByte
  • nxa.SetHiByte
  • nxa.SetLowWord
  • nxa.SetHiWord
  • nxa.And
  • nxa.Or
  • nxa.Xor
  • nxa.Tor
  • nxa.Not
  • No labels