From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-01-2012 09:52 AM
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.
06-01-2012 05:42 PM
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.
06-01-2012 06:31 PM
06-15-2012 05:01 AM
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,
06-15-2012 05:49 AM
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