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.
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.
03-16-2016 11:02 AM
I have a numeric channel A, channel data is from a collection of other channel values. I used chd() to write these values into channel A.
It seemed work fine if I run under debug mode, step by step. However, if I run under regular mode, the channel turned into NUVALUE. Which means channel A data are all NOVALUE.
Don't know what happened, Please help, thank you.
03-17-2016 01:18 AM
Hello IIX,
Please can you provide the script and data set so that I can check it?
Which DIAdem version do you use?
Greetings
Walter
03-17-2016 04:09 PM
script is like this.
example data file is attached.
The logic is very simple, to loop through a group of channels. Get maximum value of each channel write into a new channel A. Then do histogram analysis on this new channel A, report histogram.
However, the new channel values are always NOVALUE. If under debug mode, each value is written into the channel A is read.
Please help, thank you.
groupnamestr = "3D Values"
gindex = GroupIndexGet(groupnamestr)
chncount = groupchncount(gindex)
Call Data.Root.ChannelGroups.Add("result", 8).Activate()
Call Data.Root.ChannelGroups(8).Channels.Add("results",DataTypeFloat64,1)
chnlength ("/results") = chncount
Call GroupDefaultSet(gindex)
for iloop = 1 to chncount
a = chnpropvalget(iloop,"Maximum")
chd(iloop,"result/results") = a
next
03-17-2016 04:29 PM
By the way, I have tried DIAdem 2012/2014/2015, same problem.
03-18-2016 02:08 AM
Hello IIX,
You're mixing the old syntax for data accessing with the new data API. This is in general possible but not very clear and straight forward. Defining it correct by mixing the syntax is more difficult. Here is an example:
With the following code you refer to a certain channelgroup:
groupnamestr = "3D Values"
gindex = GroupIndexGet(groupnamestr)
In the for loop you read the channel max values of channel 1 up to channel "chncount". But this is just the flat channel number (which you can see in the Dataportal list page) and not the channel index of a certain channel group. So if the "3D Values" channel group is not the first group you read the wrong values.
for iloop = 1 to chncount
a = chnpropvalget(iloop,"Maximum")
chd(iloop,"result/results") = a
next
A second point:
You add a new channel group with at position 8. If you don't have already at least 7 groups you get an error.
Call Data.Root.ChannelGroups.Add("result",8).Activate()
In my tests just the min/max values of the result channel are NV. This can be recalculated with ChnCharacter.
I would prefer only using the new data API in new scripts.
Here is an example of how you can define your example in DIAdem 2015:
dim iLoop, oSourceGroupChns, oTargetGroup, oTargetChn set oSourceGroupChns = Data.Root.ChannelGroups("3D Values").Channels set oTargetGroup = Data.Root.ChannelGroups.Add("Results") set oTargetChn = oTargetGroup.Channels.Add("MaxResults", DataTypeChnFloat64) call oTargetGroup.Activate for iLoop = 1 to oSourceGroupChns.Count oTargetChn(iLoop) = oSourceGroupChns(iLoop).Maximum next call ChnCharacter(oTargetChn)
Greetings
Walter
By the way, in your attachment I miss the TDX file.
03-21-2016 12:16 PM
Walter , thank you for your reply.
oTargetChn(iLoop) = oSourceGroupChns(iLoop).Maximum
works for DIAdem 2015 only. Any way to make the code works for older version of DIAdem?
03-22-2016 01:16 AM
For older DIAdem versions you can use:
oTargetChn(iLoop) = oSourceGroupChns(iLoop).Properties("maximum").Value
Greetings
Walter
03-25-2016 03:45 PM
Hi Walter,thank you for the help.
I am using the method you provided. For some data files it worked, some of still not working (works under debug mode, however, it didn't work under regular run mode).
I noticed if I finish wrting the channel value and drag the channel to view tab. Channel values changed from NOVALUE to correct values. It is like refresh channel values.
Not sure if it is related to computer memory usage? Since for my work, I did lots of channels sort, channels deplication remove before this step.
Thank you.
03-29-2016 12:43 AM
Hi IIx,
In my example script I used the command
call ChnCharacter(oTargetChn)
to calculate the channel characteristics. Depending on your script this can be necessary. Do you use also this command?
Greetings
Walter