Sign in to follow this  
BrianYao

On Send Protocol Help

Recommended Posts

Hi,

I'm using DAQFactory to control an HPLC pump. I wrote a two separate I/O types (that use the polling function) to get the flow rate and pressure into channels to monitor these parameters. The I/O for one of them is below. This seems to be working.

device.HPLC_Pump_A.Purge()

private string A =device.HPLC_Pump_A.Poll("CC",47)

private string B = remove(A,"/")

private string C = parse(B,2,",")

private Pump_A_FR = StrToDouble(C)

local.channel.addvalue("HPLC_Pump_A",1,"GetFlowRate",2,Pump_A_FR)

I'm worried that when I send the pumps a command (for instance to start the pump, change the flow rate, or ask for other information), if I'm unlucky with the timing, the command will get purged due to purge I put in the monitoring of the flow rate and pressure. Is there something I can add to the On Send or On Receive to make sure that my commands will make it through? Or should I remove the purge from the I/O type?

Thanks

Share this post


Link to post
Share on other sites

You'll want to use the LockPort() and UnlockPort() functions to prevent the sort of overlap you described.  It should be something like:

try
   if (!LockPort())
      throw("Couldn't lock port")
   endif
   // do comms
   UnlockPort()
catch()
   UnlockPort()
   throw()
endcatch

But note that the way you are writing your script really doesn't justify using a User protocol.   You are hardcoding all the specs, even the port connection, so the channel configuration doesn't matter, and reuse will be hard.  You are just using the channel as a trigger.  You would probably be better off just writing sequences.  It will be much easier to debug.  You still might have to lock the port if you use multiple threads.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this