wincc-全套脚本总结 下载本文

&mRT.stMsgTime.wMonth, // Monat &mRT.stMsgTime.wDay, // Jahr &mRT.stMsgTime.wHour, // Stunde &mRT.stMsgTime.wMinute, // Minute &mRT.stMsgTime.wSecond, // Sekunde

&mRT.stMsgTime.wMilliseconds, // Millisekunde

&mRT.dwTimeDiff, // Zeitdauer der anstehenden Meldung &mRT.dwCounter, // Interner Meldungsz?hler &mRT.dwFlags, // Flags( intern ) &mRT.wPValueUsed, &mRT.wTextValueUsed );

//**************************************************************************************code for dcount

if (mRT.dwMsgState==MSG_STATE_COME)//信息到达处理 {

dwMsgNum=mRT.dwMsgNr;

printf(\ bRet=MSRTGetMsgCSData(dwMsgNum,&sM,&err); if (bRet==TRUE) {

dwTextID1=sM.dwTextID[0];

printf(\ bRet=MSRTGetMsgText(1,dwTextID1,&tMeld,&err); if (bRet==TRUE) {

sprintf(szMsg,\

printf(\ } } }

if (mRT.dwMsgState==MSG_STATE_GO)//信息离去处理 {

dwMsgNum=mRT.dwMsgNr;

if (dwMsgNum==GetTagDWord(TAG_MSG_NR)) SetTagChar(TAG_MSG,\}

//**************************************************************************************code for dcount // Meldungsdaten einlesen

// Prozesswerte lesen, falls gew???????§???1nscht }

printf(\ mRT.dwMsgNr, mRT.dwMsgState, mRT.stMsgTime.wDay, mRT.stMsgTime.wMonth, mRT.stMsgTime.wYear,

9

mRT.stMsgTime.wHour, mRT.stMsgTime.wMinute, mRT.stMsgTime.wMilliseconds, mRT.dwTimeDiff, mRT.dwCounter, mRT.dwFlags ) ; SetTagChar(TAG_MSG,szMsg); return( TRUE ); }

mRT.stMsgTime.wSecond,

——————17、实现用户登陆日志(wincc中用c脚本实现?)—————— 用户登陆日志:(包括用户的登陆退出信息,以便查询在什么时间段是哪个用户在使用这个监控软件)

#i nclude \int gscAction( void ) {

#pragma code(\

VOID GetLocalTime(LPSYSTEMTIME lpSystemTime); #pragma code() char* username; char buf[128];

static char preuser[128]; unsigned a,b,c,d,e,f; FILE* fp;

SYSTEMTIME sysTime;

//读取系统时间,并且复制给变量a,b,c,d,e,f GetLocalTime(&sysTime); a=sysTime.wHour; b=sysTime.wMinute; c=sysTime.wSecond; f=sysTime.wYear; e=sysTime.wMonth; d=sysTime.wDay; //得到当前用户名称

username = GetTagChar(\ fp= fopen(\

if(strcmp(username, preuser)!=0) //如果当前用户名称和前一个用户名不同 {

if((strcmp(username, \如果当前用户名称不空同时前一个用户名为空 {

sprintf(buf, \用户:%st登陆时间是:t %d-%d-%d,%d-%d-%dn\ fputs(buf, fp); } else

10

{

if((strcmp(username, \如果当前用户名称为空同时前一个用户名不空 {

sprintf(buf, \用户:%st退出时间是:t %d-%d-%d,%d-%d-%dn\ fputs(buf, fp); } else {

sprintf(buf, \用户:%st退出时间是:t %d-%d-%d,%d-%d-%dn\ fputs(buf, fp);

sprintf(buf, \用户:%st登陆时间是:t %d-%d-%d,%d-%d-%dn\ fputs(buf, fp); } } }

strcpy(preuser, username); fclose(fp); return 0; }

——————18、全局脚本--声音报警——————

#pragma code(\ VOID WINAPI PlaySoundA(char* pszSound,char* hmode,DWORD dwflag); #pragma code() if (GetTagBit(\ { if(GetTagFloat(\ //热井液位 { PlaySoundA(\热井液位高1.wav\ } if(GetTagFloat(\ //热井液位 { PlaySoundA(\热井液位低1.wav\ } if(GetTagFloat(\|| GetTagFloat(\|| GetTagFloat(\|| GetTagFloat(\|| GetTagFloat(\|| GetTagFloat(\|| GetTagFloat(\ //轴瓦温度 {

11

PlaySoundA(\轴瓦温度高1.wav\ } if(GetTagFloat(\ //冷油器出口油温 { PlaySoundA(\冷油器出口油温高.wav\ } if(GetTagFloat(\ //进汽压力 { PlaySoundA(\蒸汽压力低.wav\ } if(GetTagFloat(\ //真空低 { PlaySoundA(\排汽压力高.wav\ } if(GetTagFloat(\ //润滑油压力低 { PlaySoundA(\润滑油压力低1.wav\ } if(GetTagFloat(\|| GetTagFloat(\|| GetTagBit(\|| GetTagBit(\ //滤油器差压 { PlaySoundA(\滤油器差压高.wav\ } if(GetTagFloat(\ //主油泵出口压力 { PlaySoundA(\主油泵出口压力低.wav\ } if(GetTagFloat(\ //油箱油位 { PlaySoundA(\油箱油位低.wav\ } if(GetTagFloat(\| GetTagFloat(\ | GetTagFloat(\|| GetTagBit(\|| GetTagBit(\|| GetTagBit(\ //振动大 { PlaySoundA(\轴瓦振动高.wav\

12