WINCC几个常用C语言编程
2、建立全局动作C脚本
3、在启动画面的打开画面中调用全局脚本函数
4、在计算机的启动选项中选中全局脚本
全局脚本函数InitAction ()
extern char tagname[30] = " ";
extern SHORT count = 0;
extern FLOAT low = 0;
extern FLOAT high = 0;
extern FLOAT step = 0;
void InitAction()
按钮左键按下连续增加
男孩变僵尸extern char tagname[30];
extern SHORT count;
extern FLOAT low;
extern FLOAT high;
extern FLOAT step;
strcpy(tagname,"S32i_varia_but_04");
郑爽晒男朋友脱粉count = 1;
low = 0;
high =1400;
几年阅兵一次step =0.5;
按钮左键按下连续减少
extern char tagname[30];
extern SHORT count;
extern FLOAT low;
extern FLOAT high;
extern FLOAT step;
strcpy(tagname,"S32i_varia_but_04");
count = 2;
low = 0;
high =1400;
step =0.5;
按钮左键松开停止增减
extern SHORT count;
count=0;
全局动作C脚本(counter.pas)
#include "apdefap.h"
除夕祝福语简短2022int gscAction( void )
{
extern char tagname[30];
extern SHORT count;
extern FLOAT low;
extern FLOAT high;
extern FLOAT step;
FLOAT value;
if ((count==1)||(count==2)) {
//get current value
value = GetTagFloat (tagname);
if (count==1){ //inc
value = value+step;
if (value>high) (value=high); //high limit
}//if
if (count==2){ //dec
value = value-step;
if (value<low) (value=low); //low limit
}//if
SetTagFloat (tagname,value);
}//if
return李宇春资料(0);
}
全局脚本函数(InitAction)文件:
C脚本(counter.pas)文件:
按钮左键连续增加文件:
按钮左键松开文件:
C脚本编程(按钮按击增减)
1、 直接调用C动作方式实现:
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)
{
FLOAT value;
value=GetTagFloat("S32i_varia_but_00"); //get tag value
if (value>1300) (value=1400); //check limit
else value=value+100; //inc value
SetTagFloat("S32i_varia_but_00",value); //set new value
2、调用函数方式实现(叛逃罪incdecvalue):
FLOAT value;
value=GetTagFloat ("S32i_varia_but_04");
IncDecValue(&value,0,1400,100,1);
SetTagFloat ("S32i_varia_but_04",value);
项目函数(incdecvalue)
void IncDecValue(FLOAT *value,FLOAT low,FLOAT high,FLOAT step,DWORD a)
{
FLOAT v;
v=*value; //get current value
switch (a){
case 0: {
if (v<step) (v=0); //low limit
else v=v-step; //decrement
} //case 0
break;
case 1:{
if (v>(high-step))
(v=high); //high limit
else v=v+step; //increment
}//case 1
break;
}//switch
*value=v; //return
}
项目函数(incdecvalue)文件:
C脚本编程(按钮切换开关):
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)
发布评论