11.3 使用示例
开机运行示例
while (true) {
var status;
status = ReadStatus('system.TIME_SECOND'); //ReadStatus:读取数据点质量戳
console.log('system.TIME_SECOND status is ', status);
if(status){ // 如果该点存在并且质量戳为Good
var curVal;
curVal = ReadInt('system.TIME_SECOND'); //ReadInt:从指定数据点读取整数
console.log('system.TIME_SECOND value is ', status);
WriteInt('user.test',curVal); //WriteInt:向指定数据点写入整数
}
Sleep(1000); //休眠1秒钟
}
定时示例
var status;
status = ReadStatus('system.TIME_SECOND'); //ReadStatus:读取数据点质量戳
console.log('system.TIME_SECOND status is ', status);
if(status){
var curVal;
curVal = ReadInt('system.TIME_SECOND'); //ReadInt:从指定数据点读取整数
console.log('system.TIME_SECOND value is ', status);
WriteInt('user.test',curVal); //WriteInt:向指定数据点写入整数
}