Getting _address from dp name with DPmatch/HWmatch
Posted: Thu Apr 04, 2019 5:20 pm
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.
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.