Access to Objects in Other Groups
Posted: Thu Feb 13, 2014 7:15 am
Access to Diagnostics
In another thread, I explained that I had difficulty accessing a channel within a pre-built module that was contained in a group (Root.Wheel Speed.Front.Measured.Sensor.Diagnostic) (1) from a function another group (Root.Traction Control) if (2) a parent group containing the diagnostic channel (e.g. Measured) had a default value (Root.Wheel Speed.Front.Measured). Specifically, I got the error "Error 1337: Access to Single Wheel Speed 'Wheel Speed.Front.Diagnostic.AsInteger()' is not allowed." (or a variation thereof). However, if none of the groups that contain the diagnostic channel have a default value, then you can access the diagnostics in the pre-built group.
I previously brought up this issue in another thread and (assuming I understood the answer correctly), I was told that this is simply not possible.
My question is why not change this? According to Motec, it is "good coding practice" to assign a default value to a group -- and I would wholeheartedly agree. But, if that means that I cannot access diagnostics from outside the group, then it is simply not possible to follow this "good coding practice" because it may be necessary to access diagnostics in from a different group (e.g. wheel speed diagnostics in a TC module).
Note: I excerpted the relevant groups in the images from larger builds and also changed the code shown to make it easier to show the issues. Obviously, the code as written is meaningless.
In another thread, I explained that I had difficulty accessing a channel within a pre-built module that was contained in a group (Root.Wheel Speed.Front.Measured.Sensor.Diagnostic) (1) from a function another group (Root.Traction Control) if (2) a parent group containing the diagnostic channel (e.g. Measured) had a default value (Root.Wheel Speed.Front.Measured). Specifically, I got the error "Error 1337: Access to Single Wheel Speed 'Wheel Speed.Front.Diagnostic.AsInteger()' is not allowed." (or a variation thereof). However, if none of the groups that contain the diagnostic channel have a default value, then you can access the diagnostics in the pre-built group.
I previously brought up this issue in another thread and (assuming I understood the answer correctly), I was told that this is simply not possible.
HermannH wrote:1) Access objects inside of pre-built classes: This is possible from anywhere in the project. However, if a group has a default value and you are inside of this group, you can only access the default value. If you are outside of this group, you can only access the value by using the group object.
If you try to access the default value from outside the group you get the error code as you described in a previous post.
Internally both values are identical though, they use the same memory.
...
My question is why not change this? According to Motec, it is "good coding practice" to assign a default value to a group -- and I would wholeheartedly agree. But, if that means that I cannot access diagnostics from outside the group, then it is simply not possible to follow this "good coding practice" because it may be necessary to access diagnostics in from a different group (e.g. wheel speed diagnostics in a TC module).
Note: I excerpted the relevant groups in the images from larger builds and also changed the code shown to make it easier to show the issues. Obviously, the code as written is meaningless.