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: 

Plotting while using "when"

Is it possible to plot channel information only when another channel is true without creating new channels?

In example below, I only want to plot the Date vs Temp when State = Ramp.

 

Example:

Date,State,Temp

01/05/2023 11:38:00, "Initialize", 68

01/06/2023 05:30:00,"Ramp", 68

01/06/2023 05:31:00,"Ramp", 75

01/06/2023 05:32:00,"Ramp", 85

01/06/2023 05:33:00,"Ramp", 95

01/06/2023 05:34:00,"Dwell", 102

01/06/2023 05:35:00,"Dwell", 102

0 Kudos
Message 1 of 7
(967 Views)
labels = dd.Data.Root.ChannelGroups(1).Channels("labels").GetValuesBlock()
dd.Data.Root.ChannelGroups(1).Channels.Add("labels_bool",dd.DataTypeFloat64)
labels_bool = dd.Data.Root.ChannelGroups(1).Channels("labels_bool")
labels_bool_list = []
for label in labels:
    if label == 'a':
        labels_bool_list.append(1)
    else:
        labels_bool_list.append(None)
labels_bool.SetValuesBlock(labels_bool_list, 1, dd.eValueBlockValueInsert)
dd.ChnMul("[1]/values", "[1]/labels_bool", "/filtered")

 

Load the example data and run the script.  I essentialy create a channel of 1s and nulls based on what you want to plot and then multiply it by the channel with values to create a channels filtered to the desired label.

0 Kudos
Message 2 of 7
(946 Views)

yeah. I can do it that way. was really hoping for a way that didn't involve making any new channels at all, since I actually have 19 different states and have to be able to plot to at least 6 of them.

0 Kudos
Message 3 of 7
(908 Views)

I ended up using this instead:

 

ChnEventResultList= Null
ChnEventResultList = ChnEventDetectionEqualStr(, "[1]/[2]", "Ramp")
Call ChnEventCreateStatusChn("SteadyState/EventStatus", ChnEventResultList, "[1]/[2]", 0, 1)
Set ChnResult = ChnMul("[1]/DateTime", "[2]/EventStatus", "/DateTime")

Set ChnResult = ChnMul("[1]/DateTime", "[2]/EventStatus", "/Temp")

0 Kudos
Message 4 of 7
(902 Views)

No real way of just plotting based on a condition without creating some extra index channel.

One strange solution if you really don't want any extra channels is to set the values that you don't want plotted to NOVALUE and appending the value with a separator to the state channel.  That way you are not creating extra channels and the process is reversible (might be computationally expensive)

0 Kudos
Message 5 of 7
(898 Views)

Hi 2Pale4TX,

 

As gsklyr mentioned, the easiest way for such cases is to create new filtered channels. In DIAdem you can find a example which helps to filter the data.

 

Walter_Rick_0-1674646104336.png

 

 

But there is also a second option. For this you need a script. You need a script for initialization and a user command script. This user command script is called right before DIAdem is displaying the channels of the 2D axis system. In this script you can manipulate the data which should be displayed. Attached you find an example.

 

Greetings

Walter

0 Kudos
Message 6 of 7
(876 Views)

Here is the attachment.

0 Kudos
Message 7 of 7
(873 Views)