dpGet using CNS identifiers

Find and share HowTos to various installations / configurations!
7 posts • Page 1 of 1
RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

dpGet using CNS identifiers

Post by RudiKreiner »

In the help section What is CNS? it says:
CNS identifiers can be used for CTRL functions like dpGet, dpSet, dpConnect etc. However, they cannot be used for queries

but that is not working for me and I have the funny feeling that I am missing something really simple here.

I made a test configuration as shown in the attached picture, but wenn I try to access an entry with this code:

anytype value;
dpGet("Standard.Cnf:Kr_Gnl", value);


then I get this answer:

WCCOActrl (9), 2017.02.08 13:46:15.178, CTRL, WARNING, 71, DP does not exist, ../tmp/kr/StaCtl/scripts/test/test.ctl Line: 102, dpGet, Standard.Cnf:Kr_Gnl

What am I doing wrong?

I can't seem to add the screenshot here so I'll try to explain what I did in the Plantmodel Editor.

My System ID is Standard
I made a View ID named Cnf with Permitted groups set to (All)
I then made a Node ID named Kr_Gnl with the Node type Datapoint whose Parent ID is Cnf
I assigned its Datapoint to Standard:StrGnl.Sys.CycTimAvg which is an existing datapoint element.

The resulting ID path for this node is then Standard.Cnf:Kr_Gnl so I was hoping I could do a dpGet on it and get the value of Standard:StrGnl.Sys.CycTimAvg

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: dpGet using CNS identifiers

Post by Gertjan van Schijndel »

When CNS identifiers are used in the dp-functions (like dpGet, dpSet, dpConnect, etc), then the config, detail and attribute must be defined.
So try it again with '.Cnf:Kr_Gnl:_online.._value'.

agruber
Posts:147
Joined: Tue Sep 07, 2010 2:52 pm

Re: dpGet using CNS identifiers

Post by agruber »

In fact it should be possible without configs, details and attributes, try with a colon at the end.

Code: Select all

dpGet("Standard.Cnf:Kr_Gnl:", value);
Works for me, of course in my example CNS.

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: dpGet using CNS identifiers

Post by RudiKreiner »

Thanks guys, it works for me that way too.
My gut feeling was right that there was going to be a simple solution for my problem though I just couldn't see it. :blush:
I'm glad that I just need to add the colon at the end and not the entire config and attribute, because that would have meant reworking some libraries for use with CNS,
because since about V3.1 we've been taking advantage of the defaults for dpGet, dpSet, dpConnect, etc. as described in the Help for these functions.

Using a different notation for CNS ID paths as for simple datapoint elements may take some getting used to.
Is that described anywhere in the Help exactly where and why a dot and a colon are required in the notation?

What I still don't understand in CNS though is what node types are for.
I would have expected that if I entered the name of a data point that is in itself an embedded DP type, then its node type would have to be "Structure", but that is apparently not the case,
because when I drag such a datapoint into the Datapoint field from the DP view, the node type is changed back to Datapoint automatically and the CNS function appears to work properly.

So what is the purpose of the node type "Structure" or any other node type that I may define in the nodetypes editor for that matter?
The only thing that I could find in the Help was this sentence:
The node type is used for a further distinction of nodes (e.g. custom icons can be used for each node type)

So is that the the only purpose for making node types, to give them custom icons with which I can identify them in the plant model structure view?

kkembel
Posts:12
Joined: Wed Dec 18, 2013 9:44 pm

Re: dpGet using CNS identifiers

Post by kkembel »

Quick Follow-up question.

Does Adding the ":" force the dpGet to subscibe to all "_config.[_detail]._attr" ?

Thanks - Kurk

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: dpGet using CNS identifiers

Post by RudiKreiner »

@Kurk:
My experience is that if no config is specified, then these rules (copied from Help for dpGet()) apply:

If no definition for a config or attribute exists, the following defaults are used and added internal:
Function Default

dpSet*() _original.._value
dpGet() _online.._value
dpGetAsynch() _offline.._value
dpGetPeriod() _offline.._value
dpConnect() _online.._value
dpDisconnect() _online.._value


but of course you can also specify any other config if you want other information.

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: dpGet using CNS identifiers

Post by Gertjan van Schijndel »

Rudi Kreiner wrote:
So what is the purpose of the node type "Structure" or any other node type that I may define in the nodetypes editor for that matter?
So is that the the only purpose for making node types, to give them custom icons with which I can identify them in the plant model structure view?
If I am correct then the node type is the same as CNSDataIdentifier(Type), which can be used in the function 'cnsGetNodesByName', 'cnsGetNodesByData' and 'cnsGetIdSet' to limit the results to a specific type.

7 posts • Page 1 of 1