../pvss.htm menu.gif basics.gif

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 advised not to overwrite the original file, because this is effective WinCC OA wide. Please copy instead the original file to your project directory and make there changes. Thus the changes have an effect project-wide only.

Synopsis

int pvConnect(string funcName, string label, [string icon]);

Parameters

    Parameter

    Description

    funcName

    Name of the called function.

    label

    Label that is shown in the manu after right mouse-click.

    icon

    The icon which is shown next to the option that is opened via a right mouse-click. The icon must be stored in the /pictures directory.

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.

IconEXAMPLE
 

 

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).

#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

See also

pvAddColumn(), pvAddSeparator(), pvSetItemText()

 

Top Of Page

 

V 3.11 SP1

Copyright ETM professional control GmbH 2013 All Rights Reserved