hook_<libraryPrefix>_openFaceplate()

This function opens the faceplate of a symbol.

Synopsis

void hook_<libraryPrefix>_openFaceplate(string sDp);

Parameter

Parameter Description
sDp Name of the datapoint that the symbol describes.

Return Value

-

Description

This function opens the faceplate of a symbol.

By default this function is first checked to see whether a license for the library is available. The library HOOK-function hook_<LibName>_libLicenseAvailable() is called. Furthermore the entry of the config entry faceplateModal is checked. Depending on the set entry, the faceplate is opened modally or not modally.

You can find the function in the stdlib_hook_project.ctl under wincc_oa_path/Stdlib_3.19/scripts/libs/

void hook_openFaceplate(string dp)
{
  string sLibFct = builtHookName(dp, "hook_libLicenseAvailable");
  if ( !isFunctionDefined(sLibFct) )
  {
    throwError(makeError("", PRIO_WARNING, ERR_PARAM, 72, "'"+sLibFct+"'"));
    return;
  }
  if(!hook_libLicenseAvailable(dp))
  {
    stdlib_openPanelInvalidLicense(FALSE);
    return;
  }
  dyn_int diSize;
  string sPanel;
  dyn_string dsParameter;
  int iX, iY;
  sPanel="objects_parts/faceplates/framework/faceplate_main.pnl";
  dsParameter=makeDynString("$DP:"+dp);
  // add Dollar Parameter with global ref name of the calling object to the faceplate
  if ((string)TEXT_PARENT_REF_NAME.text!="")
  dynAppend(dsParameter, "$CALLING_OBJECT_REF_PATH:" + (string)TEXT_PARENT_REF_NAME.text);
  getCursorPosition(iX, iY, true);
  if (gFaceplateModal)
  {
    ChildPanelOnRelativModal(sPanel, hook_faceplateWindowTitle(dp), dsParameter, 0, 0);
  }
  else
  {
    // Do not draw the faceplate at the right screen edge, keep it on one screen
    // LIMITATIONS:
    // 1) displays have to be the same size
    // 2) displays have to be horizontally aligned
    // 3) faceplates will be aligned only on the X coordinate
    int margin = 737; // the x size of the opened faceplate
    int iXPos;
    int iXPosRel;
    int iYPosRel;
    int iXScreenSize;
    int tmp;
    getCursorPosition(iXPos, tmp, true);
    getCursorPosition(iXPosRel, iYPosRel);
    getScreenSize(iXScreenSize, tmp);
    int iXPosRelToWindow = iXPosRel;
    int iOneScreenSizeX = iXScreenSize / getScreenCount();
    if (margin > iOneScreenSizeX) // larger margin than screen size
    {
      margin = iOneScreenSizeX;
    }
    int iXPosLocal = iXPos;
    if (iXPosLocal >= 0)
    {
      while (iXPosLocal > iOneScreenSizeX)
      {
        iXPosLocal -= iOneScreenSizeX;
      }
    }
    else
    {
      while (iXPosLocal < 0)
      {
        iXPosLocal += iOneScreenSizeX;
      }
    }
    int fromScreenEdge = iOneScreenSizeX - iXPosLocal;
    float zoomFactor;
    getZoomFactor(zoomFactor, myModuleName());
    if ( fromScreenEdge < margin )  // on the right margin
    {
      int iNewPos = iXPosRel + fromScreenEdge - margin;
      ChildPanelOn(sPanel, hook_faceplateWindowTitle(dp), dsParameter, iNewPos/zoomFactor, (iYPosRel + 10)/zoomFactor);
    }
    else
    {
      ChildPanelOn(sPanel, hook_faceplateWindowTitle(dp), dsParameter, iXPosRelToWindow/zoomFactor, (iYPosRel + 10)/zoomFactor);
    }
  }
}