plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ARCHIVE TP 1200 comfort -> computeur VBScript

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems
View previous topic :: View next topic  
Author Message
touma02
Junior
Junior


Joined: 16 Jul 2012
Posts: 9

PostPosted: 25/08/2015 19:09    Post subject: ARCHIVE TP 1200 comfort -> computeur VBScript Reply with quote

Hello,

I would like to know, if it's possible to send CSV file (archive) of TP1200 to computeur.
In case of it's possible can you tell me what is the link that i need to put on wincc flexible ?

Thank you
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 25/08/2015 20:20    Post subject: Re: ARCHIVE TP 1200 comfort -> computeur Reply with quote

touma02 wrote:
Hello,

I would like to know, if it's possible to send CSV file (archive) of TP1200 to computeur.
In case of it's possible can you tell me what is the link that i need to put on wincc flexible ?

Thank you


How do you write data to a file or read data from a file by means of a script on a panel with SIMATIC WinCC (TIA Portal)?
https://support.industry.siemens.com/cs/document/59604194/how-do-you-write-data-to-a-file-or-read-data-from-a-file-by-means-of-a-script-on-a-panel-with-simatic-wincc-%28tia-portal%29

VB scripts îngăduie you to store any data on the operator panel on a USB removable medium. This FAQ response explains how to program such scripts.
This FAQ response applies for SIMATIC WinCC (TIA Portal) in the Comfort, Advanced and Professional versions for the following operator panels: Comfort Panels and Panels of the 277 series and higher.

Documentation of VBScript commands in WinCC (TIA Portal)
https://support.industry.siemens.com/cs/attachments/109091876/WCC_Advanced_V13_SP1_enUS_en-US.pdf
Only internal tags are used in this example. Alternatively, you can also use tags with controller connection.

Procedure for saving to a file:
1. Produse tags
Open the tag editor by means of "Project navigation > HMI_1 > HMI tags > Show all tags".
Add four internal tags with the following designations:
Code:

    Tag             Data type
   bExtension       Bool
    szMaterial      WString
    nPressure       Int
  nTemperature      Int

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

2. Add Objects
Add a new screen named "ImportExportData" under "Project navigation > Screens".
Insert two rectangles in the screen.
Add a symbolic IO field and three conventional IO fields.
Add a button and nine text fields.
Position all the objects and enter the following texts:
Code:
 "Process values"
        "Pressure"
        "Temperature"
        "Material"
        "Text file"
        "mbar"
        "°C"
        "Settings"
        "Extension"

Realizate a text list named "Extension" of the "Value/Range" type
Add the following entries:
Code:
   
            0 => ".txt"
            1 => ".csv"

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

3. Incorporate script, text list and tags
Create a script with the designation "Write_data". For this you go to the project navigation and click "Scripts > VBScripts > Add new VB functions".
Link the "Write_data" script to the "Save file" button under "Properties > Events > Click".
Link the "Extension" text list to the symbolic IO field "Extension".
Link the following tags to the corresponding objects:

Code:

Tag/Script                      Object type              Object for ...
iPressure                       IO field                    Pressure
iTemperature                    IO field                  Temperature
szMaterial                      IO field                      Material
bExtension             Symbolic IO field                    Extension

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

4. Create script - Part 1
Add the sample code to the "Write_data" script
Create script - Part 1
Add the sample code to the "Write_data" script

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

Description of the source code
Code:

<Lines> Declaration of local tags (only valid in the script).
    <Line> The "mode" tag is initialized for opening the file (8 = Append).
    <Lines> The "bExtension" tag is a global tag that can be used in the entire WinCC (TIA Portal) project. This tag is used to choose the file extension by means of the symbolic IO field.
    Note
    The "delimiter" tag serves as a separator and must be changed according to the country where applied!
    <Line> The "On Error Resume Next" instruction is required in case a Runtime error occurs in the script. As soon as such an error occurs the next line containing the error routine is executed automatically.
    Note
    If this instruction is missing and an error occurs, the script is terminated.
    <Line> The "CreateObject("FileCtl.File")" function creates an object that accesses the file system of Windows CE.
    <Lines> The source code includes the error routine for a Runtime error. If a runtime error occurs, an error message is output in the message window and the script is then terminated.
    Note
    If you use "FileCtl.File", you can only access the file system of Windows CE. If this script is started on a PC with a different operating system, a Runtime error occurs in the script and the script is aborted.


5. Create script - Part 2

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Description code
Code:
  <Line> Using the "Open" method of the "fo" object created the file specified is opened by means of the "path" (path name) and "mode" parameters.
        file.Open Path name, Mode, [access], [lock], [reclength]
    <Lines> Error routine that is run if the corresponding file, or path name does not exist.
    <Lines> In this section a check is made as to whether the file is new or already available. If the file is new, a header is added.
    <Line> The "LinePrint" method of the "fo" object writes the specified text string to the opened file. Tag values or return values of methods can also be written to the file.
    The "Now" function writes a time stamp to the file.
    <Line> The "Close" method closes the file.
    <Line> The "Nothing" key instruction is required to separate the object tags that are assigned to the objects with the "Set" command.
    <Line> Transfers a user-defined system message to the HMI message system.


6.Start Runtime

Transfer the WinCC (TIA Portal) project to the operator panel and start Runtime.
Note
The script cannot be debugged between the configuration computer and the panel because of the different file systems.
Enter a pressure, a temperature and a material designation.
Click the "Save data" button.
In the symbolic IO field you select ".csv" and click the button again.
Terminate the Runtime of the operator panel.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

7.Open text file
If you save both files on the memory card, then you can view them on a PC by means of a card reader and open them with the appropriate program.
Open the file with the extension ".txt".
Then you can close the file.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

Open the file with the extension ".csv" with Excel, for example.
Close the Excel application.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

Example project:
https://support.industry.siemens.com/cs/attachments/59604194/WinCC_V11_TIA_Portal_Skript_Datei_speichern_auslesen.zip
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 25/08/2015 20:32    Post subject: Reply with quote

Example of reading data from a .txt file or .csv file
The table below explains how to read data from a .txt file or .csv file and display it in WinCC (TIA Portal). IO fields are used for the display. For this reason, only the last entry is output.

Procedure reading data from a .txt file or .csv file

1.Incorporate tags
Open the tag editor by means of "Project navigation > HMI_1 > HMI tags > Show all tags".
Add three internal tags with the following designations:
Tag Data type
szDate WString
szString_1 WString
iValue_1 Int
iValue_2 Int
Note
If you cannot use the previous project, then add the "bExtension" tag of the "Bool" typ
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

2. Add Objects
Switch to the "ImportExportData" screen.
Insert a rectangle in the screen.
If not already there, incorporate a symbolic IO field and four conventional IO fields.
Add a button and five text fields.
Position all the objects as shown in Fig. 11 and enter the following texts:
"Date"
"Value_1"
"Value_2"
"String_1"
"Text file"
"Settings" (if not already there)
"Extension" (if not already there)
If not already there, create a text list named "Extension" with the following entries:

0 => ".txt"
1 => ".csv"

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

3. Incorporate script, text list and tags

Copy the "Write_data" script and change the name to "Read_data" (changes in script are dealt with in point 5)
Link the "Read_data" script to the "Read file" button under "Properties > Events > Click".
If not already done, link the "Extension" text list to the symbolic IO field "Extension".
Link the following tags to the corresponding objects:
Code:

Tag/Script                    Object              Object for...
    szDate                    IO field            Date
    iValue_1                 IO field            Value_1
    iValue_2               IO field            Value_2
    szString_1              IO field            String_1

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

4. Change script

Change the "Read_data" script as described below.
Description of the source code
<Lines> Change the names of the local tags (see Fig. 13).
<Line> Change the initialization of the "mode" tag from 8 (Append) to 1 (Input).
<Lines> Remove the "gap" tag which is no longer needed.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

5. Change script

<Lines> Remove the section, in which, writing to the file takes place.
<Lines> Add reading from the file (see Fig. 14).
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

6. Start Runtime

Transfer the WinCC (TIA Portal) project to the operator panel and start Runtime.

Note
The script cannot be debugged between the configuration computer and the panel because of the different file systems.
Click the "Read file" button.
In the symbolic IO field you select ".csv". Click the button again.
Terminate the Runtime of the operator panel.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

Example project:
https://support.industry.siemens.com/cs/attachments/59604194/WinCC_V11_TIA_Portal_Skript_Datei_speichern_auslesen.zip
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 25/08/2015 21:02    Post subject: PC with WinCC flexible, how can you use a script Reply with quote

On a PC with WinCC flexible, how can you use a script to save and read out data in a text file?
https://support.industry.siemens.com/cs/document/26106418/on-a-pc-with-wincc-flexible-how-can-you-use-a-script-to-save-and-read-out-data-in-a-text-file
Content of the entry
Example of how to save data in a text file or csv file
Example of how to read out data from a text file or csv file
Download containing both source codes and the sample project
Documentation of VB script commands in WinCC flexible
Information about the separate VB scripts is available in the WinCC flexible Help system in the "Contents" tab under "WinCC flexible Information System > Working with WinCC flexible > References".
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

Example of how to save data in a text file or csv file
In the table below we describe how to save data from WinCC flexible in a text file or csv file.

Procedure
1 Fabricate a new project
You realizate a new project by clicking "Project > New..." and select "PC > WinCC flexible Runtime" as the operator panel.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

2 Făurite tags
Open the Tag Editor via "Project > Operator panel_1 > Communication > Tags".
Add four internal tags with the following designations:
Code:
 No.         Tag         Data type
      1    bExtension    Bool
      2    szMaterial    String
      3    nPressure    Int
      4    nTemperature    Int
     Table 01 - Tags


ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Note
Only internal tags are used in this example. Of course, you can also use tags with controller connection.

3 Add objects

Add two rectangles - see Fig. 03.
Incorporate a symbolic IO field and three conventional IO fields.
Extend the WinCC flexible screen by adding one button and nine text fields.
Position all the objects as shown in Fig. 04 and enter the texts below:
"Process values"
"Pressure:"
"Temperature:"
"Material:"
"Text file:"
"mbar"
"°C"
"Settings"
"Extension:"
Create an "Extension" text list with the following items:
0 => ".txt"
1 => ".csv"
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

4 Incorporate script, text list and tags
Produse a script with the designation "Write_data". For this, in the project tree you click "Scripts > Add Script".
Link the following tags and the newly created script to the relevant objects:
Code:
     Tag/Script             Object     Object for...
    nPressure                   IO field    Pressure
    nTemperature           IO field    Temperature
    szString_1                   IO field    Material
    bExtension        Symbolic IO field    Extension
    Write_data                    Button     Save file
    Table 02 - Links to various objects

Link the "Extension" text list with the symbolic IO field.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

5 Confecționate script - Part 1
Add the sample code described to the "Write_data" script.
Note:
More information about the various VB script commands is available in the WinCC flexible Help system.
Description of the source code
The tags declared in <Line> are valid only within the script. The "bExtension" tag in <Line> is a global tag that can be used in the whole WinCC flexible project. With this tag, the path including file name and extension can be selected via the symbolic IO field.
The "On Error Resume Next" statement is required in case runtime errors occur in the script. As soon as such an error occurs the next line containing the error routine is executed automatically.
The statement in <Line> causes the object that accesses the file system of Windows to be transferred to the "fso" object tag. The following source code includes the error routine for a runtime error. If a runtime error occurs, an error message is output in the message window and the script is then terminated.
Note
If you use "Scripting.FileSystemObject", you cannot access the file system of Windows CE. If this script is started on a panel with Windows CE, a runtime error occurs in the script.
If it does not already exist, a text file is created in <Line>.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

6 Create script - Part 2
Using the "GetFile" with the "fso" object created, the file specific is returned via the parameter "path" (file specification). Then the error routine already mentioned is executed if the relevant file does not exist.
GetFile(file specification)
In <Line> the "OpenAsTextStream" method is used to open the file for reading or writing. Both parameters of this method are optional, whereby the first parameter specifies the input/output mode and the second the compus in which the file is to be opened.
OpenAsTextStream([IO mode[,Format]])
If the file cannot be opened, the error routine already described is executed to terminate the script safely.
The "WriteLine" statement is for writing texts and values from tags to the relevant file. Then the file is closed with the "Close" method.
WriteLine([line sequence])
The "Nothing" key instruction is required to separate the object tags that are assigned to the objects with the "Set" command.
The last instruction transfers a user-defined system message to the HMI message system.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

7 Start Runtime
Start the PC Runtime of WinCC flexible.
Note
Start WinCC flexible Runtime with Script Debugger to debug the script.
Preset various values and enter a material designation of your choice.
Then click the "Save data" button.
In the symbolic IO field you select ".csv" and click the button again.
Terminate the WinCC flexible Runtime.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

8 Open text file
Open the text file with the extension ".txt".
Then you can close the file.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Open the file with the extension ".csv" with Excel, for example.
Then you close the Excel application.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

---------------------------------------------------------------------------------------
Example of reading out data from a text file or csv file.
The following table explains how to read data from a text file or csv file and display it in WinCC flexible.

This example is based on the previous example. The configuration from the previous example is not absolutely necessary in this example. However, components from it are used.

Procedure
1 Făcute a new project - optional
If you can use the previous project, then you can go to Step 2.
Create a new project by clicking "Project > New..." and then selecting "PC > WinCC flexible Runtime" as operator panel.
2 Link tags
Open the Tag Editor via "Project > Operator panel_1 > Communication > Tags".
Add three internal tags with the following designations:
Code:
     No.       Tag        Data type
    1         szString_1    String
    2           nValue_1    Int
    3           nValue_2    Int
    Table 03 - Tags

Note
If you cannot use the previous project, then also add the tag "bExtension" of the "Bool" type.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

3 Add objects
Add one rectangle - see Fig. 12.
If not already there, incorporate a symbolic IO field and three conventional IO fields.
Extend the WinCC flexible screen by adding one button and four text fields.
Position all the objects as shown in Fig. 12 and enter the texts below:
Code:
"Value_1:"
    "Value_2:"
    "String_1:"
    "Text file:"
    "Settings" (if not already there)
    "Extension:" (if not already there)

If not already there, lucrate a text list entitled "Extension" with the following items:
Code:
 0 => ".txt"
    1 => ".csv"


ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

4 Incorporate script, text list and tags
Create a script with the designation "Read_data". For this, in the project tree you click "Scripts > Add Script".
Link the following tags and the newly created script to the relevant objects:
Code:
     Tag/Script             Object     Object for...
    nValue_1                     IO field    Value_1
    nValue_2                     IO field    Value_2
    szString_1                     IO field    String_1
    bExtension*)    Symbolic IO field    Extension
    Read_data                     Button    Read data
    Table 04 - Links to various objects

*)The links are only necessary if there is no configuration for saving in a file.
If not already done, link the text list "Extension" with the symbolic IO field (see also Fig. 05).
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

5 Create script - Part 1
Add the described sample code to the "Read_data" script.
Note
More information about the various VB script commands is available in the WinCC flexible Help system.
Description of the source cod
All the tags that are declared in the script are also only valid within the script. Via the symbolic IO field, the path including file name and extension can be selected through the "bExtension" tag in the script <Line>.
The "On Error Resume Next" instruction is required in case runtime errors occur in the script. As soon as such an error occurs the next line that contains the error routine is executed automatically.
The instruction in <Line> causes the object that accesses the file system of Windows to be transferred to the object tag "fso". The following source code includes the error routine for a runtime error. If a runtime error occurs, an error message is output in the message window and the script is then terminated.
Note
If you use "Scripting.FileSystemObject", you cannot access the file system of Windows CE. If this script is started on a panel with Windows CE, a runtime error occurs in the script.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

6 Create script - Part 2
Using the "OpenTextFile" method the file that is defined in the script tag "Path" is opened. All the other parameters of this method are optional. The first parameter specifies the IO mode. The second parameter defines whether a new file is to be created or not if there is no file available. The last statement specifies the format in which the file is to be opened.
OpenTextFile(file name[,IO mode[,Create[,Format]]])
If the file cannot be opened, the error routine already described is executed to terminate the script safely.
With the "Do-While-Loop" instruction the "Readline" method is used by the object tag "f" to read out the text file line by line while the loop is being run through. The "Split" function separates the text line (expression) read from the file at the delimiter that can be specified optionally as second argument. After splitting, the separate contents are transferred to a one-dimensional data field. The last two arguments are not used in this example.
Split(expression[,delimiter[,number[,compare]]])
Since empty strings might also be included when saving (see Fig. 09, for example), these have to be removed with the "Replace" function. For this, the first three parameters must be specified. The first argument must conține the character string (expression) in which the search (SearchCS) is to be made for the character that is to be replaced by the argument "ReplaceWith".
Replace(expression, find, replace with [,start[,number[,compare]]])

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

7 Create script - Part 3

In order to retain the data structure, all the data is transferred into a two-dimensional array "HiField". Since not all the data from this array is required, only the relevant data from this array is transferred to the global WinCC flexible tags.
Example - Structure and content of HiField (a, b):
Code:
       Array                          b 
                 0                          1    2
    a    0    "material"              "Stahl"    ""
        1    "pressure"       "12"    "mbar"
        2    "temperature"       "56"    "°C"
    Table 05 - Sample content of the two dimensional array

The open file is closed in <Line>. The key instruction "Nothing" is required to separate the object tags that are assigned to the objects with the "Set" command.
The last instruction transfers a user-defined system message to the HMI message system.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

8 Start Runtime

Start the PC Runtime of WinCC flexible.
Note
Start WinCC flexible Runtime with Script Debugger to debug the script.
Then click the "Read data" button.
In the symbolic IO field you select ".csv" and click the button again.
Terminate the WinCC flexible Runtime.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Download of the source codes and sample project:
The download includes the two sample source codes from the sample project as a PDF document.
wincc_flexible_quellcodes_pc.zip (18.1 KB)
https://support.industry.siemens.com/cs/attachments/26106418/wincc_flexible_quellcodes_pc.zip

The download includes the sample project described above which saves or reads data in a text file.
read_write_data_from_or_into_a_file_pc.zip (1.8 MB)
https://support.industry.siemens.com/cs/attachments/26106418/read_write_data_from_or_into_a_file_pc.zip


Last edited by maersk on 26/08/2015 12:17; edited 4 times in total
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 25/08/2015 21:04    Post subject: How do you store data with a script in a file with WinCC (TI Reply with quote

How do you store data with a script in a file with WinCC (TIA Portal) PC Runtime?
https://support.industry.siemens.com/cs/document/106501825/how-do-you-store-data-with-a-script-in-a-file-with-wincc-%28tia-portal%29-pc-runtime

VB scripts permit you to store any data on the operator panel on a USB removable medium.

Downloads
The following download includes the archived TIA project.
readwrite_to_file.zip (1.2 MB)
https://support.industry.siemens.com/cs/attachments/106501825/readwrite_to_file.zip

The following download includes the two VBS scripts.
scripts_readwrite_to_file.zip (1.2 KB)
https://support.industry.siemens.com/cs/attachments/106501825/scripts_readwrite_to_file.zip
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 25/08/2015 21:08    Post subject: How on a Windows-based panel can you use a script Reply with quote

How on a Windows-based panel can you use a script to save and read out data in a text file?
https://support.industry.siemens.com/cs/document/26107211/how-on-a-windows-based-panel-can-you-use-a-script-to-save-and-read-out-data-in-a-text-file

VB scripts permit you to store any data on the operator panel on a USB removable medium
Download of the source codes and sample project
The download includes the two sample source codes from the sample project as a PDF document.
wincc_flexible_quellcodes_panel.zip (18.1 KB)
https://support.industry.siemens.com/cs/attachments/26107211/wincc_flexible_quellcodes_panel.zip
This contains the sample project described above, which saves or reads data in a text file.
read_write_data_from_or_into_a_file_panel.zip (1.7 MB)
https://support.industry.siemens.com/cs/attachments/26107211/read_write_data_from_or_into_a_file_panel.zip
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 25/08/2015 21:16    Post subject: Reply with quote

How do you use a script to determine whether a storage drive with removable media (USB stick, SD/MM card) is ready for writing on an HMI device?
https://support.industry.siemens.com/cs/document/89855157/how-do-you-use-a-script-to-determine-whether-a-storage-drive-with-removable-media-%28usb-stick-sdmm-card%29-is-ready-for-writing-on-an-hmi-device
This FAQ response includes a sample script which checks whether a storage medium is available on an HMI device and whether or not it is ready for writing. You can change the script to suit your requirements.

Description
Data of an HMI project is to be stored user-triggered on a drive with removable media (USB stick, SD/MM card, etc.) when the system is running. A missing storage medium or a storage medium that is not ready to write can lead to errors in the procedure. You avoid this by checking the status of the drive before starting the write procedure.

Instructions
Before the planned write procedure you call a function from a Visual Basic Script to check whether the drive is ready for writing. The return value contains the status of the drive based on which you can decide whether to continue or abort the write procedure.
Depending on the operating system used (Windows or WinCE), Visual Basic Script provides different methods for checking whether the removable drive is ready for writing.

1 Create a script for a function with the following code:

For Windows-based devices:

Code:
Function MediaCheckWin(ByRef path)

Dim fso, drive, result
Set fso= CreateObject("Scripting.FileSystemObject")

On Error Resume Next
Set drive= fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(path)))

If Err.Number=0 Then
result= 0
Else
result= Err.Number
End If

MediaCheckWin= result

End Function

For Windows CE-based devices:

Code:
Function MediaCheckCE(ByRef path)

Dim fso, result

Set fso= CreateObject("Filectl.filesystem")

If fso.dir(path)="" Then
result= 1
Else
result= 0
End If

Set fso= Nothing

MediaCheckCE= result

Note
You can change the "result" return value to suit your requirements.

2 Call the script MediaCheckWin() or MediaCheckCE() each time prior to executing the write procedure to the chosen medium. As parameter you assign the script the path on which the file to be written is to be located, for example: "e:\" (Windows) or "\Storage Card USB\" (Windows CE).

Note
If you transfer the path as parameter via an input field, make sure that your input is accepted (press Enter key).
If you do not transfer the path as parameter, but define it in the script, then you set the path specification in quotation marks.

3 Depending on the return value you decide whether to continue the write procedure or abort it.
The return value "0" means that the medium was ready for writing when tested; any other return value means that the medium was not ready for writing.

Downloads
TIA Portal sample project KP400 Comfort / PC Runtime with integrated scripts
storage_media_status.zip (3.2 MB)
https://support.industry.siemens.com/cs/attachments/89855157/storage_media_status.zip
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 25/08/2015 21:40    Post subject: How do you export recipe data from an operator panel Reply with quote

How do you export recipe data from an operator panel configured with WinCC flexible and import it into a WinCC (TIA Portal) project?
https://support.industry.siemens.com/cs/document/98784532/how-do-you-export-recipe-data-from-an-operator-panel-configured-with-wincc-flexible-and-import-it-into-a-wincc-%28tia-portal%29-project
You can easily migrate a project with recipes from WinCC flexible to WinCC (TIA Portal). However, recipe data of a WinCC flexible configuration is often changed after downloading to the panel. Learn how you can import these modified recipe data records into a WinCC (TIA Portal) Project.

Export the recipe data from the panel into a CSV file. There are different ways of doing this depending on the panel used.
If you are using a Basic panel of the first generation or an OP 77A, OP 177A or TP 177A (Portrait) operator panel, then you should use ProSave:

1) Recipe data record export with ProSave
There are two other options available for all the other devices:
2) System function "ExportDataRecords"
3) Miniweb on the panel
After exporting CSV data records in WinCC (TIA Portal):
4) Import of recipe data into WinCC (TIA Portal)
Now the recipe data records are incorporated in your WinCC (TIA Portal) project.
1) Recipe data record export with ProSave
Open ProSave in the Windows Start menu ("SIMATIC > ProSave > ProSave"), go to the "General" tab and set the device and connection parameters. Now go to the "Backup" tab.
Alternatively you can start ProSave directly from WinCC flexible (menu "Project > Transfer > Backup").
In the "Data type" drop-down list box you select the item "Recipes (CSV format)"
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Specify an appropriate storage location of the recipe data records, a USB stick, for example.
Start the export procedure with the "Start Backup" button.
Note
"ProSave" is included as part of the installation of your WinCC (TIA Portal) or WinCC flexible DVD and is also available for downloading in
https://support.industry.siemens.com/cs/document/10347815

2) System function "ExportDataRecords"
In your WinCC flexible project you link the system function "ExportDataRecords" to an event, clicking a button, for example.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Specify the name of the recipe and the name or number of the recipe data record to be saved, and select a suitable storage location, a USB stick, for example.
Note
Specify "0" as the data record number to store all the data records of a recipe.
After project download the event (clicking a button, for example) triggers each time storage of the current recipe data in the specified storage location.

3) Miniweb on the panel
Note
The HTML pages must be activated on your panel for this procedure. The settings for this are in the WinCC flexible Project View under "Device Settings > Device Settings > Runtime Services".
Use your browser to establish a connection to the Miniweb of the panel and log on with user name and password.
Note
The default administrator name is "Administrator", the associated password is "100".
Switch to the "Control Functions" page.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Select the "Export recipes" function.
You see a list of the configured recipes.

Right-click a recipe and select the "Save Target As..." item in the pop-up menu that opens (or the corresponding browser command) to store the CSV file on your local computer.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

To view the recipe data records without storing them you simple click a recipe.

4) Import of recipe data into WinCC (TIA Portal)
Open the "Recipes" working area in WinCC (TIA Portal).
Select the recipe whose data records you want to import and click the "Import recipe data records" icon.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur

n the dialog that opens you select the recipe file from which you want to import data.
ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Confirm with "Import".
Now the recipe data records are imported.

Note
The corresponding recipe must already have been created in WinCC (TIA Portal) to be able to import recipe data records.
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 15/05/2017 16:36    Post subject: VBS programming tools in WinCC (TIA Portal) Reply with quote

VBS programming tools in WinCC (TIA Portal)
https://support.industry.siemens.com/cs/document/59885894/
VBScript is supported by the WinCC (TIA Portal) edition WinCC Comfort onwards. The manuals and information system of WinCC (TIA Portal) provide diferite information about programming Visual Basic Scripts.

The operator panels below support VBScript
Operator panels of the 277 series onwards
Comfort Panels
WinCC Runtime Advanced
WinCC Runtime Professional
The essential Visual Basic commands can be used in WinCC Runtime Advanced, in WinCC Runtime Professional and on an operator panel with Windows CE.
There are exceptions when accessing the file system, for example. Here there are differences between a Windows CE system and a PC Runtime system.
Information about the separate Visual Basic commands is available in the manual and in the information system of the TIA Portal under "Visualize processes > Working with System Functions and Runtime Scripting"

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 01

2) Information about VBScript for Windows CE and Windows
A VBScript command reference can be found
In the attachments which are available for downloading as ZIP files for the WinCC V14 manuals
https://support.industry.siemens.com/cs/document/109742297/
https://support.industry.siemens.com/cs/document/109742302/
under "Programming reference", and manuals programming reference SIMATIC WinCC Advanced V14 SP1
https://support.industry.siemens.com/cs/document/109747176/
and SIMATIC WinCC Professional V14 SP1
https://support.industry.siemens.com/cs/document/109747179/
In the information system of the TIA Portal under "Visualize processes > Working with System Functions and Runtime Scripting > Reference > VB Scripting > VBScript for Windows" and "... Windows CE"

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 02

Fig. 02 shows the list of topics. Click a topic to have detailed description of that topic displayed.

3) Programming Tools in WinCC (TIA Portal)
WinCC (TIA Portal) offers a range of different programming tools. These programming tools are integrated in the Script Editor.
Hotkey Support
When you press the key combination <Ctrl>, a pop-up menu appears containing predefined system functions.
Call Tag Editor
The <Ctrl> key combination opens an object selection dialog in which you can open the Tag Editor, for example, and select global tags and insert them in the script.
Note
A newly created script contains a "hotkey description" in the first line. You can delete the tip if you do not need the information.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 03
Autocomplete
Use "Autocomplete" when creating scripts.
Autocomplete is a feature that provides a context-dependent list in a dialog from which you can choose the tags or statements required.
Example
Enter a "period" after the "...= HmiRuntime" dialog.
A "pop-menu" opens in which you can select from all of the available tags and statements.
Tooltip Help
If you point to a statement ("ClearLog", for example) with the mouse, a tooltip about that statement is displayed. Alternatively you can use the "Tooltip" button in the toolbar.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 04
Parameter Information
In order to access information about the parameters of a function or method, for instance, all the parameters in relation the current cursor position can be displayed by clicking the "Display information about the parameter" button in the toolbar.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 05
4) Script Wizard - Function List and Code Template
Script Wizard - Function List
All the system functions, including the scripts, can be implemented in the open script by means of the script wizard.
Select the "Script Instructions" task card and then "Function list". Select the function in the function list. Click the "Apply" button to transfer the function into the script.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 06
Script Wizard - Code Templates
Standardized code sequences can be added quickly using the code templates.
Select the "Script Instructions" task card and then "Code templates". Select one of the templates. Add the selected code template to the script via a double-click or by using drag-and-drop.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 07
5) Using Script Debuggers in WinCC (TIA Portal)
Use a Script Debugger to check for runtime errors or to make sure that the script is working properly. For this you must install a Script Debugger for WinCC (TIA Portal). The following are released for use with WinCC:
"Microsoft Visual Studio Express" (recommended) (see 5.1)
"Microsoft Script Editor" and "Microsoft Script Debugger" (see 5.2)
5.1) Microsoft Visual Studio Express
Microsoft Visual Studio Express is ready for downloading on the Microsoft pages.
Start the WinCC RT Advanced.
Start Visual Studio Express
From the "Debug" menu you select the command "Attach to Process..."

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 08
In the dialog that opens you select the process "HmiRTm.exe".

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 09
In the "Solution Explorer" the WinCC (TIA Portal) project is displayed with the configured scripts.

ARCHIVE TP 1200 comfort -> computeur VBScript Re: ARCHIVE TP 1200 comfort -> computeur
Fig. 10
5.2) "Microsoft Script Editor of Office XP" and "Microsoft Script Debugger"
Details about incorporating the Microsoft Script Editor and the Microsoft Script Debugger are available in the manual under "Visualize processes > Working with System Functions and Runtime Scripting > Debugging User-defined VB Functions > Integrating the Debugger" (Advanced) and "Visualize processes > Working with System Functions and Runtime Scripting > Debug". (Professional)
The debugger is started in the TIA Portal with the menu command "Online > Simulation > With Script Debugger".

6) VBS Object Model
Information about the VBS Object Model is available in the attachments which are available for downloading as ZIP files for the WinCC V14 manuals
https://support.industry.siemens.com/cs/document/109742297/
https://support.industry.siemens.com/cs/document/109742302/
in the "Programming reference".
"Object" is the generic term for elements, basic objects and controls. Object names depend on the system language.
Using the object type, which is language independent, you can uniquely reference the object. When you look up the object or object type in the manual, you find all the properties and methods available for that object type.
Bear in mind that not all objects are available in all operator panels and in all versions of WinCC (TIA Portal).
A list of all the available objects and object types in WinCC Advanced and WinCC Professional is available in https://support.industry.siemens.com/cs/document/108893939/what-is-the-relationship-between-object-and-object-type-in-wincc- (tia-portal)

Further Information
"Tips and tricks for creating scripts in WinCC (TIA Portal)"
https://support.industry.siemens.com/cs/document/57132412/tips-and-tricks-for-creating-scripts-in-wincc- (tia-portal)
"How can you use scripts to dynamize objects in WinCC Comfort and WinCC Advanced?"
https://support.industry.siemens.com/cs/document/53752382/how-do-you-use-scripts-to-dynamize-objects-in-wincc-comfort-and-wincc-advanced
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Simatic Automation Systems All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro