Hi all,
As I understood dpNames() return the names in in alphabetical order. It is possible to avoid the alphabetical order and represent them in the same order they are on DP?
Thanks.
Antonio
dpNames()
- kilianvp
- Posts:443
- Joined: Fri Jan 16, 2015 10:29 am
Re: dpNames()
My DP return the names in in alphabetical order but the Para does the same.
If you create a "Test5" DP and than a Test4" DP the Para show them in alphabetical order
If you create a "Test5" DP and than a Test4" DP the Para show them in alphabetical order
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: dpNames()
The "problem" is related to the dp elements and not the the datapoint names.
Also the elements are sorted in alphabetical order and not as defined in the PARA module.
Why do you need the same order?
Best Regards
Leopold Knipp
Senior Support Specailist
Also the elements are sorted in alphabetical order and not as defined in the PARA module.
Why do you need the same order?
Best Regards
Leopold Knipp
Senior Support Specailist
- AMRPatricio
- Posts:61
- Joined: Mon Dec 12, 2016 4:43 pm
Re: dpNames()
Hi Leopold,
Yeap that is my problem.
Basically it helps. Lets image that we have the following dp:
DP_A
DI
D
F
A
AI
M
AI and DI are "folders". D,F,A are not linked directly to the plant(no address conf). Instead the value of those are calculated base on the M value as following: D=M bit 0, F=M bit 1, A= M bit 2.....
(dpNames as you said it returns for DI something like [A | D | F])
Best regards,
Antonio Patricio
Yeap that is my problem.
Basically it helps. Lets image that we have the following dp:
DP_A
DI
D
F
A
AI
M
AI and DI are "folders". D,F,A are not linked directly to the plant(no address conf). Instead the value of those are calculated base on the M value as following: D=M bit 0, F=M bit 1, A= M bit 2.....
(dpNames as you said it returns for DI something like [A | D | F])
Best regards,
Antonio Patricio
- AMRPatricio
- Posts:61
- Joined: Mon Dec 12, 2016 4:43 pm
Re: dpNames()
Hi Leopold,
I think a can easily use a dp_fct conf with getBit on it. My question is if there is any time of inconvenient of using the dp_fct.
Antonio Patricio
I think a can easily use a dp_fct conf with getBit on it. My question is if there is any time of inconvenient of using the dp_fct.
Antonio Patricio
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: dpNames()
You can use a dp function to read the bits and write them to the dp elements.
What datatype is DP_A.AI.M?
Does this element have an _address config und which type of data is received from the driver (e.g. 16bit word)?
Best Regards
Leopold Knipp
Senior Support Specialist
What datatype is DP_A.AI.M?
Does this element have an _address config und which type of data is received from the driver (e.g. 16bit word)?
Best Regards
Leopold Knipp
Senior Support Specialist
- AMRPatricio
- Posts:61
- Joined: Mon Dec 12, 2016 4:43 pm
Re: dpNames()
Hi Leopold,
yes, DP_A.AI.M is the only element that will contain a address config.
The data can be bit 32 or a int.
Antonio
yes, DP_A.AI.M is the only element that will contain a address config.
The data can be bit 32 or a int.
Antonio
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: dpNames()
If you want to split a 32bit word received from the PLC into its bits you can probably use one of the following solutions, if the bits can be addressed by their sub index (depending on the driver you are using):
1) Using a type array in the datapoint structure
In the datapoint structure define an element of type "bool array". Below this node define the number of elements which are needed, e.g. 32 elements.
When now an _address config is configured at the base element for the bool array the driver automatically writes the bits to the elements in the structure.
2) Addressing by the sub index
Add an _address config to the boolean elements and configure the address + sub index to read a single bit from a bit word. In your case the address is configured at DP_A.DI.D, DP_A.DI.F, ....
Then you do not need the datapoint function to read a single bit.
Best Regards
Leopold Knipp
Senior Support Specialist
1) Using a type array in the datapoint structure
In the datapoint structure define an element of type "bool array". Below this node define the number of elements which are needed, e.g. 32 elements.
When now an _address config is configured at the base element for the bool array the driver automatically writes the bits to the elements in the structure.
2) Addressing by the sub index
Add an _address config to the boolean elements and configure the address + sub index to read a single bit from a bit word. In your case the address is configured at DP_A.DI.D, DP_A.DI.F, ....
Then you do not need the datapoint function to read a single bit.
Best Regards
Leopold Knipp
Senior Support Specialist
- AMRPatricio
- Posts:61
- Joined: Mon Dec 12, 2016 4:43 pm
Re: dpNames()
Thanks Leopold.
Looking to solution 1: how do I define a element as bool array? And when you said "below" means at a different level, below?
Antonio
Looking to solution 1: how do I define a element as bool array? And when you said "below" means at a different level, below?
Antonio
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: dpNames()
In the para a array is called "struct".
When you select this as datatype you can add nodes which automatically get the type of the "struct".
Best Regards
Leopold Knipp
Senior Support Specialist
When you select this as datatype you can add nodes which automatically get the type of the "struct".
Best Regards
Leopold Knipp
Senior Support Specialist