DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

cursor x1 not returning timestamp

I need to write a script that allows the user to perform an operation on a certain portion of a waveform that has time plotted on the X axis. I am using the frame cursor to allow the user to select a portion of the waveform.  I then retreive the Y1, Y2, X1, and X2 values of the cursor in order to calculate the points in the waveform I am interested in.  The Y1 and Y2 data return what I would expect, but the X1 and X2 does not.

 

When I look at the cursor X1 and DX values on the view screen it shows the time stamps I would expect. When I try to retrieve the X1 and X2 values from the cursor in the script it gives me numbers that aren't timestamps. I tried to convert them into timestamps, but they generate an overflow error when I try. Also IsDate() tells me they are not convertable.  I don't have any idea what these number are supposed to represent.

 

What are the X1 and X2 values that are being returned if they are not X-axis (time stamp) values?

 

Is there some other way to get the user specified portion of my data table that I am not aware of?

0 Kudos
Message 1 of 5
(5,919 Views)

Hi JoJo,

 

Those big numbers are DIAdem timestamps stored as DBLs and count the number of fractional seconds since 0 AD.  You can use the TTR() and RTT() functions to go back and forth between DIAdem timestamps and datetime strings, but your next step is to find the channel rows in the Time channel with ChnFind() or PNo() that correspond to X1 and X2, and for that you actually want the big numbers DIAdem gave you.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(5,908 Views)

TTR and RTT are only of limited use as they convert the time to strings. This means that I can't compare the return values to the timestamps from my time channel.

 

Is there a way to convert the dates to timestamps rather than string?

0 Kudos
Message 3 of 5
(5,886 Views)

OK, I figured it out. I used PNo() with the X1 and X2 values to find the nearest points, and then used those points to check the limits before performing the calculations.

0 Kudos
Message 4 of 5
(5,884 Views)

Exactly,

 

The X1 and X2 values in the billions of seconds are exactly the (numeric) values you want to pass to the PNo() or ChnFind() functions to determine the P1 and P2 values.  Unfortunately the cursors do not reliably deliver the P1 and P2 values directly, so you should always go this extra mile, whether the X channel is a number or a datetime.  As far as DIAdem is concerned, datetime and numbers are both stored as DBL channels, so you can use the same code in either case.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 5
(5,849 Views)