hstephan Posted September 7, 2018 Share Posted September 7, 2018 Hello, 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) return(NULL) endif //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," "))) Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted September 10, 2018 Share Posted September 10, 2018 What is datain? And what about the other ? statements output? Quote Link to comment Share on other sites More sharing options...
hstephan Posted September 13, 2018 Author Share Posted September 13, 2018 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 "local.channel.AddValue"; 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 Heribert Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted September 13, 2018 Share Posted September 13, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.