public class X10Controller
{
public void on(char houseCode, int
unitCode)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " on");
}
public void off(char houseCode, int
unitCode)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " off");
}
public void dim(char houseCode, int
unitCode, int percent)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " dim " + percent);
}
public void bright(char houseCode, int
unitCode, int percent)
{
runCommand("ahcmd.exe sendplc " +
houseCode + unitCode + " bright " + percent);
}
private void runCommand(String command)
throws RuntimeException
{
try
{
Runtime.getRuntime().exec
(command).waitFor();
}
catch (Exception e)
{
throw new RuntimeException
("problems occured while controlling the X10
module.", e);
}
}
}