WinCC 全局动作中计算累积量时,声明变量前必须加修饰词static充当全局变量。
static double useJ1;
static double ogtJ1;
static double ohtJ1;
#include "apdefap.h"
int gscAction( void )
{
//燃烧
//useJ = allJ + (OGT - OHT) * (OMQ + OKQ) / 3600;//吸收的热量
//ogtJ = ogtJ + OGT * (OMQ + OKQ) / 3600;//总
//ohtJ = ogtJ - useJ;//损失掉的热量
//rxl = useJ/ogtJ;
static double useJ1;
static double ogtJ1;
static double ohtJ1;
double rxl1,szJ1,syJ1,sft1,syt1,k1;
static double useJ2;
static double ogtJ2;
static double ohtJ2;
double rxl2,szJ2,syJ2,sft2,syt2,k2;
static double useJ3;
static double ogtJ3;
static double ohtJ3;
double rxl3,szJ3,syJ3,sft3,syt2,k3;
BOOL flag1_1,flag1_2,flag1_3;
BOOL flag2_1,flag2_2,flag2_3;
BOOL flag3_1,flag3_2,flag3_3;
flag1_1=GetTagWord("AUTO_1_1");
flag1_2=GetTagWord("DQL1RS_1");
flag1_3=GetTagWord("DQL1SF_1");
flag2_1=GetTagWord("AUTO_2_1");
flag2_2=GetTagWord("DQL2RS_1");
flag2_3=GetTagWord("DQL2SF_1");
flag3_1=GetTagWord("AUTO_3_1");
flag3_2=GetTagWord("DQL3RS_1");
flag3_3=GetTagWord("DQL3SF_1");
//1#
if (/*flag1_1==1&&*/flag1_2==1)
{
useJ1 = useJ1 + (GetTagDouble("OGT1_1") - GetTagDouble("OHT1_1")) * (GetTagDouble("OMQ1_1") + GetTagDouble("OKQ1_1")) / 3600;//吸收热量
ogtJ1 = ogtJ1 + GetTagDouble("OGT1_1") * (GetTagDouble("OMQ1_1") + GetTagDouble("OKQ1_1")) / 3600;//总热量
ohtJ1 = ogtJ1 - useJ1;//损失掉的热量
rxl1 = useJ1/(ogtJ1+1);
}
else
{
useJ1 = 0;
ogtJ1 = 0;
ohtJ1 = 0;
rxl1 = 0;
}
SetTagDouble("useJ1",useJ1);
SetTagDouble("ogtJ1",ogtJ1);
SetTagDouble("ohtJ1",ohtJ1);
SetTagDouble("rxl1",rxl1);
//printf("rgmodel = %4.4f—%4.4f—%4.4f—%4.4f\r\n",useJ1, ogtJ1,ohtJ1, useJ1/(ogtJ1+1));
//2#
if (/*flag2_1==1&&*/flag2_2==1)
{
useJ2 = useJ2 + (GetTagDouble("OGT2_1") - GetTagDouble("OHT2_1")) * (GetTagDouble("OMQ2_1") + GetTagDouble("OKQ2_1")) / 3600;//吸收热量
ogtJ2 = ogtJ2 + GetTagDouble("OGT2_1") * (GetTagDouble("OMQ2_1") + GetTagDouble("OKQ2_1")) / 3600;//总热量
ohtJ2 = ogtJ2 - useJ2;//损失掉的热量
rxl2 = useJ2/(ogtJ2+1);
}
else
{
useJ2 = 0;
ogtJ2 = 0;
ohtJ2 = 0;
rxl2 = 0;
}
SetTagDouble("useJ2",useJ2);
SetTagDouble("ogtJ2",ogtJ2);
SetTagDouble("ohtJ2",ohtJ2);
SetTagDouble("rxl2",rxl2);
//printf("rgmodel = %4.4f—%4.4f—%4.4f—%4.4f\r\n",useJ2, ogtJ2,ohtJ2, rxl2);
//3#
if (/*flag3_1==1&&*/flag3_2==1)
{
useJ3 = useJ3 + (GetTagDouble("OGT3_1") - GetTagDouble("OHT3_1")) * (GetTagDouble("OMQ3_1") + GetTagDouble("OKQ3_1")) / 3600;//吸收热量
ogtJ3 = ogtJ3 + GetTagDouble("OGT3_1") * (GetTagDouble("OMQ3_1") + GetTagDouble("OKQ3_1")) / 3600;//总热量
ohtJ3 = ogtJ3 - useJ3;//损失掉的热量
rxl3 = useJ3/(ogtJ3+1);
}
else
{
useJ3 = 0;
ogtJ3 = 0;
ohtJ3 = 0;
rxl3 = 0;
}
SetTagDouble("useJ3",useJ3);
SetTagDouble("ogtJ3",ogtJ3);
SetTagDouble("ohtJ3",ohtJ3);
SetTagDouble("rxl3",rxl3);
//printf("rgmodel = %4.4f—%4.4f—%4.4f—%4.4f\r\n",useJ3, ogtJ3,ohtJ3, rxl3);
/*
if (flag1_3==1)
{
k1=1;
szJ1 = k1 * szJ1 + GetTagDouble("OGT1_1") * GetTagDouble("SFQ1_1") / 3600;//送走的热量
syJ1 = GetTagDouble("ogtJ1") - szJ1;//剩余的热量
SetTagDouble("szJ1",szJ1);
SetTagDouble("syJ1",syJ1);
}
*/
//送风
//szJ = k * szJ + OGT * SFQ / 3600;//送走的热量
//syJ = ogtJ - szJ;//剩余的热量
//sft = (OHTb - OHTe)/((OHT[0] - OHT[9])/10);//送风时间
//syt = (OHT - OHTe)/((OHT[0] - OHT[9])/10);//剩余送风时间
return 0;
}