/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package happywallrobot;

import basicrobotcontrol.*;
import jplot.JPlot;

public class VacuumSimulationEnvironment {
    MainControl mc;
    VacuumRobotControl roombaControl;

    // -------------------------------------------------------------------------
    public VacuumSimulationEnvironment(String[] args) {
        TCPContentServer tcs = new TCPContentServer(7654);
        mc = new MainControl(args);
        mc.robot.map.printMap();
        mc.setSafetyStopRecovery(true);
        tcs.addMainControl(mc);
    }

    // -------------------------------------------------------------------------
    public void addRobot(VacuumRobotControl rc) {
        roombaControl = rc;
        mc.addControl(roombaControl);
    }

    // -------------------------------------------------------------------------
    public void runSimulation() {
        new Thread(new FloorMonitor(mc)).start();
        while (true) {
            mc.robot.removeFromMap(false);
            mc.robot.addToMap(false);

            JPlot.clf();
            mc.robot.map.printMap();

            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
        }
    }
}

