QQ登录

只需一步,快速开始

用C脚本实现数据堆栈

[ 复制链接 ]
用C脚本实现数据堆栈

最近公司搞了个手机网页看WINCC,让客户实现随时随地的查看现场数据,之前只是看实时的数据和趋势图,前不久一个客户提出要看在线报表,现场上位机上做了半小时一归档的数据报表,可是这个报表控件网页显示不了,问了西门子的技术支持,说是目前WINCC 7.3的该控件不能支持发布在网页上,郁闷啊!!!于是乎就用脚本做了个数据堆栈,半小时触发一次,模拟了在线报表。

采用的是WINCC内部变量,脚本如下:

float a,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;

float a11,a12,a13,a14,a15,a16,a17,a18,a19,a20;

float a21,a22,a23,a24,a25,a26,a27,a28,a29,a30;

float a31,a32,a33,a34,a35,a36,a37,a38,a39,a40;

float a41,a42,a43,a44,a45,a46,a47,a48;


a=GetTagFloat("lzwendu1");        //Return-Type: float


SetTagFloat("a1",a);        //Return-Type: BOOL

a1=GetTagFloat("a1");        //Return-Type: float


SetTagFloat("a2",a1);        //Return-Type: BOOL

a2=GetTagFloat("a2");        //Return-Type: float


SetTagFloat("a3",a2);        //Return-Type: BOOL

a3=GetTagFloat("a3");        //Return-Type: float


SetTagFloat("a4",a3);        //Return-Type: BOOL

a4=GetTagFloat("a4");        //Return-Type: float


SetTagFloat("a5",a4);        //Return-Type: BOOL

a5=GetTagFloat("a5");        //Return-Type: float


SetTagFloat("a6",a5);        //Return-Type: BOOL

a6=GetTagFloat("a6");        //Return-Type: float


SetTagFloat("a7",a6);        //Return-Type: BOOL

a7=GetTagFloat("a7");        //Return-Type: float


SetTagFloat("a8",a7);        //Return-Type: BOOL

a8=GetTagFloat("a8");        //Return-Type: float


SetTagFloat("a9",a8);        //Return-Type: BOOL

a9=GetTagFloat("a9");        //Return-Type: float


SetTagFloat("a10",a9);        //Return-Type: BOOL

a10=GetTagFloat("a10");        //Return-Type: float


SetTagFloat("a11",a10);        //Return-Type: BOOL

a11=GetTagFloat("a11");        //Return-Type: float


SetTagFloat("a12",a11);        //Return-Type: BOOL

a12=GetTagFloat("a12");        //Return-Type: float


SetTagFloat("a13",a12);        //Return-Type: BOOL

a13=GetTagFloat("a13");        //Return-Type: float


SetTagFloat("a14",a13);        //Return-Type: BOOL

a14=GetTagFloat("a14");        //Return-Type: float


SetTagFloat("a15",a14);        //Return-Type: BOOL

a15=GetTagFloat("a15");        //Return-Type: float


SetTagFloat("a16",a15);        //Return-Type: BOOL

a16=GetTagFloat("a16");        //Return-Type: float  


SetTagFloat("a17",a16);        //Return-Type: BOOL

a17=GetTagFloat("a17");        //Return-Type: float


SetTagFloat("a18",a17);        //Return-Type: BOOL

a18=GetTagFloat("a18");        //Return-Type: float


SetTagFloat("a19",a18);        //Return-Type: BOOL

a19=GetTagFloat("a19");        //Return-Type: float


SetTagFloat("a20",a19);        //Return-Type: BOOL

a20=GetTagFloat("a20");        //Return-Type: float


SetTagFloat("a21",a20);        //Return-Type: BOOL

a21=GetTagFloat("a21");        //Return-Type: float


SetTagFloat("a22",a21);        //Return-Type: BOOL

a22=GetTagFloat("a22");        //Return-Type: float


SetTagFloat("a23",a22);        //Return-Type: BOOL

a23=GetTagFloat("a23");        //Return-Type: float


SetTagFloat("a24",a23);        //Return-Type: BOOL

a24=GetTagFloat("a24");        //Return-Type: float


SetTagFloat("a25",a24);        //Return-Type: BOOL

a25=GetTagFloat("a25");        //Return-Type: float


SetTagFloat("a26",a25);        //Return-Type: BOOL

a26=GetTagFloat("a26");        //Return-Type: float


SetTagFloat("a27",a26);        //Return-Type: BOOL

a27=GetTagFloat("a27");        //Return-Type: float


SetTagFloat("a28",a27);        //Return-Type: BOOL

a28=GetTagFloat("a28");        //Return-Type: float


SetTagFloat("a29",a28);        //Return-Type: BOOL

a29=GetTagFloat("a29");        //Return-Type: float


SetTagFloat("a30",a29);        //Return-Type: BOOL

a30=GetTagFloat("a30");        //Return-Type: float


SetTagFloat("a31",a30);        //Return-Type: BOOL

a31=GetTagFloat("a31");        //Return-Type: float


SetTagFloat("a32",a31);        //Return-Type: BOOL

a32=GetTagFloat("a32");        //Return-Type: float


SetTagFloat("a33",a32);        //Return-Type: BOOL

a33=GetTagFloat("a33");        //Return-Type: float


SetTagFloat("a34",a33);        //Return-Type: BOOL

a34=GetTagFloat("a34");        //Return-Type: float


SetTagFloat("a35",a34);        //Return-Type: BOOL

a35=GetTagFloat("a35");        //Return-Type: float


SetTagFloat("a36",a35);        //Return-Type: BOOL

a36=GetTagFloat("a36");        //Return-Type: float


SetTagFloat("a37",a36);        //Return-Type: BOOL

a37=GetTagFloat("a37");        //Return-Type: float


SetTagFloat("a38",a37);        //Return-Type: BOOL

a38=GetTagFloat("a38");        //Return-Type: float


SetTagFloat("a39",a38);        //Return-Type: BOOL

a39=GetTagFloat("a39");        //Return-Type: float


SetTagFloat("a40",a39);        //Return-Type: BOOL

a40=GetTagFloat("a40");        //Return-Type: float


SetTagFloat("a41",a40);        //Return-Type: BOOL

a41=GetTagFloat("a41");        //Return-Type: float


SetTagFloat("a42",a41);        //Return-Type: BOOL

a42=GetTagFloat("a42");        //Return-Type: float


SetTagFloat("a43",a42);        //Return-Type: BOOL

a43=GetTagFloat("a43");        //Return-Type: float


SetTagFloat("a44",a43);        //Return-Type: BOOL

a44=GetTagFloat("a44");        //Return-Type: float


SetTagFloat("a45",a44);        //Return-Type: BOOL

a45=GetTagFloat("a45");        //Return-Type: float


SetTagFloat("a46",a45);        //Return-Type: BOOL

a46=GetTagFloat("a46");        //Return-Type: float


SetTagFloat("a47",a46);        //Return-Type: BOOL

a47=GetTagFloat("a47");        //Return-Type: float


SetTagFloat("a48",a47);        //Return-Type: BOOL

用C脚本实现数据堆栈

用C脚本实现数据堆栈


以上就是最终效果,做的比较粗糙,不知道各位大侠有没有其他的方法能实现该功能,如果有简单的方法望赐教!!!

另外小弟还有一个问题,这个脚本用周期性触发,比如半小时、一小时什么的就可以按照这个时间周期每次自动实现数据记录一行,同时将上次保存数据依次下移一行。

但如果用变量触发就会记录两行,变量有0变1的时候记录一次,有1变0的时候又记录一次(该变量1的状态会持续一段时间,时间从几十秒到一两分钟每次不同),不知道为什么???变量触发的话要怎么设置才能实现只是变量0变1的时候记录一次呢???望赐教!!!




用C脚本实现数据堆栈

用C脚本实现数据堆栈
回复

使用道具 举报

大神点评(1)

baikhgmv 楼主 2016-9-4 13:53:55 显示全部楼层

---------变量触发就是有变化就触发一次,你这个直接用全局脚本周期触发就行了。或者你在加一个上升沿的功能:触发条件还是变量触发,然后用一个内部变量保存出发变量,然后脚本中:
dim mytag(2)
mytag(0)=hmiruntime.tags("start").read
mytag(1)=hmiruntime.tags("start_sav").read
if mytag(0)=1 and mytag(1)=0 then
上升沿需要执行的内容
end if
hmiruntime.tags("start_sav").write mytag(0)'保存变量状态
另外你的这个一个个变量的读写,效率高,你需要组的概念

-------感谢zhangli0斑竹的指导,刚按照您提供的脚本改了下,能够实现外部变量0变1记录,1变0不记录了,您提供的是VB的脚本,我这个项目中时间的记录是用的VB写的,按照您的这个重新改好的脚本如下:
其中bbsc2为触发全局脚本的外部变量,start_sav是用于实现上升沿的内部变量

Dim flag,time0,time1,time2,time3,time4,time5,time6,time7,time8,time9,time10,time11,time12,time13,time14,time15,time16,time17,time18,time19,time20,time21,time22,time23,time24,time25,time26,time27,time28,time29,time30,time31,time32,time33,time34,time35,time36,time37,time38,time39,time40,time41,time42,time43,time44,time45,time46,time47,time48
flag=Now()
Dim mytag(2)
mytag(0)=HMIRuntime.tags("bbsc2").read
mytag(1)=HMIRuntime.tags("start_sav").read
if mytag(0)=1 and mytag(1)=0 then

time1= HMIRuntime.Tags("lzpltime2_1").Read
HMIRuntime.Tags("lzpltime2_1").Write flag
time2= HMIRuntime.Tags("lzpltime2_2").Read
HMIRuntime.Tags("lzpltime2_2").Write time1
time3= HMIRuntime.Tags("lzpltime2_3").read
HMIRuntime.Tags("lzpltime2_3").Write time2
time4= HMIRuntime.Tags("lzpltime2_4").read
HMIRuntime.Tags("lzpltime2_4").Write time3
time5= HMIRuntime.Tags("lzpltime2_5").read
HMIRuntime.Tags("lzpltime2_5").Write time4
time6= HMIRuntime.Tags("lzpltime2_6").read
HMIRuntime.Tags("lzpltime2_6").Write time5
time7= HMIRuntime.Tags("lzpltime2_7").read
HMIRuntime.Tags("lzpltime2_7").Write time6
time8= HMIRuntime.Tags("lzpltime2_8").read
HMIRuntime.Tags("lzpltime2_8").Write time7
time9= HMIRuntime.Tags("lzpltime2_9").read
HMIRuntime.Tags("lzpltime2_9").Write time8
time10= HMIRuntime.Tags("lzpltime2_10").read
HMIRuntime.Tags("lzpltime2_10").Write time9

time11= HMIRuntime.Tags("lzpltime2_11").read
HMIRuntime.Tags("lzpltime2_11").Write time10
time12= HMIRuntime.Tags("lzpltime2_12").read
HMIRuntime.Tags("lzpltime2_12").Write time11
time13= HMIRuntime.Tags("lzpltime2_13").read
HMIRuntime.Tags("lzpltime2_13").Write time12
time14= HMIRuntime.Tags("lzpltime2_14").read
HMIRuntime.Tags("lzpltime2_14").Write time13
time15= HMIRuntime.Tags("lzpltime2_15").read
HMIRuntime.Tags("lzpltime2_15").Write time14
time16= HMIRuntime.Tags("lzpltime2_16").read
HMIRuntime.Tags("lzpltime2_16").Write time15
time17= HMIRuntime.Tags("lzpltime2_17").read
HMIRuntime.Tags("lzpltime2_17").Write time16
time18= HMIRuntime.Tags("lzpltime2_18").read
HMIRuntime.Tags("lzpltime2_18").Write time17
time19= HMIRuntime.Tags("lzpltime2_19").read
HMIRuntime.Tags("lzpltime2_19").Write time18
time20= HMIRuntime.Tags("lzpltime2_20").read
HMIRuntime.Tags("lzpltime2_20").Write time19


time21= HMIRuntime.Tags("lzpltime2_21").read
HMIRuntime.Tags("lzpltime2_21").Write time20
time22= HMIRuntime.Tags("lzpltime2_22").read
HMIRuntime.Tags("lzpltime2_22").Write time21
time23= HMIRuntime.Tags("lzpltime2_23").read
HMIRuntime.Tags("lzpltime2_23").Write time22
time24= HMIRuntime.Tags("lzpltime2_24").read
HMIRuntime.Tags("lzpltime2_24").Write time23
time25= HMIRuntime.Tags("lzpltime2_25").read
HMIRuntime.Tags("lzpltime2_25").Write time24
time26= HMIRuntime.Tags("lzpltime2_26").read
HMIRuntime.Tags("lzpltime2_26").Write time25
time27= HMIRuntime.Tags("lzpltime2_27").read
HMIRuntime.Tags("lzpltime2_27").Write time26
time28= HMIRuntime.Tags("lzpltime2_28").read
HMIRuntime.Tags("lzpltime2_28").Write time27
time29= HMIRuntime.Tags("lzpltime2_29").read
HMIRuntime.Tags("lzpltime2_29").Write time28
time30= HMIRuntime.Tags("lzpltime2_30").read
HMIRuntime.Tags("lzpltime2_30").Write time29


time31= HMIRuntime.Tags("lzpltime2_31").read
HMIRuntime.Tags("lzpltime2_31").Write time30
time32= HMIRuntime.Tags("lzpltime2_32").read
HMIRuntime.Tags("lzpltime2_32").Write time31
time33= HMIRuntime.Tags("lzpltime2_33").read
HMIRuntime.Tags("lzpltime2_33").Write time32
time34= HMIRuntime.Tags("lzpltime2_34").read
HMIRuntime.Tags("lzpltime2_34").Write time33
time35= HMIRuntime.Tags("lzpltime2_35").read
HMIRuntime.Tags("lzpltime2_35").Write time34
time36= HMIRuntime.Tags("lzpltime2_36").read
HMIRuntime.Tags("lzpltime2_36").Write time35
time37= HMIRuntime.Tags("lzpltime2_37").read
HMIRuntime.Tags("lzpltime2_37").Write time36
time38= HMIRuntime.Tags("lzpltime2_38").read
HMIRuntime.Tags("lzpltime2_38").Write time37
time39= HMIRuntime.Tags("lzpltime2_39").read
HMIRuntime.Tags("lzpltime2_39").Write time38
time40= HMIRuntime.Tags("lzpltime2_40").read
HMIRuntime.Tags("lzpltime2_40").Write time39

time41= HMIRuntime.Tags("lzpltime2_41").read
HMIRuntime.Tags("lzpltime2_41").Write time40
time42= HMIRuntime.Tags("lzpltime2_42").read
HMIRuntime.Tags("lzpltime2_42").Write time41
time43= HMIRuntime.Tags("lzpltime2_43").read
HMIRuntime.Tags("lzpltime2_43").Write time42
time44= HMIRuntime.Tags("lzpltime2_44").read
HMIRuntime.Tags("lzpltime2_44").Write time43
time45= HMIRuntime.Tags("lzpltime2_45").read
HMIRuntime.Tags("lzpltime2_45").Write time44
time46= HMIRuntime.Tags("lzpltime2_46").read
HMIRuntime.Tags("lzpltime2_46").Write time45
time47= HMIRuntime.Tags("lzpltime2_47").read
HMIRuntime.Tags("lzpltime2_47").Write time46
time48= HMIRuntime.Tags("lzpltime2_48").read
HMIRuntime.Tags("lzpltime2_48").Write time47
end if
HMIRuntime.tags("start_sav").write mytag(0)
以上脚本可实现48行数据的记录,外部变量触发。

--------------此外数据记录用的是C脚本,相应的脚本如下:
float lz_pl_h,lz_pl_h1,lz_pl_h2,lz_pl_h3,lz_pl_h4,lz_pl_h5,lz_pl_h6,lz_pl_h7,lz_pl_h8,lz_pl_h9,lz_pl_h10;
float lz_pl_h11,lz_pl_h12,lz_pl_h13,lz_pl_h14,lz_pl_h15,lz_pl_h16,lz_pl_h17,lz_pl_h18,lz_pl_h19,lz_pl_h20;
float lz_pl_h21,lz_pl_h22,lz_pl_h23,lz_pl_h24,lz_pl_h25,lz_pl_h26,lz_pl_h27,lz_pl_h28,lz_pl_h29,lz_pl_h30;
float lz_pl_h31,lz_pl_h32,lz_pl_h33,lz_pl_h34,lz_pl_h35,lz_pl_h36,lz_pl_h37,lz_pl_h38,lz_pl_h39,lz_pl_h40;
float lz_pl_h41,lz_pl_h42,lz_pl_h43,lz_pl_h44,lz_pl_h45,lz_pl_h46,lz_pl_h47,lz_pl_h48;

BOOL bTmp1,bTmp2;

bTmp1=GetTagBit("bbsc2");        //Return-Type: BOOL
bTmp2=GetTagBit("start_sav");        //Return-Type: BOOL

if((bTmp1==1)&(bTmp2==0))
{

lz_pl_h=GetTagFloat("bb10");        //Return-Type: float

SetTagFloat("lz_pl_h1",lz_pl_h);        //Return-Type: BOOL
lz_pl_h1=GetTagFloat("lz_pl_h1");        //Return-Type: float

SetTagFloat("lz_pl_h2",lz_pl_h1);        //Return-Type: BOOL
lz_pl_h2=GetTagFloat("lz_pl_h2");        //Return-Type: float

SetTagFloat("lz_pl_h3",lz_pl_h2);        //Return-Type: BOOL
lz_pl_h3=GetTagFloat("lz_pl_h3");        //Return-Type: float

SetTagFloat("lz_pl_h4",lz_pl_h3);        //Return-Type: BOOL
lz_pl_h4=GetTagFloat("lz_pl_h4");        //Return-Type: float

SetTagFloat("lz_pl_h5",lz_pl_h4);        //Return-Type: BOOL
lz_pl_h5=GetTagFloat("lz_pl_h5");        //Return-Type: float

SetTagFloat("lz_pl_h6",lz_pl_h5);        //Return-Type: BOOL
lz_pl_h6=GetTagFloat("lz_pl_h6");        //Return-Type: float

SetTagFloat("lz_pl_h7",lz_pl_h6);        //Return-Type: BOOL
lz_pl_h7=GetTagFloat("lz_pl_h7");        //Return-Type: float

SetTagFloat("lz_pl_h8",lz_pl_h7);        //Return-Type: BOOL
lz_pl_h8=GetTagFloat("lz_pl_h8");        //Return-Type: float

SetTagFloat("lz_pl_h9",lz_pl_h8);        //Return-Type: BOOL
lz_pl_h9=GetTagFloat("lz_pl_h9");        //Return-Type: float

SetTagFloat("lz_pl_h10",lz_pl_h9);        //Return-Type: BOOL
lz_pl_h10=GetTagFloat("lz_pl_h10");        //Return-Type: float

SetTagFloat("lz_pl_h11",lz_pl_h10);        //Return-Type: BOOL
lz_pl_h11=GetTagFloat("lz_pl_h11");        //Return-Type: float

SetTagFloat("lz_pl_h12",lz_pl_h11);        //Return-Type: BOOL
lz_pl_h12=GetTagFloat("lz_pl_h12");        //Return-Type: float

SetTagFloat("lz_pl_h13",lz_pl_h12);        //Return-Type: BOOL
lz_pl_h13=GetTagFloat("lz_pl_h13");        //Return-Type: float

SetTagFloat("lz_pl_h14",lz_pl_h13);        //Return-Type: BOOL
lz_pl_h14=GetTagFloat("lz_pl_h14");        //Return-Type: float

SetTagFloat("lz_pl_h15",lz_pl_h14);        //Return-Type: BOOL
lz_pl_h15=GetTagFloat("lz_pl_h15");        //Return-Type: float

SetTagFloat("lz_pl_h16",lz_pl_h15);        //Return-Type: BOOL
lz_pl_h16=GetTagFloat("lz_pl_h16");        //Return-Type: float  

SetTagFloat("lz_pl_h17",lz_pl_h16);        //Return-Type: BOOL
lz_pl_h17=GetTagFloat("lz_pl_h17");        //Return-Type: float

SetTagFloat("lz_pl_h18",lz_pl_h17);        //Return-Type: BOOL
lz_pl_h18=GetTagFloat("lz_pl_h18");        //Return-Type: float

SetTagFloat("lz_pl_h19",lz_pl_h18);        //Return-Type: BOOL
lz_pl_h19=GetTagFloat("lz_pl_h19");        //Return-Type: float

SetTagFloat("lz_pl_h20",lz_pl_h19);        //Return-Type: BOOL
lz_pl_h20=GetTagFloat("lz_pl_h20");        //Return-Type: float

SetTagFloat("lz_pl_h21",lz_pl_h20);        //Return-Type: BOOL
lz_pl_h21=GetTagFloat("lz_pl_h21");        //Return-Type: float

SetTagFloat("lz_pl_h22",lz_pl_h21);        //Return-Type: BOOL
lz_pl_h22=GetTagFloat("lz_pl_h22");        //Return-Type: float

SetTagFloat("lz_pl_h23",lz_pl_h22);        //Return-Type: BOOL
lz_pl_h23=GetTagFloat("lz_pl_h23");        //Return-Type: float

SetTagFloat("lz_pl_h24",lz_pl_h23);        //Return-Type: BOOL
lz_pl_h24=GetTagFloat("lz_pl_h24");        //Return-Type: float

SetTagFloat("lz_pl_h25",lz_pl_h24);        //Return-Type: BOOL
lz_pl_h25=GetTagFloat("lz_pl_h25");        //Return-Type: float

SetTagFloat("lz_pl_h26",lz_pl_h25);        //Return-Type: BOOL
lz_pl_h26=GetTagFloat("lz_pl_h26");        //Return-Type: float

SetTagFloat("lz_pl_h27",lz_pl_h26);        //Return-Type: BOOL
lz_pl_h27=GetTagFloat("lz_pl_h27");        //Return-Type: float

SetTagFloat("lz_pl_h28",lz_pl_h27);        //Return-Type: BOOL
lz_pl_h28=GetTagFloat("lz_pl_h28");        //Return-Type: float

SetTagFloat("lz_pl_h29",lz_pl_h28);        //Return-Type: BOOL
lz_pl_h29=GetTagFloat("lz_pl_h29");        //Return-Type: float

SetTagFloat("lz_pl_h30",lz_pl_h29);        //Return-Type: BOOL
lz_pl_h30=GetTagFloat("lz_pl_h30");        //Return-Type: float

SetTagFloat("lz_pl_h31",lz_pl_h30);        //Return-Type: BOOL
lz_pl_h31=GetTagFloat("lz_pl_h31");        //Return-Type: float

SetTagFloat("lz_pl_h32",lz_pl_h31);        //Return-Type: BOOL
lz_pl_h32=GetTagFloat("lz_pl_h32");        //Return-Type: float

SetTagFloat("lz_pl_h33",lz_pl_h32);        //Return-Type: BOOL
lz_pl_h33=GetTagFloat("lz_pl_h33");        //Return-Type: float

SetTagFloat("lz_pl_h34",lz_pl_h33);        //Return-Type: BOOL
lz_pl_h34=GetTagFloat("lz_pl_h34");        //Return-Type: float

SetTagFloat("lz_pl_h35",lz_pl_h34);        //Return-Type: BOOL
lz_pl_h35=GetTagFloat("lz_pl_h35");        //Return-Type: float

SetTagFloat("lz_pl_h36",lz_pl_h35);        //Return-Type: BOOL
lz_pl_h36=GetTagFloat("lz_pl_h36");        //Return-Type: float

SetTagFloat("lz_pl_h37",lz_pl_h36);        //Return-Type: BOOL
lz_pl_h37=GetTagFloat("lz_pl_h37");        //Return-Type: float

SetTagFloat("lz_pl_h38",lz_pl_h37);        //Return-Type: BOOL
lz_pl_h38=GetTagFloat("lz_pl_h38");        //Return-Type: float

SetTagFloat("lz_pl_h39",lz_pl_h38);        //Return-Type: BOOL
lz_pl_h39=GetTagFloat("lz_pl_h39");        //Return-Type: float

SetTagFloat("lz_pl_h40",lz_pl_h39);        //Return-Type: BOOL
lz_pl_h40=GetTagFloat("lz_pl_h40");        //Return-Type: float

SetTagFloat("lz_pl_h41",lz_pl_h40);        //Return-Type: BOOL
lz_pl_h41=GetTagFloat("lz_pl_h41");        //Return-Type: float

SetTagFloat("lz_pl_h42",lz_pl_h41);        //Return-Type: BOOL
lz_pl_h42=GetTagFloat("lz_pl_h42");        //Return-Type: float

SetTagFloat("lz_pl_h43",lz_pl_h42);        //Return-Type: BOOL
lz_pl_h43=GetTagFloat("lz_pl_h43");        //Return-Type: float

SetTagFloat("lz_pl_h44",lz_pl_h43);        //Return-Type: BOOL
lz_pl_h44=GetTagFloat("lz_pl_h44");        //Return-Type: float

SetTagFloat("lz_pl_h45",lz_pl_h44);        //Return-Type: BOOL
lz_pl_h45=GetTagFloat("lz_pl_h45");        //Return-Type: float

SetTagFloat("lz_pl_h46",lz_pl_h45);        //Return-Type: BOOL
lz_pl_h46=GetTagFloat("lz_pl_h46");        //Return-Type: float

SetTagFloat("lz_pl_h47",lz_pl_h46);        //Return-Type: BOOL
lz_pl_h47=GetTagFloat("lz_pl_h47");        //Return-Type: float

SetTagFloat("lz_pl_h48",lz_pl_h47);        //Return-Type: BOOL

}
else
{
SetTagBit("start_sav", (short int)bTmp1);        //Return-Type: BOOL

}
以上是48行数据记录的C脚本,外部变量触发。

------------------另外我还发现一个问题,当WINCC项目重新启动的时候,C脚本的数据记录所有行都会记录上相同的数据,但VB脚本的时间记录只记录一行当前时间!C脚本只要执行保存操作就会所有行记录相同数据!无论是周期触发还是外部变量触发都这样,不知道是不是我的C脚本有什么漏洞,望各位大侠赐教!!!
以下是外部变量触发的截屏



--------c脚本应该是倒着写数,先把47的数据写到48中,再把46的写到47中,.........再把1的数据写到2,再把当前数据写到1.

-------你这个貌似用循环就可以解决

float data[100][10];
int count = 0;//记录条数
移动数据
  for(int row = 0; row != count; ++i)
{
   for(int j = 0; j != 10; ++j)
   {
         row[i][j] = row[i + 1][j];
       }
   }
  count++;
   row[0][0] == GetTag("1");
.
   .. row[0, 9] = GetTag("9");
2.数据填充Io阵列
char s[100] = "";
   for(int i = 0; i != count; ++i)
   {
      for(int j =0; j != 10; ++j)
      {
         sprintf(s, "a%02d%02d", i, j);
          SetTagFloat(s, data[i][j]);
      }
   }
   
回复

使用道具 举报

快速回复 返回列表 客服中心 搜索