pvConnect()
Calls the specified function with the specified label.
This function is for use in the projectView.ctl file only (wincc_oa_path/[Version]/scripts/gedi/projectView.ctl
). It is
not advised to overwrite the original file, because this is effective WinCC OA wide. Instead, copy the original file to your project
directory and make changes there. Thus the changes will only have an effect
project-wide.
Synopsis
int pvConnect(string funcName, string label[, string icon | mapping
options]);
Parameters
Parameter | Description | |
---|---|---|
funcName | Name of the called function. | |
label | Label that is shown in the menu after right mouse-click. | |
icon |
The icon which is shown next to the option that is opened via right mouse-click. The icon must be stored in the /pictures directory. This parameter is optional. |
|
options | A mapping containing additional options as key-value pairs: | |
"icon" - string | This is the same as the parameter "icon" before, so it can be included in the mapping. | |
"inSubproject" - bool |
By setting this value to "true", the entry is also shown in the subprojects. The default remains as before: The entries are only shown in the project. |
|
"category" - string |
Defines on which categories of a project an entry will be shown. The possible values are the following strings:
Note that these are string values, so they have to be used as such:
The strings are flags so they can be combined with the "|" character in the string, e.g.
|
|
"filesOnly" -bool | If this value is "true", this entry will only be shown for files but not for directories | |
"parent" - string |
This key and following value tell into which submenu it shall be put. E.g.: |
|
"projectLevels" - dyn_int |
Defines the numbers of the project levels for which this entry shall be used. The level number is as usual from 1 .. SEARCH_PATH_LEN-1 (where 1 is your project and SEARCH_PATH_LEN-1 is the installation) For an example look into Since we already have a similar key named "inSubproject", the following rule applies:
|
Return value
In case of errors, the function returns -1 otherwise, 0.
Error
Missing or wrong arguments
Description
Calls the specified function with the specified label.
EXAMPLE
The following example demonstrates how to load the interface for the CVS version
control system into the project view. (See also wincc_oa_path/Scripts/Gedi/projectView.ctl
. Further examples can be found
there.)
#uses "CtrlPv2Admin"
int versionColumn, statusColumn, tagdateColumn;
string tmpFile;
main()
{
string configFile = getPath(CONFIG_REL_PATH, "config");
string vcs;
paCfgReadValue(configFile, "ui", "versionControl", vcs);
paCfgReadValue(configFile, "ui", "versionControlDiff", diffProgram);
if ( vcs != "CVS" ) return;
pvConnect("CVS_log", "CVS log");
pvAddSeparator();
pvConnect("CVS_status", "CVS status");
pvConnect("CVS_update", "CVS update", "cvs_update");
versionColumn = pvAddColumn("Version");
statusColumn = pvAddColumn("Status");
tagdateColumn = pvAddColumn("Tag/Date");
reload();
}
//----------------------------------------------------------------------
void reload()
{
CVS_entries(getPath(PANELS_REL_PATH));
CVS_entries(getPath(SCRIPTS_REL_PATH));
CVS_entries(getPath(LIBS_REL_PATH));
CVS_entries(getPath(PICTURES_REL_PATH));
CVS_entries(getPath(COLORDB_REL_PATH));
}
//----------------------------------------------------------------------
setTmpNam()
{
tmpFile = tmpnam();
}
//----------------------------------------------------------------------
CVS_log(string fileName)
{
setTmpNam();
CVS_command("log -N", fileName);
showResult(fileName);
}
//----------------------------------------------------------------------
CVS_update(string fileName)
{
setTmpNam();
CVS_command("update", fileName);
showResult(fileName);
CVS_status(fileName);
}
//----------------------------------------------------------------------
CVS_status(string fileName)
{
bool isDir = isDirectory(fileName);
setTmpNam();
CVS_command("status -l", fileName); // non recursive as we only get
filenames without path
file fd = fopen(tmpFile, "r");
string line, currentFile, version, status;
int pos;
bool gotFile = false;
while ( ! feof(fd) && (fgets(line, 1000, fd) > 0) )
{
if ( !gotFile )
{
if ( line[0] == '?' ) // file not in CVS
{
currentFile = baseName(substr(line, 2));
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
statusColumn, "not in CVS");
continue;
}
pos = strpos(line, "File: ");
if ( pos != 0 ) continue;
gotFile = true;
sscanf(line, "File: %s", currentFile);
pos = strpos(line, "Status:");
status = substr(line, pos + strlen("Status:"));
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
statusColumn, status);
}
pos = strpos(line, "Working revision:");
if ( pos == -1 ) continue;
sscanf(substr(line, pos+strlen("Working revision:")), "%s", version);
if ( version == "No" ) // No entry for ...
{
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
statusColumn, "not in CVS");
}
else
{
pvSetItemText(fileName + (isDir ? ("/" + currentFile) : ""),
versionColumn, version);
gotFile = false;
}
}
fclose(fd);
remove(tmpFile);
if ( isDir ) // recursion
{
dyn_string files = getFileNamesRev(fileName, "CVS", FILTER_DIRS);
for (int i = 1; i <= dynlen(files); i++)
if ( (files[i] != ".") && (files[i] != "..") )
CVS_status(fileName + "/" + files[i]);
}
}
Availability
UI