execute a code block at a given time in pharo ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 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

Reply | Threaded
Open this post in threaded view
|

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

Daniel BLANC
Hi All,

Sorry for the late answer, I've been swallowed by a vortex of "too much work at my day job".

Regarding the magical power of smalltalk, I definitely agree with that. I've been playing with different programming languages for 30 years now, and smalltalk programming is so refreshing, it's almost like manipulating real physical objects, the process of building an app feels way more creative this way. 

Regarding my quick hack for managing the wifi at home, unfortunately there is not so much smalltalk magic involved. Pharo is just used as a UI to launch shell scripts on a linux server. This server is inbetween a wifi access point and the ISP router. So, as you probably have guessed, all the wifi traffic goes trough this server, then it's easy to use the linux firewall (iptable) to allow/deny traffic. 

I'll continue playing/hacking on this small app and I'll publish the end result.

Thanks All,
Daniel

On Sun, Sep 17, 2017 at 7:18 PM Ben Coman <[hidden email]> wrote:
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

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
> Regarding my quick hack for managing the wifi at home, unfortunately there
> is not so much smalltalk magic involved.

That is *exactly* the magic of objects - hiding ugly implementation details
(like shell scripts) under an abstraction you can easily understand and dare
say enjoy working with!


Daniel BLANC wrote
> I'll continue playing/hacking on this small app and I'll publish the end
> result.

Great! Looking forward to it. This is a great time to share even toy
projects because GitHub et al have made the effort/pain/cost so low.



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

Cheers,
Sean