加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

wincc调用自定义dll库

(2012-03-12 20:17:32)
标签:

wincc

dll

杂谈

分类: WinCC
wincc调用自定义dll库wincc调用自定义dll库 (2012-02-09 13:12:48)
 
原文地址:wincc调用自定义dll库作者:剑思庭

You want to use the functions of a user-created library in WinCC. In this entry we show how a sample DLL is incorporated in WinCC. At the moment, DLLs created in Visual Basic cannot be incorporated in WinCC at Runtime with VBS

.More information on the use of DLLs is available in the WinCC Information System under: "Working with WinCC > ANSI-C for creating functions and actions > Using DLLs in functions and actions".

No. Procedure
1 Sample DLL:
Use a C compiler to create the library "T1_C.dll" from the following program code.

You can download the ready-compiled DLL here.

https://support.automation.siemens.com/livelinksupport/vorlagen/grafik/disk_35.gif T1_C.zip ( 17 KB )

extern "C" __declspec (dllexport) int aufruf1 (int a);

#include <stdio.h>
#include <windows.h>
FILE *h_test;
FILE *h_trace;
extern "C" __declspec (dllexport) int aufruf1(int a)
{
h_test= fopen ("C:/temp/test_dll.txt","a");
if (h_test)
{
fprintf(h_test, "Function 'aufruf1' was called!n");
fclose (h_test );
}
a+=100;
return a;
};

N.B.

  • The DLL must be created without debug information.
  • All the DLL functions used in WinCC must be specified in the corresponding syntax at the beginning of the DLL (see the first line in the sample DLL "T1_C.dll").
  • In order to be able to use the DLL functions, they must be incorporated in the action or function in WinCC at the beginning with the "#pragma code" instruction.
2 Incorporate the "T1_C.dll" library in WinCC with C script and execute the "aufruf1" function:
The following WinCC tags were used:
  • var1 (signed 32-bit value)
  • result (signed 32-bit value)

Create the following C script on the "mouse-click" event of a button:

#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#pragma code ("c:/temp/T1_C.dll")
int aufruf1(int a);
#pragma code ()

int value;
value = GetTagDouble("var1"); //Return-Type: double
SetTagDouble("result",aufruf1(value)); //Return-Type: BOOL
}

3 Result:

https://support.automation.siemens.com/WW/llisapi.dll/csfetch/8301801/8301801_WinCC_DLL_einbinden_01.gif
Fig. 01

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有