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

Hi Bill,

 

as Brad already mentioned only the 4 graphing channel properties "Minimum", "Maximum", "NoValueKey", "Monotony" are calculated and upadted by DIAdem. The custom properties you created are not updated.

The problem you observe results from these 4 graphing channel properties not being calculated automatically. This is for incident to improve script performance.

 

Especially these 4 graphing channel properties are not updated when changing channel data by using chdx, chd, or oChn.Values (see scipt example below).

For best performance oChn.Values should be used if possible.

 

After channel data manipulation ChnCharacter(...) or ChnCharacterAll needs to be called to update the 4 graphing channel properties.
After this call you can use these values to calculated your specific custom properties.

 

The example script below should reproduce the behaviort you observe.

'Clear DataPortal
Data.Root.Clear

'Create test channel
Dim oGrp, oChn
Set oGrp = Data.Root.ChannelGroups.Add("TestGrp")
Set oChn = oGrp.Channels.Add("TestChn",DataTypeChnFloat64)

'Set example values
oChn.Values(1)=NV
oChn.Values(2)=11

'Call ChnCharacter(oChn.GetReference(eRefTypeIndexName))
'Call ChnCharacterAll

'Create custom property and set max value to custom property
Call oChn.Properties.Add("MaxCustProp", oChn.Properties("maximum").Value, DataTypeFloat64)

Dim sMsg : sMsg = "MaxCustProp = "
if isNull(oChn.Properties("MaxCustProp").Value) then
  sMsg = sMsg & "NOVALUE"
else
  sMsg = sMsg & str(oChn.Properties("MaxCustProp").Value)
end if  

MsgBox(sMsg)

 

Running this script as is will display "MaxCustProp = NOVALUE" when being executed.

If you uncomment one of the following lines

'Call ChnCharacter(oChn.GetReference(eRefTypeIndexName))
'Call ChnCharacterAll

the message box will display "MaxCustProp = 11" - as expected.

 

Whether the 4 graphing channel properties are updated at the end of the script execution or better displayed as updated in the data portal depends on other details.

One is if the channel preview is being active - this will force an update of the 4 graphing channel properties of that particular channel.

 

0 Kudos
Message 11 of 14
(1,852 Views)

Brad and Stefan,

 

Thanks for the information - Stefan's code was particularly useful in demonstrating the behavior I'm seeing in a much simpler script.  The information also confirms that the ChnCharacter functions are required to update the Minimum, Maximum, NoValueKey and Monotony properties after a change.  This is one piece of confirmation that I was looking for.

 

However, I guess I am still confused about the behavior I'm seeing with regards to the custom properties created in the scripts I'm using.  If I am interpreting Brad and Stefan's comments correctly, I'm still not sure when the ChnCharacter functions are required to make the values loaded into custom properties visible.  Per Brad's comments ("There is no specific function call necessary to allow the user to view custom property values created or updated in a VBScript"), it appears that in normal DIAdem operation, values loaded into custom properties are available (if the data portal is refreshing) without any particular function calls.  However, Stefan's comments ("After channel data manipulation ChnCharacter(...) or ChnCharacterAll needs to be called to update the 4 graphing channel properties. After this call you can use these values to calculated your specific custom properties") and his script illustrate that a ChnCharacter function is required for custom properties that involve changing channel data for one (or more) of the graphing channel properties. 

Based on my interpretation of Brad and Stefan's comments, the operation of Stefan's code, and observations of our application, the behavior of our code seems to be explained by the following:

 

  • A ChnCharacter function IS needed when changes are made to one (or more) of the graphing channel properties (Minimum, Maximum, NoValueKey, and Monotony).
  • A ChnCharacter function IS needed when changes are made to a custom property if that property's value involves one (or more) of the graphing channel properties (as well demonstrated by Stefan's script).
  • A ChnCharacter function is NOT needed when changes are made to a custom property whose value is determined without any reference to one (or more) of the graphing channel properties.  This is demonstrated by the behavior of several of our scripts which:

(1) create custom properties whose values use Minimum and Maximum channel properties.  The values for these custom properties do NOT appear in the data portal if a ChnCharacter function call is not used.

(2) also create (in the same script) additional custom properties whose values do not involve any reference to the graphing channel properties.  The values for these additional custom properties DO appear in the data portal without requiring a ChnCharacter function call. 

 

Please advise if this interpretation is correct based on DIAdem's designed behavior.  In the meantime, I am looking at our entire application to identify where it might be entering an odd state with regard to refreshing the data portal per Brad's comments.

 

Thanks,

 

Bill Evans

720-988-3436

 

0 Kudos
Message 12 of 14
(1,838 Views)

Hi Bill,

 

Your detailed description looks correct to me, depending on what you mean by that special class of custom property that "involves one (or more) of the graphing channel properties".  You can't have the value of propertyA reference the value of propertyB dynamically, you can only read the current value of propertyB and use that to populate the static value of propertyA.  If propertyB changes afterwards, propertyA has no way of knowing, you'll have to update the propertyA value yourself.  If you do recalculate the value of propertyA based on one or more of the graphing channel properties such as "Minimum" or "Maximum", then you should either use CCh() to get those values or you should use the ChnCharacter() command to recalculate the graphing channel property prior to reading that value out to use in repopulating the value of propertyA.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 13 of 14
(1,823 Views)
Solution
Accepted by topic author WFEvans

Brad,

 

Thanks for the information - this is exacly what I need. 

 

Also, what i mean by the "special class of custom properties" reference in my previous post is a case where the value of the custom property in question either references one of the graphing variables (typically max or min) or is derived from a mathematical operation on one of the graphing variables (again, typically max or min).  In these cases, we typically see a "NOVALUE" for the custom property unless a ChnCharacter function is called.  In other cases (like using the timer function to determine a value for loop execution time), the value loaded into a custom property is "seen" correctly without use of ChnCharacter.

 

Thanks to all who have provided information in response to this posting.

 

Bill Evans

720-988-3436

 

0 Kudos
Message 14 of 14
(1,816 Views)