|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Fri Jul 27, 2012 3:04 pm Post subject: %dl to avoid program hanging? |
|
|
G'day, folks
The program I'm developing interacts with a set of thermocouples via the serial port. Different subroutine calls are used to open the port, to collect data through it, and to close the port. However, if any of these calls fails to complete (for example, thermocouples are not connected) then the program 'hangs', requiring intervention by the Task Manager. This can be highly frustrating for an operator, particularly if they've just searched the entire building looking for the Task Manager's office.
I'm wondering if the delay function %dl ...
Code: |
ia=winio@('%dl', interval, cb_func)
|
... can be used to avoid operator agitation by limiting the time allowed for the call to complete. The call would be contained within the call-back function cb_func (see above code). The code as written above would produce repeated calls to cb_func. The trick will be to make just one call to cb_func. Perhaps if cb_func has a return value of zero?
Eric |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
Posted: Fri Jul 27, 2012 5:04 pm Post subject: |
|
|
Eric,
Are you using FTN95 routines such as OPENCOMMDEVICE@ ? Surely this returns an error code if it can't connect and you don't need to wait. If you get the return code of 1, pop up a window with a message of the "retry or cancel" variety.
How are you communicating with the serial port ? My last few compters haven't had RS232!
Regards
Eddie |
|
Back to top |
|
|
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Sat Jul 28, 2012 3:57 pm Post subject: |
|
|
Thanks for the suggestion, Eddie
I wish I could use something like OPENCOMMDEVICE@. Unfortunately the only thing I have available is a compiled (C++ language) proprietary function tc08_open_unit(port) that drives the 'black box' into which the thermocouples are connected. Sadly, the days are long-gone when this Perth university built all its electronic equipment and wrote its own drivers.
So my only recourse was to first make the C++ tc08_open_unit(port) Fortran-callable and then repeatedly test the return value until it was non-zero, thus -
Code: |
100 ok = open_TC08(port)
if(ok .eq. 0) goto 100
|
Quite a journey from the days of Z80, with its baud rate, stop bits, parity, etc. Back in those days the latest computers had 3.5 inch floppy drives!
Eric |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
Posted: Sat Jul 28, 2012 5:49 pm Post subject: |
|
|
Eric,
If you have to use your routine, it still gives a success/fail message, so how about:
Code: | 100 KOUNTER = 0
110 ok = open_TC08(port)
IF (ok .ne. 0) GO TO 120
KOUNTER = KOUNTER + 1
if (ok .eq. 0 .AND. KOUNTER .LE 10000) goto 100
IA=WINIO@ ('%ca[No response from thermocouples]&')
IA=WINIO@ ('%nl%si!There is no response from the thermocouple '//
& 'black box&')
IA=WINIO@ ('%2nl%rj%12bt[Keep trying] %12bt[Give up]')
if (IA .EQ. 1) GO TO 100
C ... this is where you get to if the user gives up
.
.
.
120 CONTINUE ! this is where you get to if the port opens
|
Instead of counting the number of tries (10,000 was my guess, but it could be more - or fewer) you could allow a certain length of time using one of the timer routines and offer the choice of giving up after (say) 10 seconds.
If starting the black box normally takes some measurable time, there are more user friendly ways of doing it and keeping the user informed of what is happening.
You can probably code it without the ugly GO TOs - not that I mind a few, but this isn't nice ...
Eddie |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|