On Send Protocol Help


Recommended Posts


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.


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)


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?


Link to comment
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:

   if (!LockPort())
      throw("Couldn't lock port")
   // do comms

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.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.