/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ca.teamdave.caruso;
import ca.teamdave.caruso.actuator.Actuator;
import ca.teamdave.caruso.config.ConfigTable;
import ca.teamdave.caruso.logger.LogFrame;
import ca.teamdave.caruso.logger.Logger;
import ca.teamdave.caruso.sensor.Sensor;
import java.util.Hashtable;
/**
*
* @author leigh
*/
public class Machine {
private Hashtable sensors;
private Hashtable actuators;
private Logger logger;
private ConfigTable config;
public Machine() {
this(null);
}
public Machine(Logger logger) {
this.logger = logger;
this.config = null;
this.sensors = null;
this.actuators = null;
}
public void robotInit(Hashtable sensors, Hashtable actuators, ConfigTable config) throws CarusoException {
this.sensors = sensors;
this.actuators = actuators;
this.config = config;
this.logger.robotInit();
}
public Actuator getActuator(String name) {
return (Actuator) this.actuators.get(name);
}
public Sensor getSensor(String name) {
return (Sensor) this.sensors.get(name);
}
public ConfigTable getConfig() {
return this.config;
}
public void periodicUpdate() throws CarusoException {
// If there is a logger, send data to it
if (this.logger != null) {
// create a new log frame
LogFrame f = new LogFrame(
this.sensors,
this.actuators);
this.logger.addFrame(f);
}
}
}