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 

How do you access the system time with WinCC Global Script?

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

Joined: 01 Jan 2015
Posts: 752

PostPosted: 31/05/2016 17:53    Post subject: How do you access the system time with WinCC Global Script? Reply with quote

How do you access the system time with WinCC Global Script?
If you want to use this script in the operating system Windows 7 or higher, you have to disable the user account control. This might cause disadvantages which you would have to weigh up against your requirements.

The user account control, which has been tightened in Windows 7, blocks the system functions below.
Proceed as follows to prevent this restriction.

Under Start > Search Bar you enter "uac" and start the user account control (UAC stands for User Account Control). The "Settings for User Account Control" window opens. The settings are displayed as a safety governor.
Pull the safety governor to "Never report" and confirm the setting with "OK".
Restart the computer.

Instructions
You can set or read the system time with the following functions:
Code:
    SetSystemTime
    SetLocalTime
    GetSystemTime
    GetLocalTime


A distinction is made in the system between the local computer time and Greenwich Mean Time. You use the "SetSystemTime / GetSystemTime" functions to set or read Greenwich Mean Time.
You use the "SetLocalTime / GetLocalTime" functions to set or read the local computer time.
Both times vary on account of the differing geographical time zones, as well as due to the change between winter time and summer time. Use of the functions is completely identical.
The functions for determining or setting the local computer time are Windows functions and, thus, independent of the WinCC functions "GetLocalTimeString" and "GetLocalTime" in older versions of WinCC.

The following examples show how the local computer time is read or set in WinCC.
Read the time and store it in Word variables
Code:
#pragma code("kernel32.dll")
VOID GetLocalTime(SYSTEMTIME *lpst);
#pragma code();
SYSTEMTIME zeit;
GetLocalTime(&zeit);
SetTagWord("varname",zeit.wYear);
SetTagWord("varname",zeit.wMonth);
SetTagWord("varname",zeit.wDayOfWeek);
SetTagWord("varname",zeit.wDay);
SetTagWord("varname",zeit.wHour);
SetTagWord("varname",zeit.wMinute);
SetTagWord("varname",zeit.wSecond);
SetTagWord("varname",zeit.wMilliseconds);


Read the time and store it in raw data variables
Code:
#pragma code("kernel32.dll")
VOID GetLocalTime(SYSTEMTIME *lpst);
#pragma code();
SYSTEMTIME zeit;
GetLocalTime(&zeit);
SetTagRaw("varname",(Byte*)&zeit,sizeof (SYSTEMTIME));


Set the time using Word variables
Code:
#pragma code("kernel32.dll")
VOID SetLocalTime(SYSTEMTIME *lpst);
#pragma code();
SYSTEMTIME zeit;
zeit.wYear=GetTagWord("varname");
zeit.wMonth=GetTagWord("varname");
zeit.wDayOfWeek=GetTagWord("varname");
zeit.wDay=GetTagWord("varname");
zeit.wHour=GetTagWord("varname");
zeit.wMinute=GetTagWord("varname");
zeit.wSecond=GetTagWord("varname");
zeit.wMilliseconds=GetTagWord("varname");
SetLocalTime(&zeit);


Set the time using a raw data variable
Code:
#pragma code("kernel32.dll")
VOID SetLocalTime(SYSTEMTIME *lpst);
#pragma code();
SYSTEMTIME zeit;
GetTagRaw("varname",(BYTE*)&zeit,sizeof (SYSTEMTIME));
SetLocalTime(&zeit);
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