Customizing APL_InitializeDateTimeInputDialog for User-Defined Blocks in PCS 7

Customizing APL_InitializeDateTimeInputDialog for User-Defined Blocks in PCS 7

In SIMATIC PCS 7 V9.0 SP1 APL, user-defined blocks that utilize the date-time input faceplate object (APL_TIME_OP_DISPLAY3) malfunction because the underlying C-script function APL_InitializeDateTimeInputDialog contains hardcoded string checks restricted exclusively to standard Siemens block types: CountOh, TimeTrig, and CntOhSc. If a custom block type does not match these strings, the script fails to initialize time format variables, resulting in blank dialogs or input errors. To resolve this, copy APL_InitializeDateTimeInputDialog.fct into the OS project's local library folder, add the custom block type name to the appropriate type evaluation branch, and recompile project C-scripts.

Table of Contents

APL Date-Time Faceplate Controls and C-Script Architecture

The SIMATIC PCS 7 Advanced Process Library (APL) provides sophisticated graphic controls for managing temporal variables inside WinCC OS faceplates. When operators adjust operating hour targets, maintenance intervals, or batch timers, the faceplate launches an interactive date-time dialog driven by graphic object APL_TIME_OP_DISPLAY3.

Upon invocation, this dialog executes the internal C-script APL_InitializeDateTimeInputDialog.fct. The function interrogates the block type string (pszBlockType) passed from the parent faceplate to determine how time variables are structured in the AS (e.g., whether the block stores time as a double-integer DINT in seconds, a floating-point REAL in hours, or a complex standard DATE_AND_TIME structure).

Code Analysis: Hardcoded Block Type Branches in Script

Inspection of APL_InitializeDateTimeInputDialog.fct reveals the root cause of failures when deploying custom blocks. The function evaluates block identity using strict multi-byte string comparisons:

if (pszBlockType != NULL) {
    bCountOhBlock  = (_mbsicmp(((unsigned char*)pszBlockType), (unsigned char*)"CountOh") == 0);
    if (!bCountOhBlock) {
        bTimeTrigBlock = (_mbsicmp(((unsigned char*)pszBlockType), (unsigned char*)"TimeTrig") == 0);
    }
    if (!bCountOhBlock && !bTimeTrigBlock) {
        bCntOhScBlock  = (_mbsicmp(((unsigned char*)pszBlockType), (unsigned char*)"CntOhSc") == 0);
    }
}

If an engineer creates a custom scheduling or timing block (e.g., CustomTimer or BatchStep), pszBlockType fails all three comparisons. Consequently, bCountOhBlock, bTimeTrigBlock, and bCntOhScBlock remain FALSE. Downstream formatting logic is skipped, causing the dialog to initialize with unassigned pointers, corrupted display units, or unresponsive input fields.

Comparison of Data Formats for APL Time Faceplates

The table below contrasts the time representation formats handled by the three APL branches in the initialization script:

Standard Block TypeData FormatScaling UnitInternal Time RepresentationTarget Branch in Custom ScriptCountOhDINT / REALHours / MinutesOperating hours tracking; converts integer seconds to display hours.Branch 1 (bCountOhBlock)TimeTrigDATE_AND_TIMECalendar Date & TimeStandard S7 DT format (YEAR-MONTH-DAY-HOUR:MIN:SEC).Branch 2 (bTimeTrigBlock)CntOhScScaled REALUser-definedScaled counter with high/low maintenance limit thresholds.Branch 3 (bCntOhScBlock)Custom BlockCustom SCLApplication dependentMust be mapped to match either CountOh or TimeTrig structure.Modify script branch matching data model

Step-by-Step Custom Script Modification Procedure

  1. Locate System Function: In the WinCC installation directory or project library, locate APL_InitializeDateTimeInputDialog.fct (typically found in <WinCC_Project>\library or <PCS7_Path>\aplib).
  2. Copy to Project Local Library: To prevent modifications from being overwritten by PCS 7 system updates, copy the file directly into the project-specific library folder: <Project_Directory>\library\APL_InitializeDateTimeInputDialog.fct.
  3. Add Custom Block Type Comparison: Open the file in the WinCC C-Editor. Update line 116 to evaluate your custom block name. For example, if the custom block CustomTimer uses CountOh-style formatting:
if (pszBlockType != NULL) {
    bCountOhBlock = ((_mbsicmp(((unsigned char*)pszBlockType), (unsigned char*)"CountOh") == 0) ||
                     (_mbsicmp(((unsigned char*)pszBlockType), (unsigned char*)"CustomTimer") == 0));
    if (!bCountOhBlock) {
        bTimeTrigBlock = (_mbsicmp(((unsigned char*)pszBlockType), (unsigned char*)"TimeTrig") == 0);
    }
    if (!bCountOhBlock && !bTimeTrigBlock) {
        bCntOhScBlock = (_mbsicmp(((unsigned char*)pszBlockType), (unsigned char*)"CntOhSc") == 0);
    }
}
  1. Recompile C-Scripts: In WinCC Explorer, select Global Script -> C-Editor -> Compile All Functions.
  2. Test in Graphics Designer: Open the faceplate screen in Graphics Designer, link the test instance, and launch WinCC Runtime.

Verification

Verify script execution through the following tests:
1. Open the WinCC OS Runtime faceplate for the custom block.
2. Click the date/time operator input field: confirm that the APL_InitializeDateTimeInputDialog dialog opens cleanly without runtime C-script execution errors.
3. Enter a new target value (e.g., $120.0\text{ hours}$ or a specific calendar date): confirm that the value is parsed, validated, and successfully written to the AS controller data block.
4. Inspect the WinCC diagnostic console (apdiag.exe): confirm zero script warnings or null-pointer dereference faults.

Limitations and Operational Precautions

Always place modified C-scripts into the local project library (<OS_Project>\library), never into global system directories (Siemens\WinCC\aplib). Global script modifications will be overwritten without warning during software updates or OS Project Editor executions. Furthermore, ensure string comparisons remain strictly case-insensitive using _mbsicmp to prevent naming discrepancies between SIMATIC Manager and WinCC.

Engineer FAQ

Technical References

Related Articles

Related Tags

  • APL
  • C-Script
  • Faceplates
  • APL_TIME_OP_DISPLAY3
  • Custom Blocks
  • PCS 7 V9.0
6 respuestas