Read/Write Dyn String in API

Find and share HowTos to various installations / configurations!
Search

Post Reply
12 posts • Page 1 of 2
martin.jelemensky
Posts: 16
Joined: Wed Aug 09, 2017 1:20 pm

Read/Write Dyn String in API

Post by martin.jelemensky »

Hello, Can somebody please advise me how to read/write a dyn string in API manager ?? Are there some manuals or some examples ??

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: Read/Write Dyn String in API

Post by mkoller »

You mean you want to send a new value for a DPE of type dyn_string ?

Code: Select all

DynVar dyn(TEXT_VAR);
dyn.append(new TextVar("one"));
dyn.append(new TextVar("two"));
Manager::dpSet(dpid, dyn);

martin.jelemensky
Posts: 16
Joined: Wed Aug 09, 2017 1:20 pm

Re: Read/Write Dyn String in API

Post by martin.jelemensky »

actually the problem i am solving now is that i need to read lines (the content of the dp of type dyn_string) in wincc oa then append new lines to the text and the send it back to the same datapoint.

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: Read/Write Dyn String in API

Post by mkoller »

So I assume you already have the content as a DynVar instance ?

Code: Select all

for (DynPtrArrayIndex i = 0; i < dyn.getNumberOfItems(); i++)
  std::cerr getString()

martin.jelemensky
Posts: 16
Joined: Wed Aug 09, 2017 1:20 pm

Re: Read/Write Dyn String in API

Post by martin.jelemensky »

Thank you for the answer (sorry for the delay). However, I would like to continue on this topic a little bit because my API manager (working on WinXP SP3 x86, WinCC OA 3.10 x86, VS2008) crashes. Based on debugging i found out that the problem always appears when i want to write a value of "dyn_string" into a datapoint. I have a for cycle where a fill the DynVar variable : cFunc.mDynVar.append(TextVar(mfDpText)); --> cFunc is a constructor for a class, and mfDpText is of type char [10000]; and then i have the following code
res_id = Manager::getId(dpName, dpId);
res_dp = Manager::dpSet(dpId, cFunc.mDynVar);

I works for a while but the is crashes alwyas when he wants to execute those lines. And also get the following entries in the log :

PVSS00pmon (1), 2017.12.17 21:47:09.161, SYS, WARNING, 36/pmon, Blocking Manager PVSS00MsduR1(5) detected. No heartbeat since 30 seconds.
PVSS00pmon (1), 2017.12.17 21:52:39.623, SYS, WARNING, 39/pmon, Manager PVSS00MsduR1(5) is no longer blocking.

PVSS00data (0), 2017.12.17 22:06:38.215, SYS, WARNING, 39, Connection lost, MAN: (SYS: 1 Api -num 5 CONN: 1), Connection reset by peer (10054)
PVSS00event (0), 2017.12.17 22:06:38.215, SYS, WARNING, 39, Connection lost, MAN: (SYS: 1 Api -num 5 CONN: 1), Connection reset by peer (10054)

is there any connection between wirting into datapoint and those warnings ?

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: Read/Write Dyn String in API

Post by mkoller »

What you do does seem correct, and I don't think the "blocking" manager is related to the dpSet().
How many elements in the DynVar are you appending ?
And is the array empty before you append new values or can it be that the array is getting longer and longer ?
You could check with a debugger and breaking your manager when it's detected to be blocking to find out where in your code
the execution is doing nasty things.

martin.jelemensky
Posts: 16
Joined: Wed Aug 09, 2017 1:20 pm

Re: Read/Write Dyn String in API

Post by martin.jelemensky »

1.) How many elements in the DynVar are you appending ?
--> this is also dynamic it always depends on the received message that i have to parse (it is actually a xml i i need to parse the information from it)

2.) And is the array empty before you append new values or can it be that the array is getting longer and longer ?
yes the array is always cleared before i start filling it i use the command : cFunc.mDynVar.clear();

also for example what i tried is that i processed the received xml with the data on a local machine and it did not crashed but on the server the manager crashed.
And if i can also ask, because i did not find it in the manula what is the maximum size, lenght of the dyn_string array ? is this somehow limited ?

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: Read/Write Dyn String in API

Post by mkoller »

The real limit is just memory.

martin.jelemensky
Posts: 16
Joined: Wed Aug 09, 2017 1:20 pm

Re: Read/Write Dyn String in API

Post by martin.jelemensky »

so aftera while i found out that it crashes at the following line :

res_dp = Manager::dpSet(dpId, cFunc.mDynVar);

i also looked at the dynVar variable however, this was nice and contained all the informations that should.
Is there any problem with this line of code ?

User avatar
mkoller
Posts: 741
Joined: Fri Sep 17, 2010 9:03 am

Re: Read/Write Dyn String in API

Post by mkoller »

No problem with this line.
There must be some other problem in your code.
On Linux you can use valgrind to check for illegal memory access, on windows probably purify or some other tool

Post Reply
12 posts • Page 1 of 2