DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

If junk date I want to display as NOVALUE for DateTime data type in Channel values. Is that possible?

Solved!
Go to solution

If junk date I want to display as NOVALUE for DateTime data type in Channel values. Is that possible?

0 Kudos
Message 1 of 10
(3,091 Views)

Yes, this is posible:

 

dim oChn
set oChn = Data.Root.ChannelGroups(1).Channels("Date")
oChn(5) = NV

 

or interactivly in VIEW by typing NV for a date cell

 

Greetings

Walter

0 Kudos
Message 2 of 10
(3,052 Views)

I appreciate your response.. 🙂

As you suggested I tried assigning with NV and also tried with 0 and NoValue, but its displaying as 01/01/0000 00:00:00 in DIAdem.

 

What actually I'm doing is I'm trying from a C++ DataPlugin.

 

I can see some info regarding NoValues here at:

https://zone.ni.com/reference/en-XX/help/370858P-01/genmaths/genmaths/calc_novalue_description/

 

But, I dont know whether I'm looking at the right place or not.

 

In all my trails, it only displays a valid datetime or a 01/01/0000 00:00:00 but not NOVALUE or empty. Based on this I got doubt like whether displaying NOVALUE for DateTime data type is possible or not.

0 Kudos
Message 3 of 10
(3,042 Views)

I described what you can do in DIAdem after the file is loaded. Your question is about a DataPlugin.

Internally is a DIAdem date channel a numeric channel with double values, counted from year 0 in seconds. In a C++ DataPlugin you can use NaN to set a date value to NoValue (which is the representation of NaN in DIAdem)

That should work.

 

Greetings

Walter

0 Kudos
Message 4 of 10
(3,038 Views)

If I assign NaN to Int, Double and Float then its displaying as NOVALUE.

But if I assign NaN to date channel then its displaying as 00/00/0000 23:30:08.0000

 

0 Kudos
Message 5 of 10
(3,033 Views)

You are right, this does not work for date/time channels. I discussed this with R&D and got this info:

 

You need to overwrite two functions which are defined in the interface:

 

virtual HRESULT GetFlagsLength(ULONG64& val) const { val = 0; return S_OK; }

virtual HRESULT GetFlags(ULONG64 numberToSkip, ULONG numberToTake, VARIANT& values) const { numberToTake; values; if (0 != numberToSkip) { return E_FAIL; }; return S_OK; }

 

A bit more information can be found on GitHub:

https://github.com/ni/dataplugin-sdk-for-cplusplus/blob/main/include/ni/dataplugin/IChannel.h

Message 6 of 10
(2,942 Views)

Thank you Walter!

 

I will try out overwriting those two functions and let you know.

0 Kudos
Message 7 of 10
(2,934 Views)

Tried overwriting the interface methods GetFlagsLength and GetFlags.

 

What I could see is, its taking the number of invalid date time values in the channel and skipping that many number of values in the begging of the channel.

So if there are 2 junk/invalid date time values in the channel then I could see top 2 values as NOVALUE.

 

Without skipping from the beginning, I want to display NOVALUE for the date time channel value only when its not a valid date time.

 

So if channel values are like this

06/08/2021 00:22:00

invalid date

06/08/2021 01:22:00

06/08/2021 01:23:00

invalid date

06/08/2021 02:23:00

 

then I need to display NOVALUE only when its some junk/invalid date.

06/08/2021 00:22:00

NOVALUE

06/08/2021 01:22:00

06/08/2021 01:23:00

NOVALUE

06/08/2021 02:23:00

 

Is this possible? Can you please provide me with some more information on these or any other alternative ways?

 

Thank you.

0 Kudos
Message 8 of 10
(2,866 Views)
Solution
Accepted by Vinayvenugopal

GetFlagsLength() should return the number of values in your date channel, and a length of 0 for all other channels.

GetFlags() is called with the same parameters as GetValues(), and must return a flag for each value to specify if the value is valid or invalid.

GetFlags() therefore needs to return of data type VT_I2:

SAFEARRAY* psaStruct = SafeArrayCreateVector(VT_I2, 0, numTakeable);

with a value of 0xF for valid values, and 0x0 for invalid values.

 

For your example, the two arrays should be as follows:

Values:                                       Flags:

06/08/2021 00:22:00                  0xF

invalid date                                 0x0

06/08/2021 01:22:00                  0xF

06/08/2021 01:23:00                  0xF

invalid date                                 0x0

06/08/2021 02:23:00                  0xF

Message 9 of 10
(2,820 Views)

It worked! 🙂

 

Thank you very much for your help and quick responses @usac and @Walter_Rick 

 

Finally I could do what I wanted..

0 Kudos
Message 10 of 10
(2,806 Views)