Back

Topic

[KB1145]Database status check at startup

Tags: Database, HDS

3 years ago
By LM
Options
Print
Applies to:

PcVue 11.2 onwards


Summary:

Program and mimic to be set up to check if connection to a database is valid at project startup.


Details:

At project startup, HDS performs configuration and integrity check on each configured database. To do this, HDS must have access to the database server and to each database. Once these initializations are done, if a database link is broken then HDS switches to write mode in temporary .hds files as explained in (How .hds files work ?).
If the database initialization phase could not be done at project startup, please note that the mechanism of writing to temporary files does not work. In this case, users should be informed immediately so that they can re-establish the link to the concerned database and restart the project.
This article provides an example of a Scada Basic function to be executed at project startup to warn the user if this happens. In this example the database is named DB1 and the project is single-station. The script and the method should therefore be adapted to your architecture. For example, it will be useless to open a warning mimic if PcVue is running as a service, in which case it is better to force a general alarm created for this purpose.

A screenshot of the attached sample mimic:

 HDS Warning Mimic

Sample Scada Basic script:

sub main()
‘The following 6 lines are used to alert the user in case of a DB1 database initialization problem (replace DB1 by another database name depending on your project)
If (Variable(“STATUS”, “@System.HDS.DB1.Disconn”, 1)==0) Then ‘Variable does not exist? If the DB is not available the first time the project is started
  Window(“OPEN”, “HdsWarning”, “@System.HDS.DB1.Disconn” ); ‘Open the warning mimic with system variable name as branch
End If
If (Variable(“STATUS”, “@System.HDS.DB1.Disconn”, 2)==0) Then ‘Variable is invalid? If the variables have already been created but the DB is not accessible
  Window(“OPEN”, “HdsWarning”, “@System.HDS.DB1.Disconn” ); ‘Open the warning mimic with system variable name as branch
End If
end sub


Sample mimic:
HdsWarning.zip

Sample script:
PROGEXECUTED.zip


Created on: 06 Jan 2022 Last update: 30 May 2024