Você está na página 1de 28

&RQILJXUDWLRQVIRU:HEVHUYHU

:KDW\RXQHHGWRNQRZDERXWZHEVHUYHUV
,QWURGXFWLRQ
The web server allows you to monitor the CPU via the lnternet or the intranet of your company.
This permits evaluation and diagnostics over long distances.
Messages and status information are visualized on HTML pages.
:HEEURZVHr
You need a web browser that supports HTML 1.1 to access the HTML pages of the CPU.
The following web browsers, for example, are suitable for communication with the CPU:
lnternet Explorer (version 6.0 and higher)
Mozilla Firefox (V1.5 and higher)
Opera (version 9.0 and higher)
Netscape Navigator (version 8.1 and higher)
5HDGLQJLQIRUPDWLRQYLDWKHZHEVHrver
The information listed in the following can be read from the CPU. Availability of the respective
web pages depends on the CPU and its firmware version:
3DJHLQIRUPDWLRQ 'HVFULSWLRn
lntro Entry page for the standard web pages
Start Page
Start page with general CPU information
The start page provides an overview of general
information on the CPU, the name of the CPU, the
type of CPU and basic information on the current
operating state.
ldentification
ldentification information
Displays the static identification information such
as serial number, order number and version
numbers.
Diagnostic Buffer
Diagnostic information
Displays the content of the diagnostics buffer with
the most recent entries.
Module lnformation
Module information
Displays whether the centrally inserted
components of a station are OK, whether there are
maintenance requirements or components cannot
be reached, for example.
Communication
Communication
Displays the communication connections during
open communication (OUC); displays resources
and address parameters.
Varable Status
Tags
Displays the status of operands of the user
program to monitor and change the values.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
396 System Manual, 12/2011,
Page/information Description
Data Logs Data logs in CSV format to transfer to the hard disk
of the programming device. The data logs are
created with data log instructions in the user
program and filled with data.
User Pages
User pages (if custom web pages have been
configured and loaded)
The user web pages provide a list of web pages
with customized web applications.

Web access to the CPU via PG/PC
Proceed as follows to access the web server:
1. Connect the client (PG/PC) to the CPU via the PROFlNET interface.
2. Open the web browser.
Enter the lP address of the CPU in the "Address" field of the web browser in the format
http://ww.xx.yy.zz (example: http://192.168.3.141).
The start page of the CPU opens. From the start page you can navigate to further
information.
6WDQGDUGZHESDJHV
5HTXLUHPHQWVIRUZHEDFcess
The requirements for access to standard CPU web pages are explained in the following, as
well as the effects of missing or existing configuration information.
5HTXLUHPHQWs
The web server must be started.
The web server only starts when it has been activated in the properties of the CPU in the "Web
server" section.
Note the following:
The web pages are normally transmitted via an non-secure connection and are not secured
against hacker attacks. lf you want to transfer the web pages in encrypted form to the browser,
use the URL https://, followed by the lP address of the CPU.
/RJRQ
No logon is required to access the standard web pages read-only. To execute certain actions,
such as changing the operating state of the CPU or for write access, the user must be logged
on as "admin". The logon input boxes are on the top left of each standard web page.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 397
lf you log on as "admin", you must enter the user name and password there.
Name: admin.
Password: configured CPU password (for password-protected CPU).
JavaScript and cookies
The standard web pages use JavaScript and cookies. You must enable both in your web
browser.
lf JavaScript is not enabled, the following limitations apply:
Data from standard web pages are not automatically updated.
You cannot log on as "admin".
Fields cannot be sorted (module information)
lf cookies are not enabled you cannot log on as "admin".
6HHDOVR
Access for HTTPS (Page 398)
6HWWLQJVIRURSHUDWLRQ
6HWWLQJVIRURSHUDWLRn
To be able to use the web server of an S7-1200-CPU, you must select the CPU in the network
view or the device view and make the following settings in the inspector window under
"Properties > General > Web server":
Enable the web server
Restricting access to the CPU to HTTPS transmission protocol (encrypted transmission)
Access via port 80 is then blocked. Communication is only possible via port 443.
Enabling automatic update of web pages
The update interval is set by default and cannot be changed. The CPU updates web pages
with changing content ( (for example, status information or diagnostics information) at
regular intervals.
$FFHVVIRU+7736
$FFHVVYLD+773S
HTTPS is used for encrypting and authentication of communication between the browser and
web server.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
398 System Manual, 12/2011,
To transfer data between the browser and the CPU using the HTTPS protocol, enter the URL
as https://ww.xx.yy.zz in the address line of your browser, whereby ww.xx.yy.zz stands for
the lP address of the CPU.
You require a valid, installed certificate for error-free HTTPS access to the CPU.
lf no certificate is installed a warning is displayed with a recommendation not to use this page.
To view the page you must explicitly "Add exception".
You can receive a valid certificate (Certification Authority) "SlMATlC CONTROLLER" as a
download from the "lntro" web page under "Download certificate". The help function for your
respective web browser provides information on how to install a certificate.
$FFHVVLQJGDWDORJV
The "Data logs" web page allows files to be viewed or downloaded that have been created
using DataLog instructions and that have been filled with data. You can clear or delete these
entries after downloading by logging on as "admin".
2SHQLQJDGDWDORJ
To open a data log, click on the link of the desired data log. You can then open the file (.csv),
for example, in Microsoft Excel or in another program you choose or you can save the file.
Special feature: Data logs are saved in U.S. American CSV format. You can only open the file
directly using the U.S. version of Microsoft Excel. lf you are using another national version of
Microsoft Excel, you must import the file, selecting "comma" in the import assistant as the
delimiter.
'RZQORDGLQJDGDWDOog
To download a data log, click on the download icon of the desired data log. You can then open
the file (.csv), for example, in Microsoft Excel or in another program you choose or you can
save the file.
'RZQORDGLQJDQGFOHDULQJRUGHOHWLQJDGDWDORJ
To download and delete the current entries of the data log, you must be logged on as "admin".
To do this, click on the "Download and delete" icon of the required data log. You can then open
the file (.csv), for example, in Microsoft Excel or in another program you choose or you can
save the file. The web server delete the content of the file. The file itself is not deleted, only its
content. New data can then be written in this file.
'HWHUPLQLQJWKHDPRXQWRIFRQWent
As a default, the 25 most-used entries are displayed, irrespective of how many entries are
contained in the data log. The number of displayed entries can be set.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 399
Creating and loading custom web pages
What you need to know about custom web pages
Concept
The concept of custom web pages allows you to access freely-designed web pages of the
CPU from a web browser. The web server of the CPU provides this function.
You are not dependent on special tools for the design and functionality of the custom web
pages. You can adapt the pages in the layout with CSS, provide dynamic content with
JavaScript or use any framework to produce web pages.
The totality of files processed by the web server is also referred to as the "web application".
Web application and user program
Using HTML code in user-defined web pages, you can also transmit data via a web browser
to the user program of the CPU for further processing and can display data from the operand
area of the CPU in the web browser.
You can use script instructions (such as Javascript) to optimize your web pages, for example
to dynamically change contents or validate user entries.
To synchronize between the user program and the web server, but also to initialize, you must
call the WWW (SFC 99) instruction in the user program.
lf no interaction is required between the web application and the user program, for example,
if a web page only provides static information, only initialization in the user program is
required.
lf a simple data exchange is necessary between PLC tags and tags in web applications, to
display the contents of PLC tags or write a value in a PLC tag for example, the syntax for
reading and writing tags has to be observed. ln this case only an initialization is required
in the user program, for example in the startup OB.
lf a further interaction is required between the web application and the user program, you
must handle status and control information from the Web Control DB in addition to the
synchronization between Web server and user program. This is the case, for example,
when user entries are transmitted via the web browser to the web server for evaluation by
the CPU. Unlike simple data exchange, the user program directly influences the time at
which the requested web page is relayed back to the web browser. ln this case, you must
be acquainted with the concept of manual fragments and the structure of the Web Control
DB.
,QLWLDOL]DWLRn
Custom web pages are "packaged" in data blocks for processing by the CPU. You must
generate appropriate data blocks from the source data (HTML files, images, JavaScript files,
etc.) during configuration to be able to download the web application into the CPU. The Web
Control DB has a special role (default: DB 333). lt contains status and control information as
well as links to additional data blocks with coded web pages. Data blocks that contain coded
web pages are termed "Fragment DBs".
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
400 System Manual, 12/2011,
When the data block is downloaded into the CPU, the CPU does not "know" that custom web
pages are coded inside it. The "WWW" (SFC 99) instruction, for example, in the Startup OB
informs the CPU which DB is the Web Control DB. The custom web pages can be accessed
via a web browser after this initialization.
Synchronization
lf the user program is to exchange data with the user-defined web pages, the WWW (SFC 99)
instruction must be used in the cyclic program section.
Examples of interaction between user program and web page:
Check received data
Assemble and send back data to the web browser making the request
ln this case, the status information must be able to be evaluated and control information must
be transmitted to the web server, for example, to release a requested web page.
3URFHGXUDORYHUYLHZ
%DVLFFRQVLGHUDWLRQV
This section provides a step-by-step explanation of the basic procedure used to create and
download custom web pages and to use them in the operating phase.
The following graphic provides a simplified representation of the process used in creating and
displaying custom web pages:
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 401
1
5
4
3
2
HTML ...
GlF ...
WWW
Programming a web application (using suitable tools when required and AWP commands for
dynamic pages when applicable).
The web application is comprised of single source files, for example, *.html, *.gif, *.js, etc.
Using STEP 7:
Generate the data blocks (Web Control DB and fragment DBs) from source files. The DBs
contain meta information and the complete web application, including the images and the
dynamic and static parts of the web application. The DBs are stored under "System blocks"
in the project tree.
Call the "WWW" instruction in the user program. This instruction initializes the web server
of the CPU for a web application.
lf required, complete final programming for interaction between the web server and user
program
Downloading the blocks to the CPU.
Call the web page in the browser. The web pages of the CPU are called by entering the lP
address of the CPU.
Additional information
You can find additional information and examples relating to the S7-1200 web server on the
lnternet (http://support.automation.siemens.com/WW/view/en/36932465).
Creating web pages
Web design tools from various companies can be used to create custom web pages. As a rule,
the web pages should be programmed and designed compliant to the conventions of the W3C
(World Wide Web Consortium). No check is made for compliance to W3C criteria in the web
server of the CPU.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
402 System Manual, 12/2011,
Rules
The tool must be able to directly edit the HTML code so that the AWP command can be
inserted into the HTML page.
Only the AWP commands are parsed in the CPU and, for example, replaced by values from
the user program/process image of the CPU.
Files containing AWP commands must be coded in UTF-8. ln the metadata of the HTML
page, therefore, set the attribute charset to UTF-8 and save the file UTF-8 coded.
Files containing AWP commands must not contain the following sequence: ]]>
Files containing AWP commands must not contain the following sequence outside of the
"Tag-read ranges" (:=<Tag name>:): :=
Tip: Replace the first character of a prohibited sequence with its character coding; for the
colon, for example, &#58;.
A small example for a custom web page should make clear the basic design.
Requirements
The CPU must have a web server and the web server of the CPU must be activated.
To be able to access PLC tags with write access as a user, you must be logged on as
"admin".
For the example below, PLC tags must be defined for those PLC tags that are to be shown
on the web page. This is shown here for the first tab used, "Tank_below_max".
Creating custom web pages
The following code for an example web page reads values from the process image and
provides them in a table.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
<title>Mix</title>
</head>
<body>
<h1>Mix</h1>
<h2> Actual State </h2>
<table border="1">
<tr>
<th>Variable</th>
<th>State</th>
</tr>
<tr>
<td>Tank below max</td>
<td>:="Tank_below_max":</td>
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 403
</tr>
<tr>
<td>Tank above min</td>
<td>:="Tank_above_min":</td>
</tr>
</table>
</body>
</html>
AWP commands
The interface between a freely-programmable web application for a CPU that has a web server
and the CPU data is declared by the AWP command (Automation Web Programming).
To develop web applications you are only subject to the restrictions of the web browser. ln one
of the programming languages of STEP 7, control with the user program which CPU data is
displayed at what time in the web browser of the viewer. Use AWP commands, which you
comment within the HTML files, to declare data to be used for intentional interaction between
the web application and the user program.
AWP commands are inserted as HTML comments with a special syntax into HTML files; they
declare the following features:
Read PLC tags
Write PLC tag
Read special tags
Write special tags
Define enum types
Assign tags to enum types
Defining fragments
lmport fragments
Syntax of AWP commands
An AWP command begins with "<!--AWP_" and ends with "-->". ln JavaScript files, the
commands should also be enclosed by JavaScript comments ("/*...*/").
Notation rules for PLC tag names within an AWP command
The AWP commands "AWP_ln_Variable" and "AWP_Out_Variable" contain a name attribute
and optionally a use attribute. A PLC tag name is assigned to these attributes, by means of
which the PLC tags in the browser are written or read. The following rules apply to handling
PLC tag names in HTML code:
PLC tags must be enclosed in quotation marks (" ... ").
PLC tags used in AWP commands must also be enclosed by single quotation marks ('" ...
"') or with quotation marks masked by a backslash ("\" ... \"").
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
404 System Manual, 12/2011,
lf the PLC tag name contains the character \ (backslash), this character must be designated
with the escape sequence \\ as standard character of the PLC tag name.
lf the PLC tag name in the AWP command is also enclosed by single quotation marks and
the single quotation mark (') occurs within the name, it must also be designed as normal
character by the escape sequence \'.
lf an absolute address (input, output, bit memory) is used in AWP command, it is enclosed
by single quotation marks.
PLC tag PLC tag in HTML code
"Velocity" <!-- AWP_In_Variable Name='"Velocity"' -->
<!-- AWP_In_Variable Name="\"Velocity\"" -->
"abc\de" <!-- AWP_In_Variable Name='"abc\\de"' -->
"abc'de" <!-- AWP_In_Variable Name='"abc\'de"' -->
"abc'de" <!-- AWP_In_Variable Name="abcde" Use'"abc\'de"' -->
"DB name".tag <!-- AWP_In_Variable Name='"DB name".tag' -->
"DB name"."ta.g" <!-- AWP_In_Variable Name='"DB name"."ta.g"' -->
- <!-- AWP_Out_Variable Name='flag1' Use='M0.0' -->
See also
Reading tags (Page 405)
Writing tags (Page 407)
Special tags (Page 408)
Reading tags
Custom web pages can read PLC tags.
The PLC tag must be specified by a PLC tag name.
These OUT variables (direction of output as viewed from the controller) are inserted at any
location within the HTML text with the syntax described in the following.
Syntax
:=<varname>:
These references are replaced when the web server is in operation by the current values of
the PLC tag in each case.
<varname> can be a simple, global CPU tag but also a complete tag path to a structure
element.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 405
Notation rules for PLC tag names
PLC tags in HTML code are enclosed by quotation marks ("), if they are defined in the tag
table. ln the case of data block tags, the name of the data block is enclosed by quotation
marks. lf special characters are used in the structure elements of the data block, for example
the dot (.) or blank, this part must also be enclosed by quotation marks.
Quotation marks are not used for absolute addresses of inputs, outputs or bit memories.
PLC tag PLC tag in HTML code
"DB_name".var_name :="DB_name".var_name:
"DB_name".struct_name.var_name :="DB_name".struct_name.var_name:
"DB_name"."var.name" :="DB_name"."var.name":
"memory" :="memory":
- :=I0.0:
:=Q0.0:
:=MW100:
:=%MW100:
"My_Data_Block".flag1 <!-- AWP _Out_Variable Name='flag1'
Use='"My_Data_Block".flag1' -->
...
:=flag1:
lf the PLC tag name contains the character : (colon) or \ (backslash), this character must
be designated with the escape sequence \: or \\ as standard character of the PLC tag name.
PLC tag PLC tag in HTML code
"abc:de" :="abc\:de":
"abc\de" :="abc\\de":
Special characters "<, &, >"
Display problems can occur if these characters are contained in the tag name (for example,
"a<b").
Avoid expressions such as :="a<b": in the HTML page.
To prevent display problems from occurring, use e.g. an AWP command with a use
expression according to the pattern depicted below. The use attribute defines the PLC tag
with the problematic character, the name attribute defines the name without problematic
character, as it is used in the HTML page.
PLC tag PLC tag in HTML code
"a<b" <!AWP _Out_Variable Name='simplename'
Use='"a<b"' -->
...
:=simplename:
See also
AWP commands (Page 404)
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
406 System Manual, 12/2011,
Writing tags
Custom web pages can write data into the CPU.
This requires an AWP command that identifies the PLC tag to be written.
The PLC tag must also be specified by a PLC tag name.
The lN tags (direction of input as viewed from the controller) are placed on the browser page.
This can be done, for example, in a form.
The tags are either set in the HTTP header (by cookie or POST method) or in the URL (GET
method) by the browser and are then written by the web server into the respective PLC tag.
Syntax
To allow the lN tags to be written to the CPU, the tags must first be defined by an explicit AWP
instruction:
<!-- AWP_In_Variable Name='<PLC_Varname1>' Name='<PLC_Varname2>'
Name='<PLC_Varname3>' -->
Several tags can be defined in an instruction - such as that shown above.
The specific PLC tag name is hereby written in double quotation marks; for example
<PLC_Varname1> = "myVar".
ln cases where the name of the tag that you use for the web application is not identical to the
name of the PLC tag, the "Use" parameter can be used to assign to a PLC tag.
<!-- AWP_In_Variable Name='<Webapp_Varname>' Use='<PLC_Varname>'
Example
The "AWP_ln_Variable" AWP command is indispensable when handling forms.
<form method='post' action='/awp/appl/x.html'>
<p>
<input name='"var1"' type='text'>
<input value='set' name='Button1' type='submit'>
</p>
</form>
ln the form defined above, the HTTP request method "post" is used to transfer the tag "var1"
to the web server. The user places the "var1" tag in the form field. The tag 'Button1' has the
value 'set', but is not required for the CPU. To allow the "var1" tag to be written to the CPU,
the following instruction must be included in the same fragment:
<!-- AWP_In_Variable Name='"var1"' -->
Since PLC tags are enclosed in double quotation marks ("), the name in the AWP command
must be enclosed in single quotation marks (') or in masked quotation marks (\"). To avoid the
numerous escape sequences, we recommend the use of single quotation marks.
<!-- AWP_In_Variable Name='"Info".par1' -->
<!-- AWP_In_Variable Name="\"Info".par1\"" -->
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 407
Conditions for write access during operation
The following requirements have to be met in order for a user to be able to write to PLC tags
from a user-defined web page.
The CPU is is password protected.
The user is logged in as "admin".
This rules applies to all writing access to web pages on a CPU.
See also
Requirements for web access (Page 397)
AWP commands (Page 404)
Special tags
Special tags are mainly HTTP tags set in the definition of the World Wide Web Consortium
(W3C) . Special tags are also used for cookies and server tags.
The AWP command to read and write special tags differ only in that they have additional
parameters than the AWP command used to read and write normal tags.
Reading a special tag
The Web server can read PLC tags and transfer these to special tags in the HTTP Response
Header. You can, for example, read a URL for a diversion to another web page and transfer
to the special tag HEADER:Location using the special tag HEADER:Location.
The following special tags can be read:
Name Description
COOKlE_VALUE:name Value of cookie with name: "name"
COOKlE_EXPlRES:name Execution time of cookie with name: "name" in
seconds (must be set beforehand).
HEADER:Status HTTP status code (if no other value has been set,
status code 302 is returned).
HEADER:Location Path for forwarding to another page. Status code
302 must be set.
HEADER:Retry-After Anticipated time in which the service is not
available. Status code 503 must be set.
HEADER: All other header tags can also be forwarded in this
way.
Use the AWP command "AWP_Out_Variable" to specify which PLC tags are to be transferred
in the HTTP header to the web browser.
Basic structure:

<!-- AWP_Out_Variable Name="<Typ>:<Name>" [Use="<Varname>"] -->
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
408 System Manual, 12/2011,
Parameter description
Name: Type and name of special tag
Use (optional parameter): ln cases where the name of the special tag is not identical to the
name of the PLC tag, parameter "Use" can be used to assign to a PLC tag.
Example:

<!-- AWP_Out_Variable Name="COOKIE_VALUE:siemens" Use='"info".language' -->
Writing a special tag
ln principle, all HTTP tags written in the HTTP header by the web browser can be evaluated
by the user program of the CPU. Examples of tag types:
Name Description
HEADER:Accept-Language Accepted or preferred language
HEADER:Authorization Proof of authorization for a requested resource
HEADER:Host Host and port of the requested resource
HEADER:User-Agent lnformation on the browser
HEADER: All other header tags can also be forwarded in this
way

SERVER:current_user_id lndicates whether a user is logged on
(current_user_id=0: no user logged on)
SERVER:current_user_name User name of the user logged on
SERVER:GET Request method is GET
SERVER:POST Request method is POST

COOKlE_VALUE:name Value of cookie with name: "name"
The AWP command "AWP_ln_Variable" is used to define which special tags are to be
evaluated in the user program of the CPU.
Basic structure:

<!-- AWP_In_Variable Name="<Typ>:<Name>" [Use="<Varname>"] -->

Parameter description:
Name: Type and name of special tag
Use (optional parameter): ln cases where the name of the special tag is not identical to the
name of the PLC tag, the parameter Use can be used to assign to a PLC tag.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 409
Examples:

<!-- AWP_In_Variable Name="COOKIE_VALUE:siemens" Use='"info".language' -->

The tag name in the HTTP header is replaced by the PLC tag name specified by Use . The
cookie is written to the PLC tag "info".language .

<!-- AWP_In_Variable Name='COOKIE_VALUE:siemens' Use='"info".language' -->

The tag name in the HTTP header is replaced by the PLC tag name specified by Use. The
cookie is written to the PLC tag "info".language .

<!-- AWP_In_Variable Name='"COOKIE_VALUE:siemens"' -->

The HTTP-header variable is written in the same-name PLC variable.
See also
AWP commands (Page 404)
Enumeration types
Enumeration types (enums)
Numerical values from the PLC program can be converted into text and vice versa using
enums. The numerical values can also be assigned for several languages.
Creating enums
Enter an AWP command using the following syntax at the start of the HTML file:
<!-- AWP_Enum_Def Name="<Name of the enum type>"
Values='0:"<Text_1>", 1:"<Text_2>", ... , x:"<Text_x>"' -->
For example, for German values to be saved as an HTML file in the "de" folder of the HTML
directory:

<!-- AWP_Enum_Def Name="Enum1" Values='0:"an", 1:"aus", 2:"Strung"' -->

For example, for English values, to be saved as an HTML file in the "en" folder of the HTML
directory:
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
410 System Manual, 12/2011,

<!-- AWP_Enum_Def Name="Enum1" Values='0:"on", 1:"off", 2:"error"' -->

Assigning enums
Tags are assigned from the user program to the individual enum texts using a special AWP
command:

<!-- AWP_Enum_Ref Name="<VarName>" Enum="<EnumTypeName>" -->

<VarName> is thereby the symbolic name from the user program and <EnumTypeName> is
the previously set name of the enum type.


Note
ln each fragment in which enum texts are referenced by a PLC tag, this PLC tag must be
assigned by the appropriate AWP command of the enum type name.

Example
Enum type "state" is defined with values "0" and "1". "0" means "off", "1" means "on":

<!-- AWP_Enum_Def Name="state" Values='0:"off", 1:"on"' -->

The following code is contained in the HTML code of the web page to be output:

<!-- AWP_Enum_Ref Name="operating state" Enum="state" -->
:=operating state:

Depending on the value of the "operating state" tag, the result displayed is no longer "0" or
"1", but "off" or "on".
Definition of fragments
Fragments
Fragments are "logical sections" of a web page to be processed by the CPU individually.
Fragments are usually complete pages but can also be individual elements such as files (for
example, images) or complete documents.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 411
Defining fragments

<!-- AWP_Start_Fragment Name="<Name>" [Type="<Type>"] [ID="<Id>"] -->

The start of a fragment is specified by this command. A fragment runs to the start of the next
fragment or to the end of the file.
<Name> lndicates the name of the fragment.
The name must start with a letter [a-zA-Z] or an underscore ( _ ). Letters, underscores or
numbers [0-9] can follow after this first character.
<Type> lndicates the type of the fragment.
"manual" The user program is informed of the request for a fragment; the web page to
be returned can be changed by the user program.
"automatic" The page is automatically processed (default).
<id> A numeric lD can be stipulated for the fragment. lf no lD is assigned, the fragment is
automatically assigned an lD. For manual pages (<Type>=manual) , the fragment can be
addressed in the user program of the CPU by this lD.


Note
Keep the lD low because the highest lD influences the size of the Web Control DB.

The input document is completely divided into fragments by the "AWP_Start_Fragment"
command. "AWP_End_Fragment" is therefore unnecessary.
Without a start fragment command, a file is mapped as a fragment; the fragment name is
derived from the file name. lf a file is divided into several fragments (by
"AWP_Start_Fragment"), the file must begin with the "AWP_Start_Fragment" command.
lmporting fragments
You can declare a fragment in an HTML page and import this fragment into other web pages.
Example
A company logo is to be displayed on all web pages of a web application.
There is only one instance of the HTML code for the fragment that displays the company logo.
You can import the fragment as often and into as many HTML files as required.
Syntax

<!-- AWP_Import_Fragment Name = "<name>"-->

Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
412 System Manual, 12/2011,
<name> is the name of the fragment to be imported.
Example
HTML code within a web page that declares a fragment:

<!-- AWP_Start_Fragment Name = "My_Company_Logo"-->
<p><img src = "compay_logo.jpg"></p>
Example
HTML code within another web page that imports the declared fragment:

<!-- AWP_Import_Fragment Name = "My_Company_Logo"-->

Creating and loading a data block
Requirement
All source files required for the web application have been created.
Procedure
To create data blocks from the source files for custom web pages in STEP 7, proceed as
follows:
1. Select the CPU, for example, in the device configuration.
2. Select the properties for custom web pages in the inspector window under "Properties >
General > Web server".
3. As "HTML source", select the folder that contains the source files for the web application.
4. Enter the HTMP page to be opened on starting the web application as the start HTML page.
5. Enter a name for the application if required.
6. You can supplement a range of file name extensions as "Files with dynamic content" if
necessary. Only enter those file name extensions that also contain AWP commands.
7. The number for the Web Control DB and for the fragment DB start number can be kept as
long as they are not already being used by your user program.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 413
8. Click on the "Generate" button to create DBs from the source files.
The generated data blocks are saved in the project navigation in the "System block" folder
(in the "Web server" subfolder).
9. ln the CPU, select the network view to be loaded and then select the "Download to device"
command in the "Online" menu to download the blocks. Compilation of the blocks is
implicitly initiated before downloading.
lf errors are reported during this process, you must correct these errors before you can
download the configuration.
Structure of the PLC program
Your user program must call the " WWW" instruction to even allow the web application, for
example, the custom web pages, to be available to the CPU on the standard web pages and
to allow them to be called up there.
The Web Control DB you have created from the source files is the input parameter (CTRL_DB)
for the "WWW" instruction. The Web Control DB references the content of the custom web
pages coded in the fragment DB and then receives status and control information.
Calling the "WWW" instruction in the startup program
lf you do not want the user program to influence requested web pages, it is sufficient to only
call the "WWW" instruction once in a startup OB. This instruction initializes communication
between the web server and the CPU.
Calling the "WWW" instruction in the cyclic program
The "WWW" instruction can also be called in an OB processed in cycles (for example, OB 1).
This has the advantage of being able to respond to web server requests from within the user
program. Manual fragments must be used for this.
ln this case, you must evaluate information from the Web Control DB in order to identify the
requested web page or the requested fragment. On the other hand, you must set a bit in the
user program in order to explicitly release the web page to be returned by the web server after
processing the web page request.
The structure of the Web Control DB is described in the following section.
Web Control DB
The Web Control DB (DB 333 by default) is created by STEP 7 and contains information on
the structure of user pages, the status of communication and any errors that occur.
Additional fragment DBs are also created as well as the Web Control DB. These fragment DBs
(there may also only be one fragment DB) are referenced in the Web Control DB. The fragment
DBs contain the web pages and media data coded in fragments, for example, images. The
content of the fragment DB cannot be changed by the user program. lt is created automatically
and is only for data management.
The status and control tags of the Web Control DB are accessed via symbols.
The following lists the tags of the Web Control DB required for status evaluation and to control
interaction.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
414 System Manual, 12/2011,
The Web Control DB provides two types of information:
Global status information: Not bound to a concrete web page request.
Request status and control information: lnformation about queued requests.
Global status information
"WEB-Control_DB".commandstate.init Activates and initializes the web application.
"WEB-Control_DB".commandstate.deactivate Deactivates the web application.
"WEB-Control_DB".commandstate.inititializing The web application is initialized (read Web
Control DB, etc.).
"WEB-Control_DB".commandstate.error Web application could not be initialized. The
reason is coded in "WEB-
Control_DB".commandstate.last_error .
"WEB-
Control_DB".commandstate.deactivating
The web application is closed.
"WEB-Control_DB".commandstate.initialized The web application has been initialized and is
ready.
"WEB-Control_DB".commandstate.last_error Refer to the next table for a value table of
possible errors.
Last_error Description
1 Fragment DB is inconsistent (does not match the Web Control DB).
2 A web application already exists with this name.
3 Memory problem initializing in the web server.
4 lnconsistent data in the Web Control DB.
5 A fragment DB is not available (not loaded).
6 No AWP lD for a fragment DB.
7 The enum fragment is not available (contains the texts and information on the enum
types).
8 An action requested via the command flag in the Web Control DB is prohibited in the
current state.
9 Web application is not initialized (if there is no reinitializing after disabling).
10 Web server is disabled.
... Last_error is reset once the web application has been successfully initialized.
Request status information
Request status information is bound to one of four possible requests, x = [1 4].
"WEB-Control_DB".requesttab[x].idle Nothing need be done.
"WEB-Control_DB".requesttab[x].waiting The user program must react to a request from
a manual fragment and explicitly initiate further
processing in the web browser.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 415
"WEB-Control_DB".requesttab[x].sending The web server is occupied with processing the
request/fragment.
"WEB-Control_DB".requesttab[x].aborting The TCP connection is closed by the web
server.
Request control information
Request control information is bound to one of four possible requests, x = [1 4].
"WEB-Control_DB".requesttab[x].continue Releases the fragment being processed for
transmission. Processing of the next fragment
is initiated.
"WEB-Control_DB".requesttab[x].repeat Releases the fragment being processed for
transmission. The fragment is then processed
again.
"WEB-Control_DB".requesttab[x].abort Closes the TCP connection.
"WEB-Control_DB".requesttab[x].finish Releases the fragment being processed for
transmission. Stops further processing of
requests (terminates the request).
Example:
The tag for the DB is: "WEB-Control_DB". Whether errors have occurred during initialization
of the web application can be determined by requesting bit "WEB-
Control_DB".commandstate.error in the user program.
lf an error has occurred you can analyze it using the "WEB-
Control_DB".commandstate.last_error value.
lnteraction with the user program
Using manual fragments ensures that the user program reacts synchronously to the user
program, thereby allowing the responding web page to be processed by the user program.
Fragment type
To react to the received data in the user program the "manual" fragment type must be used
for the fragment writing the data (for "manual pages"):
<!-- AWP_Start_Fragment Name="testfrag" ID="1" Type="manual" -->
The values are always transferred to the web server of the CPU for automatic and manual
pages in the same way:
Example:
<form method="POST" action="">
<p>
<input type="submit" value="Set new value">
<input type="text" name='"Velocity"' size="20">
</p>
</form>
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
416 System Manual, 12/2011,
User program for manual fragments
When using manual pages, the "WWW" instruction must be called in cycles in the user program
of the CPU.
To react to values entered in the browser, the request - which is made by the manual page to
the web server - must first be evaluated in the user program. To do this, the Web Control DB
(for example, DB 333) must be examined in cycles for queued requests. The array that
manages four requests is contained in the "requesttab" section of the Web Control DB. Each
element of the array thereby contains information on the respective request within a structure.
A simple programming example shows how queued requests are checked based on the tags
of the Web Control DB.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 417

ln cases where a request has been made, this program section writes the fragment lD in the
#frag_index tag and the request no. (value range 1-4) in the #req_index tag.
Using the information from this, the information transferred in the request can now be
processed separately for each fragment lD in the program (for example, plausibility check).
Once processing of the request has been completed by the program, the request must be
answered and the appropriate entry is once more reset under"requesttab" of the Web Control
DB (for example, DB 333).
A simple programming example for replying to requests:

Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
418 System Manual, 12/2011,
Principle sequence of a browser request with interaction from the user program
The following figure shows the simplified, principle sequence of the web browser request on
the effects of Web Control DB content and the actions required from the user program until
the processed web page is returned (response).
CPU
W
e
b

s
e
r
v
e
r
W
e
b

C
o
n
t
r
o
l

D
B
U
s
e
r

p
r
o
g
r
a
m
Request
DB.waiting = TRUE DB.req.continue = TRUE
Response
Web browser
Process request Process response
1) 2) 3) ldentify requested
page (request)
Evaluate and
process lN varia-
bles, set OUT
variables
Enable requested
page
Set lN variable
(data table)
Write lN variable
(data table)
Displaying custom web pages in the browser
Display web pages in browser
Web pages are called from the standard web pages of the web browser.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 419
ln addition to the other links in the navigation bar, the standard web pages also have a link to
"user pages".
Click on the "user pages" link to open the web browser you have configured as the default
HTML page.
Creating custom web pages in several languages
You can make each of your custom web pages available in various languages.
Requirements
The language-dependent HTML; pages must be stored in a folder structure containing folders
with the respective language abbreviations:
Specified language abbreviations
Language abbreviations "de", "en", "fr", "es", "it" and "zh" are fixed. Additional language folders
or other designated language folders are not supported.
Additional folders within the same folder hierarchy for other files can be created as required;
for example, an "img" folder for images and a "script" folder for JavaScript files.
Language switching for custom web pages
Requirements
The HTML pages are contained in the predefined language folders, for example, HTML pages
with German text are in the "de" folder, HTML pages with English text are in the "en" folder.
Language switching concept
Language switching is based on a predefined cookie named "siemens_automation_language".
lf the cookie is set to value "de", at the next web page request or web page update, the web
server switches to the web page from the "de" folder.
Similarly, the web server switches to the web page from the "en" folder when the cookie is set
to "en".
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
420 System Manual, 12/2011,
Example of language switching
The example is structured as follows:
The language-dependent HTML files with the same name, for example, "langswitch.html"
are located in both language folders "de" and "en". The text to be displayed within the two
files are German or English, corresponding to the name of the folder.
There is an additional "script" folder in the folder structure containing the JavaScript file
"lang.js". Functions required for language switching are stored in this file .
Structure of the "langswitch.html" file ("de" folder)
Meta data "content language", charset and path to JavaScript file are set in the file header.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="de">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Switch language to German page</title>
<script type="text/javascript" src="script/lang.js" ></script>
<head>
Language selection is implemented in the body of the file by the "select" HTML element. The
select element initiates a list box and contains the "de" option, labeled as "German" and "en",
labeled as "English"; "de" is the default.
The "DoLocalLanguageChange(this)" function is called using the "onchange" event handler.
The "this" parameter transmits the select object with the selected option to this function.
"onchange" calls the function each time the option is changed.
<!-- Language Selection -->
<table>
<tr>
<td align="right" valign="top" nowrap>
<!-- change language immediately on change of the selection
-->
<select name="Language"
onchange="DoLocalLanguageChange(this)" size="1">
<option value="de" selected >Deutsch</option>
<option value="en" >English</option>
</select>
</td>
</tr>
</table>
<!-- Language Selection End-->
Structure of the "langswitch.html" file ("en" folder)
The header of the HTML file with English text is structured similarly to the HTML file with
German text.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en">
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 421
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Language switching english page</title>
<script type="text/javascript" src="script/lang.js" ></script>
Language selection is also implemented in the body of the file by the "select" HTML element.
ln contrast to the German HTML file, the English option is already selected as a default and
the test or the labels are in English.
<!-- Language Selection -->
<table>
<tr>
<td align="right" valign="top" nowrap>
<!-- change language immediately on change of the selection
-->
<select name="Language"
onchange="DoLocalLanguageChange(this)" size="1">
<option value="de" >German</option>
<option value="en" selected >English</option>
</select>
</td>
</tr>
</table>
<!-- Language Selection End-->
Structure of "lang.js" file (in the "script" folder)
The "DoLocalLanguageChange" function is defined in the JavaScript file; this in turn calls the
"SetLangCookie" function with the value of the language selection. SetLangCookie combines
the cookie name and the cookie value and then sets the cookie using the appropriate
document.cookie property. The web page must then be reloaded (top.window.location.reload)
to allow the web server to react to the setting of the cookie by displaying the required language.

function DoLocalLanguageChange(oSelect) {
SetLangCookie(oSelect.value);
top.window.location.reload();
}

function SetLangCookie(value) {
var strval = "siemens_automation_language=";
// this is the cookie by which the web server
// detects the desired language
// this name is required by the web server
strval = strval + value;
strval = strval + "; path=/ ;";
// set path to the application, since otherwise
// path would be set to the requesting page
// would not get the cookie.
// The path for user defined applications follows this
sample:
// path=/awp/<application name>/<pagename>
// example: path=/awp/myapp/myappstartpage.htm
//(where myapp is the name of the web application
// entered in the web server properties of the cpu)
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
422 System Manual, 12/2011,
/*
use expiration if this cookie should live longer
than the current browser session
var now = new Date();
var endttime = new Date(now.getTime() + expiration);
strval = strval + "; expires=" + endttime.toGMTString()
+ ";";
*/
document.cookie = strval;
}
Additional configurations
Configuring additional functions
The S7-1200 automation system has numerous additional functions that are useful as
integrated CPU functions or available via plug-in modules (for example, communication
modules). You can find the description via the following links.
See also
Overview of point-to-point communication (Page 535)
General information on high-speed counters (Page 530)
Configuring PlD Compact (Page 2723)
Configuring PlD_3Step (Page 2742)
Motion functionality of the CPU S7-1200 (Page 2761)
8.1.4.2 Configurations for PROFlBUS DP
The basics of configuring a DP master system
Distributed l/O
DP master systems that consist of a DP master and DP slaves which are connected via a bus
and communicate with one another via the PROFlBUS DP protocol are referred to as
distributed l/O.
Firmware version of the S71200 CPU
Use of the PROFlBUS functions with the S71200, requires CPUs with firmware version 2.0
or higher.
Editing devices and networks
8.1 Configuring devices and networks
STEP 7 Basic V11.0 SP2
System Manual, 12/2011, 423

Você também pode gostar