《winccC脚本》由会员分享,可在线阅读,更多相关《winccC脚本(47页珍藏版)》请在金锄头文库上搜索。
1、#include apdefap.hvoid OnPropertyChanged(char*IpszPiclureName,char*IpszObjectName,char*IpszPropertyName,char*value)(char*pstSource,*pstPos,*pstFirstCR,*pstBlank=NULL;char pstDest255,pstTemp255;char*szParent=NULL;int iLenght=30;int iLengthToCRJLengthToBlanc;LINKINFO pLink;pstSource=GetlnputValueChar(
2、lpszPictureNameJpszObjectName);/set pointer pstSource to 10 StringpstPos=pstDest;/set pointer pstPos to begin of internal String pstDestwhile(strlen(pstSource)iLenght)(if(pstFirstCR=strrchr(pstSource,13)=NULL)(if(pstSource!=NULL)strncpy(pstTemp,pstSource,iLenght);/copy iLenght characters to destinat
3、ion stringif(*(pstTemp+iLenght)=32)(if(pstSource!=NULL)strncpy(pstPos,pstSource,iLenght);/copy iLenght characters to destination stringiLengthToBlanc=iLenght;printf(M ilcnght is a blanc rn);Ielse(iLengthToBlanc=strrchr(pstTemp,)-pstTcmp+1;if(pstSource!=NULL)strncpy(pstPos,pstSource,iLengthToBlanc);p
4、rintf(iLengthToBlanc=%u rn,iLengthToBlane);*(pstPos+iLengthToBlanc)=13;/*(pstPos+iLengthToBlanc+1)=pstPos=pstPos+iLengthToBlanc+2;/new pointer to Temp StringpstSource=pstSource+iLengthToBlanc;/new pointer to sourceIelse/exception,found a carriage return,write text until there and set pstSourceiLengt
5、hToCR=pstFirstCR-pstSource+1;if(pstSource!=NULL)strncpy(pstPos,pstSource,iLengthToCR);pstSource=pstFirstCR+1;/new pointer to sourcepstPos=pstPos+iLengthToCR;/new pointer to Temp String)if(pstSource!=NULL)strcpy(pstPos,pstSource);/copy rest characters to destination stringGetLink(lpszPictureName,lpsz
6、ObjectName,OutputValue,&pLink);/Reliirn-Type:BOOL/SetTagCharC.OpText 1 ,pstDest);Z/Riickgabe-Typ:BOOLSetTagChar(pLink.szLinkName,pstDest);szParent=GetParentPicture(lpszPictureName);/Riickgabe-Typ:char*if(szParent!=NULL)SetVisible(szParent/OperationWindow,FALSE);/Riickgabe-Typ:B()OL#include apdefap.h
7、void OnKeyUp(char*IpszPictureName,char*IpszObjectName,char*IpszPropertyName,UINT nChar,UINT nRepCnt,UINT nFlags)(#define BMPON”PCS7_FP_HEADER_P【NON.EMF”BOOL bPinned=FALSE;TCHAR*pszPictureUp=NULL;BOOL bEnableTrace=FALSE;if(bEnableTrace)(printf(OnKeyUp:%drn,nChar);1if(nChar=13)(/#ifndcf RUN_ON_WEBNAVI
8、GATORchar*szParent=NULL;char*pszAbgelehntText,*pszVarTcxt=NULL;DWORD dOldValue,dOffset,dValue,dBitMask;LINKINFO pLink;LINKINFO pRead;DWORD dwNewMS=0;DWORD dwState;BOOL bSctTagDWordStateWait=FALSE;char szTemp_MAX_PATH=char*IpszBlockType=NULL;TCHAR*pszServerPrefix;TCHAR pszTagPrefI266=TCHAR*psz_temp=N
9、ULL,sz_temp_MAX_PATH=M,sz_Server_MAX_PATH=,H;char*IpszRcquestNumbcr=NULL;char*IpszComment=NULL;/get current maintenance statedOldValue=(DWORD)GetPropDouble(lpszPictureName,OldValue,OutputValue);/Riickgabe-Typ:doubleGetLink(lpszPictureName,LinkedValue,OutputValue,&pLink);/Riickgabe-Typ:BOOLdOffset=Ge
10、tPropWord(lpszPictureName,Bi(Offset,Output Value);dBitMask=GetPropWord(lpszPictureName,BitMask,OutputValue);dV alue=GetPropWord(lpszPictureName,V al ue,OutputV al ue);szParent=GetParentPicture(lpszPictureName);/Riickgabe-Typ:char*if(szParent!=NULL)pszVarText=GetPropChar(szParent,Operationwindow,Capt
11、ionText);if(0=strcmp(pLink.szLinkName,.MSB3)(DWORD dwMS=0;GetLink(lpszPictureName,ReadValue,OutputValue,&pRead);/Riickgabe-Typ:BOOLdOldValue=GetTagDWordStateWait(pRead.szLinkName,&dwState);/Return-Type:DWORDdBitMask=dBitMask (24+dOffset);/write False to the concerned Operator bits with the inverted
12、bit maskdwMS=dOldValue&(-dBitMask);/write the operator Bits to the maintenance state with the or functiondwNewMS=dwMS|(dValue (24+dOffset);dwNewMS=dwNewMS 24;/only MSB3bSetTagDWordStateWait=SetTagByteStateWait(pLink.szLinkName,(BYTE)dwNewMS,&dwState);/Riickgabc-Typ:BOOL)else if(0=strcmp(pLink.szLink
13、Name,.MaintcnanccStatc)(DWORD dwCurrcntMS=GetTagDWordStateWait(pLink.szLinkName,&dwState);/Rctum-Typc:DWORDDWORD dwMS=0;dBitMask=dBitMask (24+dOffset);dwMS=dwCurrcntMS&-dBitMask;dwNewMS=dwMS|(dValue (24+dOffset);/write maintenance state using functionality of SAMBOOL bSctMask=SetPropDouble(lpszPictu
14、reNamc,WritcMSData,Mask,dBitMask);/Return-Type:BOOLBOOL bSetMS=SetPropDouble(lpszPictureName,WriteMSDatci,MaintenanceState,dwNewMS);/Return-Type:BOOLBOOL bSetTrigger=SetPropBOOL(lpszPictureName,WriteMSData,WritcMaintcnanccStatc,!GctPropBOOL(lpszPicturcName,WritcMSData,WritcMaintcnanccState);if(TRUE=
15、bEnableTrace)BOOL bNewWriteMS=GelPropBOOL(lpszPiclureName,WriieMSData,WrileMainlenanceSlale);printf(MSOpcration:%s%d%d%d:%drn,pLink.szLinkName,bSctMask,bSetMS,bSetTrigger,bNewWriteMS);)else(printf(ERROR:Unexpected Tag:%srn,pLink.szLinkName);if(bEnableTrace)(printfCISOperation-OldValue:Ox%xt Bitmask:
16、Ox%x,Offset:%d.Value:%drn,dOldValue,dBitMask,dOffset,dValue);printf(MSOperation-SetTagStateWait(%s,Ox%x,%d)rn,pLink.szLinkName,dwNewMS,dwState);printf(MSOperation-bSetTagDWordStateWait%drn,bSetTagDWordStateWait);)if(dwState&DM_VARSTATE_NOT_ESTABLISHED)=0)(/if write down to AS succesful create operation logPCS7_OperationLog_V6_asset(lpszPictureName,0,dwNewMS,pszVarText)/comment and ordernumber will be written in the Maintenance View/this is temporarily until we are able to get the information fro