Rohit gupta
Rohit gupta

Reputation: 281

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

I am using a Dymola OPC server

DYMOLA HAS these many tags which can be controlled using SimControl.Run, SimControl.Stop ,etc enter image description here

here i wrote it in 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);

Now I want to Relog or getdata

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

enter image description here

Upvotes: 4

Views: 215

Answers (1)

Rohit gupta
Rohit gupta

Reputation: 281

Writing this helped me to solve this issue

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

Upvotes: 1

Related Questions