BrianYao Posted September 8, 2020 Share Posted September 8, 2020 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 Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted September 11, 2020 Share Posted September 11, 2020 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. 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.