SetTagDouble函数为什么不起作用

1、在一个wincc项目里,建立两个内部变量:Valve_SteamPress_1和Valve_SteamPress。并在变量里赋初始值Valve_SteamPress_1=55;
2、全局动作里新建一个周期为2S 的定时器,程序如下:
#include "apdefap.h"

int gscAction( void )
{
double Valve_SteamPress_1;
double Valve_SteamPress;

Valve_SteamPress_1=GetTagDouble("Valve_SteamPress_1"); 
Valve_SteamPress  = 5   +Valve_SteamPress_1;
SetTagDouble("Valve_SteamPress",Valve_SteamPress);
SetTagDouble("Valve_SteamPress_1",Valve_SteamPress);

printf("\n"); 
printf(" Valve_SteamPress=  %1.2f ",Valve_SteamPress);  
printf("\n"); 

printf("zhihou  Valve_SteamPress=  %1.2f   Valve_SteamPress_1=  %1.2f  ",GetTagDouble("Valve_SteamPress"),GetTagDouble("Valve_SteamPress_1"));

return 0; 
}
在界面的应用程序窗口里看到的结果是:
 Valve_SteamPress=  55.00 
zhihou  Valve_SteamPress=  55.00   Valve_SteamPress_1=  55.00  
 Valve_SteamPress=  60.00 
zhihou  Valve_SteamPress=  60.00   Valve_SteamPress_1=  55.00  
 Valve_SteamPress=  65.00 
zhihou  Valve_SteamPress=  60.00   Valve_SteamPress_1=  60.00  
 Valve_SteamPress=  70.00 
zhihou  Valve_SteamPress=  65.00   Valve_SteamPress_1=  65.00  
 Valve_SteamPress=  75.00 
zhihou  Valve_SteamPress=  70.00   Valve_SteamPress_1=  70.00  
 Valve_SteamPress=  80.00 
zhihou  Valve_SteamPress=  75.00   Valve_SteamPress_1=  75.00  
 Valve_SteamPress=  85.00 
zhihou  Valve_SteamPress=  80.00   Valve_SteamPress_1=  80.00  
 Valve_SteamPress=  90.00 
zhihou  Valve_SteamPress=  85.00   Valve_SteamPress_1=  85.00  
 Valve_SteamPress=  95.00 
zhihou  Valve_SteamPress=  90.00   Valve_SteamPress_1=  90.00  
 Valve_SteamPress=  100.00 
zhihou  Valve_SteamPress=  95.00   Valve_SteamPress_1=  95.00  

为什么从第二 三个周期就赋值不进去了呢?
3、如果是在按钮的C 动作里 加同样的程序,然后手动按钮周期运行,则每次的SetTagDouble都可以起作用。

最佳答案

第四个 printf 语句中的 GetTagDouble 应该替换为 GetTagDoubleWait。即:
printf("zhihou  Valve_SteamPress=  %1.2f   Valve_SteamPress_1=  %1.2f  ",GetTagDoubleWait("Valve_SteamPress"),GetTagDoubleWait("Valve_SteamPress_1"));

提问者对于答案的评价:
谢谢

原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc265945.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2019年6月11日 上午4:08
下一篇 2019年6月11日 上午4:08

相关推荐