
Reliance 4 – Example Projects
Here you can find all the example projects supplied with the Reliance 4 SCADA/HMI System. To view the detailed description of an example, please click on its name. To download the example, please click on the Download button next to the example. All example projects below are a standard part of the Reliance 4 Installation Package.
Reliance 4
Promotional Materials
Complete archive
The ZIP archive contains all example projects shipped with the Reliance 4 SCADA/HMI system. Unpack the archive contents to the folder where you have installed Reliance 4.
The following tables contain the example projects divided into the thematic groups.
Demos
The AirCondition interactive visualization project is designed to demonstrate function of the basic graphical components. Simple scripts are also used in the project to simulate the environment in an office. Project is translated into several languages (English, Russian, Czech, Dutch and Turkish).
You are enabled to control the input and output fan, recuperator, cooler, heater, humidifier and to simulate the cleanliness of input and output filter or simulate errors. Simple physical model of the office environment (temperature and humidity) is simulated with three scripts.
The BoilerRoom interactive project is designed to demonstrate function of basic components e.g. button, display, active picture, pipe, progress bar, real-time trend, etc. The project simulates heating of water in the gas boiler. The project also demonstrates usage of alarms, trends, reports and event and periodic scripts. In the project are defined several users with different access rights (Admin, User1, User2, Service – you can log on with an empty password). Similar visualization project is step by step created during Reliance 4 training lessons.
For version: 4.0.19The Factory interactive project is designed to demonstrate function of basic components (button, display, pipe, picture, progress bar, etc.) to visualize simple chemical factory. Four basic chemical ingredients are mixed together in the boiler (mixing ration can be defined either manually or via recipes). The final product is stored in the tank and gauged to moving trucks. The truck is represented as a simple picture and progress bar grouped together. The movement of the truck is achieved by dynamically changing X coordinate in a script.
The project starts in the automatic mode (the visualization is controlled by scripts), but you can switch to the manual mode by clicking on the button located on the bottom part of the screen. All important process values are logged into the data table (database) so you can easily create trend or report.
The Tannery project demonstrates usage of the Reliance system to control and visualize chemical process of leather tanning. The project contains about 250 tags and it is based on the real industrial process.
After the project is started, please select upper left drum to view an actual visualization. The screen contains system of tanks connected via pipes, valves and pumps. The Tray located at the top contains control commands (Pause, Restart, Recipe) and configuration commands (Settings). You can use the "Time shrink" option to run the simulation in faster than normal speed. The visualization runs in an automatic mode (controlled from scripts).
The SMS project is designed to send and process received SMS messages via scripts. To successfully run the project it is required to have the SMS driver licence and to have connected GSM modem (e.g. Siemens M20 Terminal).
Project contains periodical script StatusSMS and two event scripts – RecievedSMS and SendSMS. Configuration of the modem communication options including SMS service center number is done on the computer's 'SMS' tab in the 'Project structure manager'.
Components
The DataGrid project is designed to demonstrate basic features of the Data Grid component. There are defined several tags in the System device. The Array_Value, Array_FgColor and Array_BgColor tags define values and colors of the individual grid cells. Tags Offset, Position and RowCount control global behaviour of the component. The Array_FgColor tag defines font color and the Array_BgColor tag define background color of the individual cells. These tags are initialized in the scripts.
After the project is started in the runtime software, you are enabled to set values in the individual cells.
The DataTree_ControlArea project demonstrates usage of Data Tree component in the visualization of the control area structure. Tags of all basic data types which will be listed in the tree structure (the Tags subtree) are defined in the System device. Two data tables are also defined in the project (linked to the tags defined in the System device). Also two trends and reports are defined to visualize historical data. Actions to view current alarms/events, tables and trends are defined in the Action Manager. These actions are connected to the nodes of the tree. The Data Tree structure simulates the structure of the control area.
The Display type cell is used to view parameters of tags (you can also edit tag values in the runtime software). To activate commands or change structure of the Data Tree component it is required to log on. If you log on as the "Edit" user, you are enabled to edit Data Tree structure (password is not required). If you log on as the "Command" user you can execute actions (such as view trend, report or alarms/events list).
The DataTree_Localized example project demonstrates usage of the texts translated into several languages in the Data Tree component. The component is used to view a list of Actions. The node descriptions are Aliases which can be localized into different languages. The tree nodes are connected to actions. An action can be started with a mouse double click on the alias (the node description).
For version: 4.0.19The DataTree_Grid project shows how to display non-array tags in the form of data table. Project contains ten virtual devices (defined in Device Manager). All virtual devices contain identical set of tags. One data table is defined for each virtual device to log tag values to (in Data Table Manager). Trends used to visualize the historical data are defined in the Trend Manager.
An action is defined for each trend in the Action Manager. The actions are connected to the Data Tree nodes. To each node are associated cells that are connected to tags defined in virtual devices (tag values are displayed in the cells).
If the project is running in the runtime software, you are enabled to change the tag values and to show trends via actions (to show defined trend double click on the trend icon).
The RealTimeChart_Stacked project demonstrates how to configure the Real-time chart component to show horizontal stacked column chart. The column of the chart consist of two differently colored parts. You can change the size of the parts via Display components.
The Real-time chart component is configured in the following way:
1. Set parameter "Real-time Chart Properties > Series > Properties > Type" to 'Horizontal bar'.
2. Set parameter "Real-time Chart Properties > Series > Data > Y-value" according to example for each point.
3. Set parameter "Real-time Chart Properties > Static > Properties > Series > Format > Multiple Bar" to 'Stacked'.
The SimpleTimeProgram project demonstrates how to use the Simple Time Program component. The DataArray tag which is used to store time program configuration data is defined in the System device. The remaining tags (auxiliary tags) are used only to visualize this data in the example.
The DecodeData event script (designed to extract the information from the DataArray tag to auxiliary tags) is defined in Script Manager. To configure the time program, in the runtime software click on the 'Configuration' button. New configuration data is automatically decoded and displayed in the visualization window. The DataArray tag values are also displayed in the table on the left side of the visualization window.
The IPCamera_Axis project is designed to demonstrate basic features of this component – that is playback and recording data received from Axis IP camera connected to the computer. To successfully run the example project, it is required to have IP camera drivers installed on your computer (you can find the installer of the drivers in the Reliance 4 Add-On Pack).
The two tags are defined In the System device – "record" and "standby" – both Bool type. The visualization window contains the Axis IP camera component and two button components. Before the project can be started in the runtime software, it is required to enter the camera's URL or IP address and login information for connected IP camera in the component's settings (Function tab).
The IPCamera_Vivotek project is designed to demonstrate basic functions of this component – that is playback and recording data received from Vivotek IP camera connected to the computer. To successfully run the example project, it is required to have installed IP camera drivers on your computer (you can find the installer of the drivers in the Reliance 4 Add-On Pack).
There are defined "Input" and "Output" tags (World type) and "Record" and "Standby" tags (Bool type) in the System device. The visualization window contains the Vivotek IP camera component and four buttons. Before the project can be started in the runtime software, it is required to enter camera's URL or IP address and login information for connected IP camera in the component's settings (Function tab).
Devices
The OPC_EmbeddedServer project demonstrates how to connect Reliance runtime software to OPC server that is not running locally. The 'EmbeddedDevice1' device is defined in the Device Manager, the type is OPC. The parameter "OPC server Prog ID" has to be set to the OPC server identifier (you can select it from local network). The Project Structure Manager contains a computer named 'PC1' with the 'EmbeddedDevice1' connected to it. On the "Channel1 > Driver" page is selected connect to driver "On remote computer". Computer name is set to EmbeddedDevice1, which is second computer defined in the Project Structure Manager. This computer's only purpose is to identify remote computer – it holds an IP address of the OPC server (the Basic page).
Note: This type of connection to remote OPC server is not advised because of certain disadvantages. The recommended way to connect an OPC server is via local runtime software – this means that the Reliance data server runs on the same computer as the OPC server and connection to other computers of a visualization project is provided via Server Connection Groups or via thin clients.
The OPC_DeviceCommStatus project demonstrates how to determine the state of an OPC server via test a tag quality. You have to configure 'OPCDevice1' in the Device manager according to your local OPC server. The OPC Group of this device contains an OPC server's internal tag. This tag is periodically evaluated in the script (if tag quality is not 'Good', it means that an OPC server is not connected). This project uses the 'Random_UInt1' tag for this purpose. The project also contains the 'OPCDevice1Connected' tag, which is set in a script, and is linked to the 'Active text' component in the visualization window.
The Script manager contains the 'Define' script, which is performed at the initialization of a script engine thread, and defines the procedure that evaluates the quality of a tag (it's more effective to define a procedure, than to write the code directly into script's body). The script reads the 'Random_UInt1' tag value with the 'RTag.GetTagValue' method. Each method of the Reliance object sets the value of the 'RError.Code' variable. If the value of this variable is not equal to zero, an error occurred. To ensure that 'Bad' quality of the value is considered an error, the "Project Options > Scripts > Other > Treat invalid tag value as error" parameter must be enabled. The procedure is called from the 'UpdateOPCDeviceCommStatus' script with the period of one second.
The Teco_Databox project shows how to transfer data from/to the Databox memory of the Teco device. The project contains the 'Teco' device named 'Tecomat1' with defined IP address. The 'Enable reading/writing Databox' parameter of this device is enabled and other parameters on the 'Databox' tab are connected to the respective tags. The 'Control' tag controls data transfer from/to the databox (0 – ready, 1 – read, 2 – write). The 'Status' tag is connected to the 'Active text' component in the visualization window and indicates what is being done with the databox (Ready/Reading/Reading completed/Read error/Writing/Writing completed/Write error). The 'DataLength' and 'DataOffset' tags define accessed data range. The current data range is accessed via 'DataBuffer' tag, which is 'Array of Byte' type.
The visualization window contains the 'Databox data' table that displays the values of the 'DataBuffer' tag and corresponding index of the data in the databox. The 'IndexArray' tag is updated in the 'InitIndexArray' script every time the databox is accessed (read or written).
The Teco_ModemComm project shows how to make a connection to the Teco PLC via modem connected to computer's serial port. Word type tags used to control state of the modem and the PLC device are defined in the System device. The 'Modem1Control' tag controls 'Modem1' – it connects the Combo box component in the visualization window and the Modem1 object in Project structure manager. The 'Tecomat1Control' tag controls 'Tecomat1' – it connects the Combo box component in the visualization window and the the 'Channel1' object in Project structure manager. The Tecomat1Status tag, which is also connected to 'Channel1' object, is processed in the 'Tecomat1StatusChanged' script and the result is shown in the visualization window. Similar tags exist for 'Modem2' and 'Tecomat2'.
In Project structure manager 'Channel type' of the 'Tecomat1' device is set to 'Dial-up (modem)', the 'Phone number' parameter is set, and on the 'Advanced' tab, the 'Tecomat1Control' and 'Tecomat1Status' tags are connected. The 'Modem1' object is defined in the 'Modems' folder and the 'Modem1Control' tag is connected to 'Control' parameter of this object. Script manager contains the 'Tecomat1StatusChanged' which uses bit masking to extract information about device state from the 'Tecomat1Statuts' tag. Similar objects are defined for the 'Tecomat2' device.
The AMiTDemo project is designed to demonstrate basic features of the AMiT PLC connected to the visualization – that is reading/writing tag values, logging values to a data table, bit access etc. In the AMiT1 device (defined in the Device Manager) are defined tags containing current values (Sawtooth_1, Sawtooth_2, Sine, ARC_index), current binary values (Bit1, Bit2, Bit3) and group of array type tags used to display Real-Time Chart. Current tag values are logged into the Database1 data table and can be displayed in Trend1 which is defined in the Trend Manager. Trend1_RT is defined in the Real-Time Trend Manager and displayed in the visualization window.
The main visualization window contains Display components connected to the Sawtooth_1, Sawtooth_2 and Sine tags. You are enabled to set the values of these tags even if the AMiT hardware is not connected (online mode have to be disabled in "Project Structure Manager > PC1 > AMiT1 > Basic > Online") e.g. for testing purposes. If the device is not in online mode, tag values can be set, but a connection with the hardware is not made.
The DeviceCommErrorAlarm demonstrates how to replace the alarm automatically triggered by device communication error with a custom alarm defined through the Device Manager. This alarm will remain active for the duration of the communication error. This is the difference from the alarm that is automatically triggered by Reliance when an error in communication with a device occurs (the alarm is triggered but does not remain active; Reliance does not check to see if the error condition still exists - this is a drawback).
In the Device Manager, the tag "CommError" of type Bool is defined. It is an internal tag in the device "Modbus1" (not a physical tag from a PLC). In addition, there is an alarm named "CommError" in the same device which is linked to the tag "CommError". The alarm is triggered by the leading edge of the tag value (the off-to-on transition).
In the Project Structure Manager, the device "Modbus1" is connected to computer "PC1". The communication options are defined through the object "Channel1" that represents a communication channel. On the "Advanced" page of the channel properties, there are links to scripts to be executed when communication with the device is started, interrupted due to an error, and restored. To each script, an integer parameter is passed that represents the ID of the device "Modbus1" (a value of 1). If the project contained multiple devices, there would be the same scripts selected on the "Advanced" page (only the device ID numbers passed as parameters would differ).
In the Script Manager, you can find a script named "Define" that contains the definition of the procedure "SetDeviceCommError". The script "Define" has the "Run on thread initialization" option active in order to execute prior to any other script supposed to run in the same thread of execution (the "Advanced" page of the "Properties" pane). The procedure "SetDeviceCommError" is called from a script named "DeviceCommError" which executes every time that an error in communication with the device occurs, and from a script named
"DeviceCommStarted", which executes every time that communication with the device is started or restored.
The procedure "SetDeviceCommError" has the following parameters:
DeviceId: ID of the device
CommError: the value of True or False, which determines if there is an error in communication
The procedure "SetDeviceCommError" first converts DeviceId to device name and then writes the value of the CommError parameter to the internal tag "CommError" in the respective device by calling the "RTag.SetTagValue" method. This results in triggering a new alarm or ending the existing one.
Network Applications
The BoilerRoom_ClientServer project adds the network functionality to the BoilerRoom demo. A new computer named 'Client1' is added to the project in the Project structure manager. The already defined users, trends and reports are connected to this computer (objects are only accessible from a specific computer if they are connected to it). New 'Server Connection Group' with new 'Server Connection' is created (the 'Server Connection' is named Server1 and parameter 'Server computer' is set to Server1). This connection is used to connect the BoilerRoom1 device and the BoilerRoom1 data table to Client1 computer (the "Data transfer" parameter is set to 'Network' instead of 'Direct' and directories in Data Table object are set to $(HistoryData)\Client1\). The Server1 > Basic > IP Address is set to 127.0.0.1, which is the local address (if you want to operate example via network, set this parameter to the real IP or hostname).
The server part of the project has to be started via Reliance Control Server program (set the parameter "Project Options > Runtime > Start and Shutdown > Computer name" to Server1). The client part of the project has to be started via Reliance Control software (set the Computer name parameter to Client1).
The BoilerRoom_RedundantServers project adds a second server computer to the BoilerRoom_ClientServer project. This computer is used as a backup and load distribution system (also a second client computer is added). Two new computers Client1 and Client2 are created in the "Project structure manager" via duplication of two existing computers. Second Server connection (pointing to Server2) is added to Server connection groups of the Client1 and Client2 computers. The connection priority is set in such a way, that Client1 is primarily connected to Server1, and Client2 is primarily connected to Server2.
If one server is not available (e.g. Server1 is terminated), Client1 automatically connects to the Server2 computer. If a client is not connected to its primary server, availability of primary server is periodically tested. In runtime software, you are enabled to see the connections to/from runtime program on 'Network connections' tab in the 'System Information' tool.
The BoilerRoom_MultipleServers project adds to the BoilerRoom_ClientServer example second server that represents an independent boiler room and demonstrates how to configure the client computer to access data from both servers.
The second server is created duplicating the Server1 computer and all attached objects, such as BoilerRoom1 device and visualization window, data table, trend, real-time trend, report, the BoilerRoom1_Simulation script and all actions. The button in the TopTray window that enables the user to switch between visualization of the first and the second boiler room is also duplicated. Required server connection objects are created in the Project structure manager (one connection for each server). To disable the TopTray window on the server computers, the window is added to the "Disabled windows" list on the "Display" tab.
To start the project in a runtime software, create a shortcuts via the "> Project > Create Shortcut" command (for Client1 use Reliance Control and for Server1 and Server2 use Reliance Control Server).
The BoilerRoom_MobileClient project is based on the BoilerRoom demo. The project is designed to run on the PDA devices – it contains visualization windows (PDA - Overview, PDA - Trends and PDA - Boiler) designed for a limited resolution. The windows can be viewed on mobile devices via Reliance Mobile Client (program designed to run on Windows CE
operation system with .NET Compact Framework 2.0 installed). You can also test the example in a Windows CE emulator.
You can find the computer (configuration/node) named 'PDA' in the Project structure manager (all required objects such as user, trend, report and data table are connected to this computer). The 'Display > Initial window' parameter of this computer is set to the 'PDA - Overview' window, it defines the first shown visualization window.
To access the visualization on a mobile device, the device must be able to connect to the data server via network. In this example the data server computer is named 'Server1'. All scripts run on the server computer and in real application it would be connected to the PLC device. Before you can start the data server (Reliance Control Server or Reliance Server), export the PDA computer via the 'Project > Export for remote users" command. If data server is started, connect to it's web page from the PDA device and install the Reliance Mobile Client program files to the mobile device. For additional information refer to the Reliance Mobile Client documentation.
The SendEmail project demonstrates how to send an email message from a script. Before any email can be sent, you have to set the information about SMTP server. This is done in the Project structure manager on an E-mail tab for each computer of the project.
The main visualization window of the project contains the display components where you can define recipient, subject, attachments and email body. The "Send Email" button activates the script that sends the email. The core part of the script is the "RInet.SendMail" method.
The ThinClientListFromScript project demonstrates how to access the list of connected thin clients from a script. After the project is started in runtime software, main window contains the Display component with a number of connected thin clients and the Data grid component with detailed information about all connected thin clients. The data grid component is connected to array type tags, that are periodically updated in the GetThinCientList script. The script is started every 5 seconds and uses the "RWS.GetThinClientList" method to load the information about thin clients to the ClientList array.
For version: 4.0.19The ThinClientRequestHandlingFromScript project demonstrates how to handle requests from thin clients (Reliance Web Client or Reliance Mobile Client). In the "Project Options", the "Web" section, there is the "HandleThinClientRequest" script set to be executed when thin client request is received by a data server (Reliance Server or Reliance Control Server). Client request information (request type, unique session identifier, client IP address, etc.) is obtained using the "RScr.GetCurrentScriptDataEx" function. This information is written to the corresponding tags in the "System" device. Values of these tags are shown in components of Display type in the visualization window.
For version: 4.1.6Reports
The CustomReport_Text project is a simple example of the text custom report. Five tags that contain water level value in a tank are defined in the system device. The text type custom report is defined in the Report Manager. TextReport contains five items linked to the tags with the water level value. File Template.txt (custom report template) is located in the <Project>/Main/CustomReports folder. In the runtime software you can set the tags value and generate text report based on the current values.
For version: 4.0.19The CustomReport_HTML project demonstrates how to use a web page as a template for the custom report. The project contains several sets of tags organized to folders according to the technological unit (see Device Manager). A Custom Report named WebReport is defined in the Report Manager. The custom report contains items connected to the tags. Template files are located in the <Project>/Main/CustomReports (project folder). This folder also contains the Microsoft Office Word document which is a source for the custom report template. The visualization window contains the Display components forming a table. You can set the tag values via this table.
For version: 4.0.19The CustomReport_Form project shows how to use the FastReport type custom report to print a simple form. The main visualization window contains a form assembled of the 'Edit box' components. The components are linked to corresponding tags defined in the 'System' device. The 'CustomReport_CertificateOfPosting' object is defined in the 'Custom report manager' and contains items corresponding to the tags in the 'System' device.
You are enabled to enter the values to the form in the runtime software. To switch among the 'Edit box' components use the 'Tab' button. To preview and/or print the form press the 'Display' button. the project also demonstrates multi language support. It is localized into the Czech and English languages. If you switch the language of the project, the language is also changed in the texts of the custom report.
The CustomReport_ADOChart project demonstrates how to use the FastReport features to access an SQL database and to draw a trend based on this data. The TimeRange_From and TimeRange_Till tags (used to specify time range) are defined in the Device manager. Also a sample tag named 'Word' is defined in this manager. The SQL type data table defined in the Data table manager is used to log the values of the sample tag. The SQL server is named "(LOCAL)\SQLEXPRESS" (it is a standard name set when 'Microsoft SQL Server 2005 Express Edition' is installed with 'setup.bat'.
A custom report named 'Report1' is defined in the Custom report manager. The 'ADODatabase' component is used to make a link between a custom report and an SQL database. You have to set the database parameter of this component similar to 'Connection string' in the "Project Options > Project > SQL" dialog. The values from the data table are accessed via dynamically generated SQL query (the query is generated in the FastReport script).
After SQL connection is properly configured, you can start the project in the runtime software. Log some records in the database (the value of 'Word' tag is logged into the data table every 6 seconds). Select 'Time range' and display the custom report via the 'Show Trend' button.
The CustomReport_ADODatabase project shows how to use the FastReport type custom report to visualize the data from an SQL database in the form of a data grid. Three virtual devices are defined in the Device manager. Each of this devices contains five tags (Tag1, ..., Tag5). Also three SQL type data tables are defined in the Data table manager. Each of this tables contains items corresponding to the tags in the virtual devices and has different settings of the 'Time stamp base' parameter. The SQL server is named '(LOCAL)\SQLEXPRESS' (it is a standard name set after the 'Microsoft SQL Server 2005 Express Edition' server is installed with 'setup.bat'.
Three custom reports designed to display data from corresponding virtual devices are defined in the 'Custom report manager'. The reports differ in the way the time stamp is decoded. Depending on the way a time stamp is logged the Int64TimeToDateTime or UTCDateTimeToLocalDateTime conversion function is used. The 'ADODatabase' and 'ADOTable' components are used to make a link between the custom report and the SQL database. Set the database parameter of the 'ADODatabase' component similar to 'Connection string' in the "Project Options > Project > SQL dialog".
In the runtime software, you can set the tags values logged into the database and preview the reports via corresponding buttons.
The CustomReport_EquithermalCurve project is a simple example of how to print an equithermal curve via custom report (FastReport). Fourteen tags that define the equithermal curve are defined in the Device manager. The FastReport type custom report is defined in the Custom report manager – the items of this report correspond to the tags defined in the 'System' device. You can view the report template via the 'Edit Report' command. The template file is located in the <Project>/ Main/ CustomReports folder. At runtime you can change the tag values in the visualization window via Equithermal curve or via Display components.
Following script is used to draw the trend in the FastReport template:
ECChart.SeriesData[0].XSource :=VarToStr(<TempA$6>)+';'+VarToStr(<TempB$7>);
ECChart.SeriesData[0].YSource :=VarToStr(<TempEkvA$10>)+';'+VarToStr(<TempEkvB$11>);
Embedded Objects
The BoilerRoom_WindowTemplate project demonstrates using of data structures and window templates. The visualization represents a boiler room. Information related to a particular devices such as pump, valve or boiler is arranged into a data structures (Pump, Valve, Boiler). These elementary structures are then contained in a more complex one corresponding to the whole boiler room (BoilerRoom).
The structured tags named BoilerRoom are defined within the BoilerRoom1 and BoilerRoom2 devices (the tags are based on the BoilerRoom data structure). For the Pump, Valve and Boiler data structures are designed respective window templates (Pump, Valve, Boiler). These elementary templates are then contained in a more complex template corresponding to the whole boiler room (BoilerRoom). The BoilerRoom template is then repeatedly used in normal visualization windows (BoilerRoom1, BoilerRoom2).
Scripts
The ScriptTypes project demonstrates usage of the different script types. The main visualization window contains five panes, each demonstrating features of one script type. The first pane introduces the "Data change" script – if you change the value of A or B, C is automatically recalculated. The second pane introduces the "Periodic" script – the angle value is periodically incremented. The third pane introduces the features of the "Key" script – if you press the F5 button a dialog window is shown (all scripts run in the same thread and therefore other scripts are paused if the dialog is shown).
The fourth pane introduces the "Condition" script – if you enter a number bigger than 10 into the display component, the dialog window is shown. The last pane introduces the "Event" script – the buttons are linked to the binary tags. Alarm/event is defined and starts if the tag value changes from logical 0 to logical 1. A script is linked to the event of Alarm/event start. The script reads the text of this alarm and shows it in a dialog window.
The GetCurrentScriptDataEx project shows how to pass a parameter from the Reliance system to the script and how to access it inside a script. The ScriptParamValue LongInt type tag, defined in the project, is linked to a display component. The EventScript script defined in the Script manager is linked to three buttons located in the visualization window. If you click the button, the number associated with the button is passed to the script, accessed inside the script, stored in the ScriptParamValue tag and shown in the Display component located below.
For version: 4.0.19The GetFolderContents project demonstrates how to list the contents of a directory. The main visualization window contains the Display component (enter the name of a directory you want to list), the Button component (which starts the GetFolderContents script) and the two Table components. After the script is finished, the table to the left shows subdirectories and the table to the right shows the file list.
The GetFolderContents script defined in the Script manager uses the "Scripting.FileSystemObject" object to get the directory listing. The SubFolderNames and FileNames array tags are populated with the names of subfolders and files in this script. The SubFolderCount and FileCount tags hold the length of the respective lists.
The DeclareArrayVar project shows how to define and use the global and local array variables. Main visualization window contains two buttons that start the UseGlobalVar and UseLocalArray scripts.
Event script named 'Define' that declares the global variable GlobalArrayVar1 is defined in the Script Manager. This script is executed only once and prior to all other scripts, because the parameter "Run on thread initialization" on the Advanced page is enabled (the script is also executed upon a possible forcible termination of the thread ). Each global array variable has to be declared only once to avoid the "Type mismatch" error.
The UseGlobalArrayVar script writes the data to a global variable named GlobalArrayVar1 whereas the UseLocalArray script modifies only a local variable named LocalArrayVar declared inside the DoSomethingWithLocalArrayVar procedure.
The MoveTagValue project demonstrates how to copy a tag value between two devices. The project contains the AfterStartProject script. The script starts on the Runtime software start (see "Project options > Scripts > Other > After start project"). This script initializes the DataTime tag. The remaining scripts are event scripts linked to the buttons in the main visualization window. The scripts show how to use the 'RTag.MoveTagValue' method for the tags of different type. Visualization window contains the Display components showing values of source and target tags.
For version: 4.0.19The MoveTagElementValues project demonstrates how to use an event script to copy the first 10 elements from WordArray20 array to the positions 50-59 in the WordArray100 array. The RTag.MoveTagElementValues method is used to copy the values of array type tags. The script is started via a button in the visualization window.
For version: 4.0.19The LogMessage project is designed to show you how to log a text to a file form a script. The main visualization window contains a button, that starts the 'LogMessageTest' script, that contains the 'LogMessage' procedure. This procedure is defined in the 'Define' script (also the functions for custom date and time formatting are defined in this script).
Access to the file is done via object named "Scripting.FileSystemObject", the "OpenTextFile" method of this object is used. If this method is called with the filename as a parameter, a new object is created (the numerical parameter defines the opening method, 1 – read only, 2 – write, 8 – append, and the logical parameter defines whether the file should be created if it doesn't exist). Now you can call the 'WriteLine' method of this object and write an arbitrary text to the file.
If the button in the main visualization window is pressed, a new directory named 'Logs' is created in the <Project> directory. The "ScriptLog.txt" file is created in this directory. The file contains the lines with a current date, time and example text.
The ScriptDebugging project requires a debugging tool installed on your computer. You can use the Microsoft Skript Debugger application (it is shipped with the Reliance system as a part of the Add-On Pack). The visualization window contains two buttons that enable/disable script debugging function (this is done in the window registry via actions that execute the "ScriptDebuggerEnabled.reg" and "ScriptDebuggerDisabled.reg" files). Runtime program has to be restarted before the change takes place. Since the Reliance 4.1.3 you can also enable/disable the script debugging function via "Environment Options" in the development environment. If the debugging is enabled and the "Start script" button is pressed, the debugging tool is opened.
For version: 4.1.3The DownloadAndSaveFile project shows how to download and save the file defined by an URL to a local computer. The project's main functionality is done in the 'DoDownloadAndSaveFile' script. This script downloads the file based on the string values of the 'FileURL' and 'FileName' tags. The 'FileURL' tag is linked to a display component in the visualization window and defines the source file name and address (the URL has to be entered with the leading "http://"). The 'FileName' tag is linked to the second display component and defines the target file. To start the script press the 'Download file' button.
The CreateObject command is used to create and instance of the "MSXML2.XMLHTTP" object. The 'open' and 'send' methods of this object are used to make the connection. The file is saved to the disk via methods of the "ADODB.Stream" object.
The ExtractBits project shows how to use scripts to extract bits from an integer tag and store the bit values in tags of type Bool.
In the Device Manager, there are the following tags defined within the "System" device:
"Status01" of type Byte, "StatusBits01" of type "StatusBits" which is a data structure (defined via the Data Structure Manager). The tag "StatusBits01" is a structured tag and contains several nested tags of type Bool to which a script will write the value of the respective bits of the tag "Status01".
In the Script Manager, you can find a script named "Define" that contains the definition of the procedure "ExtractBits". The script "Define" has the "Run on thread initialization" option active in order to execute prior to any other script supposed to run in the same thread of execution (the "Advanced" page of the "Properties" pane). The procedure "ExtractBits" is called from a script named "ExtractBitsFromStatus" which executes every time that the data of the tag "Status01" changes (see the properties of the script "ExtractBitsFromStatus"). The following parameters are passed to the procedure "ExtractBits":
Name of the device in which the source tag is defined: "System"
Name of the source tag: "Status01"
Name of the device in which the target tag is defined: "System"
Name of the target tag (including the character used to separate a structured tag and its nested tags): "StatusBits01/"
Array containing the numbers of bits to extract: BitNumbers_StatusBits01 = Array(0, 1, 4, 5)
Array containing the names of the fields of the data structure "StatusBits" (in the same order as bit numbers in the array BitNumbers_StatusBits01): TagNames_StatusBits01 = Array("ManualMode", "EmergencyMode", "CheckDevice", "Error")
To display the data of structured tags of type "StatusBits", the same-named window template is used (see the Window Manager). This template contains Display components linked to particular fields of the structure "StatusBits". The template is embedded into the window "MainWindow" through a Container component. The window also contains a Display component that displays the value of the tag "Status01" and enables you to change it.
The solution described above has proven to be very convenient. There may be many tags like "Status01" each of which contains status information on a machine used in the industrial process being visualized. It is very easy to add a new structured tag of type "StatusBits", a new script, and call the procedure "ExtractBits" with the respective parameters.
Databases
The AppendRecordToDb project demonstrates how to use the RDB.AppendRecord method to log data to the defined data table. The LongInt, String and Word named tags are defined in the System device. The values of these tags will be logged into the data table. The following tags are also defined in the System device: RecordTimeStamp containing the current time (the RSys.Now method) and BlockSamplingData which is linked to a button in the visualization window (you can enable/disable data logging with this button).
The 'Data1' data table contains the three items connected to the three tags mentioned above. A sampling method is set to "Script-controlled". Time stamp source is set to RecordTimeStamp tag and Blocking tag is set to BlockSamplingData. The SaveRecord event script is defined in the Script manager. This script sets the RecordTimeStamp to the current time and calls the RDB.AppendRecord method. Press the "Save record" button to start the script.
The AppendRecordsToDb project shows how to manually (randomly) write data to a data table via script. One record (row) in the 'Data1' data table contains the values of the following tags (columns): RecordTimeStamp, LongInt, String and Word.
The data that will be logged into the data table is stored in the array type tags (LongInt5, StringArray5 and WordArray5). The 'RecordTimeStamp' value is assembled from the MinuteArray5, HourArray5, DayArray5 before the record is logged into the data table. The 'BlockSamplingData' tag is connected to the 'Stop bit' parameter of the data table and to the corresponding button in the visualization window.
A sampling method of the data table is set to 'Script-controlled' – this means that the data can be logged only from a script via the AppendRecord command. The time stamp source is linked to the 'RecordTimeStamp' tag – records don't have to be logged in a chronological sequence.
The InitArrays script is defined in the Script manager and initializes the array tags. This script is executed at the project start via the AfterStartProject script. The SaveArray script is started via the 'Save array of records' button in the visualization window and performs an actual logging of records to the data table. Values of the RecordTimeStamp, Word, LongInt and String tags are set and the RDB.AppendRecord method is called inside the "For" statement (this sequence is performed five times). You can view the data logged in the data table via the trend or report viewer.
The RandomAccessToDataTable project demonstrates the manual (random) access (read/write) to the DBase type data table. The 'Records' data table is defined in the Data table manager. The 'Data acquisition method' parameter of this data table is set to 'Not specified' and the 'Archive files' parameter on the 'Advanced' tab is set to 'None'. The table contains the following items: Number, Length, Color and Material. The items are linked to corresponding tags. The records in the data table are accessed manually from a script. You can view the records stored in the data table via record viewer (the 'Report1' report).
The script that contains the procedure and function definitions is defied in the script manager. The script is named 'Init' and it is executed only once before all other scripts in a thread. The RDb.CreateTableObject command is used to create an instance of an object that will be used to access the 'Records' data table. For example to add a new record to the data table (the AppendRecord procedure) the following methods of the object are called: OpenTable, Append, SetFieldValue, Post and CloseTable. For more information on the TTable object see the 'Scripts' help file.
The LogDataToSQLServer project demonstrates how to log tag values to an external SQL server and how to visualize this data in the trend viewer. The example requires access to an SQL server (MS SQL Server is a part of the Reliance 4 Add-On Pack).
Several Word type tags are defined in the System device. Tag values are logged with a period of 5 seconds to the 'Pressures' and 'Temperatures' data tables defined in the Data Table Manager (the database type is SQL). The 'SQLServer' connection is defined in the project options on the SQL page (you may have to update some of the parameters). Notice that defined SQL connection is selected in the Project Structure Manager as a parameter for connected data tables (the SQL connection parameter on Basic page).
The main visualization window contains the four edit boxes connected to the Word type tags and two buttons that display trends.
The SQLFromScript project demonstrates how to read and write data from/to SQL database via methods of the "ADODB.Command" and "ADODB.Connection" objects. The "ReadDataFromSQLTable", "WriteDataToSQLTable" and 'Define' scripts are defined in the project. The first two scripts are event scripts calling procedures defined in the 'Define' script (the script is started only once before all other scripts at the process – script engine – initialization). You have to set the "Connection string" in the 'Define' script according to your SQL server. show The usage of SQL commands SELECT and INSERT is demonstrated in the procedures.
For version: 4.0.19The ODBCFromScript project shows how to access the ODBC databases in the Reliance 4 SCADA/HMI system via scripts. The project contains a script named 'Define', that contains the ReadDataFromSQLTable and WriteDataToSQLTable procedures. The procedures work with the "ADODB.Connection" object and related objects. The procedures are called from the ReadDataFromSQLTable and WriteDataToSQLTable scripts with parameters c_ConnectString and c_TableName. You have to set this parameters according to your database. To help you construct the c_ConnectString constant, see the "Project Options > SQL > Connection string" field (configure the connection via the "Edit connection string" command before you copy the string).
For version: 4.0.19Data Exchange
The ExportToCSV project demonstrates how the scripts can be used to export the historical data into a text file (CSV). The project contains the AfterMidnight time script that is started each day one minute after the midnight (you can simulate the start of this script if you click on the button in the visualization window). The script starts the Temperatures_Air_ExportToCsv and Temperatures_Water_ExportToCsv scripts. These two scripts call the ExportYesterdayArchiveDbTable procedure with the required parameters. This procedure (which is defined in the 'Define' script) is designed to read the data from a data table and to export it into a text file. The project also contains a group of SmallInt type tags and two DBase data tables with periodical data logging. The exported files are stored in the <Project>\History\Data\xxxx\ folder, where xxxx represents a year.
For version: 4.0.19Project ImportFromCSV demonstrates how to use the scripts to import data from a text file (CSV). The project contains the following tags: RoomNumber, Occupied, Date and Time. The ImportCsvFile event script is designed to load the data from a file to these tags. The visualization window contains a button that starts the script. After the script is finished the four Display components contain the data imported from the <Project>\Import.csv file.
For version: 4.0.19The ExportImportXLS project is designed to demonstrate how to access the MS Excel files via COM interface (the MS Excel application has to be installed on the same computer as the Reliance system). The Var_Float, Var_Int and Var_Str tags are linked to corresponding Display components in the main visualization window (the display's "Enable setting value" parameter is enabled). The values of these tags are exported/imported from/to *.xls or *.xlsx file. The ExportToExcel and ImportFromExcel event scripts (activated via buttons in the main window) are defined in the Script manager. The Excel file is named "Values.*" and it is located in the <Project> folder.
At the beginning of the ExportToExcel script, an instance of the 'Excel.Application' object is created. Afterwards the methods are called to create a new WorkBook and a new WorkSheet. The 'Cells' method is used to write the data to the cells. The workbook is stored via 'SaveAs' method.
At the beginning of the ImportFromExcel script, an instance of the 'Excel.Application' object is created. The "values.*" file is opened with the 'Open' method of this object. The values stored in the file are loaded via 'Cells' method.
The DDE_Client project shows how to use the DDE protocol to exchange data between two Reliance projects. The DDE_Client project needs to be started in the Reliance Control software (and simultaneously the DDE_Server project needs to be started in the Reliance Control Server software). If both projects are successfully running, you can set the value in the DDE_Server project and the change is instantly visible in the DDE_Client project (and vise versa).
In the Device Manager (Reliance Design > Managers > Device Manager), there is a DDE device named 'R_CtlSrv_DDEServer'. The "DDE server" property has a value of 'R_CtlSrv', which is the DDE server's filename without an extension. Within the DDE device, there are tags defined in the Tags folder, which correspond to the tags defined in the project DDEServer.rp4. The tags are divided into folders T0 and T1 (just to be well-arranged). For each tag, the "DDE item" property is configured so it corresponds to the value of the "DDE item" property in the project DDEServer.rp4. Also, "Reading" and "Writing" properties can be configured.
In the Project Structure Manager (Reliance Design > Managers > Project Structure Manager), the device 'R_CtlSrv_DDEServer' is connected to the computer DDEClient. The "DDE topic" property is set to "DdeServer" (this is if the DDE server is the Reliance runtime software, i.e. Reliance View, Reliance Control, Reliance Server or Reliance Control Server).
The DDE_Client project shows how to use the DDE protocol to exchange data between the two Reliance projects. The DDE_Server project needs to be started in the Reliance Control Server software (and simultaneously the DDE_Client project needs to be started in the Reliance Control software). If both projects are successfully running, you can set the value in the DDE_Server project and the change is instantly visible in the DDE_Client project (and vise versa).
In the Device Manager (Reliance Design > Managers > Device Manager) there are two virtual devices (T0_Server and T1_Server), which contain internal tags (in the 'Tags' folder within each device). The tags are configured for DDE sharing (the 'Sharing' tab).
In the Project Structure Manager (Reliance Design > Managers > Project Structure Manager), two virtual devices are connected to the 'DDEServer' computer.
The CommWithExternalProgram project is designed to demonstrate how to transfer data between the Reliance system and an external application via COM interface. The project contains the 'RandomValue' and 'Seconds' tags which are used to hold the data received from an external application. The project also contains the 'RelianceValue' tag which is used to send the data to the external program (you can set its value in the visualization window). The external application is located in the "<Project>\Apps" folder and it is automatically started with the visualization project (the "Project Options > Scripts > Other > After start project" parameter is set to a script that contains a command to run the program). Before the project is started for the first time, execute the external program manually to register the COM object.
The project's main visualization window contains two buttons connected to the scripts that start or stop the external application. The window also contains three Display components connected to the RandomValue, Seconds and RelianceValue tags. The Script Manager contains the Create_GlobalObject and Free_GlobalObject event scripts designed to start and stop the external application (the 'CreateObject' function is used to start the external application). The SendNewValue script is designed to send the value of the 'RelianceValue' tag to the external application (this is achieved by calling the 'SetValue' function of the external application). The last object defined in the Script Manager is the 'Read_ObjValues' periodical script (the period is 0.3 seconds), that reads the values from the external program (the GetRandomValue and GetSeconds functions of the external program are used to read the values).
The external application shows the current values of the two dynamically generated tags and the list of values received from the visualization. The external program is written in the Borland Delphi (Pascal) development environment (the source code is located in the "<Project>\Main\Apps\Source\External.zip" archive).
The LogDataToFileAndDb project shows how to log tag values to a file and database via script. The main visualization window contains three display components (displaying the sine and cosine of a periodically incrementing angle) and two buttons that activate/deactivate data logging to the file or data table. The data is logged to the "<Project>\ History\ Data\ AngleData.txt" file and/or to the 'AngleData' data table (the sampling method for the data table is set to "Script-controlled"). You can browse the data logged to the data table in the Report viewer (the AngleData report).
An event script named 'Define' is defined in the Script manager. The script starts before all other scripts and sets the constants (the "Run on thread initialization" parameter on the "Advanced" tab is enabled). The "Calc_and_log" periodical script computes the sine and cosine and increments the 'Angle' tag by one degree every 200ms. The script also contains the 'Log_to_file procedure', that uses the "Scripting.FileSystemObject" object to log the data to the file, and the 'Log_to_database' procedure, that uses the "RDB.AppendRecord" method to log the data to the 'AngleData' data table.


Products


