Professional Documents
Culture Documents
Lập Trình C Cho WINCC
Lập Trình C Cho WINCC
v VB - Phn 1
Ti Nguyn 6:52 PM Add Comment lp trnh wincc cho scada , scada , trnh wincc ,VB trong WINCC
Trong qu trnh lm hc v project, mnh c nghin cu cht v phn lp trnh C, VB trong WinCC.
Di y l mt s code mnh tham kho v t code. Mong gip phn no cho cc bn mi s dng
WinCC.
#include apdefap.h
SetVisible(lpszPic
tureName,set_oto,1GetVisible(lpszPictureName,set_oto));
========================================
static
int x0,y0;
if(x1<=x2)
{ x0+=10;
y0=(int)((y2y1)*(x0x1)/(x2x1)+y1);
if(x0>=x2)
x0=x2; y0=y2;
else
{ x0-=10;
y0=(int)((y2y1)*(x0x1)/(x2x1)+y1);
if(x0<=x2)
x0=x2; y0=y2;
}
SetTop(lpszPictureName,lpszObjectName,y0);
SetLeft(lpszPictureName,lpszObjectName,x0);
//SetTagDWord(move_x,x0);
//SetTagDWord(move_y,y0);
==========================================================
#include apdefap.h
#include dmclient.h
extern Delay(ms);
static
int x1=990,y1=270;
static
int x2=650,y2=460;
static x=x1,y=y1;
//x=x1,y=y1;
if(GetTagBit(start)==1)
{
x-=8;
y=(int)((y2y1)*(xx1)/(x2x1)+y1);
if(x<=x2)
x=x2;
SetTagDWord(move_xy,y);
//Return-Type: BOOL
return x;
===============================
//***************
BOOL value;
value = GetTagBit(Lamp);
if
(value==0)
SetTagBit(Lamp,1);
else
SetTagBit(Lamp,0);
//**************
====================================================
#include apdefap.h
static a=970,b=680;
if(GetTagBit(start)==1) a=a10;
if(a<=b) a=b;
//delay(2000);
return a;
========================================================
#include apdefap.h
long _main(char* lpszPictureName,
char* lpszObjectName,
char* lpszPropertyName)
static a=0;
if(GetTagBit(start)==1)
a=a+20;
if(a>=360) a=0;
if(GetTagBit(start)==0) a=0;
return a;
==========================================================================
#include apdefap.h
{
static a=0;
if(GetTagBit(phai)==1) a=a+10;
if(GetTagBit(trai)==1) a=a10;
if(a>=500) a=500;
if(a<=0) a=0;
return a;
==================================================================================
==
#include apdefap.h
static b=0;
if(GetTagBit(len)==1) b=b10;
if(GetTagBit(xuong)==1) b=b+10;
if(b>=500) b=500;
if(b<=0) b=0;
return b;
==================================================================================
================
Code X:
#include apdefap.h
static a=433;
if(GetTagBit(bang_chuyen_sp_lon)==1&&a<=436)
a=a1;
if(GetTagBit(bang_chuyen_sp_lon)==1&&a>436)
a=433;
}
return a;
// WINCC:TAGNAME_SECTION_START
// next TagID : 1
// WINCC:TAGNAME_SECTION_END
// WINCC:PICNAME_SECTION_START
// next PicID : 1
// WINCC:PICNAME_SECTION_END
Code Y :
#include apdefap.h
static b=200;
if(GetTagBit(bang_chuyen_sp_lon)==1&&b<=203)
b=b+2;
if(GetTagBit(bang_chuyen_sp_lon)==1&&b>203)
{
b=200;
return b;
// WINCC:TAGNAME_SECTION_START
// next TagID : 1
// WINCC:TAGNAME_SECTION_END
// WINCC:PICNAME_SECTION_START
// next PicID : 1
// WINCC:PICNAME_SECTION_END
====================================================================
static
int a=340;
if
(GetTagBit(dichtrai)==1)
a=a10;
}
if(a<=200)a=340;
if
(GetTagBit(dichphai)==1)
a=a+10;
if(a>=600)a=340;
return a;
================================================================
for(i ; i<75
; i++){
SetPropWord(Hethonghoatdong.pdl,ong,Left,lef t i);
===================================================================
Cho cc s huynh! Trong WinCC mnh mun phn quyn truy cp trong (v d:trong graphics mnh to
mt nt nhn, Khi runtime nu nhn vo nt th n s hin ln bng logon yu cu ng nhp.) Mnh s dng
cng c user Adminnator to user v password cho ngi s dng nhng khi mnh gn user cho nt nhn th
n li khng hin ln bng yu cu ng nhp! huynh no gii quyt uc vn ny gip mnh vi!
==================================================================================
========
#include apdefap.h
#include pwrt_api.h
#pragma code ()
int i, j, n;
char pic_name[256];
char obj_name[60];
PWRTLogout();
n = strlen( lpszPictureName );
for
( i = n; i >
0; i
)
if
( lpszPictureName[i]
==
.
)
strcpy( obj_name,
&lpszPictureName[i+1]
);
for
(j=
0; j <
(ni); j++)
if
( obj_name[j]
==
:
)
obj_name[j]
=
;
break;
}
SetVisible(pic_name,obj_name,FALSE);
break;