Page 1 of 1

Getting _address from dp name with DPmatch/HWmatch

Posted: Thu Apr 04, 2019 5:20 pm
by giorgiob
Given an address wildcard (for example for IecDriver: "30.*.*.*.*.*") and the datapoint name, I need to retrieve the specific _address config of that datapoint.

So I realized this solution: I execute a double step:

1- dpSet("_DriverX.AD.HWmask",wildcard) / dpGet("_DriverX.AD.DPmatch") to retrieve the list of dp names whose _address matches the wildcard
2- dpSet("_DriverX.HW.HWmask",wildcard) / dpGet("_DriverX.HW.HWmatch") to retrieve the list of addresses that match the wildcard

Then, in the list 1, I take the index of the element that matches the dp name I'm looking for. From the list 2, I take the element of the same index so I find the exact _address, because I suppose the two lists are ordered in the same way (by several tries, it seems so).

But I can experience the following problem: if, for mistake, two or more datapoints of the list has the same _address, the two lists haven't the same length, so the comparison fails.

Is there another way to do that?
Thanks in advance.

Re: Getting _address from dp name with DPmatch/HWmatch

Posted: Thu Apr 04, 2019 5:47 pm
by dbindernagel
Not sure I understood the problem. If you already have the datapoint can't you just make a dpGet for the _address.._reference?
string address;
dpGet("PUMP1.value.speed:_address.._reference", address);

Re: Getting _address from dp name with DPmatch/HWmatch

Posted: Fri Apr 05, 2019 9:19 am
by giorgiob
You are right!

I was really sure that dpget couldn't return _address config, as I read in:
viewtopic.php?f=16&t=8595&p=963721&hili ... ch#p963699
But it talks about dpQuery, not dpGet!!!

Thank you very much....