一个用WINCC做的系统,每次重新运行时,数据显示的应该是其对应内部变量的初始值。如果我在系统运行时在界面上改变内部变量的值,下次重新启动wincc 想让它显示我改变的那个值,而不是初始值,该怎么做?
是不是要用 用户归档保存内部变量呢?如果是,用户归档怎样操作?
谢谢!
最佳答案
写文件:
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#define MaxLineLength 80
FILE *fpFile;
char *strTag[5] = { "TagA", "TagB", "TagC", "TagD", "TagE" };
char *pTmp;
char buffer[MaxLineLength];
double dVal;
int i;
fpFile = fopen(GetTagChar("Filename"), "w+" ); //open file to write
printf ("C-Script: write file: %s\r\n", GetTagChar("Filename"));
if (fpFile !=NULL)
{
for (i=0; i<=4; i++){
dVal = GetTagDouble(strTag[i]);
sprintf(buffer, "%s;%lf\n", strTag[i],dVal);
// Search for '.' and replace with ','
pTmp = strchr(buffer, (int)'.');
if (pTmp != NULL){
*pTmp = ',';
}
fputs(buffer,fpFile);
printf("%s\r\r\n", buffer);
}
fclose(fpFile); //close file
} else {
printf ("Error: File not found!\r\n");
}
}
提问者对于答案的评价:
Thanks
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc266462.html