项目函数
//状态:
//稳定 = 2 //稳定
//递增 = -1
//无序 = 0 //波动
//递减 = 1
int ordered(double *Trend_data, int Trend_len)
{
int Trend_out = 0,Order = 0;
if (Trend_len == 1)
{
return 2;
}
Trend_out = (Trend_data[0] < Trend_data[1]) - (Trend_data[0] > Trend_data[1]) + 2 * (Trend_data[0] == Trend_data[1]);
Order = ordered(Trend_data + 1,Trend_len - 1);
if (Trend_out*Order == 0 || Trend_out*Order == -1)
{
return 0;
}
if (Trend_out > Order)
{
Trend_out = Order;
}
return Trend_out;
}
//输入:过程值,数组大小
//输出:过程值容器
/*
void yl1array(double AI_IN, double yl1LB[],int LB_CS)
{
int zqN = 0;
for(zqN = LB_CS - 1;zqN>=1;zqN--)
{
yl1LB[zqN] = yl1LB[zqN-1];
}
yl1LB[0] = AI_IN;
}
*/
double yl1LB[601] = {0.0};
double* yl1array(double AI_IN,int LB_CS)
{
int zqN = 0;
for(zqN = LB_CS - 1;zqN>=1;zqN--)
{
yl1LB[zqN] = yl1LB[zqN-1];
}
yl1LB[0] = AI_IN;
return yl1LB;
}
全局脚本
#include "apdefap.h"
int gscAction( void )
{
// WINCC:TAGNAME_SECTION_START
// syntax: #define TagNameInAction "DMTagName"
// next TagID : 1
// WINCC:TAGNAME_SECTION_END
// WINCC:PICNAME_SECTION_START
// syntax: #define PicNameInAction "PictureName"
// next PicID : 1
// WINCC:PICNAME_SECTION_END
/*
static double YL1LB[601];
double V1;
int LEN1;
int QS1;
V1=GetTagDouble("V1");
LEN1=GetTagWord("LEN1");
yl1array(V1,YL1LB,10);
QS1 = ordered(YL1LB,10);
SetTagDouble("QS1",QS1);
SetTagDouble("YLEND",YL1LB[LEN1-1]);
printf("方法一:%4.4f——%d\r\n", V1, LEN1);
*/
double V1;
double* YL1;
int LEN1;
int QS1;
V1=GetTagDouble("V1");
LEN1=GetTagWord("LEN1");
YL1 = yl1array(V1,10);
QS1 = ordered(YL1,10);
SetTagDouble("QS1",QS1);
SetTagDouble("YLEND",YL1[LEN1-1]);
printf("方法二:%4.4f——%d\r\n", V1, LEN1);
return 0;
}