Chronometer

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

Chronometer

Germán S. Arduino
Hello Folks:

I want to develop a chronometer program, a simple textbox showing the time
counting and with buttons to take a time (registering them in a grid
(collection)) and again starting with the new lap (is to try to make a
software to messure the time in qualifyng sessions of race cars).

The program must have 3 buttons (one to put the chronometer at 0, one to
take lap time (and register the time in a grid) and one to stop the
chronometer).

I've made a model, but I'm lossing times when I'm taking the lap times, also
I can't figure other several things (by example how to show the exact time
ever in the screen).

Someone know some examples of a similar thing where I can see for some
ideas?

TIA.

---
Germán S. Arduino
http://gsa.swiki.net


Reply | Threaded
Open this post in threaded view
|

Re: Chronometer

Ian Bartholomew-18
Germán,

> Someone know some examples of a similar thing where I can see for some
> ideas?

I've just put together a package (which needs Dolphin 5.0.3) that might
give you some ideas.  You can download it from

http://www.idb.me.uk/files/lapper.zip  (about 4K)

Just evaluate "Lapper show" to run it.

--
Ian


Reply | Threaded
Open this post in threaded view
|

Re: Chronometer

Germán S. Arduino
Thanks You very much Ian!

I've downloaded and seems exactly that I'm needing.

Thanks Again.

---
Germán.




"Ian Bartholomew" <[hidden email]> escribió en el mensaje
news:tpIca.221$[hidden email]...

> Germán,
>
> > Someone know some examples of a similar thing where I can see for some
> > ideas?
>
> I've just put together a package (which needs Dolphin 5.0.3) that might
> give you some ideas.  You can download it from
>
> http://www.idb.me.uk/files/lapper.zip  (about 4K)
>
> Just evaluate "Lapper show" to run it.
>
> --
> Ian
>


Reply | Threaded
Open this post in threaded view
|

Re: Chronometer

Germán S. Arduino
In reply to this post by Ian Bartholomew-18
Ian:

I've see your code.

Mine previous code was similar, but with a model (not only a shell) and
without process and fork.

I'm a newbie yet with Dolphin and don have clear several things, by example:

1) Why not a model? It's possible to think in a complete app (small like
this) without a model?.

2) I think that i've understood the process and fork, are to update each 50
milliseconds the display, without bother the main process (which is
measuring the time)? (That was mi problen in my original code).

3) QueryCommand: I don't well understand how and where you are using this
method.

4) GUI: I must to learn much more, by example ListView, layout managers,
etc. Some recommnedations about places where to read about using all
elements of view composer?.

Again, Thanks You very much by your time and help.

---
Germán.







"Ian Bartholomew" <[hidden email]> escribió en el mensaje
news:tpIca.221$[hidden email]...

> Germán,
>
> > Someone know some examples of a similar thing where I can see for some
> > ideas?
>
> I've just put together a package (which needs Dolphin 5.0.3) that might
> give you some ideas.  You can download it from
>
> http://www.idb.me.uk/files/lapper.zip  (about 4K)
>
> Just evaluate "Lapper show" to run it.
>
> --
> Ian
>


Reply | Threaded
Open this post in threaded view
|

Re: Chronometer

Ian Bartholomew-18
Germán,

> 1) Why not a model? It's possible to think in a complete app (small
> like this) without a model?.

Yes, there is nothing that says that you _have_ to have a Model
associated with the View and Presenter.  In this case it isn't really
needed and would just add extra complexity.

If you were to add more functionality, ways of saving and comparing sets
of lap times for example, then that might make a better case for using a
model (or models).

> 2) I think that i've understood the process and fork, are to update
> each 50 milliseconds the display, without bother the main process
> (which is measuring the time)? (That was mi problen in my original
> code).

Yes.  It just uses the system timer (Time>>millisecondClockCount) to do
the low level timing.  The forked loop just provides an interrupt every
50mS that updates the display - it is not involved in the actual timing
at all.  You could change the loop delay so that it only updated the
display every second and you would still get mS precision for the lap
times.

When you press "start" it just remembers the current mS clock value and
starts updating the display with the elapsed time (current count - start
count) every 50mS

When you press the 'lap' button it grabs the current mS count, works out
the elapsed time and adds it to the lap list and then resets the saved
start time to the new value.   The display updates continue but now
start showing the time that has elapsed (current count - start) since
the button was pressed.

When you press "stop" the final elapsed time is added to the list and
the 50mS loop terminated, resulting in the end of the display updates.

Note that the display update process can be killed in three ways
- pressing the stop button
- when the view is closed (for when the user closes the view with the
timer running)
- when the Lapper instance is finalized (for when a running timer
crashes and leaves a zombie view).

It's better to be as sure as you can be that forked processes are always
terminated as it can lead to some annoying walkbacks if you leave one
running without a visible view, although you can always use the
ProcessMonitor tool if you need to.

> 3) QueryCommand: I don't well understand how and where you are using
> this method.

It's part of Dolphins built in mechanism for handling the enabling and
disabling of buttons (or, to be more exact, the commands sent by buttons
and menus).  There have been a number of discussions about this in the
newsgroup so you might like to search the archive for #queryCommand.

FWIW, There was one small omission in that method.  The test for the
#clear command should read

command == #clear
 ifTrue:
  [aCommandQuery isEnabled: process isNil & historyP list notEmpty.
  ^true].

as you only want to enable the clear button if the timer is stopped
_and_ there is actually some data to clear.

> 4) GUI: I must to learn much more, by example ListView, layout
> managers, etc. Some recommnedations about places where to read about
> using all elements of view composer?.

Ted Bracht has written a book that talks you through creating a complete
application using Dolphin and is based around a Formula 1 motor racing
theme so it might be doubly useful to you.  It's probably worth while
you trying to locate a copy.

In the meantime my recommendation would be to just have a play with the
ViewComposer.  Create some _simple_ applications and add things like
ListViews, Edit, Buttons and the like.  You should also have a look at
the example sample applications that Dolphin provides.  If you get stuck
then ask about the specific issue here in the newsgroup - I'm sure
someone will be able to point you in the right direction

Once you get used to it the Dolphin ViewComposer is not, in my opinion,
particularly difficult to use and can be quite powerful.

--
Ian


Reply | Threaded
Open this post in threaded view
|

Re: Chronometer

Germán S. Arduino
Thanks again by your very complete response!.

Regards.

"Ian Bartholomew" <[hidden email]> escribió en el mensaje
news:qsOca.346$[hidden email]...

> Germán,
>
> > 1) Why not a model? It's possible to think in a complete app (small
> > like this) without a model?.
>
> Yes, there is nothing that says that you _have_ to have a Model
> associated with the View and Presenter.  In this case it isn't really
> needed and would just add extra complexity.
>
> If you were to add more functionality, ways of saving and comparing sets
> of lap times for example, then that might make a better case for using a
> model (or models).
>
> > 2) I think that i've understood the process and fork, are to update
> > each 50 milliseconds the display, without bother the main process
> > (which is measuring the time)? (That was mi problen in my original
> > code).
>
> Yes.  It just uses the system timer (Time>>millisecondClockCount) to do
> the low level timing.  The forked loop just provides an interrupt every
> 50mS that updates the display - it is not involved in the actual timing
> at all.  You could change the loop delay so that it only updated the
> display every second and you would still get mS precision for the lap
> times.
>
> When you press "start" it just remembers the current mS clock value and
> starts updating the display with the elapsed time (current count - start
> count) every 50mS
>
> When you press the 'lap' button it grabs the current mS count, works out
> the elapsed time and adds it to the lap list and then resets the saved
> start time to the new value.   The display updates continue but now
> start showing the time that has elapsed (current count - start) since
> the button was pressed.
>
> When you press "stop" the final elapsed time is added to the list and
> the 50mS loop terminated, resulting in the end of the display updates.
>
> Note that the display update process can be killed in three ways
> - pressing the stop button
> - when the view is closed (for when the user closes the view with the
> timer running)
> - when the Lapper instance is finalized (for when a running timer
> crashes and leaves a zombie view).
>
> It's better to be as sure as you can be that forked processes are always
> terminated as it can lead to some annoying walkbacks if you leave one
> running without a visible view, although you can always use the
> ProcessMonitor tool if you need to.
>
> > 3) QueryCommand: I don't well understand how and where you are using
> > this method.
>
> It's part of Dolphins built in mechanism for handling the enabling and
> disabling of buttons (or, to be more exact, the commands sent by buttons
> and menus).  There have been a number of discussions about this in the
> newsgroup so you might like to search the archive for #queryCommand.
>
> FWIW, There was one small omission in that method.  The test for the
> #clear command should read
>
> command == #clear
>  ifTrue:
>   [aCommandQuery isEnabled: process isNil & historyP list notEmpty.
>   ^true].
>
> as you only want to enable the clear button if the timer is stopped
> _and_ there is actually some data to clear.
>
> > 4) GUI: I must to learn much more, by example ListView, layout
> > managers, etc. Some recommnedations about places where to read about
> > using all elements of view composer?.
>
> Ted Bracht has written a book that talks you through creating a complete
> application using Dolphin and is based around a Formula 1 motor racing
> theme so it might be doubly useful to you.  It's probably worth while
> you trying to locate a copy.
>
> In the meantime my recommendation would be to just have a play with the
> ViewComposer.  Create some _simple_ applications and add things like
> ListViews, Edit, Buttons and the like.  You should also have a look at
> the example sample applications that Dolphin provides.  If you get stuck
> then ask about the specific issue here in the newsgroup - I'm sure
> someone will be able to point you in the right direction
>
> Once you get used to it the Dolphin ViewComposer is not, in my opinion,
> particularly difficult to use and can be quite powerful.
>
> --
> Ian
>