Creating new device / channel.AddValue

Recommended Posts


I tried to create anew device, following the instructions in the Serial / Ethernet Communications Gude.


The instrument delivers severel values in an ASCII string. I want towrit two of this values in channels, as described in the guide.

But only the valu for channel 0 is written. The channel.AdddValue command does not work (See listing below)

Of course the channel is created as channel 1, device 0.


Any hints?

Best regards


if (Channel != 0)

//Control debug output (all lines with ?)
System.SequencePrint = 1

//Data aquisition
private string datain = Poll("ACT",13)

//Replace double blanks
datain = replace(datain,"  "," ")
? "datain = " + datain

// Write temperature to channel 1
Channel.AddValue(strDevice,0,"GetData1",1,StrToDouble(Parse(datain,4," ")))
? "strDevice = " + strDevice
? "Temperature = " + Parse(datain,4," ")

//Write pH Value (to Channel 0)
? "pH Value = " + Parse(datain,3," ")
return (StrToDouble(Parse(datain,3," ")))

Link to comment
Share on other sites

Hello  Guru,

datain is the string where the output from the device is stored. The values are separated by one or two blanks . Therefore the unnecessary blanks are eliminated with the replace statement.

Most of the other statements are only for testing purposes to see whether the values are read correctly.

I found the error meanwhile: one has to use ""; i found this in an other post in the forum; but initially it didn't work for me, because the *.ddp file with the device definition is stored in the "c:\windows\program files (x86)\DAQFactory" directory. With windows 7 changes are only stored when you run DAQFactory as Adminstrator.

Best regards



Link to comment
Share on other sites

Yes, that is because Windows made the program files folder read only unless run as admin.

And right, inside the protocol script for an iotype, there is a local variable created called "Channel" that is passed in corresponding to the channel # in your channel.  So, it gets confused and uses that variable instead of the global Channel object.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.