WinCC OA tag (interpreter string)

HTML features so-called tags as control characters that are used to format page layout, perform queries and more. WinCC OA contains a number of tags that are explained further on.

WinCC OA interprets and replaces all strings (WinCC OA tags) having the following syntax:

<%[Query]%>

The query statement may only contain absolute data point names, keywords, scripts and $parameters.

Example

The simplest form of a query is (see Example HTML References):

<html>

<title> This is the simplest test </title>

Value: <%?"ExampleDP_Result."%>

</html>

You should be familiar with the basics of references and $parameters. The chapter on references provides more information on the subject.

WinCC OA HTML references allow you to perform all queries in WinCC OA.

Simple queries (texts and DP values)

Complex queries (CTRL functions and Control scripts)

Simple queries

  • Compile and display text (without prefix "?"). Square braces stand for any text below.

<% [Query] %> Description Result
<%$Text%> Displays the text specified by the parameter. , for example, outputs "ExampleDP_Arg2"
<%$Text + "[fixed text]"%> Concatenates and displays the text specified by the parameter and the fixed text , for example, "ExampleDP_Arg2 has the following value"
<%$P1 + $P2%> The strings "$P1" and "$P2" are concatenated and displayed , for example, "ExampleDP_Arg2 ExampleDP_Arg1" are concatenated and displayed
<%"[T1]" + $Text+ "[T2]"%> Concatenates "T1" , "$Text" and "T2" , for example, "Data point ExampleDP_Arg2 has this value.

Display the name of the $parameter $dpe on the HTML page. So far, these have only been current contents and fixed texts. In order to display the name of the $parameter, the query in the HTML reference would have to look as any of the following two:

<%"data point element: "+$dpe%>

or

data point element: <%$dpe%>

or for fixed data point elements

data point element: <%"dp1"%>

  • Querying DPE values, times and all other attributes (with prefix "?"). Again, braces stand for any text.

<% ? [Query] %> Meaning
<%?$DPE.comment%> Comment of DP(E) | $parameter
<%?$DPE.alias%> Alias of DP(E) | $parameter
<%?$DPE%> Formatted value with unit of the DPE | $Param.
<%?$DPE.dateTime%> Date and time stamp of the DPE | $parameter
<%?$DPE.alertColor%> Alert color of DPE for HTML| $parameter
<%?$DP+"[element]:config.[detail].attribute!"%> Value of selected attribute of DPE | $param.
<%?$DP+"[element]".<X>%> <X> of the DPE | $parameter ("X" combination , for example, comment, alias, dateTime, alertColor see above)
<%?"DP.[element]:config.[detail].attribute"%> Value of selected attribute of specified DPE
<%?$DP+"[element]".<X>%> <X> (comment, alias, etc.) of the DPE ("X" combination, see above)
<%?$DP+$Element+":config..attribute"%> Value of compound parameter
<%?"DP"+$Element+":config..attribute"%> Value of compound parameter
<%?$DP+$Element.<X>%> <X> (such as comment, alias) of the DPE ("X" combination, see above)

Example

Display the online value of the ".regratio" of the DP in the $parameter "$dp" on the HTML page. The appropriate query in the HTML reference looks as this:

Value: <%?$dp+".regratio"%>

with format and unit or

Value: <%?$dp+".regratio:_online.._value"%>

Without format and unit and, additionally, display the DP comment for the DPE:

Comment: <%?$dp+".regratio".comment%>

Example

Make a table cell take on the alert handling color of a DPE:

<table><tr>

<td bgcolor="<%?$dpe.alertColor%>">Cell contents</td>

</tr></table>

Complex queries

You can also make use of $parameters passed to the reference in functions and scripts called on the server when creating dynamic pages. The following additional $parameters are always passed:

$parameter Description
$User User name (for example, "operator")
$Ip TCP-IP number of station (for example, "193.81.17.85")
$LangId Language index (for example, "1")
  • Execute CTRL functions (prefix "=")

<% = [Function] %> Description
<%=http_color(string)%> WinCC OA converts the color name specified in string (WinCC OA color name) into an HTML color (HEX+RGB code).
<%=http_currentTime()%> Outputs the current date and time of the WinCC OA system.
<%=http_multi(float, float)5> The specified floats are multiplied together and the result is output. (see example references)
<%=http_getConfig(string)%> Returns the value of the config parameter specified in string.
<%=f([p1], [p2], ...[pn])%> Calls a custom string function from the proj_http.ctl library and inserts the result into the HTML reference page.

Example

Make a table cell containing "Text" take on the color "_invalid". The appropriate query in the HTML reference looks like this:

  1. <table><tr>

    <td bgcolor="<%=http_color("_invalid")%>">Text</td>

    </tr></table>

  • Execute control script (Prefix "={")

Executes a complex WinCC OA script in which the specified $parameters and all functions from the proj_http.ctl library are known.

<% ={ [Script] }%> Description
={ [Script] }

Executes a complex script and inserts the result into the HTML reference page.

The specified script must end with "return(string);" and be (completely) enclosed in {}.

Example

Read and subtract the online values of two DPEs in the $parameters "$dpe1" and "$dpe2" and return the result as an HTML string. The appropriate script in the HTML reference looks as:

<%=
{
  string sHtml;
  http_sub(sHtml); 
  return(sHtml); 
}
%>
This requires the following function in the CONTROL library:
void http_sub(string &html)
{
  float f1, f2;
  dpGet($dpe1+":_online.._value", f1,$dpe2+":_online.._value", f2);
  sprintf(html, "%5.2f - %5.2f = <b>%5.2f</b>", f1, f2,(f1-f2));
}

Example

Display an image (LED) on the HTML page depending on the invalid bit of the data point in the $parameter $dpe. The appropriate script in the HTML reference looks as this:

<%$dpe%>: <img align="middle" src="/pictures/http/<%={string s;
http_bool(s, $dpe+":_online.._bad", "led_invalid", "led_active");
return(s);}%>.gif"> 
<br>
This requires the following function in the library:
void http_bool(string &sHtml, string sDpe,
string sImgOn, string sImgOff)
{
  bool b;
  dpGet(sDpe, b);
  sHtml= ( b ? sImgOn : sImgOff );
}