WINCC动画脚本动态实例

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

WINCC动画脚本动态实例
WINCC动画脚本
电机风扇旋转(几何---起始角度):
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {
static DWORD f=20;
if (GetTagBit("DI电机运行信号")) {
f= f+30;
if (f==360) (f=0);
}
return f;
}
电机风扇旋转(几何---结束角度):
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {
static DWORD i=80;
if (GetTagBit("DI电机运行信号")) {
i = i+30;
if (i==360) (i=0);
}
return i;
}
**物料水平右移动(几何---位置X)(停车后,物料回到原点)**
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {
static int a=350;
if (GetTagBit("DI电机运行信号") && (a<=730)) {
a+=20;
if (a>=720) (a=350);
}
if (!GetTagBit("DI电机运行信号")) (a=350);
return a;
}
物料水平右移动(几何---位置X)(停车后,物料停在该点)
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {
static int a=350;
if (GetTagBit("DI电机运行信号") && (a<=730)) {
a+=20;
if (a>=720) (a=350);
}
return a;
}
物料向上移动(几何---位置Y)(停车后,物料停在该点)
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
static int b=450;
if (GetTagBit("DI电机运行信号") && (b>=290)) {
b-=10;
if (b<=280) (b=450);
}
return b;
年月日(静态文本)
#include "apdefap.h"
char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
time_t timer ;
struct tm *ptm;
char *p;
time(&timer);
ptm =localtime(&timer);
p =SysMalloc(9);
sprintf(p,"d/d/d",ptm->tm_year-
100+2000,ptm->tm_mon+1,ptm->tm_mday);
return(p);
}
时分秒(静态文本)
#include "apdefap.h"
char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
time_t timer ;
struct tm *ptm;
char *p;
time(&timer);
ptm =localtime(&timer);
p =SysMalloc(9);
sprintf(p,"d:d:d",ptm->tm_hour,ptm->tm_min,ptm->tm_sec );
return(p);
登陆到指定的用户名无须手动输入(按钮操作)
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y) {
#pragma code("useadmin.dll")
#include "PWRT_API.H"
#pragma code()
PWRTSilentLogin("用户名", "口令");
}
**显示登陆对话框无须热键(按钮操作)**
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y) {
#pragma code ("useadmin.dll")
#include "PWRT_api.h"
#pragma code( )
PWRTLogin('c');
}
退出WINCC运行(按钮操作)
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y) {
{
DeactivateRTProject ();
}
}
单位递增按钮(到上限不提示出错)
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
DWORD value;
value=GetTagDWord("AI标签");
if (value>90) (value=上限);
else value=value+10;
SetTagDWord("AI标签",value);
}
单位递减按钮(到下限不提示出错)
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
DWORD value;
value=GetTagDWord("AI标签");
if (value<10) (value=下限);
else value=value-10;
SetTagDWord("AI标签",value);
}
**单位递增按钮(到上限提示出错)**
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
DWORD value;
HWND hWnd=NULL ;
hWnd=FindWindow(NULL,"Wincc-运行系统- ");
value=GetTagDWord("AI标签");
if (value<=90) (value=value+10);
else MessageBox(hWnd,"已到达上限值!","错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL); SetTagDWord("AI标签",value);
}
**单位递减按钮(到下限提示出错)**
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
DWORD value;
HWND hWnd=NULL ;
hWnd=FindWindow(NULL,"Wincc-运行系统- ");
value=GetTagDWord("AI标签");
if (value>0) (value=value-10);
else MessageBox(hWnd," 已到达下限值!"," 错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL); SetTagDWord("AI标签",value);
}
**自动登陆到指定的用户(画面属性--其它—**)**
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#pragma code("useadmin.dll")
#include "PWRT_API.H"
#pragma code()
PWRTSilentLogin("用户名", "口令");
return(0X0);
}
**询问框(最好用于单机启动,组启也可,2个按钮,NO不操作)**
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y) {
HWND hWnd=NULL;
int 上位启动信号;
hWnd=FindWindow(NULL,"WinCC C-Course");
if (GetTagBit("DI备妥"))
{
上位启动信号=MessageBox(hWnd,"电源已备妥,您现在确定要启动吗?","启动!",
MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL);
printf("\r\nExample 3\r\n");
if (上位启动信号==IDNO) (printf("User selected NO button \r\n"));
else (SetTagByte("上位启动信号",1));
}
else
MessageBox(hWnd,"电源未备妥,请查证后重试!","启动!",
MB_OK|MB_ICONHAND|MB_APPLMODAL);
}
**询问框(最好用于单机启动,组启也可,3个按钮,NO复位)**
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y) {
HWND hWnd=NULL;
int上位启动信号;
hWnd=FindWindow(NULL,"WinCC C-Course");
if (GetTagBit("DI备妥"))
{
上位启动信号=MessageBox(hWnd," 电源已备妥,您现在确定要启动吗?","启动!",
MB_YESNOCANCEL|MB_ICONQUESTION|MB_APPLMODAL);
if (上位启动信号==IDCANCEL) (printf("User selected NO button \r\n"));
else
{
if (上位启动信号==IDYES) (SetTagByte("上位启动信号",1));
else (SetTagByte("上位启动信号",0));
}
}
else
MessageBox(hWnd," 电源未备妥,请查证后重试!","启动!", MB_OK|MB_ICONHAND|MB_APPLMODAL);
}
**搅拌器左侧扇页(几何—宽度)**
#include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
static int h=50;
static int u=0;
if (GetTagBit("DI电机运行信号"))
{
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("DI电机运行信号")){
h=50;
u=0;
return h;
return u;
}
}
**搅拌器左侧扇页(几何—位置X,右侧扇页没有位置变化)** #include "apdefap.h"
long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {
static int h=75;
static int u=125;
if (GetTagBit("DI电机运行信号"))
{
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("DI电机运行信号")){
h=75;
u=125;
return h;
return u;
}
**显示层按钮**
Sub
X6309X94AE2X0000X0000_X6309X94AE2X0000X60C5_X6309X9 4AE2X0000X653E_OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y) Dim objScreen
Dim CountLayer
Set objScreen = HMIRuntime.Screens("layer")
For CountLayer=1 To 32 Step 1
/doc/836877149.html,yers(CountLayer).Visi ble = vbFalse
Next
/doc/836877149.html,yers(n).Visible = vbTrue
End Sub
n=层数+1
初始画面程序(画面空地--属性--事件--其它--打开画面--动作)**打印按钮**
#include "apdefap.h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)
{
WinExec("PRTSCR.EXE -hardcopy",SW_SHOWNORMAL);
}
**一个圈代表电机两种状态**
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
char* opentag="DI1电机运行信号";
char* closetag="DI2电机运行信号";
BOOL open,close;
open = GetTagBit(opentag);
close = GetTagBit(closetag);
if (open)
return CO_GREEN;
if (close)
return CO_BLUE;
}。

相关文档
最新文档