发布于 2013-03-16 10:55:41
3楼
看了这个例程,知道了。
1、VAR_GLOBAL_RETAIN ,书写错误,应该为:VAR_GLOBAL RETAIN
2、关于ID号的指定,参照如下例程:
VAR_GLOBAL
error : BOOL := FALSE;
ds_rslt : EnumDeviceUnitDataSetCommand;
ds_ret : StructRetUnitDataSetCommand;
cmd_busy : BOOL := FALSE;
cmd_done : BOOL := FALSE;
END_VAR
PROGRAM save_data_cycl
// Program is assigned to a cyclic task.
IF NOT cmd_busy THEN
cmd_busy := TRUE;
// Function is executed asynchronously:
ds_ret := _saveUnitDataSet (
unitName := 'ds1',
id := 1,
storageType:= TEMPORARY_STORAGE,
overwrite := TRUE,
nextCommand:= IMMEDIATELY);
IF (ds_ret.functionResult <> DONE) THEN
cmd_busy := FALSE;
error := TRUE; // Start of the function has failed
// (e.g. too many services)
END_IF;
ELSE
// Function is running, wait for result:
ds_rslt := _getStateOfUnitDataSetCommand (
ds_ret.handle);
IF (ds_rslt <> ACTIVE) THEN
cmd_busy := FALSE;
IF (ds_rslt = DONE) THEN
cmd_done := TRUE;// Function successfully
// completed
ELSE
error := TRUE;// Function failed
END_IF;
END_IF;
END_IF;
END_PROGRAM
办法总比困难多