We ran our unit tests and found
that we have a problem. Our simulator sends the message too many times. So what we need to do is keep track of
what state the switch was in and only send the message if it changes. Let's write some code. |
|
package simulator.r7;
public class Simulator extends Thread
{SimulationInterface gui;
boolean boilerIsOn;
public Simulator (SimulationInterface
aGUI)
{super();
gui = aGUI;}
public void run()
{for (int each = 0; each < 50;
each++)
{if ((PIA.register & 0x1000)
> 0 && !boilerIsOn)
{gui.boilerOn();
boilerIsOn = true;}
try
{sleep(100);}
catch (InterruptedException exception)
{};};};}
|
Run those unit tests again. Now
they run just fine. Let's clean up a bit now. |
|