How to configure a panel from an external file

In large multi-channel setups you often have the same panel design used on many workstations, but the IP addresses of the the controlled devices change. One way to handle this would be to edit each individual panel, but that would make it really hard if you then want to change the panel design. So the best way is to have a generic panel that pulls in it’s configuration from a local file. Here we show you how to do that.

The Panel

wpid-media_1417770538702.png

It’s a very simple master control panel controlling a router and an Imagestore. You can download this example here to explore it in Hem Designer. At the moment we’ve set up default IP addresses and the router busses control arbitrary outputs. To deploy this panel we need to set:

  • Imagestore IP address
  • Router IP address
  • PGM bus controlled output
  • PST bus controlled output
  • text of CHANNEL NAME label

And it’s all done using a BeforeConnect script in the Root Panel to get this data from an external file. So let’s first take a look at the config file and then see how the script reads it in.

Config file

wpid-media_1417770769929.png

The config file is actual lua code. It defines a table called ‘panel_setups’.

Each setup is a named group of individual property settings. So for example at the beginning of the News setup we set the IS750 IP address like this:

{device=”IS750_1″, property=”IP_Address”, value=”192.168.0.34″}

just a simple list of named items that tells our config script exactly which property of which device to set to what value.

Each setup is a list of property settings which we give a name to so as to find it later e.g.

News={ {device=”IS750_1″, property=”IP_Address”, value=”192.168.0.34″},
{device= …
{device=”PST_BUS”, property=”RouterOutput”, value=”2″} }

And panel_setups is a list of named setups.

You can add as many property settings as you like. Brackets and commas are important. Each list and sub-list must be enclosed in its own set of curly brackets or lua will not understand it. So make sure when you edit that you separate list items with commas and close open brackets. We’ve formatted the table in this example so as to make the structure as clear as possible.

BeforeConnect script

wpid-media_1417770622322.png

A simple Lua script that gets executed by Helm before connecting to devices. Let’s see line-by-line how it works:

  1. we define a variable called active_setup_name and give it a value, in this case “Films”
  2. we call the lua function dofile with parameter our setup file name in this case “PnlConfig.lua”. dofile reads the file in and executes it as lua code.
  3. we create a function called apply_setup_item. It takes list of the form {device=”<device name>”, property=”<property name>”, value=”<property value>”} and applies this data to the corresponding Helm property
  4. we create another function called apply_setup which takes each property setting in the setup list and applies it using the apply_setup_item function.
  5. Finally we get the setup list that corresponds to the active_setup_name and call apply_setup to configure the panel

apply_setup shows the sheer power of the lua language – just one line of code to iterate through a list and execute a function for each list item. Truly amazing!

Run Panel

wpid-media_1417771084521.png

And here’s the panel. This time we chose to set it to Films. In our example we’ve put some diagnostic text labels that are property-linked to things like router bus output settings and IS750 IP address to see that things are working.

By adding this code to your BeforeConnect script you can simplify panel deployment and save hours of editing workstation-specific parameters.