DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Working with waveform properties in Python

Solved!
Go to solution

Hello,

 

I'm trying to work with waveform data and having a bit of trouble with time calculations.

The challenge is that the data type of start time / offset and increment are not compatible.

 

For example simply adding start time and increment like this:

dd.Data.Root.ActiveChannelGroup.Channels("DUT 01").Properties("wf_start_time").Value 
+ dd.Data.Root.ActiveChannelGroup.Channels("DUT 01").Properties("wf_increment").Value

results in a

TypeError: unsupported operand type(s) for +: 'pywintypes.datetime' and 'float'

 

I'm not familiar with pywintypes and haven't really looked into this library yet.

But i have tried converting to datetime with no luck.

 

Is there maybe a simple "How-to" for handling time data in with Python in DIAdem?

0 Kudos
Message 1 of 3
(1,145 Views)
Solution
Accepted by topic author maflAut

Hi, 

 

to add those values it is possible to import "datetime" and to use the function "timedelta". 

Below you find a short example, adding step width of one day to the waveform start time. 

"timedelta" offers also options to add the value to month, year etc.

 

import datetime 
StartTimeVal=dd.Data.Root.ChannelGroups(1).Channels("DUT 01").Properties("wf_start_time").Value
StepWidthVal=dd.Data.Root.ChannelGroups(1).Channels("DUT 01").Properties("wf_increment").Value

StartTimeVal=StartTimeVal+datetime.timedelta(days=StepWidthVal)

With

wf_start_time: 01.08.2012 00:00:00.000000000

wf_increment: 1 

 

you receive: 

wf_start_time 02.08.2012 00:00:00.000000000

Message 2 of 3
(1,090 Views)

Thank you!

0 Kudos
Message 3 of 3
(1,065 Views)