100% found this document useful (1 vote)
822 views16 pages

Wincc Scripts

This document contains a change sheet listing various scripts and their types. It includes scripts for functions like inverting bits, logging in/out, changing screens, logical gates, opening files, setting languages, and arithmetic operations. It also includes examples of scripts for pushing tags to trend views, changing the base screen name, and inserting data into an Access database. The document provides code snippets in C-script and VB-script to implement these various HMI scripts and functions.

Uploaded by

ntrimurthulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
822 views16 pages

Wincc Scripts

This document contains a change sheet listing various scripts and their types. It includes scripts for functions like inverting bits, logging in/out, changing screens, logical gates, opening files, setting languages, and arithmetic operations. It also includes examples of scripts for pushing tags to trend views, changing the base screen name, and inserting data into an Access database. The document provides code snippets in C-script and VB-script to implement these various HMI scripts and functions.

Uploaded by

ntrimurthulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 16

CHANGE SHHET NAME

INDEX
Abot tia s/w donload sl.nbr SCRIPT NAME TYPE OF script

C-SCRIPT

WINCC FACEPLATES_1 1 invert bit

VB-SCRIPT

SIEMENS_LICENCES

C-SCRIPT
2 stop scada
WINCC POP-WITHOUT-SCRIPT
SINGLE-TREND VIEW COMPARISION VB-SCRIPT

C-SCRIPT
3 LOGIN
WINCC TO SQL SERVER DATALOG
VB-SCRIPT

C-SCRIPT
4 LOGOUT

VB-SCRIPT
C-SCRIPT
5 change to screen
VB-SCRIPT
C-SCRIPT

6 AND GATE
VB-SCRIPT

C-SCRIPT

7 OR GATE
VB-SCRIPT
C-SCRIPT

8 INCREMENT
VB-SCRIPT

C-SCRIPT

9 OPEN .EXE FILE OR ANY DOC .PDF


VB-SCRIPT

C-SCRIPT

10 FOR MS OFFICE
VB-SCRIPT

C-SCRIPT
11 MOVE

VB-SCRIPT
C-SCRIPT

12 invert bit for with tag in script


12 invert bit for with tag in script
VB-SCRIPT

C-SCRIPT
13 SetLanguage ENGLISH
VB-SCRIPT
C-SCRIPT
14
VB-SCRIPT
C-SCRIPT
15
VB-SCRIPT

MUL(AND_GATE) DYNAMIC

ADD(OR GATE) DYNAMIC

SUB DYNAMIC

move
move

RT TO ACC DATA BASE


SCRIPT_1 SCRIPT_2

{
WORD A,B;
{ B=pow(2,8);
#define MyTag "HMI_Tag_3" A=GetTagWord("PDV_VALVES_MAN_OP/C
SetTagBit(MyTag, !GetTagBit(MyTag)); L");
} SetTagWord("PDV_VALVES_MAN_OP/CL",
A ^ B);
}

Sub OnClick(Byval Item)


Dim MyTag
Sub OnClick(Byval Item)
Set MyTag = HMIRuntime.Tags("HMI_Tag_2")
HMIRuntime.tags("HMI_Tag_1").write (1
MyTag.Read
-HMIruntime.Tags("HMI_Tag_1").read)
MyTag.Value = 1 - MyTag.Value End Sub
MyTag.Write
End Sub

{
DeactivateRTProject ();
}
HMIRuntime.Stop
#pragma code("useadmin.dll")
#include "pwrt_api.h"
#pragma code()
PWRTLogin('c');
NA
#pragma code("useadmin.dll")
#include "pwrt_api.h"
#pragma code()
PWRTLogout();
NA
NA
HMIRuntime.BaseScreenName = "NewPdl0" newpdl==pictrename NEED TO VERIFY.
NA
If HMIRuntime.tags("TAG_1").read = 1 And
HMIRuntime.Tags("TAG_2").Read = 1 Then
Set objTag1 = HMIRuntime.tags("TAG_3").write (1) Else
HMIRuntime.tags("TAG_3").write (0)
End If
NA

If HMIRuntime.tags("TAG_1").read = 1 Or
HMIRuntime.Tags("TAG_2").Read = 1 Then
Set objTag1 = HMIRuntime.tags("TAG_3").write (1)
Else
HMIRuntime.tags("TAG_3").write (0)
End If
NA

Function action
If HMIRuntime.tags("TAG_BOOL").read = 1 Then
If HMIRuntime.tags("TAG_INT").read < 2 Then
Dim objTag1
Dim lngValue
Set objTag1 = HMIRuntime.Tags("TAG_INT")
lngValue = objTag1.Read
TAG_BOOL, TAG_INT
objTag1.Write lngValue + 1
action = CLng(objTag1.value)
Else
HMIRuntime.tags("TAG_INT").write (1)
End If
Else HMIRuntime.tags("TAG_INT").write (0)
End If

ProgramExecute("E:\\sharing\\ModRSsim2.exe");

Dim Program ***no space and .exe or .pdf compalsury


Set Program = CreateObject("WScript.Shell")
Program.Run("E:\SIEMENSSSSS\AnyDesk.exe")

Using VBS:

Dim Program ***EXCEL CHANGE TO AS PER REQURIED


Set Program = CreateObject("WScript.Shell")
Program.Run("ExcelC:\path\yourfile.xls")

int gscAction( void )


{

//Copy One Tag to Another//


float a; //OR INT
a= ( GetTagFloat("TAG_1") ); /// INT
SetTagFloat("TAG_2",a); //INT

return 0;
}

HMIRuntime.Tags("PLC_2").Write HMIRuntime.Tags("PLC_1").Read
Dim datenfeld, name
name = item.ObjectName

Dim TagName
Set TagName = HMIRuntime.Tags(name)
TagName.Read
TagName.Value= 1-TagName.Value
TagName.Write
// ObjectName== tag name

SetLanguage(0x0409);

invert_1' * 'invert_2'
0+0 = 0
0+1 = 0
1+0 = 0
1+1 = 1
if two bits high than output high

invert_1' + 'invert_2'
0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 1
if two bits LOW than output LOW

invert_1' - 'invert_2'
0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 0
if two bits LOW OR high than output LOW

Function SetAddress(Tagname,Address)
Dim HG, strVariableName
Set HG = CreateObject("HMIGenObjects.HMIGO")
HG.GetTag Tagname
HG.TagS7S5Address = Address
HG.CommitTag
Set HG = Nothing
End Function
---------------------------------------------------------------
--------------------------
Function GetAddress(Tagname) 'Returns Tag Address as String
Dim HG, strVariableName
Set HG = CreateObject("HMIGenObjects.HMIGO")
HG.GetTag Tagname
GetAddress = HG.TagS7S5Address
Set HG = Nothing
End Function

Dim objConnection, sql, ConnStr


Set objConnection = CreateObject("ADODB.Connection")

ConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\data\Database31.accdb;Jet OLEDB:;"'''' source location DB


objConnection.open ConnStr
sql = "insert into biosafetyarea values (now(),'"'''database table name
sql = sql & HmiRuntime.SmartTags("DP&T&RH_T BIO SAFETY AREA{1}") & "','"''''tags1
sql = sql & HmiRuntime.SmartTags("DP&T&RH_T BIO SAFETY AREA{0}") & "','"''''tag2
sql = sql & HmiRuntime.SmartTags("Data_block_1_AHU-1 DATA{3}") & "','"''''tag3
sql = sql & HmiRuntime.SmartTags("AHUONOFFCOUNT")''''''' last tag must and shud be this farmat
sql = sql & "')"
objConnection.execute sql
'' source location DB
CHANGE SHHET

\
--------------------------------------------to push 1&2 trends tags to trend view------------object name=Control1,Tags=INT8,INT9,INT10
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
SetPropWord(lpszPictureName,"Control1","TrendIndex",0);
SetPropChar(lpszPictureName,"Control1","TrendTagName","ARCTAGS\\INT8");
SetPropWord(lpszPictureName,"Control1","TrendIndex",1);
SetPropChar(lpszPictureName,"Control1","TrendTagName","ARCTAGS\\INT9");
}
--------------------------------------------to push 2&3 trends tags to trend view------------
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{

SetPropWord(lpszPictureName,"Control1","TrendIndex",0);
SetPropChar(lpszPictureName,"Control1","TrendTagName","ARCTAGS\\INT9");

SetPropWord(lpszPictureName,"Control1","TrendIndex",1);
SetPropChar(lpszPictureName,"Control1","TrendTagName","ARCTAGS\\INT10");

}
--------------------------------------------to push 1&3 trends tags to trend view------------
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{

SetPropWord(lpszPictureName,"Control1","TrendIndex",0);
SetPropChar(lpszPictureName,"Control1","TrendTagName","ARCTAGS\\INT8");

SetPropWord(lpszPictureName,"Control1","TrendIndex",1);
SetPropChar(lpszPictureName,"Control1","TrendTagName","ARCTAGS\\INT10");
}

------------------------------------------------------
--------------------------------------------to push trend screen1 to picture window ---------------Picture window name=PICTURETREND,S
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
SetVisible("Trend view","PICTURETREND",1);
SetPictureName("Trend view","PICTURETREND","TREND1.PDL");
}

--------------------------------------------to push trend screen2 to picture window ------------

#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
SetVisible("Trend view","PICTURETREND",1);
SetPictureName("Trend view","PICTURETREND","TREND2.PDL");
}
-------------------------VB SCRIPT FOR THE ABOVE------------------
------------------------------VB SCRIPT---------------------
Option Explicit
Function action
Dim conn,rst, some,something
On Error Resume Next
Set conn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
conn.Open "Provider=MSDASQL;Initial Catalog=RAJU;DSN=TESTSQL"
some = "INSERT INTO XYZ VALUES (" & _
HMIRuntime.SmartTags("one") & "," & _
HMIRuntime.SmartTags("two") & "," & _
HMIRuntime.SmartTags("tre") & "," & _
HMIRuntime.SmartTags("four") & ")"
Set rst = conn.Execute(some)
conn.close
Set rst = Nothing
Set conn = Nothing
End Function
'\//////////RAJU====NAME OF SQL DATABACE//////////////////////////
'\\/////////TESTSQL========NAME OF ODBC CONECTION///////////////////
'\\\////////XYZ=====NAME OF TABLE In SQL////////////////////////////
'\\\\///////ONE======LOGING TAG In SCADA/////////////////////////////
'\\\\\///////TWO======LOGING TAG In SCADA/////////////////////////////
'\\\\\\///////TRE======LOGING TAG In SCADA/////////////////////////////
'\\\\\\\///////FOUR======LOGING TAG In SCADA/////////////////////////////
'.

'NUMBER OF DATA LOGING In SQL.

You might also like