Sign in to follow this  
CH2014

Preventing A 2Nd Instance Of Daqfactory From Starting

Recommended Posts

I meant to ask this question a while ago but is there a way to stop someone accidentally starting a DAQFactory ctl program twice? (i.e. They may have minimised the program and then forgot it was minimised, then accidentally start the program again.)?

 

 

Share this post


Link to post
Share on other sites

You can't keep them from starting the program, but you can do something in script if you detect it (like quit, or stop acquisition).  To do this, create a background sequence that simply sets a registry variable every second:

 

while(1)

   registry.watchdog = systime()

   delay(1)

endwhile

 

Then, in your auto start sequence, look at registry.watchdog and compare with systime().  If its within, say, 5 seconds, then another copy of DAQFactory must be updating that value. Something like:

 

if (systime() - registry.watchdog < 5)

   system.quit()

endif

Share this post


Link to post
Share on other sites

I have been a Labjack/daqfactory user for over 5 years and now have 2 different labjacks (ue9 and u3).

I have had the problem of after shutting down a daq session and I reload daqfactory again I get the message that there is another session running. This requires a trip to the Task Manager and killing one or more of the DAQFactory.exe *32 processes. Will this technique above fix this also?

 

The flip side of this subject is another question:

Is it possible to run 2 daqfactory sessions on 2 different labjacks on a single PC and is there a way to pick which labjack goes with each session?

 

I have a general set of startup sequences that trys to find a labjack first on USB and identifies which labjack(U3 orUE9) it found and if none found checks the ethernet for  the UE9. This sequence also Pings for the UE9 via a .bat file which seems to help connecting especially if I am operating through a wireless bridge. After finding which labjack model it found then the DAQfactory will use either a UE9 or U3 setup sequence and channel list. Each sequence for getting data has select statement where the case for U3 and case for UE9 each contain the appropriate eget statements for the labjack model determined at startup.

 

Thanks

Bob

Share this post


Link to post
Share on other sites

In your case, no, it likely won't.  Its not the starting of the second program that's keeping the first from not quitting.  The problem is that the LabJack driver is busy doing something and DAQFactory has to wait on it and can't completely quit.  My first suggestion is to make sure you are running the absolute latest LabJack drivers.  I think they've made some improvements on cleanup.

 

As for the second question, I do not remember if the UD supports communication from two processes at the same time.  I know you can't communicate with the same LabJack device from two processes, but I'm not sure about the UD.  If you can, then you can do the rest.  Consider using some of the discovery functions built into the UD to find your devices.  You'll have to import them using extern(), but they should work.

Share this post


Link to post
Share on other sites

Hi,

I tried with above solution to prevent running second instance. In my one PC its working fine. But in another PC located in another project, this is not working. it means it doesn't update the watchdog registry and it keep as zero all the time. I tried this with sequences and also through edit boxes with some values as well.

registry.watchdog = 5

But the registry is not getting updated. what can be the reason for this?

 

BR,

thushara

Share this post


Link to post
Share on other sites

Under newer versions of WIndows, the registry gets tricky to use due to tighter security.  This is probably why DAQFactory is unable to write to the registry.  I believe we have tried to have our installer expand the security rights of the registry folder for DAQFactory variables, but I'm not sure if that is in the 17.x releases.  You probably should consider using a file instead.  This original post was from 4 years ago when Win 7 was the prevalent OS.

Share this post


Link to post
Share on other sites

Hi

Thanks for the reply.

And also can you let me know how to try using a file? I'm using windows 10 64bit. 

Br,

Thushara. 

Share this post


Link to post
Share on other sites

For a single flag it is especially easy:

private handle = file.open("c:\data\myfile.txt", 0, 1, 0, 1)
file.write(handle,"5")
file.close(handle)

or to read from the file:

private handle = file.open("c:\data\myfile.txt", 1,0, 0, 1)
private string datain  = file.read(handle)
file.close(handle)

 

 

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