ResearchTimer1456, an experimental 1456 applet landscape.

William Overington

Copyright 2000 William Overington

This 1456 applet landscape is an experimental variation of the Print1456 1456 applet landscape. In addition to the facilities of Print1456, there are five timers, which are essentially the same as each other, except that timer 5 can handle longer time intervals, as will be explained later. The ResearchTimer1456 1456 applet landscape has all of the features of the Print1456 1456 applet landscape and may be used as if it were the Print1456 1456 applet landscape, though if the timers are not being used it would be better to use the Print1456 1456 applet landscape itself as ResearchTimer1456 is experimental and the way that the mouse clicks are handled by the applet landscape is not the same as for Print1456.

In that which follows, reference is made to program elapsed clock time. This is derived from the clock time of the local computer. Please consider program elapsed clock time as starting at zero when the program starts running and increasing in time with the clock time of the local computer.

An important concept is that of idle time. Idle time is necessary so that the system can keep up with the events that it is required to service. However, ResearchTimer1456 has a facility that allows about forty events to be queued at any one time, so that if, say, there is the occasional event that holds up other events then the system will catch up. This is illustrated in demo19.htm below, yet this is left for now as the basics of the system have yet to be explained.

Let us consider timer 1. Timer 1 is controlled from 1456 software by means of using software interrupts. A typical simple usage of timer 1 involves a sequence of three software interrupts. Timer 1 starts off as inactive, as do all of the timers. The first step is to set up a time interval. This is measured in deciseconds, that is, units of one tenth of a second. Suppose that every two seconds it is desired to draw a magenta disc of diameter 20 pixels in a random place on the screen using timer 1 to control this happening. The time interval is 2 seconds, which is 20 deciseconds, so timer 1 is set to have a time interval of 20 deciseconds by the command 71020? using a software interrupt. Next the time offset is set. This is also a time measured in deciseconds. When deciding if a timer event should occur the time offset is effectively added to program elapsed clock time and the sum obtained is integer divided by the time interval for that timer. If the timer is active and there is no remainder to that division, then a timer event occurs. It is not done quite like that as situations such as that in demo19.htm are handled. Sometimes the timer events will be generated later, then placed in a queue and the system will catch up, but that is not apparent to the user. It appears just as if timer events had been generated at the correct time and queued up. An important point for a 1456 programmer is that the offset time advances the occurence of a timer event by the chosen time. However, the first event for the timer that actually occurs will occur later than it would have done had a zero offset time been used. The event that would have been the first event is not obeyed as it would have needed to have been carried out before the program started. For this example let us choose an offset time of 0.5 seconds, which is 5 deciseconds. This is a more or less arbitrary choice with just one timer in use. Timer 1 is set to have an offset time of 5 deciseconds by the command 81005? using a software interrupt.

In order for timer events to be generated the timer must be active. Timer 1 is made active by the command 91000? using a software interrupt.

In ordinary simple usage it will not be necessary to turn a timer off, that is, making it inactive. However, commands to turn timers off are provided. Timer 1 can be made inactive by the command 61000? using a software interrupt. Turning timers on and off can be used to effect. A timer may be turned on or off by another timer and may turn itself off. In addition, a mouse click may be used to turn a timer on or off. In ResearchTimer1456 the turning on or off of a timer takes place immediately, yet the new state affects all and only those timer events that are scheduled after the change. Where there is a catching up of events by the scheduling software some events that should have been scheduled may not occur or some events that should not have been scheduled may occur. Nevertheless in situations where there is no great time delay in events being obeyed, the use of the switching on and off of timers automatically works as one would expect. Used carefully the switching on and off of timers can be quite effective. In demo20.htm below, switching off of timers is used to effect.

Software Interrupt Parameter, p Meaning
p = 61000 Make timer 1 inactive.
p = 71001 ... 71999 Make timer 1 have the time interval
(p - 71000)/10 seconds.
p = 81000 ... 81999 Make timer 1 have the time offset
(p - 81000)/10 seconds.
p = 91000 Make timer 1 active. Timer events that occur cause 1456 software at 11: to be obeyed.

Here are the files to download to a directory on your local computer should you wish to experiment with writing some 1456 software of your own.

ResearchTimer1456.htm

ResearchTimer1456.class

The other timers are very similar to timer 1. For three of them, timers 2, 3 and 4, the only differences are those concerned with which timer is the timer being referenced. Timer 5 is slightly different as a longer time interval may be used. For completeness, the commands are detailed here.

Software Interrupt Parameter, p Meaning
p = 62000 Make timer 2 inactive.
p = 72001 ... 72999 Make timer 2 have the time interval
(p - 72000)/10 seconds.
p = 82000 ... 82999 Make timer 2 have the time offset
(p - 82000)/10 seconds.
p = 92000 Make timer 2 active. Timer events that occur cause 1456 software at 12: to be obeyed.

Software Interrupt Parameter, p Meaning
p = 63000 Make timer 3 inactive.
p = 73001 ... 73999 Make timer 3 have the time interval
(p - 73000)/10 seconds.
p = 83000 ... 83999 Make timer 3 have the time offset
(p - 83000)/10 seconds.
p = 93000 Make timer 3 active. Timer events that occur cause 1456 software at 13: to be obeyed.

Software Interrupt Parameter, p Meaning
p = 64000 Make timer 4 inactive.
p = 74001 ... 74999 Make timer 4 have the time interval
(p - 74000)/10 seconds.
p = 84000 ... 84999 Make timer 4 have the time offset
(p - 84000)/10 seconds.
p = 94000 Make timer 4 active. Timer events that occur cause 1456 software at 14: to be obeyed.

Software Interrupt Parameter, p Meaning
p = 65000 Make timer 5 inactive.
p = 75001 ... 79999 Make timer 5 have the time interval
(p - 75000)/10 seconds.
p = 85000 ... 89999 Make timer 5 have the time offset
(p - 85000)/10 seconds.
p = 95000 Make timer 5 active. Timer events that occur cause 1456 software at 15: to be obeyed.

demo16.htm

In this demonstration, timer 1 is used to draw a green disc in a random position every 4 seconds.

demo17.htm

In this demonstration, timer 1 is used to draw a green disc in a random position every 4 seconds as with demo16.htm. In addition timer 2 is used to draw a cyan disc in a random position every 4 seconds. The spots are synchronized such that a disc is drawn every 2 seconds, alternate green and cyan, with a green disc drawn first. Please note that timer 1 has a higher offset than timer 2.

demo18.htm

This demonstration is constructed from a copy of demo14.htm. That was one of the examples in the document on quaternions which some readers of this section may have chosen not to study. However, the demonstration can be viewed and used for experimentation without needing to understand the underlying quaternion software. There is one change and two additions. The choice of 1456 applet landscape to be used is changed from Print1456.class to become ResearchTimer1456.class, timer 1 is set up using

{set up timer 1}
71020?81010?91000?

and the code 11:71JH is added. That is all! The effect is that every two seconds, an event occurs that is the equivalent of clicking the mouse on the red +theta panel. Clicking on the red panel itself causes 1456 software at 71: to be obeyed. The user may click on the panels as with demo14.htm and achieve the same effects. The timer events and the mouse click events both affect the display that is achieved.

demo19.htm

This demonstration uses two timers. Timer 1 draws a red square every 1 second, that is, every 10 deciseconds. Timer 2 draws a blue square every 10 seconds, that is, every 10 deciseconds. The drawing of the blue square is made deliberately slow by the computation of lots of random numbers that are not needed. The effect is that when the drawing of the blue square is completed, the drawing of red squares catches up. This effect will vary depending upon the speed of the computer being used for viewing.

In addition, a click on the mouse will draw a cyan square with a longer delay. This can be used to observe how the system will catch up. A useful scenario is to let the system complete the drawing of two blue squares and then click the mouse.

demo20.htm

This demonstration is designed to demonstrate the use of switching off a timer. Timer 1 is used. When the mouse is clicked, timer 1 is activated. A disc is drawn in a random position every 2 seconds. When five such discs have been drawn, timer 1 switches itself off. The XOR Mode of drawing is used, with the chosen colour specified as white. The background of the applet is originally white. The discs are specified as magenta. This has the effect that the first disc drawn appears as a magenta disc. After that, each disc that is drawn is drawn magenta, or partly magenta and partly white, or potentially even totally white in rare cases, counterchanged magenta and white with respect to whichever colours were there before the disc were drawn. This has the effect that a disc size piece of the screen changes colour at every disc drawing, so that it is obvious that a disc has been drawn. This is helpful to observing the demonstration as otherwise once a number of discs were drawn, the drawing of some later drawn discs might not be observable as they might be drawn over an area that were already filled with magenta colour.

Clicking the mouse while the discs are being drawn will add another five discs to the total drawn for each such mouse click.

demo21.htm

This demonstration is adapted from demo20.htm. In this case once the mouse has been clicked five discs will be drawn, all but the last notionally magenta, the last notionally red. Clicking the mouse during drawing of the discs will have no effect. Five discs will be drawn and a red disc drawn before the mouse click will have any effect.

demo22.htm

This demonstration shows a timer switching on and off another timer. Timer 1 will draw discs in a random manner one every two seconds when it is active. Timer 2 will switch the activity state of timer 1 to the opposite of what it was every 10 seconds. The effect should be that five discs of a colour of the rainbow will be drawn. There will then be a pause, then five discs in the next colour of the rainbow will be drawn. The fact that the colours of the eutodraw system are numbered in the order of the colours of the rainbow makes the changing of the colours a straightforward matter.

1456 object code

Copyright 2000 William Overington