BBC BASIC for Windows
« timer & scedules »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:54pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: timer & scedules  (Read 463 times)
dynamic35
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 34
xx timer & scedules
« Thread started on: Feb 8th, 2010, 8:28pm »

Hi
I have now a 6 week feeling and experience with The BBC basic and I am very happy with its quality including these help methods Thanks to Richard et all

As a beginner I turn to you again. I would need to start a bbc basic exe every morning 10:30, collect data from environmental sensor from 10:30 to 11:15 , then save that data to disk (CSV) and then again immediatelly after 11:15 the 2nd round. That 2nd round will end 12:30 and then PC must the go to sleep with screen black i.e from 12:30 until next morning 10:30. and so on: 5 days a week ,every weekday same two timed data collection processes
Windows (XP) do have its in-build scheduler i know, but is seems not to fit my case.
An example/help available here? Thank you
Greetings N62E25
User IP Logged

Richard Russell
Guest
xx Re: timer & scedules
« Reply #1 on: Feb 8th, 2010, 9:40pm »

Quote:
Windows (XP) do have its in-build scheduler i know, but is seems not to fit my case. An example/help available here?

It would be pretty easy just to check the value of TIME$ to determine when to do things:

Code:
  REPEAT
    WAIT 50
    IF LEFT$(TIME$,3)<>"Sat" AND LEFT$(TIME$,3)<>"Sun" THEN
      CASE MID$(TIME$, 17, 5) OF
        WHEN "10:30", "11:15": PROCcollect
        WHEN "12:30": PROCsleep
      ENDCASE
    ENDIF
  UNTIL FALSE

  DEF PROCcollect
  REPEAT
    REM collect data
  UNTIL MID$(TIME$,17,5) = "11:15" OR MID$(TIME$,17,5) = "12:30"
  PROCsavedata
  ENDPROC 

Obviously this will need a lot of fleshing-out.

Richard.
User IP Logged

Malcolm
Guest
xx Re: timer & scedules
« Reply #2 on: Feb 9th, 2010, 5:13pm »

I think you can do much of what you want with Scheduler and a simple batch file.

If you write a single line batch file:
%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState hibernate

and then at the end of your BB4W executable do a
*RUN filename ;
The help files will tell you how to format that filename correctly.
The computer will go into hibernation until the scheduler wakes it to run the BB4W.exe for the next day.

Then during the day the code that Richard had would do the acquisition etc.
User IP Logged

Richard Russell
Guest
xx Re: timer & scedules
« Reply #3 on: Feb 10th, 2010, 08:10am »

Quote:
If you write a single line batch file:
%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState hibernate

Pretty much stating the obvious, but since that's just a DLL function you can do the equivalent in your BASIC program without the inconvenience (and inelegance) of running an external script:

Code:
      SYS "LoadLibrary", "powrprof.dll" TO powrprof%
      SYS "GetProcAddress", powrprof%, "SetSuspendState" TO `SetSuspendState`
      SYS `SetSuspendState`, 1, 0, 0 

Your process must have the appropriate privileges.

Richard.
User IP Logged

Malcolm
Guest
xx Re: timer & scedules
« Reply #4 on: Feb 10th, 2010, 4:35pm »

There is a subtle difference between the two though. The sys approach Hibernates immediately at that instruction. The batch file can let you exit the BB4W program before it hibernates. The ";" at the end of the RUN statement means that the BB4W program does not wait for the *.bat to complete before continuing.

I am quite happy with scripts and batch files as they are easy to construct. It also lets you run backups and other stuff at the end of a day and before hibernation.

You could just leave the BB4W program running day and night, which, I think, is what Richard was thinking with the initial reply. Then you just need a task to wake up the system in the morning and have the BB4W go back into its time polling loop. That wake task could be a real task or just a dummy, but you have to give Windows something to do.

User IP Logged

dynamic35
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 34
xx Re: timer & scedules
« Reply #5 on: Feb 10th, 2010, 7:39pm »

Much thanks to Malcom and Richard

I will report you in two three days what took place
N62E25
User IP Logged

Richard Russell
Guest
xx Re: timer & scedules
« Reply #6 on: Feb 10th, 2010, 10:36pm »

Quote:
The batch file can let you exit the BB4W program before it hibernates.

There's absolutely no guarantee of that. It entirely depends on process priorities, scheduler behaviour, version of Windows etc. If it's important that the BB4W program quits before the PC hibernates there is probably some way to achieve it, but that isn't it!

Quote:
You could just leave the BB4W program running day and night

Exactly. Since you can arrange for a waitable timer to wake the PC from its hibernation, you should be able to do the whole thing from BB4W without needing to use the scheduler:

http://msdn.microsoft.com/en-us/library/aa373235.aspx

Richard.
User IP Logged

Malcolm
Guest
xx Re: timer & scedules
« Reply #7 on: Feb 11th, 2010, 01:28am »

We await the elegant solution. Over and out!
User IP Logged

dynamic35
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 34
xx Re: timer & schedules
« Reply #8 on: Feb 11th, 2010, 10:57am »

First result: After hibernate I have to push a key- like the return key to go on. I do not want this.

BBC exe turns the PC nicely into hibernate sleeping status at 12:30 and so also the screen becomes dark .
Then via the normal PC scheduling menu settings, the very same BBC program becomes active again at 10:30 next morning. But now I cannot see any text or images on the screen produced by the BBC sw, since the screen is still dark; my program is running there behind ok. Therefore I has to push a button- pending on computer I think, typically the return key or the powerswitch to be able to se the graphics on the screen.

How to push -via software -the PC powerswitch or the PC keyboard return-switch.That's the mission impossible' for me now.
User IP Logged

Malcolm
Guest
xx Re: timer & scedules
« Reply #9 on: Feb 11th, 2010, 3:00pm »

It may be the power settings.

Try setting the monitor off to "never".

I expect your monitor was in a power save mode when the machine went into hibernate, so that's the state when it came back out. Usually a key stroke or mouse input will bring the monitor on.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls