OPC Server: Start Stop Pause getData(再次使用) DYMOLA MATLAB

OPC Server: Start Stop Pause getData(again use) DYMOLA MATLAB

我正在使用 Dymola OPC 服务器

DYMOLA 有很多标签,可以使用 SimControl.Run、SimControl.Stop 等来控制

这里是用MATLAB写的

hostInfo = opcserverinfo('localhost');
da = opcda('localhost','Dymosim.OPCServer.1');
connect(da);
fprintf("CONNECTED\n");
grp=addgroup(da,'Demo');
itmIDs={'ModelVariables.Tco','ModelVariables.der(Tco)'};
itm=additem(grp,itmIDs);
area=additem(grp,{'ModelVariables.Area'});
set(grp,'UpdateRate',0.2,'RecordsToAcquire',50);
start(grp);
wait(grp);
[logIDs,Tco]=getdata(grp,'double'); // PREVIOUS ONE
Now I want to change/write  value to area so what I did is this
write(area,23);

现在我想重新登录或获取数据

NEWTco=read(itm,'device').Value; //using This I can read one instance
[NewlogIDs,NewTco]=getdata(grp,'double');// GIVES ERR

写这篇文章帮助我解决了这个问题

grp2=addgroup(da,'Demo2');
Run=additem(grp2,{'SimControl.Run'});
Status=additem(grp2,{'SimControl.Status'});
Stop=additem(grp2,{'SimControl.Stop'});
Pause=additem(grp2,{'SimControl.Pause'});

RunStatusBefore=read(Run,'device');
StatusBefore=read(Status,'device').Value;
StopStatusBefore=read(Stop,'device');
PauseStatusBefore=read(Pause,'device');

write(Initialize,1);  //INITITALIZE
write(Run,1);  // RUN
write(Stop,1);  // STOP
write(Pause,1);  // PAUSE