赞
踩
WINCC几个常用C语言编程.doc
WINCC几个常用C语言编程全局脚本编程(按钮连续增减)说明1、建立全局脚本函数 2、建立全局动作C脚本 3、在启动画面的打开画面中调用全局脚本函数 4、在计算机的启动选项中选中全局脚本全局脚本函数InitAction extern chartagname30 SHORT count 0;externFLOAT low 0;externFLOAT high 0;externFLOAT step 0;voidInitAction按钮左键按下连续增加extern chartagname30;externSHORT count;externFLOAT low;externFLOAT high;externFLOAT step;strcpytagname,S32i_varia_but_04;count 1;low 0;high 1400;step 0.5;按钮左键按下连续减少extern chartagname30;externSHORT count;externFLOAT low;externFLOAT high;externFLOAT step;strcpytagname,S32i_varia_but_04;count 2;low 0;high 1400;step 0.5;按钮左键松开停止增减externSHORT count;count0;全局动作C脚本(counter.pas)includeapdefap.hintgscAction void extern chartagname30;externSHORT count;externFLOAT low;externFLOAT high;externFLOAT step;FLOAT value;ifcount1count2 get current value value GetTagFloat tagname;ifcount1 inc value valuestep;ifvaluehigh valuehigh; high limit ififcount2 dec value value-step;ifvaluelow valuelow; low limit if SetTagFloat tagname,value; ifreturn0;全局脚本函数(InitAction)文件C脚本(counter.pas)文件按钮左键连续增加文件按钮左键松开文件C脚本编程(按钮按击增减)1、直接调用C动作方式实现includeapdefap.hvoidOnLButtonDownchar* lpszPictureName,char* lpszObjectName,char* lpszPropertyName,UINTnFlags,intx,intyFLOAT value;valueGetTagFloatS32i_varia_but_00; get tag valueifvalue1300 value1400; check limitelsuevalue100; inc valueSetTagFloatS32i_varia_but_00,value; set new value2、调用函数方式实现(incdecvalue)FLOAT value;valueGetTagFloat S32i_varia_but_04;IncDecValuevalue,0,1400,100,1;SetTagFloat S32i_varia_but_04,value;项目函数(incdecvalue)voidIncDecValueFLOAT *value,FLOAT low,FLOAT high,FLOAT step,DWORD aFLOAT v;v*value; get current valueswitchacase0 ifvstep v0; low limitelsevv-step; decrement case 0 break;case1ifvhigh-step vhigh; high limit elsevvstep; increment case 1 break; switch*valuev; return项目函数(incdecvalue)文件C脚本编程(按钮切换开关)include apdefap.hvoidOnLButtonDownchar* lpszPictureName,char* lpszObjectName,char* lpszPropertyName,UINTnFlags,intx,intyBOOL state; flip tagstate GetTagBitBINi_varia_but_16,SetTagBitBINi_varia_but_16,SHORTstate;按钮切换开关文件
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。