In the following we show two different ways of archiving STRING tags.
Archiving STRING tags using a script
Archiving STRING tags using a message archive
At the end of this entry there is a sample project in which both ways are implemented. An MP277 Touch operator panel and PC Runtime were used.
||Archiving STRING tags using a script|
||This sample program shows how you can archive STRING tags in a CSV file using a script.
The scripts used in the project have the same functionality
(archiving of STRING tags).
The scripts differ mainly in the display of the CSV file created.
(See "Fig. 04" and "Fig. 05" below).
Note the difference in VBS syntax in Windows-based CE devices and in PC Runtime. The commands are sometimes different in these operating systems.
Thus the script stored in the MP277 Touch cannot be tested in the RT simulation.
||Function/structure of the scripts:|
An archive file is created via the script, or if already available, the archive file is opened and the tag values are added.
The name of the file is composed of the month and year when the tags were stored.
The script runs each time there is a change of tag value.
"Script_01" has two parameters.
With these parameters you define the storage path (e.g. "Drive C:\" or "\Storage Card MMC\") and the name of the tag to be archived.
"Script_02" has one parameter.
You use this parameter to specify the storage path (e.g. drive C:\).
The tags to be archived are specified in this script.
The VBS functionality gives you a wide range of options for influencing the display and parameterization of the separate scripts.
You can change the scripts as you wish to suit your requirements.
Please refer to the WinCC flexible Online Help or relevant specialist literature for information on the functions and commands used.
For the sake of clarity...
- Tags "Tag_01 to Tag_03" have been assigned to "Script_01".
- Tags "Tag_10 to Tag_12" have been assigned to "Script_02".
The relevant script is called in the Properties of the tags - "Properties > Events > Change value".
Input/specification of the storage path and the tag name.
The storage path and tag name, e.g. for the "TagName" parameter, must be entered "manually".. Do not use the "Selection window" or "Automatic completion" for this.
- When entered, the "Text" must not be displayed as "bold".
- Copy the complete tag name from the "Tag Editor" and paste the "Text".
If you take the tag name from the "Selection window", for example, the value of the object is not transferred to the parameter, but only the "Reference" to that object (similar to a link).
On the other hand, this might be necessary for other application cases.
You can use the "Screen_1" screen to test the functions stored.
Enter a text in the appropriate IO fields and accept the entries with the Enter key.
||Excel file view:
"Archiv_01_1_2008.csv" (Archive_01, January 2008)
The STRING tags to be archived are listed one after the other.
"Archiv_02_1_2008.csv" (Archive_02, January 2008)
The STRING tags to be archived are listed in separate columns.
||Archiving STRING tags using a message archive|
||This sample program shows how you can archive STRING tags in a CSV file using a message archive.|
The STRING tags to be archived are configured as "bit alarms" - only the "STRING tag" is entered in the alarm text line instead of an alarm text.
When one of these "bit alarms" is "called" (via the Trigger tags), they are stored in an alarm log.
In this sample application, tags Tag_20; Tag_21 and Tag_22 are stored in an alarm log.
The function "InvertBitInTag" was configured for the tags under "Properties > Events > Change value".
The parameterized tag "Trigger_Tag_Log_File" is the tag which later triggers the "bit alarms". The "Bit" corresponds to the number of the "Trigger Bit".
-> see Point 6 below
||Configure bit alarm:
- Alarm class
A separate alarm class was created for better handling. In this way, you can assign a separate alarm class for the "bit alarms" configured.
- Bit alarm
Below is the procedure for creating the "bit alarm".
- Point 1:
Only a STRING tag is entered in the text line instead of a text.
Under the item "Properties > General > Settings > Text" you can add fields for output of tag values.
- Point 2:
Under the item "Class" you select the newly created alarm class "String_Log_File_Class".
- Point 3:
The "Trigger_Tag_Log_File" tag is used as "Trigger tag".
When the relevant bit is set, the associated "alarm" is displayed.
- Point 1:
In Point 1, three IO fields are configured via which you can enter the texts later.
- Point 2:
The archived alarm texts are output via this alarm display.
- Point 3:
Selection of the "alarm log" parameter and selection of the alarm log "String_log_01".
- Point 4:
Selection of the alarm class "String_Log_File_Class".
- Point 5:
You can recall "Screen_2" with this button to update the display of the alarm log.
||Handling and method:
You can enter texts via the IO fields (1).
The entry causes a "Change value" in the stored tag and the function behind the tag is executed - the bit of the "Trigger_Tag_Log_File" tag is inverted. Change from 0->1 or 1-> 0 (see also Point 3 - Tag declaration).
This change in value of the "Trigger_Tag_Log_File" tag sets or resets the relevant alarm bit and an alarm is triggered/reset automatically (see also Point 4 - Bit alarm).
For this application, the "message" is not displayed directly in alarm display as "error message", but the "message" is only for storing the tag text in a CSV file.
In this application, the alarm log (2) is only for output of the content of the stored texts in the CSV file. It is not possible to write back the data/texts from the CSV file.
You can use the button (3) to update the display of the alarm log.
The attached download contains the archived WinCC flexible project with the sample functions described above.
Attachment 1: Project_01.zip ( 3416 KB )
Runnability and test environment:
The following table lists the components that have been used to create this entry and verify the functions described.
||Product and version designation|
|PC operating system
||Microsoft Windows XP SP2|
||WinCC flexible 2007 HF3|
Table 1: Creation environment of the download attached