execute a code block at a given time in pharo ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

execute a code block at a given time in pharo ?

Daniel BLANC
Hi All,

I'm a very beginner with smalltalk. I am building a small seaside app for controlling wifi access of my teenagers kids. In this app I need to start or stop the wifi acces at a given time.
For the moment I'm doing it with an infinite loop in a process, with this code:

WifiController >> startScheduler
^ SchedulerProcess
ifNil: [ SchedulerProcess := [ [ true ]
whileTrue: [ self schedulerApplyAutoStartStopRules.
56 seconds wait ] ] forkNamed: 'DanWifiManagerScheduler' ]


 I'm wondering if there is a way to do this without this infinite loop ? May be there is a class in the standard pharo image that can execute a code block at a given time ? 

Thanks,
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: execute a code block at a given time in pharo ?

Stephane Ducasse-3
Welcome daniel

This sounds like a super cool app. (I have teens at home and well I
know the story).

I remember a calendar triggering system.... but I do not know where it
is. Someone should know.

Stef


On Wed, Sep 13, 2017 at 10:36 PM, Daniel BLANC <[hidden email]> wrote:

> Hi All,
>
> I'm a very beginner with smalltalk. I am building a small seaside app for
> controlling wifi access of my teenagers kids. In this app I need to start or
> stop the wifi acces at a given time.
> For the moment I'm doing it with an infinite loop in a process, with this
> code:
>
> WifiController >> startScheduler
> ^ SchedulerProcess
> ifNil: [ SchedulerProcess := [ [ true ]
> whileTrue: [ self schedulerApplyAutoStartStopRules.
> 56 seconds wait ] ] forkNamed: 'DanWifiManagerScheduler' ]
>
>
>  I'm wondering if there is a way to do this without this infinite loop ? May
> be there is a class in the standard pharo image that can execute a code
> block at a given time ?
>
> Thanks,
> Daniel

Reply | Threaded
Open this post in threaded view
|

Re: execute a code block at a given time in pharo ?

hernanmd
In reply to this post by Daniel BLANC
http://www.smalltalkhub.com/#!/~TorstenBergmann/Scheduler

Cheers,

Hernán

2017-09-13 17:36 GMT-03:00 Daniel BLANC <[hidden email]>:

> Hi All,
>
> I'm a very beginner with smalltalk. I am building a small seaside app for
> controlling wifi access of my teenagers kids. In this app I need to start or
> stop the wifi acces at a given time.
> For the moment I'm doing it with an infinite loop in a process, with this
> code:
>
> WifiController >> startScheduler
> ^ SchedulerProcess
> ifNil: [ SchedulerProcess := [ [ true ]
> whileTrue: [ self schedulerApplyAutoStartStopRules.
> 56 seconds wait ] ] forkNamed: 'DanWifiManagerScheduler' ]
>
>
>  I'm wondering if there is a way to do this without this infinite loop ? May
> be there is a class in the standard pharo image that can execute a code
> block at a given time ?
>
> Thanks,
> Daniel

Reply | Threaded
Open this post in threaded view
|

Re: execute a code block at a given time in pharo ?

Daniel BLANC
Thanks Stef, this app is just a quick hack but I already can stop the wifi from my phone and I feel like I have new negociations superpowers...

Thanks 
Hernán ! That's a perfect fit :) 

On Thu, Sep 14, 2017 at 9:24 PM Hernán Morales Durand <[hidden email]> wrote:
http://www.smalltalkhub.com/#!/~TorstenBergmann/Scheduler

Cheers,

Hernán

2017-09-13 17:36 GMT-03:00 Daniel BLANC <[hidden email]>:
> Hi All,
>
> I'm a very beginner with smalltalk. I am building a small seaside app for
> controlling wifi access of my teenagers kids. In this app I need to start or
> stop the wifi acces at a given time.
> For the moment I'm doing it with an infinite loop in a process, with this
> code:
>
> WifiController >> startScheduler
> ^ SchedulerProcess
> ifNil: [ SchedulerProcess := [ [ true ]
> whileTrue: [ self schedulerApplyAutoStartStopRules.
> 56 seconds wait ] ] forkNamed: 'DanWifiManagerScheduler' ]
>
>
>  I'm wondering if there is a way to do this without this infinite loop ? May
> be there is a class in the standard pharo image that can execute a code
> block at a given time ?
>
> Thanks,
> Daniel

Reply | Threaded
Open this post in threaded view
|

Re: execute a code block at a given time in pharo ?

Sean P. DeNigris
Administrator
Daniel BLANC wrote
> I feel like I have new negociations superpowers...

The magic of Smalltalk ha ha :)



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: execute a code block at a given time in pharo ?

Stephane Ducasse-3
In reply to this post by Daniel BLANC
once you are done please share it.
You see I'm good in deep little details but I often lack other knowledge :)

On Sun, Sep 17, 2017 at 9:59 AM, Daniel BLANC <[hidden email]> wrote:

> Thanks Stef, this app is just a quick hack but I already can stop the wifi
> from my phone and I feel like I have new negociations superpowers...
>
> Thanks Hernán ! That's a perfect fit :)
>
> On Thu, Sep 14, 2017 at 9:24 PM Hernán Morales Durand
> <[hidden email]> wrote:
>>
>> http://www.smalltalkhub.com/#!/~TorstenBergmann/Scheduler
>>
>> Cheers,
>>
>> Hernán
>>
>> 2017-09-13 17:36 GMT-03:00 Daniel BLANC <[hidden email]>:
>> > Hi All,
>> >
>> > I'm a very beginner with smalltalk. I am building a small seaside app
>> > for
>> > controlling wifi access of my teenagers kids. In this app I need to
>> > start or
>> > stop the wifi acces at a given time.
>> > For the moment I'm doing it with an infinite loop in a process, with
>> > this
>> > code:
>> >
>> > WifiController >> startScheduler
>> > ^ SchedulerProcess
>> > ifNil: [ SchedulerProcess := [ [ true ]
>> > whileTrue: [ self schedulerApplyAutoStartStopRules.
>> > 56 seconds wait ] ] forkNamed: 'DanWifiManagerScheduler' ]
>> >
>> >
>> >  I'm wondering if there is a way to do this without this infinite loop ?
>> > May
>> > be there is a class in the standard pharo image that can execute a code
>> > block at a given time ?
>> >
>> > Thanks,
>> > Daniel
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: execute a code block at a given time in pharo ?

Ben Coman
In reply to this post by Daniel BLANC
On Sun, Sep 17, 2017 at 3:59 PM, Daniel BLANC <[hidden email]> wrote:
> Thanks Stef, this app is just a quick hack

Quick hacks are still often interesting reading and useful starting
points for others.
I've often thought of doing something like this for my kids but never
got around to it.

> but I already can stop the wifi from my phone

I'm interested to know what you use for that also.

cheers -ben