VID Overview
The VID (Virtual Instrument Desktop) software allows low cost industry standard Modbus or NetCommander hardware to be used in distributed control and monitoring systems. The Software combines a customizable virtual instrument display with a "behind the scenes" event monitoring, logging, alerting and control systems. The system is equally "at home" with a local LAN or RS232/RS485 connected system or a globally distributed system using the Internet or Corporate VPN. The virtual instrument panel can comprise a variety of meters, dials, digital displays, graph plotters, thermometers, LED indicators, control knobs, sliders, buttons and switches. These can be "connected" to a Netcommander monitoring point anywhere on the local or World Wide network allowing data sources, temperature, pressure, voltages etc. to be visualised in seconds. The instruments are viewed in multiple virtual screens; the current screen can be selected by using the toolbar forward, backward, and page cycle buttons or from the drop down list of configured pages. Each NetCommander monitoring unit can provide up to 16 analogue input and outputs, 16 switch (relay) control outputs and inputs, . The VID software will control up to fifty monitoring units. Logs can be maintained and analysed for trends and compared week on week. Control schedules can also be set up. The events system provides a configurable cause and effect system, several "causes" can be combined using AND/OR/NOT logic to produce an event that can have several "effects". An "effect" can be a control output, raise an alarm, make a log entry send an e-mail or SMS, run a control script etc. An almost unlimited number of events can be processed by the VID software, and a more limited number can be processed by the NetCommander nodes natively, this will allow some basic control to be maintained autonomously, in the event of network or PC failure. VID is available for free download, VID has been tested using windows 98/2000/XP and Vista™, the system will work identically, however, the windows may be rendered slightly
differently to those illustrated below, which were mostly recorded on Windows XP. Alternately the raw web interface to the Netcommander can be investigated here. The "view only" password is Cuberoot. Top VID Download Click Setup.exe to download the latest Full VID installer or here for other versions. Unregistered, VID is fully functional but will only run for half an hour at a time before closing down, also the
registration dialogue box will pop-up every five minutes, just to annoy you! There is a publicly available NetCommander at IP address (81.138.209.253) which
is monitoring the computer room here in Leicester, England, use with the configuration file "examples.vid" to view this on the "power
monitoring" page. The unregistered software will allow you to explore all aspects of the system and to design your own instrument panels,
and control regimes and save the files for future use. The downloaded file is a self extracting installer, an un installer is also
provided. VID has been tested using windows 98/2000/XP/Vista™* please report any problems to support@thecodemachine.co.uk. Alternately the raw web interface can be investigated (http://81.138.209.253). The "view only" password is cuberoot. *Partial Windows Vista™ testing only. TopInstalling VIDDouble click on the file Setup.exe which can be found on either the Installation CD (this should
auto-start) or downloaded from the Internet from http://thecodemachine.co.uk/VID/Setup/VID_Full/Setup.exe. Un-Installing VIDVID may be removed from the system by navigating to "Uninstall VID" from the Start Menu or using the "Add/Remove Programs" dialogue from the Control Panel. Any configuration files generated after the installation will not be deleted, if you want to remove these as well simply delete the installation directory after the un-install completes.Top How to Register VID
Top
Edit MenuOne concerns the local configuration and one for configuring individual NetCommander nodes. The System configuration is accessed from the Edit menu, and allows setting up of the system wide defaults.
Poll PeriodPoll Period sets the inter poll period in seconds for refreshing the NetCommander data.Some Internet connected nodes may require a slower poll to allow for network delays, local and time critical applications can have shorter poll periods. The shortest practical poll period is 0.3 Seconds. With many connected NetCommanders, consideration should be given to the available bandwidth. PasswordsA valid password always needs to be specified to access the NetCommander, passwords are up to 10 characters long and should contain numbers and letters of both cases for maximum security. To change the password on the NetCommander enter the new password into the Password & Repeat boxes and check Change It, the password will not appear on screen. You must be already logged on to the NetCommander with a valid "Full Access" password before you can change the password.WebThis button will launch the default web browser pointing at the native Web interface of the selected NetCommanderPort scale conversions
Top Modbus Nodes
Top File Menu
The completed desktop arrangement can be saved from the [Files][Save] menu or by clicking Options Menu
Instrument Pages
Top Virtual InstrumentsAnalogue Instruments Binary Instruments Labels Dynamic Graphics Static Graphics Web GraphicsAnalogue Controls Switches VI Configuration Charts Instrument Scaling Virtual Instrumentation provides a visualization of the monitored system. A variety of instruments may be included on the display, a selection of round, horizontal and vertical analogue meters, thermometers, bar indicators, Oscillograph, digital displays and LEDs. For analogue control there are rotary mouse adjustable knobs, and slider controls and for switch outputs clickable toggle and slide switches and push buttons.
Top Analogue InstrumentsThe available instruments are 270, 180 and 120 degree meters, horizontal and vertical meters, horizontal and vertical bar indicators, a representation of various tanks with varying liquid levels, thermometer, a numeric value indicator and a graph plotter.Top Graph PlotterThe Graph Plotter is a type of analogue instrument but has a few more options. The Graph Plotter can display more than one input value, this is specified by a start port and range. For example if "port" is set to 3 and "num ports" to 4 then the values of Netcommander ports 3,4,5 & 6 will be displayed. The same scaling is applied to all ports. A typical use would be to measure the power consumption in a three phase supply, and with this in mind the first three channels are coloured Blue, Yellow and Red (these can be changed). By specifying a "log file" in the configuration, chart data is logged to a disk file. There are 60 plotted points to a graph division, so if an hour per division is specified each point represents one minute and an entry is logged every minute. The log scale can be specified from one day per division down to five minutes. Right clicking on a graph brings up the usual properties selection panel with the addition of "logger" this produces an historical log analyses tool, this will open with the log file and scaling associated with the graph plotter instrument. These values can be subsequently changed in the analyses tool, and the new settings will be remembered for the next time. Binary InstrumentsThe only Binary "instruments" are the Light Emitting Diode (LED) representation and Dynamic Labels, these can be made to change colour and the displayed text according to input value. There are also options to flash the LED or Label and to play a sound file when changing state. The dynamic caption described in Labels below is useful with LEDs. A typical Caption would be of the form "Off;On"; The scaling would then be arranged to produce values in the range 0.0.. 1.9999, anything below 1.0 represents "off" and 1.0 and upwards represents "on" a typical mapping for an analogue input would be 0..4095 (raw) 0.1.9999 (scaled), this would mean any input value over half scale deflection (2.5V)
would cause the "LED" to be "on".LabelsLabels can either display a fixed text and a dynamic numeric value or a dynamic text which changes according to value. The font size, text and text colour can be changed from the properties dialogue. Dynamic Label ValueA dynamic numeric value and fixed text is displayed if units are specified in the properties dialogue. Dynamic Label TextIf the units field in the properties dialogue is blank then labels can be considered as a binary (or multi-state)
instruments as the text can change according to the monitored value. This feature is available on the caption property of ALL the instrument types but is probably of most use in switches and LEDs that have
only two discrete states i.e. "on" and "off". Dynamic GraphicsGraphics can be considered as a binary (or multi-state) instruments as picture can change according to the monitored value. Up to 100 pictures are allowed are allowed selected by the scaled values 0.00 through to 99.99. The "base" picture for the graphic should have a name ending in "00" e.g."PipeValve00.jpg" that could represent (for example) a closed valve, "PipeValve01.jpg", "PipeValve02.jpg" could then represent the same valve in various degrees of flow. The are some example picture in the "VID/Media" folder, the user can add some more if desired.Top Static GraphicsStatic Graphics are primarily for displaying a fixed background picture, they can be re-sized and the picture file changed at run-time. Also you can specify a "refresh" interval from approximately one second upwards, this is useful for monitory the image file generated by a locally connected "web cam". For internet connected web Cameras use the "Web Graphic" option below. Top
Analogue ControlsAnalogue Controls include two knobs, one is a single turn with a digital readout, the other is a 10 turn "pot" called a Gear Dial, horizontal and vertical sliders are also supplied, also numeric controls in edit box and spin button styles. Right clicking on the control will allow various properties to be changed. VID (Lite) does not support analogue controls.SwitchesThere are Toggle and Rocker switches which remember their state (just like a light switch) and a "momentary action" switch called a Bit Button. The Bit Button will only change state whilst the mouse button is held down. Right clicking on the switch will
allow various properties to be changed, such as control point, caption etc. Rocker and toggle switch styles are available. The text on the
face of the switch can be made to change according to state using the dynamic caption described in Labels above The
caption could be of the form "Lights|Off;Lights|On". The "Bit Button" is a momentary contact push-button, it is only "On" whilst it is
being "pressed". The Bit Button is unique in that it can also be associated with a control script which will run when the
button is clicked for more about control scripts see this. The state of the control will reflect the last update
message received from the Netcommander, if there is more than one instance of VID controlling the system the switches and controls may
change position by themselves, all VID displays will be kept consistent. VID (Lite) does not support switches. Pinger
Top Instrument Configuration
Right clicking on any instrument will bring up a popup menu with options to change instrument properties, Nudge (make fine adjustments to size and position), clone (duplicate), delete, and change the type of instrument preserving all applicable settings. The history chart generator and Tariff tool can also be launched from here, for graph type instruments. Only a subset of the above options will appear depending on instrument type. PropertiesThe Instrument properties form is similar for all instrument types, some fields will be missing if not applicable. The form on the left contains all possible fields, they will never all be present, the fields visible will depend on the type of instrument being configured.Caption and Units will appear on the face of the instrument, special symbols from the Extended ASCII character set can be added using the &#nnn; syntax, nnn being the character code e.g. ° would display °C. Caption text can change according to the current instrument/ switch value see Labels above for full explanation. Font sets the font attributes to be used. Colour allows non-standard Font colours to be used. Node/Type/Port dialogue set the monitoring or control point . Value box shows the current scaled value. Dig. min/max and Scaled min/max boxes are used to define the scaling function. Volts check box determines whether the Digital range boxes contain the digital value (checked) ie 0..4095 or an analogue value 0..5.0 Volts at the NetCommander input. Sc. Default button will pre-load the scaling boxes with the NetCommander port defaults.The raw input value can be pre-processed by a Script (written in a simplified "c" programming language) to provide extra data processing, averaging or calibration etc. Browse button is used to locate the desired script, more about this below. X Interval is only applicable to the graphs and ranges from one minutes per division to one day per division. GlyphFile and associated Browse button appears for certain switches and allows an image to be overlaid on the switch. Inner Colour & Set Colour set the background and inner colours, these buttons are renamed "On colour" and "Off Colour" when processing binary instruments such as LEDs. Sec Low & Sec Hi sliders control the size of the coloured sectors on the instrument face, or in the case of thermometers the "mercury" colour and in value indicators the colour of the value text. Only the Mid sector is controlled, the upper and lower sectors extend to the extremities of the scale. The instrument values including sector ranges can be imported into the Events Cause form by left clicking on an instrument whilst a cause dialogue is open. Caption tracks LED Colour obviously only appears for LEDs and does what it says! Page allows the instrument to be "sent to" another page, this can be used in conjunction with cloning (below) to duplicate an instrument onto another page with identical settings. Beveled controls whether the instrument bezel is displayed. Change FaceThis option brings up the Change Face Dialogue, the instrument face type can be change (within reason!). It is not possible to change a switch to an analogue meter for example, but all analogue instruments are interchangeable, likewise binary displays, and switch types.RefreshThis option retrieves a web based image from a server and refreshes the instrument on the display.Control SchedulesTop
CloneThis option creates an identical instrument on the display, useful when there a lot of only slightly differently configured instruments.Delete InstrumentThe Instrument will removed from the display and from the active configuration.LoggerThis option opens the instrument logging and charting tool.Delete InstrumentThe Instrument will removed from the display and the active configuration. TopToolbar![]() Page SelectionThe drop-down menu selects the page of instruments to be displayed.Web Server activity LEDIs to the right of the page selection box, and indicates activity on the internal web server (or Web Client for Client versions of VID)Monitoring node Status BarThe row of bars to the right of the Web server activity LED indicate the status of the monitoring nodes.
ToolBar IconsMost of functions available from the toolbar icons are available from the menus (above). The page control Icons will not be present in VID (Lite).
All the above Icons are self explanatory or have functions described in the relevant menu section. With the exception of:- Full Screen, this button hides the menu and tool bars and expands the main form to fill the screen, pressing the Escape (ESC) key cancels this. Log Annotation (see below). Top
Log Analyses Tool![]()
CancelCloses the property selection form.Top
Instrument ScalingThe Instrument Scale factors require a little more explanation. Analogue input and outputs have raw digital values expressed as a scaler
number between 0 and 4095 (for A 12bit resolution A/D). Scaling functions are required to convert this range to a floating point
representation of a "real world" value e.g. degrees Centigrade or Volts. result=input_rel(0); This will be familiar to any 'C' programmer. The above script does nothing, the input value is simply conveyed un-altered to the
auto-defined double precision variable "result".
double Av[size];
int c,count=0,size=10;
Av[count%size]=input_rel(0);
result=0;
count++;
if (count>=size) {
c=0;
while (c<size) {
result+=Av[c];
c++;
}
result = result/size;
} else {
c=0;
while (c<count) {
result+=Av[c];
c++;
}
result = result/count;
}
The important thing to note here is that variables are "static", each time the script is called the values are remembered from the last
run, "count" is incremented from one call to the next, the variables assigned a value in declaration statements "int" or "double" are set
to that value on the first run only, and then may subsequently be updated (or left the same). Each instruments' scaling function has its
own set of variable values, even though the same script may be in use by several different instruments. Top VID Control ScriptsScriptor Window Variables Arithmetic Built in Functions VID Software OverviewThe language itself is a subset of 'C' so will be familiar to any 'C' programmer. Only the for, while, switch and if flow control constructs are implemented, there are no do .. while loops. All variables, constants and functions are integers (int) or double precision floating point. Strings can also be defined using char[]; VID can invoke a script from either a push button on the virtual display panel, or as an "effect" from the event handler, or can be run from the [File][Run Script] Menu. The script will open in a window as above, but can be subsequently hidden and revealed under control of the script itself. several scripts can run concurrently, and may run continuously in a loop, waiting for various conditions to occur in the monitored system. On a Pentium class 1Ghz PC the script interpreter should exceed one million lines of code per second. The scripts are interpreted rather than compiled, this means that the system only "sees" the code as it is executed, any areas of your script that only execute under exceptional conditions e.g. alarm handling may contain errors that will only become evident when the alarm condition occurs, be careful coding these areas and test thoroughly before putting on a live system. Script TypesThere are two types of scripts, their syntax is identical, but they are used for different purposes within the system, these are "Scaling Algorithms" and "Control Scripts".Scaling AlgorithmsScaling Algorithms are used to process the raw values into a suitable range for display by an instrument see Virtual Instruments or Scaling inputs into the Events system. In addition to simple scaling they may calculate, for example, averaging functions, and non-linear conversions for instruments like thermo-couples etc. These scripts have the ".vsa" (VID Scaling Algorithm) file extension. These scripts should be kept as simple as possible to reduce execution time and CPU overhead to a minimum, as they may be being called hundreds of times a second. Scaling algorithms are run "blind" they do not run in a Scriptor WindowControl ScriptsControl Scripts can use the full functionality of the scripting engine including writing information to a Console Window these scripts run asynchronously to the main code, in a separate thread, and so can run for a long time without disturbing the main functionality of the program. In fact, a control script may run continuously in a loop monitoring inputs etc. Control Scripts have the ".vcs" (VID Control Script) filename extension. The system can run eight scripts concurrently. The scripts may be launched from the [File][Run Script] menu or from a virtual on-screen Button, or as an event action. If invoked from the [File][Run Script] menu the Console Window will be visible otherwise it is minimized, the running script may force a minimized window open by a call to the visible() function, the window opens automatically in the event of an error.Top The Scriptor Window
Control Scripts are usually run minimized (left),
however the Scriptor Window, as above, is available, and can be used to start,stop,resume and edit the scripts. The File button opens the file dialogue to select a control script file, this will run automatically. Start is used to re-load from
disk and run the previously selected file name, this is useful for reloading the script if it has been edited, Halt will
halt the running script, Continue will cause the script to resume at the same point. This will otherwise, generally, not
effect the operation of the script, however, events in the monitored plant may be missed or functions that rely on time differences (as
read by the get_time() function) may malfunction. Exit will exit from the running script. Edit will open the "NotePad"
editor (on a Microsoft Windows system) and open the current script for editing. This is a convenient way to achieve a fast edit/run/debug
cycle for scripts. Close will exit from the current script and close the scriptor window. Any outputs made from the
running script (using the print(...) command) will appear in the main window. The eight boxes at the bottom of the window, give a display
of what the Script Engines are doing, the first box is reserved for Scaling Algorithms, as these always run in the same thread there can
only be one of them! The other seven are the general control scripts, the number following the file name is the "program counter", the
current position in the script file. The file associated with the current window is coloured red. The screen shot above is showing the
execution of the test.vcs syntax and performance test script.
Instrument ScalingThe Instrument Scale factors were introduced in the Virtual Instruments topic. These have the same syntax as control scripts but have the specific function of processing raw input values to engineering units, Volts, Liters etc. for display on virtual instruments or for processing in the event handler. The basic anatomy of a VID Scaling Algorithm (.vsa) file is:-double scale_max=5,scale_min=0; result=input_rel(0)*scale_max/4095; result+=scale_min; This will be familiar to any 'C' programmer, the two double precision variables "scale_min" and "scale_max" set the upper and lower bounds of the instrument scale, "result" will represent the value to be sent to the instrument in the scaled units. The raw value is retrieved by a call to the "input_rel(0)" function, which returns the raw value from the port specified in the Instrument or event Cause, this is a value in the range 0 .. 4095 for an analogue signal. The calculation in the script coverts this to a value in the range (in this case) 0.0..5.0 for display this value must be stored in a variable called "result" which is pre-declared by the system. The same script can be used for many instruments, each instrument will maintain its own copies of all variable values. The scripts should be designed to drop "straight through" without excessive looping, these scripts may be called hundreds of times a second, so keep them simple! The above script is stored in the scripts folder as "electrical5V.vsa" a slightly more complex script "average10.vsa" used for calculating the average of the last 10 values is reproduced below. double Av=0,scale_max=5; Av *= 0.9; Av += (input_rel(0)*scale_max*0.1)/4095; result = Av;Building on this is a script to calculate domestic power consumption, it uses averaging as above and also time functions.
//==================================================================================
// KWH.vsa : script to tot up power consumption in KW/hours
// The input value is 0..2400 Watts @ FSD
//==================================================================================
double power;
double background=150; // make an initial guess at background consumption (watts)
int iv, Watt_secs;
iv = input_rel(0);
if (iv==4095) {
// FSD on current transformer, make a guess at what is happening!
double tod = get_time();
if (tod<50) {
Watt_secs=0; // reset total at midnight
}
if (tod<730000) {
// before 7:30
if (tod>100000) {
// Time between 1am, and 7:30am
power=2700+background; // assume this is the immersion heater 2.7kW + background
}
} else {
// after 7:30 am
if (tod<905000) {
// Time between 7:30am, and 9:05am
power=7000+background; // assume this is the shower 7kW + background
}
}
} else {
power = iv*2400/4095; // 2400 Watts FSD
background*= 0.9;
background+= (power/10);
}
Watt_secs += (power/10); // come here every 100mS hence /10
result = Watt_secs; // Watt/Seconds
result = result/3600; // Watt/Hours
result = result/1000; // KWH
The important thing to note here is that variables are "static", each time the script is called the values are remembered from the last run, the variables assigned a value in declaration statements "int" or "double" are set to that value on the first run only, and then may subsequently be updated (or left the same) and their current value remembered from one call to the next see "background" above. More about Scaling Algorithms and Control Scripts in the Scripts section. If the same script is running on several instruments each will have its own set of variables. You can create your own scripts using "NotePad" or similar editor and place them in the scripts folder. The Scripts may be indented and commented freely, this will make them easier to maintain and be understood by others, this will not effect the speed of execution as all "white space" and comments will be discarded when the file is first loaded. Scaling Algorithms are only loaded from disk once (or when the instrument properties are changed) so changing the files will not effect the running system until restarted. Scripts can be tested and debugged using the [File][Run Script] launching the Scriptor mechanism. TopVariable DeclarationsVariables must be declared before first use, this is usual in most programming languages, this allows memory to be allocated for storage and allows the type of variable to be defined so the appropriateness of subsequent assignment statements can be assessed.The variables can be assigned an initial value in the declaration statement, In the case of scaling algorithms, this value is set on the first pass only, and the current value remembered from one run to the next for that instrument, in that way counters (for example) can be initialized and subsequently incremented. The following variable types and associated declaration syntax are available.
More than one variable can be declared per statement by separating with a comma. All variable types can be declared as arrays by adding an array dimension in square brackets to the end of the name e.g. int results[40]; ConstantsAll variable types can be declared "constant" by prefixing with the keyword "const" the run time system will then check that the variable has not been modified. this is useful in making code more readable e.g.
const int server_room_netcommander=1;
const int boiler_room_netcommander=2;
if (get_input(server_room_netcommander,rack3_temp)>45) {
// Server cabinet 3 is overheating
....
}
Non VolatilesAll outer block variables can be prefixed "nonvolatile" the system will then remember the variables value, if VID is restarted, the PC crashes etc. this is useful foe scripts that keep running totals eg kWh counters. The keyword "volatile" can also be used for clarity but this is the default.Note: the data is stored keyed on Node,Port,Port Type and Script Name. If the same script is running on the identical port configuration on a second instrument there will be a clash in the variable store, resulting in unpredictable behavior!
volatile int RunTimeHourCounter,TickCount;
if (++TickCount==36000) {
// The 0.1S counter has reached one hour, reset it and increment hour counter
TickCount=0;
RunTimeHourCounter++;
}
Character arrays can be assigned strings, and subsequently used in place of quoted strings, the blank dimension "[]" will allocate just sufficient space for the assigned string. eg.
char email_boiler_faults[]="fixit@boilersRus.co.uk";
char email_my_address[]="sysmon@bigfactory.com";
...
...
send_email(email_boiler_faults,
email_my_address, "Alarm,
feedwater low",
"Feedwater header tank boiler room 2 level low");
Top
ArithmeticAll the usual arithmetic and comparison operators are provided. Processing of an expression is from left to right. Multiplication and division are processed before addition and subtraction. bracketed expressions are resolved first, brackets can be used to prevent any ambiguity.Top Built in FunctionsNetCommander InterfaceThe following functions are available for monitoring and control of the NetCommander inputs and outputs. All
variables are double precision types, most of these functions return and integer or boolean (1 or 0) value as a double precision
quantity. iv = input_rel(0); // Red Phase current iv += input_rel(1); // + Yellow phase iv += input_rel(2); // + Blue phaseinput_abs(port) As above; the node and port type are specified by the instrument configuration, "port" specifies the port number. input_scaled() Returns the scaled result from the attached instrument, there are no parameters. sync(node) This function waits until the next NetCommander Poll response has been received. event_set(node, id) Check to see if a VID event has been triggered, returns 1 if triggered otherwise 0. get_input(node, port) Get the value from an A/D converter input 0 .. FSD. get_switch(node, port) Get the value from a switch (binary) input returns 0 or 1. get_output(node, port) Get the value from an D/A converter output 0 .. FSD. get_state(node, port) Get the value from a NetCommander state variable. get_node_vidvar(node, port) Get the value from a VID node variable 0..65535 associated with node "node". get_vidvar(port) Get the value from a VID variable 0..4294967295. set_output(node, port, value) Set the value of a D/A converter output 0 .. FSD. set_switch(node, port, value) Set the value of a boolean switch output (1 or 0). set_state(node, port, value) Set the value of a NetCommander state variable. set_node_vidvar(node, port, value) Set the value of a VID node variable 0..65535 associated with node "node". set_vidvar(port) Set the value of a VID variable 0..4294967295. In all the functions above, "node" refers to a monitoring unit, this can either be the index number from the VID node configuration dialogue or more usefully (from the point of view of portability of the script between VID files) either an IP address or node name e.g. value = get_input(3,4); value = get_input("Turbo Generator 3",4); value = get_input("192.168.33.74",4); These examples all equally validly access port 4 of the node at IP address 192.168.33.74 the "node", "port" and "value" parameters can be any constant, variable or expression that resolves to a valid number. "node" (if numeric) and "port" are both based from 1. e.g. set_output("Turbo Generator 3", exciter_drive, 200); Date and Time FunctionsThe time functions (below) use a floating point number to express date and time. The integer part of the value is the number of days that have passed since 30/12/1899. The fractional part of a time value is the time of day in fractions of a day (from midnight), negative dates are before 30/12/1899 but are unlikely to be of any concern to us!Following are some example values and their corresponding dates and times:
0.00000 30/12/1899 12:00 am (mid-night)
2.75000 1/1/1900 6:00 pm
-1.25 29/12/1899 6:00 am
35065.50 1/1/1996 12:00 pm (mid-day)
The time has a resolution of about 10mS eg. int hour = int(get_time()/10000);All instrument scaling scripts are called 10 times per second, so get_time() will return a unique incrementing value on every call in a particular script, so lines like "if (get_time()==1200000)" will be safe, the value eg. 1200000 will never be skipped. date(date) Returns a string representation of the date, omitting the the argument i.e. data() returns the current date. print(date()); // print the current time and date convert_date("DD/MM/YY HH:MM:SS") converts a date/time string to the internal date format The following Snippet of code illustrates the operation of the time functions
double switch_off_time = convert_time("3/7/2004 17:30:00"); // switch off at this time
while(1) { // loop "forever"
while (get_date()<=switch_off_time) {
sleep(60000); // sleep for a minute
}
print("Plant Shutdown initiated at ");
print_time(switch_off_time);
switch_off_time += 1.0; // add one to do the same thing at this time TOMORROW!
plant_shutdown(); // call the plant shutdown procedure
}
or ...
while(1) { // loop "forever"
int t = get_time();
while (t<=1730) { // switch off at 5:30pm
sleep(60000); // sleep for a minute
}
print("Plant Shutdown initiated at ", t/100, ":", t%100 );
plant_shutdown(); // call the plant shutdown procedure
}
Arithmetic FunctionsAll the arithmetic functions use double precision arithmetic and have 15 digit resolution.abs(expression) Returns the absolute value of a floating point expression int(expression) Returns the integer part of a floating point expression fraction(expression) Returns the fractional part of a floating point expression exp(expression) Returns the exponential e to the power <expression>, used in infinite series averaging etc. logn(expression) Returns the natural logarithm of <expression>, ie. the inverse of exp(x) above. System FunctionsSleep(duration) Sleep for "duration" milliSeconds, this should be used in loops whilst waiting for a condition to occur, to avoid excessive CPU utilisation. e.g.
// wait for steam pressure to reach 6 Bar before opening turbine valve
mins=0;
while (get_input("Boiler Room", steam_pressure)<600) {
if (++mins>60) {
generate_alarm("Failed to raise steam after one hour!");
exit; // run-up sequence failed exit script
}
Sleep(60000); // wait for 60 Seconds (60,000 mS)
}
set_switch("Boiler Room",tubine_valve,1); // Open the turbine steam valve
print(format_string, ....)Prints uses a format string and expressions to print to the output window e.g.
print("Flour Silo %d is %d%%", silo_num, level);
This could possibly print:- "Flour Silo 3 is 27% full"
eg.
if (get_time()==0) {
// Log Kwh at midnight
syslog("Yesterdays total power consumption: %f Kwh", Kwatt_hours);
}
will create a log entry similar to:
22/06/2006 00:00:00:0 user: Mike > Yesterdays total power consumption: 145.47 Kwh syscommand(file[, arguments])
eg.
syscommand("scripts/delete_logs.bat","site3logs");
Where (in this case) "delete_logs.bat" could be a batch file to delete the VID log files in folder "site3logs", however, a batch file or other DOS command could be invoked to achieve just about anything.
com(port, format_string, ....) visible()
if (bunker_level[num]<33) {
print("Heavy Fuel Oil bunker ", num, " level below 33% consider arranging delivery");
visible(); // reveal console window
}
alarm( format_string, ....)
alarm_popup(alarm_texts[alarm_no]);
send_email(to,from,subject,body)
send_email("fixit@boilersRus.co.uk",
"sysmon@bigfactory.com",
"Alarm, feedwater low",
"Feedwater header tank boiler room 2 level low");
set_page(page)Programmatically set the current on-screen page (1..10). hold() This function is typically placed at the end of the script, it will wait with the screen visible, until it is manually closed. This allows printouts to be read before the window is closed. Normally the window is automatically closed on reaching the end of the script or an explicit exit(); function call. exit() Exit the script and close the script window. LibrariesLibraries of useful functions can be built up over time, this can be included into your script using the directive // pid_test.vcs PID Controller // All values used by the PID refer to 0..5V at the A/D inputs double Proportional_Gain=1.3; double Integral_Gain=1.2; double Derivative_Gain=0.025; double Acceleration_Feed_Forward=0.0; double Friction_Feed_Forward=0.0; double Velocity_Feed_Forward=0.0; double Bias=0.0; double Acceleration_Rate=3.0; double Set_Point=3.5; // Volts at A/D double Min_Output=0.0; // minimum output value allowed double Max_Output=5.0; // maximum output value allowed double Slew=0.0; // maximum output slew rate V/Cycle int Output_Hold=0; // in Cycles int Cycles=0; // terminate script after this no. of cycles (or never) char NC_Input_Node[] = "Temp controller 2"; int NC_Input_Port = 3; char NC_Output_Node[] = "Temp controller 2"; int NC_Output_Port = 3; #include "scripts\pid.inc"; // include the standard PID algorithm The control script above just declares and initializes variables for the PID controller, and then includes the main body of the PID logic from the file "pid.inc". In this way if the PID control algorithm is modified the modifications are automatically inherited by all the scripts that use it. Top Join LinesLines may be drawn on the screen to join or box instruments into logical groups. Lines are drawn using <ALT><Right Click> ... Drag mouse movements. Lines that are very nearly vertical or horizontal will snap to the relevant axis to avoid "jaggies". Lines ending very close to another line end will be automatically joined up. An existing line can be moved by dragging in the usual way, only one end can be dragged at once, the end nearest to the mouse on left-clicking will be selected. If the a moved line is joined to another line both lines will move together. This allows the easy drawing of boxes around instrument groups.
Top The Events SystemThere are essentially two events system, one handled locally in the VID software and one remotely in the NetCommander nodes. The remote event system is more limited in scope, one advantage is the remote system will operate autonomously of the VID software in the event of a communication failure, and will respond better to transitory events that may fall between VID poll periods. We shall describe the local system first as it is more comprehensive, the remote system has a subset of the functionality. Local Events systemThe system combines several "causes" to produce one or more "effects". In this example the event indicates that a server room door is open AND an intruder is present. This is further qualified by time to only occur outside office hours. In the example an Email is sent, an alarm will display and an output is made which could for example switch on an alarm bell.
The Check Boxes labeled Sunday, Monday Causes
EffectsThe effects are actioned when the logical combination of the event causes becomes true.There may be up to four effects for each event.
This is the basic action for drawing a local operators' attention to an event, a red pop-up box will appear on screen, with the requested message, and (optionally) a sound file will play, a browse button is provided to locate suitable files, the Windows Media directory is a good source of bells and whistles! A count is incremented on the pop-up display if the same alarm condition occurs more than once to avoid duplication and clutter of pop-up boxes. The pop-up boxes will cascade across the screen from top-left. Operator acknowledgement of the alarm will be recorded in the system log. Alarms will be cleared from the screen after an hour. ![]()
System LogsThe System log records all actions and conditions that effect the monitored system, All the operator's actions are logged, switch
settings, control knob movements, configuration changes etc. System events (are optionally) logged. All log entries are time stamped and in
chronological order. Log Cycling
With the log folder's contents listed in MicroSoft Explorer, clicking the "Name" tab will sort the files in alphabetic (and as the name structures are chosen to do so) Chronological order. VID also maintains chart data logs with a similar naming convention for time-cycled logs. Top VID Data Views
|