lua_loader

This is a lua version of the bncs_script_helper, this allows bncs components and panels to
be written in lua.

The advantages of this is, no IDE, no compiling and dll hell.

The disadvantage no IDE help/auto complete, there are lua IDEs available, zeroBrane studio
is one such example. There is an intellisense configuration created for zeroBrane.

Below maybe incorrect, possible using normal lua currently
The lua version used is LuaJit 2.0.4, this is a jit (just in time complied)
version of lua that implements lua 5.1 plus some features of 5.2

How to

Place a .lua file within a folder, the lua file name has to be the same as the folder.

To use as a component there is a bncs control called lua_loader.

Callbacks

Unlike in the C++ code, only the callbacks that are used need to be in the file.

  • Main(path,pointer) - Called when the code is first loaded, like a constructor
  • ButtonCallback(buttonInfo) - Called when a button on our panel is clicked, or a component does a hostNotify
  • RevertiveCallback(revertiveInfo) - Called when a index/slot we have registered for arrives
  • DatabaseCallback(databaseInfo) - Called when a database changes on a device we have registered for
  • ParentCallback(parentInfo) - Called when our parameters change, or our parents passes info to us
  • TimerCallback(id) - Called when a timer we have started elapses

Main

Main(path,pointer)

This is like a constructor in a C++ project.
It can be used to do thing such as set the default panel.

ButtonCallback

ButtonCallback(buttonInfo)

ButtonCallback is called when children buttons or components on our panel notifies us.

buttonInfo holds:

  • command - Button command
  • value - Button Value
  • sub{} - Table of sub commands
  • subs - How Many sub commands there are
  • id - Button Id
  • panel - Panel Id

RevertiveCallback

RevertiveCallback(revertiveInfo)

RevertiveCallback is called when a revertive you have registered for is recieved

revertiveInfo holds:

  • device - Device
  • index - Index
  • info - if routerRevertive Source Index else 0
  • sinfo - if routerRevertive Source Name else Slot value
  • database - 0
  • type - string of revertive type see Revertive type

DatabaseCallback

DatabaseCallback(databaseInfo)

DatabaseCallback is called a database changes for any device we are registered for

databaseInfo holds:

  • device - Device
  • index - Index
  • info - 0
  • sinfo - Database value
  • database - Databse number
  • type - string DATABASE

Revertive types

  • UNKNOWN
  • ROUTER
  • INFODRIVER
  • GPI
  • DATABASE

ParentCallback

ParentCallback(parentInfo)

ParentCallback is called when our parent send us information, or a parameter is set or
when a connection sends us data.

parentInfo holds:

  • command - Parent command
  • value - Parent Value
  • sub{} - Table of sub commands
  • subs - How Many sub commands there are

TimerCallback

TimerCallback is called when a timer elapses, the id of the elapsed timer is passed to us.

### id

The name of the timer that has elapsed

# Commands

## ```panelShow(name, panel, (instance))```

description = "Creates/shows panel from .bncs_ui file"
args = "(name: string, file: string, instance string (optional))"
returns = "(boolean)"

## ```panelInit(name, panel, instance)```

description = "Creates but does not show a panel from .bncs_ui file",
args = "(name: string, file: string)",
returns = "(boolean)"

## ```panelTarget(name, instance)```

description = "Targets a previously created panel with a new instance",
args = "(name: string, instance: string)",
returns = "(boolean)"

## ```panelPopup(name, panel)```

description = "Creates/shows panel from .bncs_ui file as a popup window (like a context menu)",
args = "(name: string, file: string)",
returns = "(boolean)"

## ```panelRemove(name)```

description = "Hides panel, but doesn't destroy it",
args = "(name: string)",
returns = "(boolean)"

## ```panelDestroy(name)```

description = "Destroys the panel",
args = "(name: string)",
returns = "(boolean)"

## ```hostNotify(message)```

description = "Tell our parent that something interesting's happened",
args = "(message: string)",
returns = "(void)"

## ```textPut(command, value, panel, id)```

description = "Send message to a control",
args = "(command: string, value: string, panel: string, id: string)",
returns = "(boolean)"

## ```textGet(command, panel, id)```

description = "Puts text on label",
args = "(command: string, panel: string, id: string)",
returns = "(string)"

## ```routerName(device, database, index)```

description = "Gets a router database name",
args = "(device: int, database: int, index: int)",
returns = "(string)"

## ```routerIndex(device, database, name)```

description = "Gets the index for the given router database name",
args = "(device: int, database: int, name: string)",
returns = "(int)"

## ```routerCrosspoint(device, source, dest, (mask, now))```

description = "Make a crosspoint",
args = "(device: int, source: int, dest: int, mask: string (optional), bool now (optional))",
returns = "(void)"

## ```routerRegister(device, start, end, (add))```

description = "Register for 'revertives'",
args = "(device: int, start: int, end: int, bool add (optional))",
returns = "(void)"

## ```routerUnregister(device)```

description = "Deregister for this device",
args = "(device: int)",
returns = "(void)"

## ```routerPoll(device, start, end)```

description = "Poll for a range of router destinations",
args = "(device: int, start: int, end: int)",
returns = "(void)"

## ```routerModify(device, database, index, name, reload)```

description = "Change a database name",
args = "(device: int, database: int, index: int, name: string, reload: bool)",
returns = "(void)"

## ```infoUnregister(device)```

description = "Deregister for this device",
args = "(device: int)",
returns = "(void)"

## ```infoPoll(device, start, end)```

description = "Poll for a range of infodriver slots",
args = "(device: int, start: int, end: int)",
returns = "(void)"

## ```infoWrite(device, info, index, now)```

description = "Write an infodriver slot",
args = "(device: int, info: string, index: int, now: bool)",
returns = "(void)"

## ```infoRegister(device, start, end, (add))```

description = "Register for 'revertives'",
args = "(device: int, start: int, end: int, bool add (optional))",
returns = "(void)"

## ```gpiRegister(device, start, end, (add))```

description = "Register for 'revertives'",
args = "(device: int, start: int, end: int, bool add (optional))",
returns = "(void)"

## ```gpiSwitch(device, state, index, now)```

description = "Switch a GPI",
args = "(device: int, state: bool, index: int, now: bool)",
returns = "(void)"

## ```gpiPoll(device, start, end)```

description = "Poll for a range of gpi slots",
args = "(device: int, start: int, end: int)",
returns = "(void)"

## ```gpiUnregister(device)```

description = "Deregister for this device",
args = "(device: int)",
returns = "(void)"

## ```register(device, start, end, (add))```

description = "Register for 'revertives'",
args = "(device: int, start: int, end: int, now: add (optional))",
returns = "(void)"

## ```unregister(device)```

description = "Deregister for this device",
args = "(device: int)",
returns = "(void)"

## ```getIDList(name, filter)```

description = "Get a list of controls or the given panel",
args = "(name: string, filter: string (optional))",
returns = "(kvislist)",
valuetype="kvislist"

## ```getDev(instance)```

description = "Gets a Table describing the Device",
args = "(instance: string)",
returns = "(deviceTable)",

## ```getDevSlot(instance, param)```

description = "Gets a Table describing the Device and param",
args = "(instance: string, param: string)",
returns = "(deviceTable)",

## ```navigateAdjust(instance)```

description = "Navigate to given instance",
args = "(instance: string)",
returns = "(boolean)"

## ```navigateExecute(path)```

description = "Navigate to given UI",
args = "(path: string)",
returns = "(boolean)"

## ```navigateCanAdjust(instance)```

description = "True if the given instance can be adjusted (i.e, navigate to appropriate UI)",
args = "(instance: string)",
returns = "(boolean)"

## ```navigateCanExecute(path)```

description = "True if the given UI can be navigated to",
args = "(path: string)",
returns = "(boolean)"

## ```getWorkstationSetting()```

description = "Get a list of all the workstation settings for this workstation",
args = "(void)",
returns = "(kvsslist)",

## ```getWorkstationSettings(key)```

description = "Gets the named workstation setting",
args = "(key: string)",
returns = "(string)"

## ```workstation()```

description = "Gets the workstation number",
args = "(void)",
returns = "(integer)"

## ```getRouterSize(device, database)```

description = "Gets the BNCS database size",
args = "(device: integer, database: integer)",
returns = "(integer)"

## ```getObjectSetting(object, key)```

description = "Gets the setting for the given keys",
args = "(object: string, key: string)",
returns = "(string)"

## ```getUser()```

description = "Gets the current user name",
args = "(void)",
returns = "(string)"

## ```getUserLevel()```

description = "Gets the current user level",
args = "(void)",
returns = "(string)"

## ```getUserLevelInt()```

description = "Gets the current user level as integer (1=user, 2=Supervisor, 3=Administrator, 4=Developer, 0=Unknown)",
args = "(void)",
returns = "(integer)"

## ```controlEnable(panel, control)```

description = "Enable the given control",
args = "(panel: string, control: string)",
returns = "(void)"

## ```controlDisable(panel, control)```

description = "Disable the given control",
args = "(panel: string, control: string)",
returns = "(void)"

## ```controlShow(panel, control)```

description = "Show the given control",
args = "(panel: string, control: string)",
returns = "(void)"

## ```controlHide(panel, control)```

description = "Hide the given control",
args = "(panel: string, control: string)",
returns = "(void)"

## ```controlMove(panel, control, x, y)```

description = "Move the given control",
args = "(panel: string, control: string, x: integer, y: integer)",
returns = "(boolean)"

## ```controlPosition(panel, control)```

description = "Get position of the given control - return is table containing x and y values",
args = "(panel: string, control: string)",
returns = "(xyposition)"

## ```controlCreate(panel, requestedButtonName, buttonClass, x, y, w, h, settings)```

description = "Create a new control - return is actual button name (may not be the same as actual name)",
args = "(panel: string, requestedButtonName: string, buttonClass: string, x: integer, y: integer, w: integer, h: integer, settings: string)",
returns = "(string)"

## ```timerStart(timerId, duration_ms)```

type = "method",
description = "Start a new timer (stopping any previous timer with the same timerid)",
args = "(timerId: integer, duration_ms: integer)",
returns = "(void)"

## ```timerStop(timerId)```

description = "Stops given timer",
args = "(timerId: integer)",
returns = "(void)"

## ```debug(string)```

description = "Write the given string with optional parameters",
args = "(debugString: string)",
returns = "(void)"

## ```setGeometry(x, y, w, h)```

description = "Set overall size/position of the UI",
args = "(x: integer, y: integer, w: integer, h: integer)",
returns = "(void)"

## ```setSize(w, h)```

description = "Set overall size of the UI",
args = "(w: integer, h: integer)",
returns = "(void)"
```

Objects

kvislist

Integer Key, String Value list

Example

myValue = kvislist[1]

kvsslist

String Key, String Value list

Example

myValue = kvislist["key"]

xypostion

X = xypostion.x
Y = xypostion.y

deviceTable

Table of device parameters

device = deviceTable.device
offset = deviceTable.offset
slot = deviceTable.slot
typeChar = deviceTable.type
altid = deviceTable.altid
Version | Date | Author | Notes
1 |  | Simon Armstrong |
1.0.4 | 201216 |  | Sets path to help file to be correct
1.0.5 | 131017 | David Yates | BNCS_V6 (extended ranges)
1.0.6 | 240418 | David Yates | Removes extended ranges
1.0.7 | 010519 | David Yates | Change to callback types
1.0.8 | 110120 | David Yates | Updates build settings (adds _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS) to build VS2019

3rd Pary Licenses

Lua

/******************************************************************************
* Copyright (C) 1994-2008 Lua.org, PUC-Rio.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************///

Lua bridge

/*
  https://github.com/vinniefalco/LuaBridge

  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
  Copyright 2007, Nathan Reed

  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
*/
Build: bncs_4.7.5 5800 a1b48197a Atos|Syntel © 2021