控制工程师论坛

自动化软件

求助组态王报表问题出在哪

xuwenbin
xuwenbin

2017-08-21

借用组态王日报表脚本模板,改写如下,目的实现数据每天一记录,测试时人为修改变量值,人为修改计算机系统时间日期,发现问题,日期选择当天如2017/1/15,数据正确,而后选择2017/1/14,发现14号正常,15号的变错了,再往前选择13号13号正常,14,15,都变了12,如图,请问什么原因造成。

float Ayear;

float Amonth;

float Aday;

long x;

long y;

long Col;

long StartTime;

string temp;

Ayear=ADate.Year;

Amonth=ADate.Month;

Aday=ADate.Day;

temp=StrFromInt( Ayear, 10 );

if(Amonth<10)

temp=temp+"-0"+StrFromInt( Amonth, 10 );

else

temp=temp+"-"+StrFromInt( Amonth, 10 );

if(Aday<10)

temp=temp+"-0"+StrFromInt( Aday, 10 );

else

temp=temp+"-"+StrFromInt( Aday, 10 );

\\本站点\选择日期=temp;

ReportSetCellString2("Report1", 3, 2, 7, 16, " "); //清空单元格

//ReportSetCellString("Report1", 2, 2, temp);//填写日期,封存,没必要保留

//查询数据

StartTime=HTConvertTime(Ayear,Amonth,Aday,8,0,0);

ReportSetHistData("Report1", "\\本站点\[A]201", StartTime, 86400, "B3:P3");//每天记录一次

ReportSetHistData("Report1", "\\本站点\[A]202", StartTime, 86400, "B4:P4");

ReportSetHistData("Report1", "\\本站点\[A]203", StartTime, 86400, "B5:P5");

ReportSetHistData("Report1", "\\本站点\[A]204", StartTime, 86400, "B6:P6");

ReportSetHistData("Report1", "\\本站点\[A]205", StartTime, 86400, "B7:P7");

//填写时间

x=0;//定义为列号

       while(x<16)//小于表格总列数,即要求的15天

       {

       Col=2+x;//第一列被占用

       y=StartTime+x*86400;

       temp=StrFromTime( y, 1 );//按控制面板日期显示

       ReportSetCellString("Report1", 2, Col, temp);//此处修改liu2016.12.8,将日期填制第一行每一列

       x=x+1;

       }


回帖

评论3

总共 , 当前 /
首页 | 登录 | 注册 | 返回顶部↑
手机版 | 电脑版
版权所有 Copyright(C) 2016 CE China