请教专家:
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;
printf("\n");
printf("SetTag之前 Valve_SteamPress= %1.2f ",Valve_SteamPress);
SetTagDouble("Valve_SteamPress",Valve_SteamPress);
SetTagDouble("Valve_SteamPress_1",Valve_SteamPress);
printf("\n");
printf("SetTag之后 Valve_SteamPress= %1.2f Valve_SteamPress_1= %1.2f ",GetTagDouble("Valve_SteamPress"),GetTagDouble("Valve_SteamPress_1"));
printf("\n");
printf("\n");
return 0;
}
在界面的应用程序窗口里看到的结果是:
SetTag之前 Valve_SteamPress= 55.00
SetTag之后 Valve_SteamPress= 55.00 Valve_SteamPress_1= 55.00
SetTag之前 Valve_SteamPress= 60.00
SetTag之后 Valve_SteamPress= 60.00 Valve_SteamPress_1= 55.00
SetTag之前 Valve_SteamPress= 65.00
SetTag之后 Valve_SteamPress= 60.00 Valve_SteamPress_1= 60.00
SetTag之前 Valve_SteamPress= 70.00
SetTag之后 Valve_SteamPress= 65.00 Valve_SteamPress_1= 65.00
SetTag之前 Valve_SteamPress= 75.00
SetTag之后 Valve_SteamPress= 70.00 Valve_SteamPress_1= 70.00
从结果可以看到,SetTag之前显示的是中间变量的值,然后中间变量Valve_SteamPress的值SetTag给“Valve_SteamPress”和“Valve_SteamPress_1”这两个内部变量之后,显示出来的却和中间变量值不同。
3、如果是在按钮的C 动作里加同样的程序,然后每2S手动按钮周期运行,则每次的SetTagDouble都可以起作用。结果如下:
SetTag之前 Valve_SteamPress= 55.00
SetTag之后 Valve_SteamPress= 55.00 Valve_SteamPress_1= 55.00
SetTag之前 Valve_SteamPress= 60.00
SetTag之后 Valve_SteamPress= 60.00 Valve_SteamPress_1= 60.00
SetTag之前 Valve_SteamPress= 65.00
SetTag之后 Valve_SteamPress= 65.00 Valve_SteamPress_1= 65.00
SetTag之前 Valve_SteamPress= 70.00
SetTag之后 Valve_SteamPress= 70.00 Valve_SteamPress_1= 70.00
SetTag之前 Valve_SteamPress= 75.00
SetTag之后 Valve_SteamPress= 75.00 Valve_SteamPress_1= 75.00
请专家再给我解答一次,谢谢!
问题补充:
好吧 算了 不用帮我解答了 谢谢
最佳答案
使用GetTagDoubleWait和SetTagDoubleWait试试。
提问者对于答案的评价:
谢谢
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc266044.html