Access to Objects in Other Groups

Support forum for users of the M1 Build

Access to Objects in Other Groups

Postby Fast_Moto on 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.

Diagnostic Access No Error.jpg
Diagnostic Access No Error.jpg (257.3 KiB) Viewed 12898 times

Diagnostic Access Error.jpg
Diagnostic Access Error.jpg (318.01 KiB) Viewed 12898 times


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.
Last edited by Fast_Moto on Thu Feb 13, 2014 7:18 am, edited 2 times in total.
Fast_Moto
 
Posts: 111
Joined: Mon Apr 19, 2010 12:49 pm

Re: Access to Objects in Other Groups

Postby Fast_Moto on Thu Feb 13, 2014 7:16 am

Access to Constant
On a related note, a function in a group (Root.Fuel.Lambda) had difficulty accessing a constant contained in a sub-group of a different group (Root.Engine.Calibration) but had no difficulties if the constant was contained merely in another group (e.g. in Root.Engine). Why would that be the case?

Constant Error.jpg
Constant Error.jpg (319.67 KiB) Viewed 12896 times


Constant No Error.jpg
Constant No Error.jpg (310.87 KiB) Viewed 12896 times



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.
Fast_Moto
 
Posts: 111
Joined: Mon Apr 19, 2010 12:49 pm

Re: Access to Objects in Other Groups

Postby HermannH on Fri Feb 14, 2014 1:04 pm

Hello,

Thanks for these detailed examples, we were able to understand and verify the issues you reported.

To cut it short, we will fix both issues in future updates of M1 Build.
The general idea in M1 Build is that you can access every object from any location in the project. Apparently you found two current restrictions where this does not work as intended:
- when a class serves as a default value for a group, its child objects cannot be accessed
- constants used as integer bounds in an 'expand'-statement must be in a main group or on Root level. Also other object reference keywords like 'Parent' or 'Root' do not work on the integer bounds of an 'expand'-statement.

We will post here when there is a newer version of M1 Build where these issues have been fixed. For the moment, you can work around the first listed issue for example as follows:
- in the group 'Measured' from your example, create a channel 'Value' as the default value for 'Measured'. Add a scheduled function and assign 'Sensor' to 'Value' (for example this is shown for 'Inlet Manifold Pressure' in the Engine Example form M1 Build). Then you can access the channels inside of 'Sensor'.

Regards,

Hermann
User avatar
HermannH
 
Posts: 3
Joined: Fri Jun 07, 2013 1:37 pm
Location: Melbourne, Victoria

Re: Access to Objects in Other Groups

Postby Fast_Moto on Sun Feb 16, 2014 5:48 am

Thank you Hermanm.
Fast_Moto
 
Posts: 111
Joined: Mon Apr 19, 2010 12:49 pm

Re: Access to Objects in Other Groups

Postby AndrewD on Wed Dec 03, 2014 8:53 am

Both of these issues have been fixed and will be in the next release.
MoTeC Research Centre
Melbourne, Australia
User avatar
AndrewD
MoTeC
 
Posts: 38
Joined: Fri Jun 07, 2013 1:34 pm


Return to M1 Build

Who is online

Users browsing this forum: No registered users and 7 guests