From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Max/Min Property Errors

Solved!
Go to solution

Hello

 

I have run into a really wired situation but I am trying to access the max & min channel properties in a script and I get a null value as a result

 

So I am using the following function to gain access to the channel group in a for loop and it returns a null value after the first iteration of the loop.  However when I use the debugger, the function below return the correct values.

Data.Root.ActiveChannelGroup.Channels(i).Properties.Item("Maximum").Value

or

Data.Root.ActiveChannelGroup.Channels(i).Maximum

 

I am using 2017 SP1

 

Anyone else come across this?

Tim
0 Kudos
Message 1 of 5
(2,711 Views)
Solution
Accepted by topic author smoothdurban
Message 2 of 5
(2,685 Views)
Solution
Accepted by topic author smoothdurban

Depending on how the data was brought in before you called this function, it's most likely that the characteristic values of the channel have yet to be calculated.  You have multiple options:

 

Call ChnCharacter(ChnArg1)  - This will calculate characteristics for one channel. 

Call ChnCharacterAll()  - Does it for all channels, could take a long time depending on how many channels. 

I personally like the CCh command. Function: CCh

ReturnValue = CCh(Channel,StatValueIndex)
Function: CCh
ChannelName Specifies the data channel.
StatValueIndex Specifies the index of the characteristic value to be calculated.
Index Characteristic value
0 Mean value
1 Minimum
2 Maximum
3 Range
4 Total

 

Message 3 of 5
(2,681 Views)

Awesome thanks for the input

 

I ended up using the ChnCharacter() function for each individual channel in an active channel group.

 

Call ChnCharacter(Data.Root.ActiveChannelGroup.Channels(i))

Tim
0 Kudos
Message 4 of 5
(2,677 Views)

Some explanations:

  1. I assume starting with 2017 the default for generating min max changed
    In older versions, the characteristics where automatically calculated on load
    Because it not always necessary, the default was changed
    Settings->DIadem Settings-> Panels->NAVIGATOR->Loading Behavior->Automatic calculate characteristic values
    or in Script
    ChnCharacteristicsUpdate="Automatic"
    
  2. In your Debug Case Min Max is calculated because you selected the channel in Data Portal and preview was switched on.
    To show the preview the characteristics are calculated
  3. ChnCharacter
    ChnCharacterAll
    is used to calculate them.
    You can also interactive right click in Data portal to calculate them
Message 5 of 5
(2,646 Views)