DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert channels from numeric to waveform with dataplugin

Hi folks,

 

I'm importing some data from CSV files, in which the first column is TIME, and they're easier to analyse when converted to waveforms, but unfortunately the time period is slightly irrelgular, so the channel to waveform function throws the error "The x-channel must be equidistant".

 

For my purposes, I don't care about the irregularity, so I used the dataplugin wizard to create a new CSV import plugin. The associated VBS script contained a section like this:

 

If Waveform Then
Call Channel.Properties.Add("wf_start_offset",CDbl(1))
Call Channel.Properties.Add("wf_increment",CDbl(1))
Call Channel.Properties.Add("wf_xname","")
Call Channel.Properties.Add("wf_xunit_string","")
Call Channel.Properties.Add("wf_samples",CLng(1))
Call Channel.Properties.Add("wf_time_pref","relative")
Call Channel.Properties.Add("wf_start_time",CreateTime(0,1,1,0,0,0,0,0,0))

Endif

 

To which I added the bold section, so it reads:

 

If Waveform Then
Call Channel.Properties.Add("wf_start_offset",CDbl(1))
Call Channel.Properties.Add("wf_increment",CDbl(1))
Call Channel.Properties.Add("wf_xname","")
Call Channel.Properties.Add("wf_xunit_string","")
Call Channel.Properties.Add("wf_samples",CLng(1))
Call Channel.Properties.Add("wf_time_pref","relative")
Call Channel.Properties.Add("wf_start_time",CreateTime(0,1,1,0,0,0,0,0,0))
else
Call Channel.Properties.Add("Waveform","Yes")
Call Channel.Properties.Add("wf_start_offset",CDbl(0))
Call Channel.Properties.Add("wf_increment",CDbl(0.02))
Call Channel.Properties.Add("wf_xname","Time")
Call Channel.Properties.Add("wf_xunit_string","s")
Call Channel.Properties.Add("wf_samples",CLng(1))
Call Channel.Properties.Add("wf_time_pref","relative")
Call Channel.Properties.Add("wf_start_time",CreateTime(0,1,1,0,0,0,0,0,0))
End If

 

This works almost perfectly and forces numeric channels to be waveforms with a time period of 0.02 seconds, which was the intended time period for the CSV files.

 

The one anomoly is that the line: Call Channel.Properties.Add("Waveform","Yes") correctly sets "Waveform" to "Yes", but also creates an extra property field called "Waveform1", which it also sets to "Yes".

 

Is there a function equivalent to Channel.Properties.Set that could be used to set the "Waveform" property to "Yes", without creating the field?

 

Regards,

 

John.

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

Hi John -

 

I'm pretty sure the "Waveform" property is a read-only property.  This would explain why your script isn't actually setting the "Waveform" property, but attempting to add a new property called "Waveform" which already exists and is therefore iterated to "Waveform1" and set to "Yes" in your function call.

 

Try the same code without using Call Channel.Properties.Add("Waveform","Yes") - I bet this would prevent the addition of the extranneous Waveform1 property.

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 2 of 5
(5,153 Views)
Hi,

Yes, I did try the script without the add waveform property line, but then the channels are imported as numeric, so it must succeed in setting the waveform property.

It doesn't really matter that the waveform1 field is created, it would just be tidier if it wasn't.

Thanks,

John.
0 Kudos
Message 3 of 5
(5,148 Views)

Hi John,

 

I've been looking at this for a dataplugin I have been working on as well.

 

The key line is setting "wf_samples". As soon as this is non-zero DIAdem treats these as waveforms and you don't have to set the "waveform" property as Derrick says.

 

Cheers,

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 4 of 5
(5,067 Views)

Hi James,

 

Well, you (and Derrick) are correct, the Channel.Properties.Add("Waveform","Yes") line is not required after all.

 

I was totally sure that I initially ran the code without this line, and it failed to set the channels as waveforms, which was why I added the line in the first place!

 

However, I deleted the line, tried again and for whatever reason it is now working - strange, but true.

 

So the section of code now looks like this and works perfectly:

 

If Waveform Then
Call Channel.Properties.Add("wf_start_offset",CDbl(1))
Call Channel.Properties.Add("wf_increment",CDbl(1))
Call Channel.Properties.Add("wf_xname","")
Call Channel.Properties.Add("wf_xunit_string","")
Call Channel.Properties.Add("wf_samples",CLng(1))
Call Channel.Properties.Add("wf_time_pref","relative")
Call Channel.Properties.Add("wf_start_time",CreateTime(0,1,1,0,0,0,0,0,0))
else
Call Channel.Properties.Add("wf_start_offset",CDbl(0))
Call Channel.Properties.Add("wf_increment",CDbl(0.02))
Call Channel.Properties.Add("wf_xname","Time")
Call Channel.Properties.Add("wf_xunit_string","s")
Call Channel.Properties.Add("wf_samples",CLng(1))
Call Channel.Properties.Add("wf_time_pref","relative")
Call Channel.Properties.Add("wf_start_time",CreateTime(0,1,1,0,0,0,0,0,0))
End If

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