Changing Sequence From Using V.channel To Using Local Channel


ace5150

Recommended Posts

I created a sequence that reads a .txt file, writes values to a V.channel, then deletes the file. This works great. I recently found out that

V.channel data can not be read by a remote runtime copy of DF. Is there a simple way to change my script to use a local channel instead of a V.channel?

I created a local channel and changed the script, it seems to only read 1st line of the .txt file and there are other problems as well:

 

THIS WORKS:
while(1)
  V.Exist = File.GetFileExists("C:\Users\scott\Documents\DAQSUB.txt")    
   while(V.Exist==0)                                                     
   V.Exist = File.GetFileExists("C:\Users\scott\Documents\DAQSUB.txt")
   delay(2)
  endwhile
     private handle=File.Open("C:\Users\scott\Documents\DAQSUB.txt",1,0,0,1)
V.Cycle_Time_3[0]=File.ReadDelim(handle,-1,",",chr(10),4)
File.CloseAll()
 File.Delete("C:\Users\scott\Documents\DAQSUB.txt")
  delay(20)
endwhile

 

THIS DOESNT WORK:

 

while(1)
   Exist = File.GetFileExists("C:\Users\scott\Documents\DAQSUB.txt")   
   while(Exist==0)                                                    
   Exist = File.GetFileExists("C:\Users\scott\Documents\DAQSUB.txt")
   delay(2)
  endwhile
     private handle=File.Open("C:\Users\scott\Documents\DAQSUB.txt",1,0,0,1)
Cycle_Time_3=File.ReadDelim(handle,-1,",",chr(10),4)
File.CloseAll()
 File.Delete("C:\Users\scott\Documents\DAQSUB.txt")
  delay(20)
endwhile

 

 

 

 

Link to comment
Share on other sites

First, why did you use a V channel for exist?  You really can just use a private variable:

 

private exist = 0

while(1)

   while(exist == 0)

      exist = file.getFileExists("....")

      delay((!exist) * 2)

   endwhile

...

 

Next, you can't do:

 

SomeChannel = ...

 

unless SomeChannel is an output channel, and then, well, it will go out the output.  If you want to add a value or array of values to a channel without going through any drivers, use the addValue() function:

 

private datain = file.readDelim(....)

Cycle_time.addValue(datain)

 

 

Link to comment
Share on other sites

Archived

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