Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

BaSyx / Introductory Examples / Java / Example Heater

Heater stub

This stub code realizes an interface to an oven and a dummy implementation for the example code that can be executed without any hardware.


The heater interface defines common interface functions to control the oven.

/**
 * The heater enables controlling of the oven
 */
public interface IHeater {
 
	public void activate();
 
	public void deactivate();
 
	public boolean isActive();
}


The heater stub is used during the example.

Heater Code

/**
 * Simple heater with two states: activated or deactivated
 *
 */
public class Heater implements IHeater {
	private boolean isActive = false;
 
	public void activate() {
		if (!isActive) {
			System.out.println("Heater: activated");
			isActive = true;
		}
	}
 
	public void deactivate() {
		if (isActive) {
			System.out.println("Heater: deactivated");
			isActive = false;
		}
	}
 
	public boolean isActive() {
		return isActive;
	}
}

Copyright © Eclipse Foundation, Inc. All Rights Reserved.