DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Is ChnCharacterAll() required to show values loaded to custom properties if those values derive from channel max or min values?

Solved!
Go to solution

All,

 

Many references (DIAdem Help, this forum) indicate that the ChnCharacterAll() and ChnCharacter() functions calculate the characteristic values of all channels or a channel respectively.  These references indicate that the characteristic values involved are for the minimum, maximum, novaluekey, and monotony properties.

 

The references I’ve read indicate that there are many other statistically-based characteristic values for a channel, but it is not clear to me from the references whether custom properties created in scripts are affected by the ChnCharacterAll() and ChnCharacter() functions.  However, it appears from the behavior of some scripts I’ve developed that a call to one of these functions may be necessary for the values of newly created and populated custom properties to be “available” for further operations and reporting:     

 

As part of a larger application containing multiple scripts, we are determining specific values from the data set being analyzed, creating new custom properties under the relevant channels, and then populating the newly created properties with the values determined.  Those custom properties are then referenced for subsequent reporting using a report template.  When the scripts are run without including calls to the ChnCharacter functions, some of the desired custom properties are not populated and this leads to “missing” results in the final report. 

 

When the channel is inspected in the data portal, the custom property name exists, but it is populated with a value of 0 (or NoValue), rather than the correct value calculated in a previous script (in which the ChnCharacter function was not used).  Addition of a call to either ChnCharacterAll() or ChnCharacter() for the channel in question causes the custom property to then be populated with and show the correct value.  Subsequent reporting then works correctly.  Please see attached document for some additional details.

 

The values loaded into the custom properties are from variables that are set (in the analysis scripts) to either the maximum or minimum value for the channel; however, the maximum or minimum values themselves are not changed in the scripts. 

 

Is it because these variables reference the channel’s max or min values that using the ChnCharacterAll() or ChnCharacter() functions are required for the correct population of the custom properties that contain them?

 

Thanks in advance for any additional information on the ChnCharacter functions,

 

Bill Evans

720-988-3436

 

 

0 Kudos
Message 1 of 14
(5,983 Views)

Hello Bill,

 

Thanks for your extensive description of the problem. Which version of DIAdem are you using?

 

Cheers,

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 2 of 14
(5,948 Views)

Hi Kyle,

 

Of course I should have included the DIAdem version information with my original post.  I am running DIAdem 2011:

 

DIAdem 2011: 11.3.1f4723 TDM Service Pack 1
USI:  1.9.1f4681
DataFinder: 3.0.0f4681

 

Thanks in advance for any information you can provide.

 

Bill Evans

720-988-3436

 

0 Kudos
Message 3 of 14
(5,943 Views)

Hello Bill,

 

the characterist values of a DIAdem channel are not always calculated for performance reasons. Here are some examples:

 - Loading a channel into DIAdem calculates these characteristic values in case they are not preset by the channel to load. Whereas if the channel is "registered" (data still onfile) to DIAdem those values are not calculated.

 - Most ANALYSIS functions update these characteristic values, whereas some perfomance optimized script methods such as CHdX don't.

 

- Stefan

0 Kudos
Message 4 of 14
(5,919 Views)

Stefan,

 

Thanks for the information - I assumed that what you said (some script methods don't automatically update the characteristic properties) was what I was seeing based on the behavior of my scripts, but it's very good to have that confirmed.

 

According to your information, and the DIAdem help system, the script method CHdX does not automatically update the characteristic properties, so using ChnCharacterAll() or ChnCharacter() is required to ensure that the characteristic properties are updated.  However, our scripts do not use CHdX, they use CHD instead.  If I understand the DIAdem help system correctly, the CHD method does automatically recalculate the characteristic values:

 

"Note  Use the ChD variable instead of the ChDX variable so that DIAdem specifies the channel length automatically and automatically recalculates the characteristic values. Accessing the CHD variable takes much longer than accessing the CHDX variable." [From the DIAdem help system - "Variable: CHdX"]

 

We are setting custom properties and populating them with values determined using the CHD function to identify the max or min values of certain regions of the channel curve, as in the following example:

 

If Data.Root.ChannelGroups(2).Channels.Exists(ATD(m) & " Upper Neck Mx") Then
  Call Data.Root.ChannelGroups(2).Channels(ATD(m) & " Upper Neck Mx").Properties.Add("Mx_LateralInjuryLevelMoment", 0.000000000000000, DataTypeFloat64)
  Data.Root.ChannelGroups(2).Channels(ATD(m) & " Upper Neck Mx").Properties("Mx_LateralInjuryLevelMoment").Value = NeckMx_Final

  Call ChnCharacter(Data.Root.ChannelGroups(2).Channels(ATD(m) & " Upper Neck Mx"))

End IF

 

In our case, it seems like using the ChnCharacter() call is required for a reason other than use of the CHD command.  Is it sometimes necessary to use the ChnCharacterAll() or ChnCharacter() functions if a custom property is created and populated? 

 

Thanks,

 

Bill Evans

720-988-3436

 

0 Kudos
Message 5 of 14
(5,902 Views)

Hi Bill,

 

Are you able to replicate the behavior in a simpler script? I'm interested to know if there is something in your environent that is causing the behavior, or if the way you've written the script is causing the characteristic values not to be updated without ChnCharacter.

 

Cheers,

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 6 of 14
(5,878 Views)

Kyle,

 

In trying to verify the behavior of ChnCharacterAll() and ChnCharacter() in our scripts, I have “stripped down” one of the scripts to what is the bare minimum for this component calculation:

 

Option Explicit  'Forces the explicit declaration of all the variables in a script.

 

DIM m

DIM Nij_TensionFlexion_B, Nij_TensionFlexion_S, Nij_TensionFlexion

DIM Nij_TensionExtension_B, Nij_TensionExtension_S, Nij_TensionExtension

DIM Nij_CompressionFlexion_B, Nij_CompressionFlexion_S, Nij_CompressionFlexion

DIM Nij_CompressionExtension_B, Nij_CompressionExtension_S, Nij_CompressionExtension

 

for m = 1 to NoATDs  ' Loop for the number of instrumented ATDs present in the test

 

'*************************************************************************************

' Nij Tension Flexion

' ************************************************************************************

If Data.Root.ChannelGroups(2).Channels.Exists(ATD(m) & " Upper Neck Fz") Then

  Nij_TensionFlexion_B = ABS(Data.Root.ChannelGroups(3).Channels(ATD(m) & " Upper Neck Fz").Properties("maximum").Value/6806) + ABS(Data.Root.ChannelGroups(3).Channels(ATD(m) & " Upper Neck My").Properties("maximum").Value/310)

  Nij_TensionFlexion_S = ABS(Data.Root.ChannelGroups(4).Channels(ATD(m) & " Upper Neck Fz").Properties("maximum").Value/6806) + ABS(Data.Root.ChannelGroups(4).Channels(ATD(m) & " Upper Neck My").Properties("maximum").Value/310)

 

  IF Nij_TensionFlexion_B > Nij_TensionFlexion_S THEN

    Nij_TensionFlexion = Nij_TensionFlexion_B

  ELSE

    Nij_TensionFlexion = Nij_TensionFlexion_S

  END IF

End IF

 

'- - - - - - - - - - -  Custom properties creation for Nij Results - - - - - - - - -

If Data.Root.ChannelGroups(2).Channels.Exists(ATD(m) & " Upper Neck Fz") Then

  Call Data.Root.ChannelGroups(2).Channels(ATD(m) & " Upper Neck Fz").Properties.Add("Nij_TensFlex", 0.000000000000000, DataTypeFloat64)

  Data.Root.ChannelGroups(2).Channels(ATD(m) & " Upper Neck Fz").Properties("Nij_TensFlex").Value = Nij_TensionFlexion

 

  Call ChnCharacter(Data.Root.ChannelGroups(2).Channels(ATD(m) & " Upper Neck Fz"))

End IF

'- - - - - - - - - - -  End of custom properties creation for Nij Results - - - - - -

 

Next

 

When I run this script, it appears that the ChnCharacter(channel) function call (see above) does NOT result in the custom property “Nij TensFlex” showing the value added to it (see attached document).

 

This behavior remains the same if I replace the ChnCharacter(channel) call with ChnCharacterAll().

In our application, we are calling a series of scripts (including the “complete” version of the above script) from a SUD.  Curiously, if I include a ChnCharacterAll() script as the first line of code behind the SUD, then all subsequent scripts seem to work properly without having ChnCharacter calls within those scripts  – all custom properties created and populated show up properly in the Data Portal and are properly loaded to the templates we are using to produce final reports.

I realize this type of behavior is very hard to assess without having the complete application available.  Perhaps if there is more information and details about the ChnCharacter() and ChnCharacterAll() functions than is included in the DIAdem help system, I could better understand why our scripts are working as they are.

 

Bill Evans

720-988-3436

0 Kudos
Message 7 of 14
(5,862 Views)

Hi Bill,

 

ChD was changed some time ago to only recalculate after the script has finished, rather than recalculating after that line has executed. Are you not seeing the change at all, or only in the middle of script execution?

 

Cheers,

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 8 of 14
(5,828 Views)

Kyle,

 

I am not seeing the values associated with added custom properties even after the completion of script execution.  This is occuring whether ChD is used at all.  For example, in the script example I submitted previously, the custom property ("Nij_TensFlex") created in this script and populated with a value calculated in the script shows NOVALUE at the completion of the script, even with Call ChnCharacter(Data.Root.ChannelGroups(2).Channels(ATD(m) & " Upper Neck Fz")) included. If I replace this ChnCharacter(channel) with ChnCharacterAll() and run the script, the custom property value then shows up in the Data Portal.  However, doing this for the number of scripts in our overall application takes more time than I would like.

 

Hence, my question about whether (and when) Call ChnCharacterAll() is needed for custom property values to show up in the Data Portal and be available to report templates.  Also, I'm a bit confused about why issuing Call ChnCharacterAll() at the initiation of a SUD (before any subsequent scripts are executed) causes the values calculated and loaded into custom properties by subsequent execution of multiple scripts causes the values for the custom properties to be displayed and available.

 

Any thoughts on this behavior and/or additional details on ChnCharacterAll() would be appreciated.

 

Bill Evans

720-988-3436

 

 

0 Kudos
Message 9 of 14
(5,816 Views)

Hi Bill,

 

None of the DIAdem behavior you describe is normal.  There is no specific function call necessary to allow the user to view custom property values created or updated in a VBScript.  The ChnCharacter... functions only update the values of the 4 graphing channel properties "Minimum", "Maximum", "NoValueKey", "Monotony".

 

My guess is that your script is leaving DIAdem in an odd state where the Data Portal is not autorefreshing.  I think we should abandon the ChnCharacter... avenue and focus on forcing autorefreshing.  I have used the following command to escape from an odd state like this:

 

Call RootPropValSet("description", RootPropValGet("description"))

 You could also try using the generic UI autorefreshing command, like this:

 

UIAutoRefreshSet(1)
UIAutoRefreshSet(0)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 14
(5,807 Views)