Project object

This object defines the project widget. The project widget is used to retrieve data about the project such as tags, alarms, recipes, schedules, tags and so on. There is only one widget for the project and it can be referenced through the project variable.

Project object properties

Properties to be set at project level.

startPage

string startPage

Page shown when the project is started.

var startPage = project.startPage;

project.startPage = "Page2.jmx";

Project object methods

Methods to be used at project level.

nextPage

void nextPage()

The script executes the Next page action.

project.nextPage();

(Available on web pages)

prevPage

void prevPage()

The script executes the previous page action.

project.prevPage();

(Available on web pages)

lastVisitedPage

void lastVisitedPage()

The script executes the last visited page action.

project.lastVisitedPage();

(Available on web pages)

homepage

void homePage()

The script executes the Home page action.

project.homePage();

(Available on web pages)

loadPage

void loadPage(pageName)

The script executes to load the set page defined in the script.

project.loadPage("Page5.jmx");

(Available on web pages)

WARNING: When page change, all active time events are forced to removed and the JavaScript procedure will run until the end before switch to the new page.

showDialog

void showDialog(pageName)

The script executes to show the dialog page.

project.showDialog("Dialog.jmx");

(Available on web pages)

closeDialog

void closeDialog()

The script executes to close the currently-opened dialog page.

project.closeDialog();

(Available on web pages)

showMessage

void showMessage( message )

The script executes to display the message popup.

project.showMessage("Hi This is test message");

(Available on web pages)

getGroup

number getGroup( groupName, groupInstance, [callback] )

Fast read method; this gets the values of all tags in a group.

Parameter Description
groupName

String containing the names of the groups.

The and/or expression to retrieve tags list from multiple group is supported.

  | OR operator
  & AND operator
  (...) The brackets can be used to define how evaluate the expression

Examples:

  • project.getGroup("one", group);
  • project.getGroup("(one|two)", group);
  • project.getGroup("((one&two)*three)", group);
groupInstance Group element to be filled
callback String containing the name of the function to be called when the group is ready

Return value

A number value that is the status: 1 for success, 0 for fail.

var group = new Group();

var status = project.getGroup ("enginesettings", group);

if (status == 1) {

var value = group.getTag("Tag1");

if (value!=undefined) {

// do something with the value

}

}

var g = new Group();

var status = project.getGroup ("enginesettings", g,

function (groupName, group) { fnGroupReady(groupName, group);} );

 

function fnGroupReady(groupName, group) {

var val = group.getTag("Tag1");

if (val!=undefined) {

// do something with the value

}

}

(Available on web pages)

getTag

object getTag( tagName, state, index, forceRefresh)

void getTag( tagName, state, index, callback, forceRefresh)

It returns the tag value or the complete array if index value is -1 of the given tagName.

Parameter Description
tagName String of tag name
state State element to be filled
index Index if the tag is of array type. -1 returns the complete array. Default = 0.
callback

  Function name if an asynchronous read is required. Default = “".

forceRefresh

(Optional parameter) True = the Runtime will read an updated value of the tag directly from the device. Default is false.

Return value

Tags value is returned. If tag is array type and index = -1 then the complete array is returned. For non-array tags provide index as 0.

var state = new State();

var value = project.getTag("Tag1", state, 0);

//

//for non array type

//tags index is not considered, so can be left as 0

//

if (value!=undefined) {

//...do something with s

}

var state = new State();

project.getTag("Tag1", state, -1,

function(tagName, tagState) { fnTagReady(tagName, tagState); });

function fnTagReady(tagName, tagState) {

if (tagName=="Tag1") {

var myValue = tagState.getValue();

}

}

(Available on web pages)

setTag

number setTag( tagName, tagValue, [index], [forceWrite] )

Sets the given tag in the project. Name and value are in strings.

Parameter Description
tagName String of tag name
tagValue Object containing the value to write
index Index if the tag is of array type. -1 pass the complete array. Default = 0.
forceWrite

Boolean value for enabling force write of tags, the function will wait for the value to be written before it returns back. Default = false.

Return value

Interger value for denoting success and failure of action when forceWrite is true. 0 means success and -1 means failure. If forceWrite is false, returned value will be undefined.

var val = [1,2,3,4,5];

var status = project.setTag("Tag1", val, -1, true);

if (status == 0) {

// Success

} else {

// Failure

}

var val = "value";

project.setTag("Tag1", val);

(Available on web pages)

updateSystemVariables

void project.updateSystemVariables()

Force system variables to refresh.

project.updateSystemVariables()

selectAllAlarms

void project.selectAllAlarms(bool selected)

Select/unselect all alarms

project.selectAllAlarms(true)

(Available on web pages)

ackAlarms

void project.ackAlarms()

Acknowledge all selected alarms

project.selectAllAlarms(true);

project.ackAlarms();

project.selectAllAlarms(false);

(Available on web pages)

resetAlarms

void project.resetAlarms()

Reset all selected alarms

project.selectAllAlarms(true);

project.resetAlarms();

project.selectAllAlarms(false);

(Available on web pages)

enableAlarms

void project.enableAlarms()

Enable all selected alarms

project.selectAllAlarms(true);

project.enableAlarms();

project.selectAllAlarms(false);

(Available on web pages)

getRecipeItem

object getRecipeItem (recipeName, recipeSet, recipeElement)

Gets the value of the given recipe set element.

Parameter Description
recipeName String representing the recipe name
recipeSet String representing the recipe set, can be either the recipe set name or 0 based set index.
recipeElement String representing the recipe Element, can be either the element name or 0 based element index.

Return value

An object with the value of the recipe. undefined is returned if invalid. If of type array, an array object type is returned.

var value = project.getRecipeItem("recipeName", "Set", "Element");

setRecipeItem

number setRecipeItem (recipeName, recipeSet, recipeElement, value )

Gets the value of the given recipe set element.

Parameter Description
recipeName String representing the recipe name
recipeSet String representing the recipe set, can be either the recipe set name or 0 based set index.
recipeElement String representing the recipe Element, can be either the element name or 0 based element index.
value An object containing the value to store in the recipe. It can be an array type.

Return value

Interger value for denoting success and failure of action. A ‘0’ means success and ‘-1’ means failure.

var val = [2,3,4];

project.setRecipeItem("recipeName", "Set", "Element", val);

if (status == 0) {

// Success

} else {

// Failure

}

downloadRecipe

void downloadRecipe (recipeName, recipeSet )

Downloads the recipe set to the corresponding tag.

Parameter Description
recipeName String representing the recipe name
recipeSet String representing the recipe set, can be either the recipe set name or 0 based set index.

project.downloadRecipe("recipeName", "Set");

uploadRecipe

void uploadRecipe (recipeName, recipeSet )

Uploads the value of tags into the provided recipe set.

Parameter Description
recipeName String representing the recipe name
recipeSet String representing the recipe set, can be either the recipe set name or 0 based set index.

project.uploadRecipe("recipeName", "Set");

launchApp

void launchApp( appName, appPath, arguments, singleInstance)

Executes an external application.

Parameter Description
appName String containing the application name
appPath String containing the application absolute path
Arguments String containing the arguments to be sent to application
singleInstance

true = only single instance allowed, false = multiple instances allowed

Note the pathname's syntax depend from the native OS format (see "HMI devices capabilities").

On Linux devices, the pathname's syntax need slash character (even double slash character is permitted).

project.launchApp("pdfViewer","/mnt/data/hmi/qthmi/deploy","/mnt/usbmemory/test.pdf","true");

getClientType

string getClientType()

Return the client type

Client Type Description
local Running on HMI device
remote Running on HMI Client client
web Running on Web client
var clientType = project.getClientType();
if (clientType=="web") {
	// Currently running on web client
} else  if (clientType=="remote") {
	// Currently running on HMI Client
} else  if (clientType=="local")  {
	// Currently running on HMI Device
}		

(Available on web pages)

login

int project.login("username", "password")

Access to the system with the given credentials

var ReplyCode;
ReplyCode = project.login("admin", "admin");
if (ReplyCode != 0) {
    alert("Access denied");
}	
Return value
0 No Error
1 Error: You are not authorized.
2 Error: Connection lost with the Runtime.
3 Error: The username or password you entered is incorrect
4 Error: The password entered is incorrect
5 Error: Action cannot be executed
6 Error: Passwords do not match
7 Error: Password length too short
8 Error: Password must contain numbers
9 Error: Password must contain special characters
10 Error: Password must be different than previous passwords
11 Error : User already exist
12 Error: Password cannot be empty
13 Error: Your password has expired
14 Warning: Your password will expire soon
logout

project.logout(AllowDefaultUser)

Exiting the system

project.logout();       // Logout even from default user				
project.logout(true);   // Logout even from default user
project.logout(false);  // Logout only if not logged as default user

Project object widgets

getCurrentPageName

string getCurrentPageName()

Return the name of current active page

// Get PageMgr widget
var pageMgr = project.getWidget( "_PageMgr" );

// Show Current Page
var currentPageName = pageMgr.getCurrentPageName();
project.showMessage( "Current active page is: " + currentPageName );						

(Available on web pages)

hasPage

boolean hasPage(string pageName)

Return true if the page exist, false otherwise

// Get PageMgr widget
var pageMgr = project.getWidget( "_PageMgr" );

//Page exists
var pageExists = pageMgr.hasPage( "Page10" );
if (pageExists) {
    project.showMessage( "Page10 exists" );
} else {
    project.showMessage( "Hei Page10 not exists!" );
}							

(Available on web pages)

curLangCode

string curLangCode

Property of MultiLangMgr widget. Contains the code of the active language.

// Get MultiLangMgr widget
var MultiLangMgr = project.getWidget( "_MultiLangMgr" );

// Show curLangCode
var curLangCode = MultiLangMgr.curLangCode;
project.showMessage( "Current active language is: " + curLangCode );		

Print reports object

printGfxReport

void printGfxReport( reportName, silentMode)

Prints the graphic report specified by reportName.

Parameter Description
reportName String containing the report name
silentMode

True = silent mode enabled. No printer settings dialog is displayed.

project.printGfxReport("Report Graphics 1", true);

emptyPrintQueue

void emptyPrintQueue()

Empties the print queue. Current job will not be aborted.

project.emptyPrintQueue();

pausePrinting

void pausePrinting();

Suspends printing operations. Will not suspend the print of a page already sent to the printer.

project.pausePrinting();

resumePrinting

void resumePrinting();

Resumes previously suspended printing.

project.resumePrinting();

abortPrinting

void abortPrinting();

Aborts current print operation and proceed with the next one in queue. This command will not abort the print of a page already sent to the printer.

project.abortPrinting();

printStatus

project.printStatus;

Returns a string representing current printing status.

Status string Description
error An error occurred during printing
printing Ongoing printing
idle System is ready to accept new jobs
paused Printing has be suspended

var status = project.printStatus;

project.setTag("PrintStatus",status);

printGfxJobQueueSize

project.printGfxJobQueueSize;

Returns the number of graphic reports in queue for printing.

var gfxqueuesize = project.printGfxJobQueueSize;

project.setTag("printGfxJobQueueSize",gfxqueuesize);

printTextJobQueueSize

project.printTextJobQueueSize;

Returns the number of text reports in queue for printing.

var textjobqueuesize = project.printTextJobQueueSize;

project.setTag("printTextJobQueueSize",textjobqueuesize);

printCurrentJob

project.printCurrentJob;

Returns a string representing current job being printed

var currentjob = project.printCurrentJob;

project.setTag("printCurrentJob",currentjob);

printActualRAMUsage

project.printActualRAMUsage;

Returns an estimate of RAM usage for printing queues

var myVar = project.printActualRAMUsage;

alert(" actual ram usage is   "+ myVar);

printRAMQuota

project.printRAMQuota;

Returns the maximum allowed RAM usage for printing queues

var ramquota = project.printRAMQuota;

project.setTag("printRAMQuota",ramquota);

printActualDiskUsage

project.printActualDiskUsage;

Returns the spool folder disk usage (for PDF printouts)

var myVar1 = project.printActualDiskUsage;

alert(" actual disk usage is   "+ myVar1);

printDiskQuota

project.printDiskQuota;

Returns the maximum allowed size of spool folder (for PDF printouts).

var ramquota = project.printRAMQuota;

var diskquota = project.printDiskQuota;

printSpoolFolder

project.printSpoolFolder;

Returns current spool folder path (for PDF printouts).

var spoolfolder = project.printSpoolFolder;

project.setTag("printSpoolFolder",spoolfolder);

printPercentage

project.printPercentage;

Returns current job completion percentage (meaningful only for multipage graphic reports)

var percentage = project.printPercentage;

project.setTag("printPercentage",percentage);