wincc常用C脚本..

内容发布更新时间 : 2024/11/19 8:44:59星期一 下面是文章的全部内容请认真阅读。

hWnd=FindWindow(NULL,\

if (GetTagBit(\备妥\

{

上位启动信号=MessageBox(hWnd,\电源已备妥,您现在确定要启动吗?

\启动!\ MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL);

printf(\

if (上位启动信号==IDNO) (printf(\

else (SetTagByte(\上位启动信号\

} else

MessageBox(hWnd,\电源未备妥,请查证后重试!\启动!\

MB_OK|MB_ICONHAND|MB_APPLMODAL);

}

**询问框(最好用于单机启动,组启也可,3个按钮,NO复位)**

#include \

void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

char* lpszPropertyName, UINT nFlags, int x, int y)

{

HWND hWnd=NULL; int上位启动信号;

hWnd=FindWindow(NULL,\

if (GetTagBit(\备妥\

{

上位启动信号=MessageBox(hWnd,\电源已备妥,您现在确定要启动

吗?\启动!\ MB_YESNOCANCEL|MB_ICONQUESTION|MB_APPL

MODAL); if (上位启动信号==IDCANCEL) (printf(\

\\r\\n\

else {

if (上位启动信号==IDYES) (SetTagByte(\上位启动信号\

else (SetTagByte(\上位启动信号\

} } else

MessageBox(hWnd,\电源未备妥,请查证后重试!\启动!\

MB_OK|MB_ICONHAND|MB_APPLMODAL);

}

**搅拌器左侧扇页(几何—宽度)**

#include \

long _main(char* lpszPictureName, char* lpszObjectName, char*

lpszPropertyName)

{

static int h=50; static int u=0;

if (GetTagBit(\电机运行信号\

{

if ((h>0)&&(h<=50))

{ (h-=2); return h;

}

if ((u>=0)&&(u<50))

{ (u+=2); return u;

} u=0; h=50;

return h; return u;

}

if (!GetTagBit(\电机运行信号\

h=50; u=0; return h; return u;

} }

**搅拌器左侧扇页(几何—位置X,右侧扇页没有位置变化)**

#include \

long _main(char* lpszPictureName, char* lpszObjectName, char*

lpszPropertyName)

{

static int h=75; static int u=125;

if (GetTagBit(\电机运行信号\

{

if ((h>=75)&&(h<125))

{ (h+=2); return h;

}

if ((u<=125)&&(u>75))

{

(u-=2); return u;

} u=125; h=75; return h; return u;

}

if (!GetTagBit(\电机运行信号\

h=75; u=125; return h; return u;

} }

**显示层按钮**

Sub

X6309X94AE2X0000X0000_X6309X94AE2X0000X60C5_X6309X94AE2X0000X653E_OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal

y)

Dim objScreen Dim CountLayer

Set objScreen = HMIRuntime.Screens(\

For CountLayer=1 To 32 Step 1

objScreen.Layers(CountLayer).Visible = vbFalse

Next

objScreen.Layers(n).Visible = vbTrue

End Sub

n=层数+1

初始画面程序(画面空地--属性--事件--其它--打开画面--动作)

**打印按钮** #include \

void OnLButtonDown(char* lpszPictureName, char* lpszObjectName,

char* lpszPropertyName, UINT nFlags, int x, int y)

{

WinExec(\

}

**一个圈代表电机两种状态** #include \

void OnClick(char* lpszPictureName, char* lpszObjectName, char*

lpszPropertyName)

{

char* opentag=\电机运行信号\ char* closetag=\电机运行信号\

BOOL open,close; open = GetTagBit(opentag); close = GetTagBit(closetag);

if (open) return CO_GREEN;

if (close) return CO_BLUE;

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4 ceshi