LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Absolute Time in Graph Limit 2035

Hello everybody,

 

I use a graphic control with the absolute time format on the X axis. 

But this has a big limitation. The date can only reach 2035.
In order not to have this limit in working with dates I use the National Instruments Binary Time Format.
The problem returns when working with the graphs because using the CVIAbsoluteTimeToCVIUILTime to set the X axis the limit to 2035 is again present.
Is there a solution to avoid this problem?

 

Thanks in advance for your help,

 

Mattia

0 Kudos
Message 1 of 3
(118 Views)

This appears to be a problem of the native time format in the graph control, which relies on MakeDateTime and inherits its limitations.

The graph control however can display any quantity that can be expressed in double numbers, and time indeed can be and well past year 2035, so while you wait for NI to update CVI to address this problem you could solve it with a bit of effort on your side.

 

Basically:

  • Get rid of time display and use floating point format instead
  • Use label strings on the axis
  • Calculate appropriate range for your time axis and apply to the graph control
  • Populate the axis with an array of label strings

I made a quick and dirty example that shows this solution: you can input any date you want and it will format a 10-days graph axis.

 

Note 1: this example only works in 64-bit mode

Note 2: there is no control on day/month/year overflow in 10-days calculation: did I mention it is a quick-and-dirty code? 😉



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(78 Views)

Hello Roberto,

 

Thanks for your timely help.

 

The only problem is that my application has to be compiled to 32bit due to some LIBs. 

 

I thought of a workaround using the NI-BTF functions to get the number of seconds from 1/1/1900 into a 64-bit integer.

 

CVIAbsoluteTime absTimeStart, absTime2;
CVITimeInterval timeInterval;
__int64 start;

// Convert to absolute time
CVIAbsoluteTimeFromLocalCalendar((unsigned int) year, (unsigned int) month, (unsigned int) day, (unsigned int) 14, (unsigned int) 30, (unsigned int) 30, 0.0, &absTimeStart);
CVIAbsoluteTimeFromLocalCalendar((unsigned int) 1900, (unsigned int) 1, (unsigned int) 1, (unsigned int) 0, (unsigned int) 0, (unsigned int) 0, 0.0, &absTime2);

// Diff
SubtractCVIAbsoluteTimes(absTimeStart, absTime2, &timeInterval);

// Convert to int64
CVITimeIntervalToTimeUnit(timeInterval, CVITimeUnitSeconds, CVITimeRoundMethodUp, &start);

 

The variable 'start' corresponds to the one calculated with mktime in your example.

In your opinion can it be a valid solution?

 

Grazie del tuo aiuto 😉

 

 

0 Kudos
Message 3 of 3
(66 Views)