100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Removed v2 agent/controller port
Christian Bauer726d44f3b491
diff --git a/agent/build.gradle b/agent/build.gradleindex 6117257ac..2bb204206 100644--- a/agent/build.gradle+++ b/agent/build.gradle@@ -10,7 +10,4 @@ dependencies {compile "com.luckycatlabs:SunriseSunsetCalculator:$sunriseSunsetCalculatorVersion"compile "org.quartz-scheduler:quartz:$quartzVersion"-- testCompile "junit:junit:$junitVersion"- testCompile "org.spockframework:spock-core:$spockVersion"}\ No newline at end of filediff --git a/agent/src/main/java/org/openremote/agent/AgentService.java b/agent/src/main/java/org/openremote/agent/AgentService.javadeleted file mode 100644index 6dfc8a3c0..000000000--- a/agent/src/main/java/org/openremote/agent/AgentService.java+++ /dev/null@@ -1,73 +0,0 @@-package org.openremote.agent;--import org.openremote.container.Container;-import org.openremote.container.ContainerService;-import org.openremote.agent.command.CommandBuilder;-import org.openremote.agent.context.AgentContext;-import org.openremote.agent.context.InMemorySensorStateHandler;-import org.openremote.agent.deploy.xml.AgentDOMParser;-import org.openremote.agent.deploy.Deployment;-import org.openremote.agent.rules.RulesProvider;--import java.io.InputStream;--public class AgentService implements ContainerService {-- final protected AgentDOMParser agentDOMParser = new AgentDOMParser();- final protected InputStream deploymentXml;- final protected CommandBuilder commandBuilder;- final protected RulesProvider rulesProvider;- final protected String droolsClock;-- protected AgentContext agentContext;-- public AgentService(InputStream deploymentXml, CommandBuilder commandBuilder, RulesProvider rulesProvider) {- this.deploymentXml = deploymentXml;- this.commandBuilder = commandBuilder;- this.rulesProvider = rulesProvider;- this.droolsClock = "realtime";- }-- public AgentService(InputStream deploymentXml, CommandBuilder commandBuilder, RulesProvider rulesProvider, String droolsClock) {- this.deploymentXml = deploymentXml;- this.commandBuilder = commandBuilder;- this.rulesProvider = rulesProvider;- this.droolsClock = droolsClock;- }-- @Override- public void init(Container container) throws Exception {- // TODO Support booting of multiple instances- Deployment deployment = new Deployment(- agentDOMParser.parse(deploymentXml, true).getDeploymentDefinition(),- commandBuilder,- new InMemorySensorStateHandler(),- rulesProvider- );- agentContext = new AgentContext("OpenRemoteAgent123", deployment, droolsClock);- }-- @Override- public void start(Container container) throws Exception {- if (agentContext != null) {- agentContext.start();- }- }-- @Override- public void stop(Container container) throws Exception {- if (agentContext != null) {- agentContext.stop();- }- }-- public AgentContext getContext() {- return agentContext;- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- '}';- }-}diff --git a/agent/src/main/java/org/openremote/agent/command/Command.java b/agent/src/main/java/org/openremote/agent/command/Command.javadeleted file mode 100644index e492d2bb4..000000000--- a/agent/src/main/java/org/openremote/agent/command/Command.java+++ /dev/null@@ -1,4 +0,0 @@-package org.openremote.agent.command;--public interface Command {-}diff --git a/agent/src/main/java/org/openremote/agent/command/CommandBuilder.java b/agent/src/main/java/org/openremote/agent/command/CommandBuilder.javadeleted file mode 100644index 779065143..000000000--- a/agent/src/main/java/org/openremote/agent/command/CommandBuilder.java+++ /dev/null@@ -1,25 +0,0 @@-package org.openremote.agent.command;--import org.openremote.agent.command.builtin.DateTimeCommand;-import org.openremote.agent.command.builtin.VirtualCommand;-import org.openremote.agent.deploy.CommandDefinition;--/**- * Build protocol- and device-specific command implementation.- */-public class CommandBuilder {-- public Command build(CommandDefinition commandDefinition) {-- // Handle some built-in protocols- switch (commandDefinition.getProtocolType()) {- case "virtual":- return new VirtualCommand(commandDefinition);- case "datetime":- return new DateTimeCommand(commandDefinition);- }-- return null;- }--}diff --git a/agent/src/main/java/org/openremote/agent/command/Commands.java b/agent/src/main/java/org/openremote/agent/command/Commands.javadeleted file mode 100644index 22330d6cc..000000000--- a/agent/src/main/java/org/openremote/agent/command/Commands.java+++ /dev/null@@ -1,76 +0,0 @@-package org.openremote.agent.command;--import org.openremote.agent.deploy.CommandDefinition;-import org.openremote.agent.deploy.Deployment;--import java.util.logging.Level;-import java.util.logging.Logger;--/**- * Facade for running {@link ExecutableCommand}s (e.g. in rules or from simple client call).- */-public class Commands {-- private static final Logger LOG = Logger.getLogger(Commands.class.getName());-- final protected Deployment deployment;-- public Commands(Deployment deployment) {- this.deployment = deployment;- }-- public void execute(String commandName) {- execute(commandName, null);- }-- public void execute(String commandName, int arg) {- execute(commandName, Integer.toString(arg));- }-- public void execute(String commandName, String arg) {- CommandDefinition commandDefinition = deployment.getCommandDefinition(commandName);- if (commandDefinition == null) {- LOG.warning("Command definition not found, ignoring execution: " + commandName);- return;- }- execute(commandDefinition, arg);- }-- /**- * Executes a command. This normally means a device protocol is used to communicate with- * some physical device.- */- public void execute(CommandDefinition commandDefinition) {- execute(commandDefinition, null);- }-- /**- * Build a {@link Command} from this definition and, if possible, execute it with the given argument.- *- * @param arg command parameter value- */- public void execute(CommandDefinition commandDefinition, String arg) {- Command command;- try {- command = deployment.getCommandBuilder().build(commandDefinition);- if (command == null) {- LOG.log(Level.WARNING,- "No command was produced (does the protocol have an ExecutableCommand?): " + commandDefinition- );- } else if (command instanceof ExecutableCommand) {- LOG.fine("Executing '" + commandDefinition.getName() + "' with: " + arg);- ExecutableCommand executableCommand = (ExecutableCommand) command;- try {- executableCommand.send(arg);- } catch (Exception ex) {- LOG.log(Level.SEVERE, "Error executing '" + commandDefinition.getName() + "' with: " + arg, ex);- }- } else {- LOG.log(Level.WARNING, "Ignoring, not an ExecutableCommand: " + command);- }- } catch (Throwable t) {- LOG.log(Level.SEVERE, "Error building: " + commandDefinition, t);- }- }-}-diff --git a/agent/src/main/java/org/openremote/agent/command/ExecutableCommand.java b/agent/src/main/java/org/openremote/agent/command/ExecutableCommand.javadeleted file mode 100644index b07084bbe..000000000--- a/agent/src/main/java/org/openremote/agent/command/ExecutableCommand.java+++ /dev/null@@ -1,9 +0,0 @@-package org.openremote.agent.command;--public interface ExecutableCommand extends Command {-- /**- * Send some executable command to device.- */- void send(String value);-}diff --git a/agent/src/main/java/org/openremote/agent/command/PullCommand.java b/agent/src/main/java/org/openremote/agent/command/PullCommand.javadeleted file mode 100644index e6c6e0b5b..000000000--- a/agent/src/main/java/org/openremote/agent/command/PullCommand.java+++ /dev/null@@ -1,32 +0,0 @@-package org.openremote.agent.command;--import org.openremote.agent.sensor.Sensor;--/**- * Pull commands are intended for collecting updates from "passive" devices which must- * be called periodically to read state updates.- */-public interface PullCommand extends SensorUpdateCommand {-- int POLLING_INTERVAL = 500;-- /**- * Read and return raw device status.- *- * The {@link Sensor} is only provided as a hint, don't call- * {@link Sensor#update} but return the current state instead.- */- String read(Sensor sensor);-- /**- * Used by {@link Sensor} to determine the interval used before the next call to read() method.- * This method can be overridden by subclasses (protocol specific implementations) to specify- * individual polling intervals. The value must be strictly positive, if a negative or zero- * value is provided, the default is used instead.- *- * @return a polling interval in milliseconds (default is 500ms)- */- default int getPollingInterval() {- return POLLING_INTERVAL;- }-}diff --git a/agent/src/main/java/org/openremote/agent/command/PushCommand.java b/agent/src/main/java/org/openremote/agent/command/PushCommand.javadeleted file mode 100644index b1752a60e..000000000--- a/agent/src/main/java/org/openremote/agent/command/PushCommand.java+++ /dev/null@@ -1,72 +0,0 @@-package org.openremote.agent.command;--import org.openremote.agent.sensor.Sensor;--/**- * Push commands are intended for collecting updates from "active" devices which broadcast- * them over various transport mechanisms -- examples include bus installations such as- * KNX bus or IP-network broadcasts.- *- * Push commands are expected to create their own threads (if needed) which implement the- * push functionality and also push updates to the context of the agent using the- * sensor callback API provided.- *- * Push command implementations use the sensor {@link Sensor#update} method to push state- * changes into the agents's context, as shown in the example below:- *- * <pre><code>- *- * public class SamplePushCommand implements PushCommand, Runnable {- *- * // This implementation assumes a command instance per sensor, so only- * // deals with a single sensor reference- * Sensor sensor;- *- * @Override- * public void setSensor(Sensor sensor) {- * this.sensor = sensor;- *- * // Initialize the sensor with a default value. The sensor implementation may provide- * // additional validation or translations to these values...- *- * sensor.update("0");- *- * // This implementation starts a listening thread per sensor. If you want multiple- * // push commands / sensors to share same resources or threads, this can be managed in- * // the command builder implementation...- *- * Thread t = new Thread(this);- * t.start();- * }- *- * @Overide- * public void run() {- * String sensorValue = implementYourListenerLogic()- * sensor.update(sensorValue);- * }- * }- *</code></pre>- *- *- *- * <b>NOTE:</b> The agent at this point does not implement any flow control on its side --- * therefore a very busy listener can overflow it with too many updates. Control- * flow must be implemented by the listener implementation ensuring that not too- * many updates are created.- */-public interface PushCommand extends SensorUpdateCommand {-- /**- * This method may be invoked multiple times if the command instance is associated- * with several sensors. How many instances of the command exist and how multiple- * associations are handled is the responsibility of the command/factory implementation.- */- void start(Sensor sensor);-- /**- * This method may be invoked multiple times if the command instance is associated- * with several sensors. How many instances of the command exist and how multiple- * associations are handled is the responsibility of the command/factory implementation.- */- void stop(Sensor sensor);-}diff --git a/agent/src/main/java/org/openremote/agent/command/SensorUpdateCommand.java b/agent/src/main/java/org/openremote/agent/command/SensorUpdateCommand.javadeleted file mode 100644index 4f6f4ff10..000000000--- a/agent/src/main/java/org/openremote/agent/command/SensorUpdateCommand.java+++ /dev/null@@ -1,7 +0,0 @@-package org.openremote.agent.command;--/**- * A command that can be used to update the state of a sensor.- */-public interface SensorUpdateCommand extends Command {-}diff --git a/agent/src/main/java/org/openremote/agent/command/builtin/DateTimeCommand.java b/agent/src/main/java/org/openremote/agent/command/builtin/DateTimeCommand.javadeleted file mode 100644index f09ba7dba..000000000--- a/agent/src/main/java/org/openremote/agent/command/builtin/DateTimeCommand.java+++ /dev/null@@ -1,218 +0,0 @@-package org.openremote.agent.command.builtin;--// TODO Can this dependency be replaced with Java 8 datetime API?-import com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator;-import com.luckycatlabs.sunrisesunset.dto.Location;-import org.openremote.model.util.TextUtil;-import org.openremote.agent.command.PushCommand;-import org.openremote.agent.deploy.CommandDefinition;-import org.openremote.agent.sensor.Sensor;--import java.text.SimpleDateFormat;-import java.util.Calendar;-import java.util.TimeZone;-import java.util.logging.Logger;--/**- * DateTime commands can be used to display date or time on the console- * or use certain DateTime events to trigger rules. To calculate sunrise and sunset the location has to be given as longitude, latidude- * and timezone. Timezone is the string identifier which is available in Java eg. Europe/Berlin- * <p>- * The following commands are available in the moment:- * - date (returns a date/time as string depending on the given formatter)- * - sunrise (returns the sunrise time as string depending on the given formatter)- * - sunset (returns the sunset time as string depending on the given formatter)- * - minutesUntilSunrise (returns an integer with the minutes until sunrise)- * - minutesUntilSunset (returns an integer with the minutes until sunset)- * - isDay (returns a boolean string)- * - isNight (returns a boolean string)- *- * @author Marcus- */-public class DateTimeCommand implements PushCommand, Runnable {-- private static final Logger LOG = Logger.getLogger(DateTimeCommand.class.getName());-- private TimeZone timezone;- private String command;- private SimpleDateFormat dateFormatter;- private SunriseSunsetCalculator calculator;- private Calendar now;-- /**- * The polling interval which is used for the sensor update thread- */- private Integer pollingInterval;-- private Thread pollingThread;- private Sensor sensor;-- boolean doPoll = false;--- public DateTimeCommand(CommandDefinition commandDefinition) {- this(- commandDefinition.getProperty("latitude"),- commandDefinition.getProperty("longitude"),- commandDefinition.getProperty("timezone"),- commandDefinition.getProperty("command"),- commandDefinition.getProperty("format"),- TextUtil.convertPollingIntervalString(commandDefinition.getProperty("pollingInterval", "60000"))- );- }-- public DateTimeCommand(String latitude, String longitude, String timezone, String command, String format, Integer pollingInterval) {-- if (command.equals("sunrise") || command.equals("sunset") || command.equals("minutesUntilSunrise")- || command.equals("minutesUntilSunset") || command.equals("isDay") || command.equals("isNight")) {- if (null == longitude || null == latitude) {- throw new IllegalArgumentException("Unable to create DateTime command for sunrise/sunset related command, " +- "missing configuration parameter(s)");- }- }-- if (timezone == null) {- this.timezone = TimeZone.getDefault();- } else {- this.timezone = TimeZone.getTimeZone(timezone);- }-- if (format != null) {- dateFormatter = new SimpleDateFormat(format);- } else {- dateFormatter = new SimpleDateFormat();- }-- dateFormatter.setTimeZone(this.timezone);-- this.command = command;- this.pollingInterval = pollingInterval;-- if (!command.equalsIgnoreCase("date")) {- Location location = new Location(latitude, longitude);- this.calculator = new SunriseSunsetCalculator(location, timezone);- LOG.fine(- "DaylightCalculatorCommand created with values latitude=" + latitude + ", longitude=" + longitude + ", timezone=" + timezone- );- }- }-- public long getTime() { return now.getTimeInMillis(); }-- public String calculateData() {- return calculateData("");- }-- public String calculateData(String customTime) {- // customTime should be in format "hhhh[:mm[:ss]]" or "" for current time.- // hours filed can be more than one day. For example "25" is 1 the following day.- now = Calendar.getInstance(this.timezone);- if(customTime != null && !customTime.isEmpty()) {- String[] timeParts = customTime.split(":");- now.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timeParts[0]));- now.set(Calendar.MINUTE, timeParts.length>1 ? Integer.parseInt(timeParts[1]) : 0);- now.set(Calendar.SECOND, timeParts.length>2 ? Integer.parseInt(timeParts[2]) : 0);- }- if (command.equalsIgnoreCase("date")) {- return dateFormatter.format(now.getTime());- } else if (command.equalsIgnoreCase("sunrise")) {- Calendar officialSunriseDate = calculator.getOfficialSunriseCalendarForDate(now);- return dateFormatter.format(officialSunriseDate.getTime());- } else if (command.equalsIgnoreCase("sunset")) {- Calendar officialSunsetDate = calculator.getOfficialSunsetCalendarForDate(now);- return dateFormatter.format(officialSunsetDate.getTime());- } else if (command.equalsIgnoreCase("minutesUntilSunrise")) {- Calendar officialSunriseDate = calculator.getOfficialSunriseCalendarForDate(now);- if (now.after(officialSunriseDate)) {- Calendar tomorrow = (Calendar) now.clone();- tomorrow.add(Calendar.DAY_OF_YEAR, 1);- officialSunriseDate = calculator.getOfficialSunriseCalendarForDate(tomorrow);- }- int daysUntilSunrise = officialSunriseDate.get(Calendar.DAY_OF_YEAR) - now.get(Calendar.DAY_OF_YEAR);- int hoursUntilSunrise = officialSunriseDate.get(Calendar.HOUR_OF_DAY) - now.get(Calendar.HOUR_OF_DAY);- int minutesUntilSunrise = officialSunriseDate.get(Calendar.MINUTE) - now.get(Calendar.MINUTE);- return Integer.toString((daysUntilSunrise * 24 * 60) + (hoursUntilSunrise * 60) + minutesUntilSunrise);- } else if (command.equalsIgnoreCase("minutesUntilSunset")) {- Calendar officialSunsetDate = calculator.getOfficialSunsetCalendarForDate(now);- if (now.after(officialSunsetDate)) {- Calendar tomorrow = (Calendar) now.clone();- tomorrow.add(Calendar.DAY_OF_YEAR, 1);- officialSunsetDate = calculator.getOfficialSunsetCalendarForDate(tomorrow);- }- int daysUntilSunset = officialSunsetDate.get(Calendar.DAY_OF_YEAR) - now.get(Calendar.DAY_OF_YEAR);- int hoursUntilSunset = officialSunsetDate.get(Calendar.HOUR_OF_DAY) - now.get(Calendar.HOUR_OF_DAY);- int minutesUntilSunset = officialSunsetDate.get(Calendar.MINUTE) - now.get(Calendar.MINUTE);- return Integer.toString((daysUntilSunset * 24 * 60) + (hoursUntilSunset * 60) + minutesUntilSunset);- } else if (command.equalsIgnoreCase("isDay")) {- Calendar officialSunriseDate = calculator.getOfficialSunriseCalendarForDate(now);- Calendar officialSunsetDate = calculator.getOfficialSunsetCalendarForDate(now);- if (now.after(officialSunriseDate) && now.before(officialSunsetDate)) {- return "true";- } else {- return "false";- }- } else if (command.equalsIgnoreCase("isNight")) {- Calendar officialSunriseDate = calculator.getOfficialSunriseCalendarForDate(now);- Calendar officialSunsetDate = calculator.getOfficialSunsetCalendarForDate(now);- if (now.after(officialSunriseDate) && now.before(officialSunsetDate)) {- return "false";- } else {- return "true";- }- }- LOG.severe("DateTimeCommand does not know about this command: " + command);- return "Unknown command";- }-- @Override- public void start(Sensor sensor) {- if (pollingInterval == null) {- throw new RuntimeException("Could not set sensor because no polling interval was given");- }- this.sensor = sensor;- pollingThread = new Thread(this);- pollingThread.setName("Polling thread for: " + sensor);- pollingThread.start();- }--- @Override- public void stop(Sensor sensor) {- this.doPoll = false;- }-- @Override- public void run() {- LOG.fine("Sensor thread started for sensor: " + sensor);- this.doPoll = true;- while (this.doPoll) {- String readValue = this.calculateData();- if (!"N/A".equals(readValue)) {- sensor.update(readValue);- }- try {- Thread.sleep(pollingInterval); // We recalculate at requested polling interval- } catch (InterruptedException e) {- this.doPoll = false;- pollingThread.interrupt();- }- }- LOG.fine("*** Out of run method: " + sensor);- }-- public TimeZone getTimezone() {- return timezone;- }-- public String getCommand() {- return command;- }-- @Override- public String toString() {- return "DateTimeCommand{" +- "timezone=" + timezone +- ", command='" + command + '\'' +- '}';- }-}diff --git a/agent/src/main/java/org/openremote/agent/command/builtin/VirtualCommand.java b/agent/src/main/java/org/openremote/agent/command/builtin/VirtualCommand.javadeleted file mode 100644index e07688fbf..000000000--- a/agent/src/main/java/org/openremote/agent/command/builtin/VirtualCommand.java+++ /dev/null@@ -1,152 +0,0 @@-package org.openremote.agent.command.builtin;--import org.openremote.agent.command.ExecutableCommand;-import org.openremote.agent.command.PullCommand;-import org.openremote.agent.deploy.CommandDefinition;-import org.openremote.agent.sensor.*;--import java.util.Map;-import java.util.concurrent.ConcurrentHashMap;-import java.util.logging.Logger;--/**- * OpenRemote virtual command implementation.- * <p>- * Maintains a virtual-machine-wide state for each address. This can be used for testing.- * Incoming read() and send() requests operate on a map where the command's {@code <address>}- * field is used as a key and either the command name, or configured command parameter, or- * the argument of send() is stored as a virtual device state value for that address.- */-public class VirtualCommand implements ExecutableCommand, PullCommand {-- private static final Logger LOG = Logger.getLogger(VirtualCommand.class.getName());-- private final static Map<String, String> virtualDevices = new ConcurrentHashMap<>(20);- private String address = null;- private String command = null;-- public VirtualCommand(CommandDefinition commandDefinition) {- this(- commandDefinition.getProperty("address"),- commandDefinition.getProperty("command")- );- }-- /**- * Constructs a new "virtual" device command with a given address and command.- * <p>- * When this command's {@link #send} method is called, the command name is stored as a- * virtual device state value for the given device address.- *- * @param address arbitrary address string that is used to store the command value in memory- * @param command arbitrary command string that is stored in memory and can be later retrieved- * via invoking {@link #read}.- */- public VirtualCommand(String address, String command) {- this.address = address;- this.command = command;- }-- /**- * Allows this command implementation to be used with components that require write command- * implementations.- * <p>- * Stores the argument (or command parameter, if no argument is provided) as a "virtual" device state- * value when a send() is triggered. The state is stored and indexed by this command's address.- */- @Override- public void send(String arg) {- virtualDevices.put(address, arg != null && arg.length() > 0 ? arg : command);- }-- /**- * Allows this command implementation to be used as pull commands for sensors.- * <p>- * Stored values are looked up using address string as key on read() requests. Device state- * values can be stored for any given address using {@link #send} method of this class.- * <p>- * If the sensor associated with this command is of 'switch' type, the stored value should- * match 'on' or 'off' ('off' will be returned if the stored value cannot be translated or- * if no value has been stored for this command's address yet).- * <p>- * If the sensor associated with this command is of 'level' type, the stored value should- * be an integer string within range of [0-100]. String '0' will be returned if the stored- * device value for this address cannot be translated to integer or if no value has been- * stored for this command's addres yet.- * <p>- * Range behaves the same as 'level' but allows arbitrary integer to be stored.- * <p>- * Sensor type 'custom' allows arbitrary string values to be returned from this implementation.- *- * @param sensor the sensor- * @return the value stored for this command's address (in memory) or a default value based- * on the associated sensor type, if no value has been stored yet in memory- */- @Override- public String read(Sensor sensor) {- String state = virtualDevices.get(address);-- if (sensor instanceof SwitchSensor) {- if (state == null) {- return "off";- } else if (state.trim().equalsIgnoreCase("on")) {- return "on";- } else if (state.trim().equalsIgnoreCase("off")) {- return "off";- } else {- LOG.warning("Was expecting either 'on' or 'off' for SwitchSensor, got: " + state);- return "off";- }- } else if (sensor instanceof LevelSensor) {- if (state == null) {- return "0";- } else {- try {- int value = Integer.parseInt(state.trim());-- if (value > 100) {- return "100";- }-- if (value < 0) {- return "0";- }-- return "" + value;- } catch (NumberFormatException e) {- LOG.warning("Can't parse LevelSensor value into a valid number: " + e.getMessage());- return "0";- }- }- } else if (sensor instanceof RangeSensor) {- if (state == null) {- return "0";- } else {- try {- int value = Integer.parseInt(state.trim());-- return "" + value;- } catch (NumberFormatException e) {- LOG.warning("Can't parse RangeSensor value into a valid number: " + e.getMessage());- return "0";- }- }- } else if (sensor instanceof CustomSensor) {- return (state == null) ? "" : state;- } else {- throw new Error(- "Unrecognized sensor type '" + sensor + "'. Virtual command implementation must " +- "be updated to support this sensor type."- );- }- }-- @Override- public String toString() {- return "VirtualCommand{" +- "address='" + address + '\'' +- ", command='" + command + '\'' +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/context/AgentContext.java b/agent/src/main/java/org/openremote/agent/context/AgentContext.javadeleted file mode 100644index b406b2cc9..000000000--- a/agent/src/main/java/org/openremote/agent/context/AgentContext.java+++ /dev/null@@ -1,135 +0,0 @@-package org.openremote.agent.context;--import org.openremote.agent.command.Commands;-import org.openremote.agent.deploy.Deployment;-import org.openremote.agent.sensor.Sensor;-import org.openremote.agent.sensor.SensorState;-import org.openremote.agent.sensor.SensorStateUpdate;--import java.util.logging.Level;-import java.util.logging.Logger;--/**- * An instance of an agent, bootstrapped from {@link Deployment}, this is the main API.- */-public class AgentContext {-- private static final Logger LOG = Logger.getLogger(AgentContext.class.getName());-- final protected String agentID;- final protected Deployment deployment;- final protected String droolsClock;-- private volatile Boolean shutdownInProgress = false;-- public AgentContext(String agentID, Deployment deployment) {- this.agentID = agentID;- this.deployment = deployment;- this.droolsClock = "realtime";- }-- public AgentContext(String agentID, Deployment deployment, String droolsClock) {- this.agentID = agentID;- this.deployment = deployment;- this.droolsClock = droolsClock;- }-- public String getAgentID() {- return agentID;- }-- public Deployment getDeployment() {- return deployment;- }-- public Commands getCommands() {- return getDeployment().getCommands();- }-- public String getDroolsClock() { return droolsClock; }-- public synchronized void start() {- if (shutdownInProgress)- return;- LOG.info("Starting context: " + getAgentID());- getDeployment().getSensorStateHandler().start(this);- getDeployment().getRuleEngine().start(this);- for (Sensor sensor : deployment.getSensors()) {-- // Put initial state "unknown" for each sensor- getDeployment().getSensorStateHandler().put(- new Sensor.UnknownState(sensor)- );-- sensor.start(this);- }- }-- public synchronized void stop() {- try {- LOG.info("Stopping context: " + getAgentID());- shutdownInProgress = true;- try {- getDeployment().getRuleEngine().stop();- } catch (Throwable t) {- LOG.log(Level.SEVERE, "Error stopping rule engine", t);- }- for (Sensor sensor : deployment.getSensors()) {- try {- sensor.stop();- } catch (Throwable t) {- LOG.log(Level.SEVERE, "Error stopping sensor: " + sensor, t);- }- }- try {- getDeployment().getSensorStateHandler().stop();- } catch (Throwable t) {- LOG.log(Level.SEVERE, "Error stopping state handler", t);- }- } finally {- shutdownInProgress = false;- }- }-- public synchronized void update(SensorState sensorState) {- LOG.fine("==> Update: " + sensorState);- if (shutdownInProgress) {- LOG.fine("<== Shutting down. Ignoring update for: " + sensorState);- return;- }-- SensorStateUpdate sensorStateUpdate = new SensorStateUpdate(this, sensorState);-- getDeployment().getRuleEngine().process(sensorStateUpdate);-- if (sensorStateUpdate.hasTerminated()) {- LOG.fine("<== Update complete, processing terminated, no update was made for: " + sensorStateUpdate.getSensorState());- return;- }-- getDeployment().getSensorStateHandler().put(sensorState);- LOG.fine("<== Update complete for: " + sensorState);- }-- public synchronized String queryValue(int sensorID) {- SensorState state;- if ((state = queryState(sensorID)) == null) {- LOG.info("Requested sensor id '" + sensorID + "' was not found. Defaulting to: " + SensorState.UNKNOWN_VALUE);- return SensorState.UNKNOWN_VALUE;- }- return state.serialize();- }-- public synchronized String queryValue(String sensorName) {- return queryValue(deployment.getSensorID(sensorName));- }-- public synchronized SensorState queryState(int sensorID) {- return getDeployment().getSensorStateHandler().get(sensorID);- }-- public synchronized SensorState queryState(String sensorName) {- Integer sensorID = deployment.getSensorID(sensorName);- return sensorID != null ? queryState(sensorID) : null;- }-}diff --git a/agent/src/main/java/org/openremote/agent/context/InMemorySensorStateHandler.java b/agent/src/main/java/org/openremote/agent/context/InMemorySensorStateHandler.javadeleted file mode 100644index 62c4ee964..000000000--- a/agent/src/main/java/org/openremote/agent/context/InMemorySensorStateHandler.java+++ /dev/null@@ -1,46 +0,0 @@-package org.openremote.agent.context;--import org.openremote.agent.sensor.SensorState;--import java.util.HashMap;-import java.util.Map;-import java.util.logging.Logger;--public class InMemorySensorStateHandler implements SensorStateHandler {-- private static final Logger LOG = Logger.getLogger(InMemorySensorStateHandler.class.getName());-- final protected Map<Integer, SensorState> sensorStates = new HashMap<>();-- @Override- public void start(AgentContext agentContext) {-- }-- @Override- public void stop() {- sensorStates.clear();- }-- @Override- public void put(SensorState sensorState) {- int sourceID = sensorState.getSensorID();- if (sensorStates.get(sourceID) == null) {- LOG.fine("Inserted: " + sensorState);- sensorStates.put(sourceID, sensorState);- } else {- SensorState previousState = sensorStates.get(sourceID);- if (previousState.equals(sensorState)) {- LOG.fine("No change, stored state equals: " + sensorState);- return;- }- LOG.fine("Updated: " + sensorState);- sensorStates.put(sourceID, sensorState);- }- }-- @Override- public SensorState get(int sensorID) {- return sensorStates.get(sensorID);- }-}diff --git a/agent/src/main/java/org/openremote/agent/context/SensorStateHandler.java b/agent/src/main/java/org/openremote/agent/context/SensorStateHandler.javadeleted file mode 100644index a5f456169..000000000--- a/agent/src/main/java/org/openremote/agent/context/SensorStateHandler.java+++ /dev/null@@ -1,25 +0,0 @@-package org.openremote.agent.context;--import org.openremote.agent.sensor.SensorState;--/**- * Store and/or publish sensor state.- *- * TODO This is not accessed concurrently at this time, what happens after we improve agent's thread handling?- */-public interface SensorStateHandler {-- void start(AgentContext agentContext);-- void stop();-- void put(SensorState sensorState);-- SensorState get(int sensorID);-- /* TODO For polling/pushing to external system we need to be able to continue processing state from a known offset- Iterator<SensorState> getSince(int timestamp);-- Iterator<SensorState> getSince(int timestamp, int sensorID);- */-}diff --git a/agent/src/main/java/org/openremote/agent/deploy/CommandDefinition.java b/agent/src/main/java/org/openremote/agent/deploy/CommandDefinition.javadeleted file mode 100644index ed9aa0d8a..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/CommandDefinition.java+++ /dev/null@@ -1,104 +0,0 @@-package org.openremote.agent.deploy;--import org.openremote.model.Constants;--import java.util.Locale;-import java.util.Map;--import static org.openremote.model.Constants.NAMESPACE;--/**- * Command deployment model- */-public class CommandDefinition {-- public final static String NAME_PROPERTY = "name";- public final static String NAME_PROPERTY_DEFAULT_VALUE = "<No Name>";- public final static String DEVICE_NAME_PROPERTY = NAMESPACE + ":device-command:device-name";- public final static String DEVICE_ID_PROPERTY = NAMESPACE + ":device-command:device-id";-- final protected String protocolType;- final protected int commandID;- final protected Map<String, String> properties; // Note: properties are not case-sensitive, we convert to lowercase!-- /**- * @param commandID Unique identifier- * @param protocolType Protocol type identifier for this command. The protocol type identifier is used- * with the command factory to identify which plugin (Java bean implementation) is- * used to construct command's protocol specific execution model.- * @param properties Command's properties. Arbitrary list of properties that can be used to configure- * command instances. Certain property values such as {@link #NAME_PROPERTY}- * may have special meaning.- */- public CommandDefinition(int commandID, String protocolType, Map<String, String> properties) {- if (protocolType == null)- throw new IllegalArgumentException("Command protocol type can't be null");- this.commandID = commandID;- this.protocolType = protocolType;- if (properties == null)- throw new IllegalArgumentException("Command definition properties are required: " + this);- this.properties = properties;- if (getDeviceID() == null)- throw new IllegalStateException("Command definition must have device identifier: " + this);- if (getDeviceName() == null)- throw new IllegalStateException("Command definition must have device name: " + this);- }-- public String getProtocolType() {- return protocolType;- }-- public int getCommandID() {- return commandID;- }-- /**- * Returns a command property value.- *- * @param name Name of the command property to return. Note that command property names are- * not case-sensitive. All names are converted to lower case characters.- * @return Command property value, or empty string if not found.- */- public String getProperty(String name) {- return getProperty(name, "");- }-- public String getProperty(String name, String defaultValue) {- String value = properties.get(name.trim().toLowerCase(Locale.ROOT));- return (value == null) ? defaultValue : value;- }-- /**- * @return commands name, or a default {@link #NAME_PROPERTY_DEFAULT_VALUE} string if name property is not present- */- public String getName() {- String name = getProperty(NAME_PROPERTY);- if (name.length() == 0) {- return NAME_PROPERTY_DEFAULT_VALUE;- }- return name;- }-- public String getDeviceName() {- return getProperty(CommandDefinition.DEVICE_NAME_PROPERTY).trim();- }-- public Integer getDeviceID() {- try {- return Integer.parseInt(getProperty(CommandDefinition.DEVICE_ID_PROPERTY));- } catch (NumberFormatException ex) {- return null;- }- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "protocolType='" + protocolType + '\'' +- ", ID=" + getCommandID() +- ", name=" + getName() +- ", properties=" + properties +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/deploy/Deployment.java b/agent/src/main/java/org/openremote/agent/deploy/Deployment.javadeleted file mode 100644index 151f2ebe3..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/Deployment.java+++ /dev/null@@ -1,199 +0,0 @@-package org.openremote.agent.deploy;--import org.openremote.agent.command.Command;-import org.openremote.agent.command.CommandBuilder;-import org.openremote.agent.command.Commands;-import org.openremote.agent.command.SensorUpdateCommand;-import org.openremote.agent.context.SensorStateHandler;-import org.openremote.agent.rules.RuleEngine;-import org.openremote.agent.rules.RulesProvider;-import org.openremote.agent.sensor.*;--import java.util.Map;-import java.util.concurrent.ConcurrentHashMap;--/**- * Encapsulates:- * <pre>- * - General configuration properties- * - How protocol-specific commands are build- * - How sensor state is handled- * - Which rules process sensor state updates- * - All known sensors, commands and their devices- * </pre>- */-public class Deployment {-- final protected Map<String, String> config;- final protected CommandBuilder commandBuilder;- final protected Commands commands;- final protected SensorStateHandler sensorStateHandler;- final protected RulesProvider rulesProvider;- final protected RuleEngine ruleEngine;- final protected Map<String, Device> devices = new ConcurrentHashMap<>();- final protected Map<Integer, Sensor> sensors = new ConcurrentHashMap<>();-- public Deployment(DeploymentDefinition deploymentDefinition,- CommandBuilder commandBuilder,- SensorStateHandler sensorStateHandler,- RulesProvider rulesProvider) {-- this.config = deploymentDefinition.getConfig();- this.commandBuilder = commandBuilder;- this.commands = new Commands(this);- this.sensorStateHandler = sensorStateHandler;- this.rulesProvider = rulesProvider;- this.ruleEngine = new RuleEngine();-- for (SensorDefinition sensorDefinition : deploymentDefinition.getSensorDefinitions()) {- Sensor sensor = buildSensor(sensorDefinition);- sensors.put(sensor.getSensorDefinition().getSensorID(), sensor);- }-- for (CommandDefinition commandDefinition : deploymentDefinition.getCommandDefinitions()) {- Device device = devices.get(commandDefinition.getDeviceName());- if (device == null) {- device = new Device(commandDefinition.getDeviceID(), commandDefinition.getDeviceName());- devices.put(device.getName(), device);- } else if (device.getDeviceID() != commandDefinition.getDeviceID()) {- throw new IllegalStateException(- "Device '" + device.getName() + "' with ID " + device.getDeviceID() + " conflicts with: " + commandDefinition- );- }- device.addCommandDefinition(commandDefinition);- }- }-- public Map<String, String> getConfig() {- return config;- }-- public CommandBuilder getCommandBuilder() {- return commandBuilder;- }-- public Commands getCommands() {- return commands;- }-- public SensorStateHandler getSensorStateHandler() {- return sensorStateHandler;- }-- public RulesProvider getRulesProvider() {- return rulesProvider;- }-- public RuleEngine getRuleEngine() {- return ruleEngine;- }-- public CommandDefinition getCommandDefinition(int commandID) {- for (Device device : devices.values()) {- CommandDefinition commandDefinition = device.getCommandDefinition(commandID);- if (commandDefinition != null)- return commandDefinition;- }- return null;- }-- public CommandDefinition getCommandDefinition(String deviceName, String commandName) {- if (deviceName == null || commandName == null || deviceName.length() == 0 || commandName.length() == 0) {- return null;- }- Device device = devices.get(deviceName);- return device != null ? device.getCommandDefinition(commandName) : null;- }-- public CommandDefinition getCommandDefinition(String commandName) {- if (commandName == null || commandName.length() == 0) {- return null;- }- for (Device device : devices.values()) {- CommandDefinition commandDefinition = device.getCommandDefinition(commandName);- if (commandDefinition != null)- return commandDefinition;- }- return null;- }-- public Device getDevice(String deviceName) {- return devices.get(deviceName);- }-- public Device[] getDevices() {- return devices.values().toArray(new Device[devices.values().size()]);- }-- public Sensor[] getSensors() {- return sensors.values().toArray(new Sensor[sensors.values().size()]);- }-- public Sensor getSensor(int sensorID) {- return sensors.get(sensorID);- }-- public Sensor getSensor(String sensorName) {- for (Sensor sensor : sensors.values()) {- if (sensor.getSensorDefinition().getName().equals(sensorName))- return sensor;- }- return null;- }-- public Integer getSensorID(String sensorName) {- Sensor sensor = getSensor(sensorName);- return sensor != null ? sensor.getSensorDefinition().getSensorID() : null;- }-- protected Sensor buildSensor(SensorDefinition sensorDefinition) {- Sensor sensor;-- Command command = commandBuilder.build(sensorDefinition.getUpdateCommandDefinition());- SensorUpdateCommand updateCommand;- if (command instanceof SensorUpdateCommand) {- updateCommand = (SensorUpdateCommand) command;- } else {- throw new IllegalStateException(- "Sensor must reference " + SensorUpdateCommand.class.getSimpleName() + ", not '" + command + "': " + sensorDefinition- );- }-- switch (sensorDefinition.getType()) {- case "range":- String minValue = sensorDefinition.getProperties().get("range-min");- if (minValue == null)- throw new IllegalStateException("Sensor of range type must have min/max value defined: " + sensorDefinition);- String maxValue = sensorDefinition.getProperties().get("range-max");- if (maxValue == null)- throw new IllegalStateException("Sensor of range type must have min/max value defined: " + sensorDefinition);- sensor = new RangeSensor(sensorDefinition, updateCommand, Integer.valueOf(minValue), Integer.valueOf(maxValue));- break;- case "level":- sensor = new LevelSensor(sensorDefinition, updateCommand);- break;- case "custom":- CustomSensor.DistinctStates distinctStates = new CustomSensor.DistinctStates();- for (Map.Entry<String, String> entry : sensorDefinition.getProperties().entrySet()) {- if (entry.getKey().startsWith("state-")) {- distinctStates.addStateMapping(entry.getKey().substring(6), entry.getValue());- }- }- sensor = new CustomSensor(sensorDefinition, updateCommand, distinctStates, false);- break;- case "switch":- distinctStates = new CustomSensor.DistinctStates();- for (Map.Entry<String, String> entry : sensorDefinition.getProperties().entrySet()) {- if (entry.getKey().startsWith("state-")) {- distinctStates.addStateMapping(entry.getKey().substring(6), entry.getValue());- }- }- sensor = new SwitchSensor(sensorDefinition, updateCommand, distinctStates);- break;- default:- throw new IllegalArgumentException("Unsupported sensor type: " + sensorDefinition);- }- return sensor;- }--}diff --git a/agent/src/main/java/org/openremote/agent/deploy/DeploymentDefinition.java b/agent/src/main/java/org/openremote/agent/deploy/DeploymentDefinition.javadeleted file mode 100644index 41fd558c7..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/DeploymentDefinition.java+++ /dev/null@@ -1,41 +0,0 @@-package org.openremote.agent.deploy;--import java.util.HashMap;-import java.util.Map;--/**- * The deployment definition model, source for building a {@link Deployment}.- */-public class DeploymentDefinition {-- protected CommandDefinition[] commandDefinitions = new CommandDefinition[0];- protected SensorDefinition[] sensorDefinitions = new SensorDefinition[0];- protected Map<String, String> config = new HashMap<>();-- public DeploymentDefinition() {- }-- public CommandDefinition[] getCommandDefinitions() {- return commandDefinitions;- }-- public void setCommandDefinitions(CommandDefinition[] commandDefinitions) {- this.commandDefinitions = commandDefinitions;- }-- public SensorDefinition[] getSensorDefinitions() {- return sensorDefinitions;- }-- public void setSensorDefinitions(SensorDefinition[] sensorDefinitions) {- this.sensorDefinitions = sensorDefinitions;- }-- public Map<String, String> getConfig() {- return config;- }-- public void setConfig(Map<String, String> config) {- this.config = config;- }-}diff --git a/agent/src/main/java/org/openremote/agent/deploy/Device.java b/agent/src/main/java/org/openremote/agent/deploy/Device.javadeleted file mode 100644index 456c479a7..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/Device.java+++ /dev/null@@ -1,43 +0,0 @@-package org.openremote.agent.deploy;--import java.util.Map;-import java.util.concurrent.ConcurrentHashMap;--/**- * A device is simply a collection of command definitions.- */-public class Device {-- final protected int deviceID;- final protected String name;- final protected Map<Integer, CommandDefinition> commandDefinitions = new ConcurrentHashMap<>();-- public Device(int deviceID, String name) {- this.deviceID = deviceID;- this.name = name;- }-- public int getDeviceID() {- return deviceID;- }-- public String getName() {- return name;- }-- public CommandDefinition getCommandDefinition(int commandID) {- return commandDefinitions.get(commandID);- }-- public CommandDefinition getCommandDefinition(String commandName) {- for (CommandDefinition commandDefinition : commandDefinitions.values()) {- if (commandDefinition.getName().equals(commandName))- return commandDefinition;- }- return null;- }-- public void addCommandDefinition(CommandDefinition commandDefinition) {- commandDefinitions.put(commandDefinition.getCommandID(), commandDefinition);- }-}diff --git a/agent/src/main/java/org/openremote/agent/deploy/SensorDefinition.java b/agent/src/main/java/org/openremote/agent/deploy/SensorDefinition.javadeleted file mode 100644index bf868f695..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/SensorDefinition.java+++ /dev/null@@ -1,77 +0,0 @@-package org.openremote.agent.deploy;--import java.util.HashMap;-import java.util.Map;--/**- * Sensor deployment model- */-public class SensorDefinition {-- final protected int sensorID;- final protected String name;- final protected String type;- final protected CommandDefinition updateCommandDefinition;- final protected Map<String, String> properties;-- /**- * @param name Human readable name of the sensor.- * @param sensorID A unique identifier.- * @param type A sensor type.- * @param updateCommandDefinition A command definition used to update sensor values.- * @param properties Additional sensor properties. These properties can be used by the protocol- * implementors to direct their implementation according to sensor configuration.- */- public SensorDefinition(int sensorID, String name, String type, CommandDefinition updateCommandDefinition, Map<String, String> properties) {- if (properties == null) {- properties = new HashMap<>(0);- }- this.sensorID = sensorID;- this.name = name;- this.type = type;- this.updateCommandDefinition = updateCommandDefinition;- this.properties = properties;- }-- public int getSensorID() {- return sensorID;- }-- public String getName() {- return name;- }-- public String getType() {- return type;- }-- public CommandDefinition getUpdateCommandDefinition() {- return updateCommandDefinition;- }-- /**- * Returns sensor's properties. Properties are simply string based name-value mappings.- * Concrete sensor implementations may specify which particular properties they expose.- * <p>- * The returned map does not reference this sensor instance and can be modified freely.- *- * @return sensor properties or an empty collection- */- public Map<String, String> getProperties() {- HashMap<String, String> props = new HashMap<>(5);- props.putAll(properties);- return props;- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "ID=" + getSensorID() +- ", name=" + getName() +- ", type=" + getType() +- ", properties=" + properties +- ", updateCommandDefinition=" + getUpdateCommandDefinition() +- '}';- }--}diff --git a/agent/src/main/java/org/openremote/agent/deploy/xml/AgentDOM.java b/agent/src/main/java/org/openremote/agent/deploy/xml/AgentDOM.javadeleted file mode 100644index fac62fb31..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/xml/AgentDOM.java+++ /dev/null@@ -1,144 +0,0 @@-package org.openremote.agent.deploy.xml;--import org.openremote.container.xml.DOM;-import org.openremote.agent.deploy.CommandDefinition;-import org.openremote.agent.deploy.DeploymentDefinition;-import org.openremote.agent.deploy.SensorDefinition;-import org.w3c.dom.Document;--import javax.xml.xpath.XPath;-import java.util.*;-import java.util.logging.Logger;--/**- * Usage:- * <p>- * <pre><code>- * AgentDOM dom = new AgentDOMParser().parse(deploymentXml);- * Deployment deployment = new Deployment(dom.getDeploymentDefinition(), ...);- * </code></pre>- */-public class AgentDOM extends DOM {-- private static final Logger LOG = Logger.getLogger(AgentDOM.class.getName());-- public static final String NAMESPACE_URI = "http://www.openremote.org/schemas/agent/3";-- final protected XPath xpath;- final protected DeploymentDefinition deploymentDefinition;-- public AgentDOM(Document dom, XPath xpath) {- super(dom);- this.xpath = xpath;-- this.deploymentDefinition = new DeploymentDefinition();-- try {- List<CommandDefinition> commandDefinitionList = new ArrayList<>();- AgentElement[] commandElements = getRoot(xpath).getFirstChild("commands").getChildren();- for (AgentElement commandElement : commandElements) {- Integer commandID = Integer.valueOf(commandElement.getAttribute("id"));- String protocolType = commandElement.getAttribute("protocol");- Map<String, String> properties = new LinkedHashMap<>();- for (AgentElement propertyElement : commandElement.getChildren("property")) {- properties.put(propertyElement.getAttribute("name"), propertyElement.getAttribute("value"));- }- commandDefinitionList.add(- new CommandDefinition(commandID, protocolType, properties)- );- }- deploymentDefinition.setCommandDefinitions(- commandDefinitionList.toArray(new CommandDefinition[commandDefinitionList.size()]- )- );-- List<SensorDefinition> sensorDefinitionList = new ArrayList<>();- AgentElement[] sensorElements = getRoot(xpath).getFirstChild("sensors").getChildren();- for (AgentElement sensorElement : sensorElements) {- Integer sensorID = Integer.valueOf(sensorElement.getAttribute("id"));- String sensorName = sensorElement.getAttribute("name");- String sensorType = sensorElement.getAttribute("type").toLowerCase(Locale.ROOT);-- Integer commandRefID = null;- AgentElement includeElement = sensorElement.getFirstChild("include");- if (includeElement != null && "command".equals(includeElement.getAttribute("type"))) {- commandRefID = Integer.valueOf(includeElement.getAttribute("ref"));- }- if (commandRefID == null) {- throw new IllegalStateException(- "Missing command reference in sensor definition: " + sensorID + "/" + sensorName- );- }-- CommandDefinition commandDefinition = null;- for (CommandDefinition cmdDefinition : commandDefinitionList) {- if (cmdDefinition.getCommandID() == commandRefID) {- commandDefinition = cmdDefinition;- break;- }- }- if (commandDefinition == null) {- throw new IllegalStateException(- "Unknown command '" + commandRefID + "' referenced in sensor definition: " + sensorID + "/" + sensorName- );- }-- // TODO This is horrible, not uniform- Map<String, String> properties = new LinkedHashMap<>();- for (AgentElement stateElement : sensorElement.getChildren("state")) {- properties.put("state-" + stateElement.getAttribute("name"), stateElement.getAttribute("value"));- }- AgentElement minElement = sensorElement.getFirstChild("min");- if (minElement != null)- properties.put("range-min", minElement.getAttribute("value"));- AgentElement maxElement = sensorElement.getFirstChild("max");- if (maxElement != null)- properties.put("range-max", maxElement.getAttribute("value"));-- sensorDefinitionList.add(- new SensorDefinition(sensorID, sensorName, sensorType, commandDefinition, properties)- );- }- deploymentDefinition.setSensorDefinitions(- sensorDefinitionList.toArray(new SensorDefinition[sensorDefinitionList.size()])- );-- Map<String, String> config = new HashMap<>();- AgentElement[] configPropertyElements = getRoot(xpath).getFirstChild("config").getChildren();- for (AgentElement configPropertyElement : configPropertyElements) {- String name = configPropertyElement.getAttribute("name");- String value = configPropertyElement.getAttribute("value");- if (name != null) {- if (value != null) {- config.put(name, value);- } else {- LOG.info("Ignoring config property without value: " + name);- }- }- }- deploymentDefinition.setConfig(config);-- } catch (Exception ex) {- throw new RuntimeException("Error parsing agent deployment from XML document", ex);- }- }-- @Override- public String getRootElementNamespace() {- return NAMESPACE_URI;- }-- @Override- public AgentElement getRoot(XPath xPath) {- return new AgentElement(xPath, getW3CDocument().getDocumentElement());- }-- @Override- public AgentDOM copy() {- return new AgentDOM((Document) getW3CDocument().cloneNode(true), xpath);- }-- public DeploymentDefinition getDeploymentDefinition() {- return deploymentDefinition;- }-}\ No newline at end of filediff --git a/agent/src/main/java/org/openremote/agent/deploy/xml/AgentDOMParser.java b/agent/src/main/java/org/openremote/agent/deploy/xml/AgentDOMParser.javadeleted file mode 100644index 5ca3bf039..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/xml/AgentDOMParser.java+++ /dev/null@@ -1,46 +0,0 @@-package org.openremote.agent.deploy.xml;--import org.openremote.container.xml.DOMParser;-import org.openremote.container.xml.NamespaceContextMap;-import org.w3c.dom.Document;--import javax.xml.transform.stream.StreamSource;-import javax.xml.xpath.XPath;--/**- * Usage:- *- * <pre><code>- * AgentDOM dom = new AgentDOMParser().parse(deploymentXml);- * </code></pre>- */-public class AgentDOMParser extends DOMParser<AgentDOM> {-- public static final String SCHEMA_XSD = "/org/openremote/agent/schemas/agent-3.xsd";-- public AgentDOMParser() {- super(new StreamSource(AgentDOMParser.class.getResourceAsStream(SCHEMA_XSD)));- }-- @Override- protected AgentDOM createDOM(Document document) {- return new AgentDOM(document, createXPath());- }-- public NamespaceContextMap createDefaultNamespaceContext(String... optionalPrefixes) {- NamespaceContextMap ctx = new NamespaceContextMap() {- @Override- protected String getDefaultNamespaceURI() {- return AgentDOM.NAMESPACE_URI;- }- };- for (String optionalPrefix : optionalPrefixes) {- ctx.put(optionalPrefix, AgentDOM.NAMESPACE_URI);- }- return ctx;- }-- public XPath createXPath() {- return super.createXPath(createDefaultNamespaceContext(AgentElement.XPATH_PREFIX));- }-}diff --git a/agent/src/main/java/org/openremote/agent/deploy/xml/AgentElement.java b/agent/src/main/java/org/openremote/agent/deploy/xml/AgentElement.javadeleted file mode 100644index cad7ada69..000000000--- a/agent/src/main/java/org/openremote/agent/deploy/xml/AgentElement.java+++ /dev/null@@ -1,45 +0,0 @@-package org.openremote.agent.deploy.xml;--import org.openremote.container.xml.DOMElement;-import org.w3c.dom.Element;--import javax.xml.xpath.XPath;--public class AgentElement extends DOMElement<AgentElement, AgentElement> {-- public static final String XPATH_PREFIX = "c";-- public AgentElement(XPath xpath, Element element) {- super(xpath, element);- }-- @Override- protected String prefix(String localName) {- return XPATH_PREFIX + ":" + localName;- }-- @Override- protected Builder<AgentElement> createParentBuilder(DOMElement el) {- return new Builder<AgentElement>(el) {- @Override- public AgentElement build(Element element) {- return new AgentElement(getXpath(), element);- }- };- }-- @Override- protected ArrayBuilder<AgentElement> createChildBuilder(DOMElement el) {- return new ArrayBuilder<AgentElement>(el) {- @Override- public AgentElement[] newChildrenArray(int length) {- return new AgentElement[length];- }-- @Override- public AgentElement build(Element element) {- return new AgentElement(getXpath(), element);- }- };- }-}diff --git a/agent/src/main/java/org/openremote/agent3/protocol/AbstractProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.javasimilarity index 99%rename from agent/src/main/java/org/openremote/agent3/protocol/AbstractProtocol.javarename to agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.javaindex 10f04d17b..52e653131 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/AbstractProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/AbstractProtocol.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol;+package org.openremote.agent.protocol;import org.apache.camel.ProducerTemplate;import org.apache.camel.builder.RouteBuilder;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/Protocol.java b/agent/src/main/java/org/openremote/agent/protocol/Protocol.javasimilarity index 99%rename from agent/src/main/java/org/openremote/agent3/protocol/Protocol.javarename to agent/src/main/java/org/openremote/agent/protocol/Protocol.javaindex 59ae53267..5adef203b 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/Protocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/Protocol.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol;+package org.openremote.agent.protocol;import org.openremote.container.ContainerService;import org.openremote.model.asset.Asset;@@ -32,7 +32,6 @@ import org.openremote.model.value.ValueType;import java.util.Collection;import java.util.function.Consumer;-import java.util.logging.Logger;/*** A protocol is a thread-safe singleton {@link ContainerService} that connects devices anddiff --git a/agent/src/main/java/org/openremote/agent3/protocol/ProtocolAssetService.java b/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent3/protocol/ProtocolAssetService.javarename to agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.javaindex 3f2a2bd40..1d0ff08c5 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/ProtocolAssetService.java+++ b/agent/src/main/java/org/openremote/agent/protocol/ProtocolAssetService.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol;+package org.openremote.agent.protocol;import org.openremote.container.ContainerService;import org.openremote.model.asset.AssetAttribute;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/ProtocolExecutorService.java b/agent/src/main/java/org/openremote/agent/protocol/ProtocolExecutorService.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent3/protocol/ProtocolExecutorService.javarename to agent/src/main/java/org/openremote/agent/protocol/ProtocolExecutorService.javaindex 6cc8ba211..ce95e005b 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/ProtocolExecutorService.java+++ b/agent/src/main/java/org/openremote/agent/protocol/ProtocolExecutorService.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol;+package org.openremote.agent.protocol;import org.openremote.container.ContainerService;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/macro/MacroAction.java b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroAction.javasimilarity index 95%rename from agent/src/main/java/org/openremote/agent3/protocol/macro/MacroAction.javarename to agent/src/main/java/org/openremote/agent/protocol/macro/MacroAction.javaindex adbefec33..22beb0663 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/macro/MacroAction.java+++ b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroAction.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.macro;+package org.openremote.agent.protocol.macro;import org.openremote.model.attribute.AttributeState;import org.openremote.model.attribute.MetaItem;@@ -29,7 +29,7 @@ import org.openremote.model.value.Values;import java.util.Objects;import java.util.Optional;-import static org.openremote.agent3.protocol.macro.MacroConfiguration.META_MACRO_ACTION;+import static org.openremote.agent.protocol.macro.MacroConfiguration.META_MACRO_ACTION;/*** A desired {@link AttributeState} and a delay in milli seconds before that statediff --git a/agent/src/main/java/org/openremote/agent3/protocol/macro/MacroConfiguration.java b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroConfiguration.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent3/protocol/macro/MacroConfiguration.javarename to agent/src/main/java/org/openremote/agent/protocol/macro/MacroConfiguration.javaindex 420adec84..a7bfbb8eb 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/macro/MacroConfiguration.java+++ b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroConfiguration.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.macro;+package org.openremote.agent.protocol.macro;import org.openremote.model.asset.AssetAttribute;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/macro/MacroProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent3/protocol/macro/MacroProtocol.javarename to agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.javaindex bfb577f94..dd3ac0999 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/macro/MacroProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/macro/MacroProtocol.java@@ -17,9 +17,9 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.macro;+package org.openremote.agent.protocol.macro;-import org.openremote.agent3.protocol.AbstractProtocol;+import org.openremote.agent.protocol.AbstractProtocol;import org.openremote.model.AbstractValueHolder;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.asset.AssetMeta;@@ -32,8 +32,8 @@ import java.util.*;import java.util.concurrent.ScheduledFuture;import java.util.logging.Logger;-import static org.openremote.agent3.protocol.macro.MacroConfiguration.META_MACRO_ACTION;-import static org.openremote.agent3.protocol.macro.MacroConfiguration.isValidMacroConfiguration;+import static org.openremote.agent.protocol.macro.MacroConfiguration.META_MACRO_ACTION;+import static org.openremote.agent.protocol.macro.MacroConfiguration.isValidMacroConfiguration;import static org.openremote.model.Constants.ASSET_META_NAMESPACE;import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/simulator/SimulatorProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent3/protocol/simulator/SimulatorProtocol.javarename to agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.javaindex 4797765b8..f4d76ce4b 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/simulator/SimulatorProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/SimulatorProtocol.java@@ -17,10 +17,10 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.simulator;+package org.openremote.agent.protocol.simulator;-import org.openremote.agent3.protocol.AbstractProtocol;-import org.openremote.agent3.protocol.simulator.element.*;+import org.openremote.agent.protocol.AbstractProtocol;+import org.openremote.agent.protocol.simulator.element.*;import org.openremote.model.AbstractValueHolder;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.AttributeEvent;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/ColorSimulatorElement.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/ColorSimulatorElement.javasimilarity index 94%rename from agent/src/main/java/org/openremote/agent3/protocol/simulator/element/ColorSimulatorElement.javarename to agent/src/main/java/org/openremote/agent/protocol/simulator/element/ColorSimulatorElement.javaindex 8303175a8..d79f60bca 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/ColorSimulatorElement.java+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/ColorSimulatorElement.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.simulator.element;+package org.openremote.agent.protocol.simulator.element;import org.openremote.model.attribute.AttributeType;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/DecimalSimulatorElement.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/DecimalSimulatorElement.javasimilarity index 94%rename from agent/src/main/java/org/openremote/agent3/protocol/simulator/element/DecimalSimulatorElement.javarename to agent/src/main/java/org/openremote/agent/protocol/simulator/element/DecimalSimulatorElement.javaindex 0ce1ded67..8c6c5396b 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/DecimalSimulatorElement.java+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/DecimalSimulatorElement.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.simulator.element;+package org.openremote.agent.protocol.simulator.element;import org.openremote.model.attribute.AttributeType;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/IntegerSimulatorElement.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/IntegerSimulatorElement.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent3/protocol/simulator/element/IntegerSimulatorElement.javarename to agent/src/main/java/org/openremote/agent/protocol/simulator/element/IntegerSimulatorElement.javaindex fa1b19718..e83d76695 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/IntegerSimulatorElement.java+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/IntegerSimulatorElement.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.simulator.element;+package org.openremote.agent.protocol.simulator.element;import org.openremote.model.attribute.AttributeType;import org.openremote.model.value.Value;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/SimulatorElement.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/SimulatorElement.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent3/protocol/simulator/element/SimulatorElement.javarename to agent/src/main/java/org/openremote/agent/protocol/simulator/element/SimulatorElement.javaindex c11e06365..deb0ce84a 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/SimulatorElement.java+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/SimulatorElement.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.simulator.element;+package org.openremote.agent.protocol.simulator.element;import org.openremote.model.attribute.AttributeType;import org.openremote.model.value.Value;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/SwitchSimulatorElement.java b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/SwitchSimulatorElement.javasimilarity index 94%rename from agent/src/main/java/org/openremote/agent3/protocol/simulator/element/SwitchSimulatorElement.javarename to agent/src/main/java/org/openremote/agent/protocol/simulator/element/SwitchSimulatorElement.javaindex e81c4e5d7..6fa191cb2 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/simulator/element/SwitchSimulatorElement.java+++ b/agent/src/main/java/org/openremote/agent/protocol/simulator/element/SwitchSimulatorElement.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.simulator.element;+package org.openremote.agent.protocol.simulator.element;import org.openremote.model.attribute.AttributeType;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/AbstractTriggerHandler.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/AbstractTriggerHandler.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/AbstractTriggerHandler.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/AbstractTriggerHandler.javaindex 4ae227232..cf3268593 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/AbstractTriggerHandler.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/AbstractTriggerHandler.java@@ -17,9 +17,9 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger;+package org.openremote.agent.protocol.trigger;-import org.openremote.agent3.protocol.AbstractProtocol;+import org.openremote.agent.protocol.AbstractProtocol;import org.openremote.container.Container;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.AttributeEvent;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerConfiguration.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerConfiguration.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerConfiguration.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerConfiguration.javaindex 23dddc054..e0336d7a3 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerConfiguration.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerConfiguration.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger;+package org.openremote.agent.protocol.trigger;import org.openremote.model.AbstractValueHolder;import org.openremote.model.asset.AssetAttribute;@@ -29,8 +29,8 @@ import org.openremote.model.value.Values;import java.util.Optional;import java.util.function.Function;-import static org.openremote.agent3.protocol.trigger.TriggerProtocol.*;-import static org.openremote.agent3.protocol.trigger.TriggerType.toValue;+import static org.openremote.agent.protocol.trigger.TriggerProtocol.*;+import static org.openremote.agent.protocol.trigger.TriggerType.toValue;import static org.openremote.model.asset.agent.ProtocolConfiguration.getProtocolName;import static org.openremote.model.attribute.AttributeType.STRING;import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerHandlerProducer.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerHandlerProducer.javasimilarity index 94%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerHandlerProducer.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerHandlerProducer.javaindex a87bfc585..6442701c0 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerHandlerProducer.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerHandlerProducer.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger;+package org.openremote.agent.protocol.trigger;public interface TriggerHandlerProducer {AbstractTriggerHandler getHandler();diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerProtocol.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerProtocol.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerProtocol.javaindex 8c15fdd5d..7c6bb0fff 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerProtocol.java@@ -17,9 +17,9 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger;+package org.openremote.agent.protocol.trigger;-import org.openremote.agent3.protocol.AbstractProtocol;+import org.openremote.agent.protocol.AbstractProtocol;import org.openremote.container.Container;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.AttributeEvent;@@ -33,7 +33,7 @@ import java.util.Map;import java.util.Optional;import java.util.logging.Logger;-import static org.openremote.agent3.protocol.trigger.TriggerConfiguration.*;+import static org.openremote.agent.protocol.trigger.TriggerConfiguration.*;import static org.openremote.model.Constants.ASSET_META_NAMESPACE;import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerType.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerType.javasimilarity index 91%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerType.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerType.javaindex 6c55c79d3..7db8d00af 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/TriggerType.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/TriggerType.java@@ -17,10 +17,10 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger;+package org.openremote.agent.protocol.trigger;-import org.openremote.agent3.protocol.trigger.attribute.AttributeTriggerHandler;-import org.openremote.agent3.protocol.trigger.time.TimeTriggerHandler;+import org.openremote.agent.protocol.trigger.attribute.AttributeTriggerHandler;+import org.openremote.agent.protocol.trigger.time.TimeTriggerHandler;import org.openremote.model.attribute.AttributeEvent;import org.openremote.model.value.Value;import org.openremote.model.value.Values;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/attribute/AttributeTriggerHandler.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/attribute/AttributeTriggerHandler.javasimilarity index 94%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/attribute/AttributeTriggerHandler.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/attribute/AttributeTriggerHandler.javaindex 83e3fcf3f..e3f3ffc1d 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/attribute/AttributeTriggerHandler.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/attribute/AttributeTriggerHandler.java@@ -17,9 +17,9 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger.attribute;+package org.openremote.agent.protocol.trigger.attribute;-import org.openremote.agent3.protocol.trigger.AbstractTriggerHandler;+import org.openremote.agent.protocol.trigger.AbstractTriggerHandler;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.AttributeEvent;import org.openremote.model.attribute.AttributeRef;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronExpressionParser.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronExpressionParser.javasimilarity index 99%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronExpressionParser.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronExpressionParser.javaindex 1cf7d1f30..093f6068c 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronExpressionParser.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronExpressionParser.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger.time;+package org.openremote.agent.protocol.trigger.time;import org.openremote.model.syslog.SyslogCategory;import org.quartz.CronExpression;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronJob.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronJob.javasimilarity index 96%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronJob.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronJob.javaindex c45efc7fa..ef97f7af4 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronJob.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronJob.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger.time;+package org.openremote.agent.protocol.trigger.time;import org.quartz.Job;import org.quartz.JobExecutionContext;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronScheduler.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronScheduler.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronScheduler.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronScheduler.javaindex 6ced42b0d..a716bf503 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/CronScheduler.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/CronScheduler.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger.time;+package org.openremote.agent.protocol.trigger.time;import org.openremote.model.syslog.SyslogCategory;import org.openremote.model.util.Pair;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/TimeTriggerHandler.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/TimeTriggerHandler.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/time/TimeTriggerHandler.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/time/TimeTriggerHandler.javaindex c0864b341..e1352e2fd 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/TimeTriggerHandler.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/TimeTriggerHandler.java@@ -17,9 +17,9 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger.time;+package org.openremote.agent.protocol.trigger.time;-import org.openremote.agent3.protocol.trigger.AbstractTriggerHandler;+import org.openremote.agent.protocol.trigger.AbstractTriggerHandler;import org.openremote.model.asset.AssetAttribute;import org.openremote.model.attribute.AttributeEvent;import org.openremote.model.attribute.AttributeRef;@@ -38,7 +38,7 @@ import java.util.Optional;import java.util.logging.Logger;import static java.util.logging.Level.FINER;-import static org.openremote.agent3.protocol.trigger.time.CronExpressionParser.parseNumberExpression;+import static org.openremote.agent.protocol.trigger.time.CronExpressionParser.parseNumberExpression;import static org.openremote.model.syslog.SyslogCategory.PROTOCOL;import static org.openremote.model.util.TextUtil.isNullOrEmpty;diff --git a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/TimeTriggerProperty.java b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/TimeTriggerProperty.javasimilarity index 96%rename from agent/src/main/java/org/openremote/agent3/protocol/trigger/time/TimeTriggerProperty.javarename to agent/src/main/java/org/openremote/agent/protocol/trigger/time/TimeTriggerProperty.javaindex 38fe4b439..e4b81bb0f 100644--- a/agent/src/main/java/org/openremote/agent3/protocol/trigger/time/TimeTriggerProperty.java+++ b/agent/src/main/java/org/openremote/agent/protocol/trigger/time/TimeTriggerProperty.java@@ -17,7 +17,7 @@* You should have received a copy of the GNU Affero General Public License* along with this program. If not, see <http://www.gnu.org/licenses/>.*/-package org.openremote.agent3.protocol.trigger.time;+package org.openremote.agent.protocol.trigger.time;import java.util.Locale;diff --git a/agent/src/main/java/org/openremote/agent/rules/LevelFacade.java b/agent/src/main/java/org/openremote/agent/rules/LevelFacade.javadeleted file mode 100644index 34e8b822b..000000000--- a/agent/src/main/java/org/openremote/agent/rules/LevelFacade.java+++ /dev/null@@ -1,38 +0,0 @@-package org.openremote.agent.rules;--import org.openremote.agent.sensor.LevelSensorState;--public class LevelFacade extends SingleValueSensorFacade<LevelFacade.LevelAdapter, LevelSensorState> {-- @Override- protected LevelSensorState createDefaultState(int sourceID, String sourceName) {- return new LevelSensorState(sourceID, sourceName, 0);- }-- @Override- protected LevelAdapter createAdapter(LevelSensorState sensorState) {- return new LevelAdapter(sensorState);- }-- public class LevelAdapter {-- private LevelSensorState levelSensorState;-- private LevelAdapter(LevelSensorState levelSensorState) {- this.levelSensorState = levelSensorState;- }-- public void value(int value) {- // TODO Duplicate max/min logic?!- if (value < 0) {- value = 0;- } else if (value > 100) {- value = 100;- }-- LevelSensorState newLevelSensorState = levelSensorState.clone(value);- terminateAndReplaceWith(newLevelSensorState);- }- }-}-diff --git a/agent/src/main/java/org/openremote/agent/rules/RangeFacade.java b/agent/src/main/java/org/openremote/agent/rules/RangeFacade.javadeleted file mode 100644index d7d09ff73..000000000--- a/agent/src/main/java/org/openremote/agent/rules/RangeFacade.java+++ /dev/null@@ -1,38 +0,0 @@-package org.openremote.agent.rules;--import org.openremote.agent.sensor.RangeSensorState;--public class RangeFacade extends SingleValueSensorFacade<RangeFacade.RangeAdapter, RangeSensorState> {-- @Override- protected RangeSensorState createDefaultState(int sourceID, String sourceName) {- // TODO We drop the min/max here? This leads to updates that don't restrict boundaries...- return new RangeSensorState(sourceID, sourceName, 0, Integer.MIN_VALUE, Integer.MAX_VALUE);- }-- @Override- protected RangeAdapter createAdapter(RangeSensorState sensorState) {- return new RangeAdapter(sensorState);- }-- public class RangeAdapter {-- final private RangeSensorState rangeSensorState;-- private RangeAdapter(RangeSensorState rangeSensorState) {- this.rangeSensorState = rangeSensorState;- }-- public void value(int value) {- if (value < rangeSensorState.getMinValue()) {- value = rangeSensorState.getMinValue();- } else if (value > rangeSensorState.getMaxValue()) {- value = rangeSensorState.getMaxValue();- }-- RangeSensorState newRangeSensorState = rangeSensorState.clone(value);- terminateAndReplaceWith(newRangeSensorState);- }- }-}-diff --git a/agent/src/main/java/org/openremote/agent/rules/RuleEngine.java b/agent/src/main/java/org/openremote/agent/rules/RuleEngine.javadeleted file mode 100644index d01c880c8..000000000--- a/agent/src/main/java/org/openremote/agent/rules/RuleEngine.java+++ /dev/null@@ -1,282 +0,0 @@-/*- * OpenRemote, the Home of the Digital Home.- * Copyright 2008-2016, OpenRemote Inc.- *- * See the contributors.txt file in the distribution for a- * full listing of individual contributors.- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <http://www.gnu.org/licenses/>.- */-package org.openremote.agent.rules;--import org.drools.core.ClockType;-import org.kie.api.KieBase;-import org.kie.api.KieServices;-import org.kie.api.builder.KieBuilder;-import org.kie.api.builder.KieFileSystem;-import org.kie.api.builder.Message;-import org.kie.api.builder.model.KieBaseModel;-import org.kie.api.builder.model.KieModuleModel;-import org.kie.api.conf.EqualityBehaviorOption;-import org.kie.api.conf.EventProcessingOption;-import org.kie.api.io.Resource;-import org.kie.api.io.ResourceType;-import org.kie.api.runtime.KieContainer;-import org.kie.api.runtime.KieSession;-import org.kie.api.runtime.KieSessionConfiguration;-import org.kie.api.runtime.conf.ClockTypeOption;-import org.kie.api.runtime.conf.TimedRuleExectionOption;-import org.kie.api.runtime.rule.FactHandle;-import org.kie.internal.builder.DecisionTableConfiguration;-import org.kie.internal.builder.DecisionTableInputType;-import org.kie.internal.builder.KnowledgeBuilderFactory;-import org.openremote.agent.context.AgentContext;-import org.openremote.agent.sensor.SensorState;-import org.openremote.agent.sensor.SensorStateUpdate;-import org.openremote.container.Container;-import org.openremote.container.util.Util;--import java.util.Collection;-import java.util.HashMap;-import java.util.Map;-import java.util.logging.Level;-import java.util.logging.Logger;--public class RuleEngine {-- private static final Logger LOG = Logger.getLogger(RuleEngine.class.getName());-- private KieBase kb;- private KieSession knowledgeSession;- private Map<Integer, FactHandle> stateSources = new HashMap<>();- private long currentFactCount;-- private SwitchFacade switchFacade;- private LevelFacade levelFacade;- private RangeFacade rangeFacade;- private RulePersistence rulePersistence;- private Util ruleUtil;-- public void start(AgentContext agentContext) {-- KieServices kieServices = KieServices.Factory.get();- KieModuleModel kieModuleModel = kieServices.newKieModuleModel();-- KieBaseModel kieBaseModel = kieModuleModel.newKieBaseModel("OpenRemoteKBase")- .setDefault(true)- .setEqualsBehavior(EqualityBehaviorOption.EQUALITY)- .setEventProcessingMode(EventProcessingOption.STREAM);- KieFileSystem kfs = kieServices.newKieFileSystem();- kfs.writeKModuleXML(kieModuleModel.toXML());-- agentContext.getDeployment().getRulesProvider().getResources(kieServices).forEach(resource ->- addResource(resource, kieServices, kfs)- );-- KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());-- kb = kieContainer.getKieBase();-- KieSessionConfiguration kieSessionConfiguration = kieServices.newKieSessionConfiguration();- // Use this option to ensure timer rules are fired even in passive mode (triggered by fireAllRules.- // This ensures compatibility with the behaviour of previously used Drools 5.1- kieSessionConfiguration.setOption(TimedRuleExectionOption.YES);- if(agentContext.getDroolsClock().equals("pseudo")) {- kieSessionConfiguration.setOption(ClockTypeOption.get("pseudo"));- }-- knowledgeSession = kb.newKieSession(kieSessionConfiguration, null);-- switchFacade = new SwitchFacade();- rangeFacade = new RangeFacade();- levelFacade = new LevelFacade();- rulePersistence = new RulePersistence();- ruleUtil = new Util();-- setGlobal("commands", agentContext.getDeployment().getCommands());- setGlobal("switches", switchFacade);- setGlobal("ranges", rangeFacade);- setGlobal("levels", levelFacade);- setGlobal("persistence", rulePersistence);- setGlobal("util", ruleUtil);- setGlobal("JSON", Container.JSON);- setGlobal("LOG", LOG);-- try {- RuleExecutionLogger ruleExecutionLogger = new RuleExecutionLogger();- knowledgeSession.addEventListener(ruleExecutionLogger);- } catch (Throwable t) {- throw new RuntimeException(t);- }-- LOG.info("Rule engine started");- LOG.info(kieBaseModel.toString());-- knowledgeSession.fireAllRules();- }-- public void stop() {- LOG.fine("Stopping RuleEngine");- if (knowledgeSession != null) {- knowledgeSession.dispose();- LOG.fine("Knowledge session disposed");- }- stateSources.clear();-- // We're disposing of the knowledge base, don't keep references to any facts (ORCJAVA-407)- stateSources.clear();-- kb = null;- }-- public void process(SensorStateUpdate sensorStateUpdate) {- if (kb == null) {- LOG.fine("No knowledge base configured, skipping processing of: " + sensorStateUpdate);- return;- }-- SensorState sensorState = sensorStateUpdate.getSensorState();-- switchFacade.process(sensorStateUpdate);- levelFacade.process(sensorStateUpdate);- rangeFacade.process(sensorStateUpdate);-- try {- long newFactCount;-- // If this fact is not in working memory (considering its equals() method)...- if (!knowledgeSession.getObjects().contains(sensorState)) {-- // ... update or new insert?- boolean isUpdate = true;-- // If there already is a fact in wm with the same sensor ID ...- if (stateSources.keySet().contains(sensorState.getSensorID())) {- try {- // ... retract it from working memory ...- knowledgeSession.delete(stateSources.get(sensorState.getSensorID()));- } finally {- // ... and make we don't keep a reference to a fact- stateSources.remove(sensorState.getSensorID());- }- } else {- isUpdate = false;- }-- // Put the fact into wm and remember the handle- FactHandle handle = knowledgeSession.insert(sensorState);- stateSources.put(sensorState.getSensorID(), handle);-- if (isUpdate) {- LOG.finest("Inserted: " + sensorState);- } else {- LOG.finest("Updated: " + sensorState);- }-- newFactCount = knowledgeSession.getFactCount();- LOG.finest("New fact count: " + newFactCount);- if (newFactCount != currentFactCount) {- LOG.finest("Fact count changed from " + currentFactCount + " to " + newFactCount + " on '" + sensorState.getSensorName() + "'");- }- currentFactCount = newFactCount;- }-- LOG.finest("Firing all rules");- knowledgeSession.fireAllRules();-- // TODO: This doesn't look right, why would it matter if there are 1000 facts? Who says that- // MR: this is heuristic number which comes good for finding facts memory leak in the drl file.- // problem - when you are not careful then drl can insert new facts till memory exhaustion. As there- // are usually few 100 facts in drl's I'm working with, putting arbitrary number gives me early feedback- // that there is potential problem. Perhaps we should think about a better solution to this problem?- newFactCount = knowledgeSession.getFactCount();- if (newFactCount >= 1000) // look for runaway insertion of facts- if (newFactCount != currentFactCount) {- LOG.info("Fact count changed from " + currentFactCount + " to " + newFactCount + " on '" + sensorState.getSensorName() + "'");- }- currentFactCount = newFactCount;-- } catch (Throwable t) {- LOG.log(Level.SEVERE, "Error executing rules for: " + sensorStateUpdate.getSensorState(), t);- if (t.getCause() != null) {- LOG.log(Level.SEVERE, "Root Cause: \n", t.getCause());- }- }- }-- public KieSession getKnowledgeSession() {- return knowledgeSession;- }-- protected void setGlobal(String identifier, Object object) {- try {- knowledgeSession.setGlobal(identifier, object);- } catch (Throwable t) {- // Ignore, Drools complains if the DRL doesn't declare the global, but it works- }- }-- protected void addResource(Resource resource, KieServices kieServices, KieFileSystem kfs) {- String sourcePath = resource.getSourcePath();- if (sourcePath == null) {- throw new IllegalArgumentException("Resource definition must have source path: " + resource);- }- LOG.info("Adding rule definition: " + resource);- try {-- // TODO Drools config API is shit, this is hidden in some internal code- if (ResourceType.DTABLE.matchesExtension(sourcePath)) {- int lastDot = sourcePath.lastIndexOf('.');- if (lastDot >= 0 && sourcePath.length() > lastDot + 1) {- String extension = sourcePath.substring(lastDot + 1);- DecisionTableConfiguration tableConfig = KnowledgeBuilderFactory.newDecisionTableConfiguration();- tableConfig.setInputType(DecisionTableInputType.valueOf(extension.toUpperCase()));- resource.setConfiguration(tableConfig);- }- }-- LOG.fine("Rule definition resource config: " + resource.getConfiguration().toProperties());- kfs.write("src/main/resources/" + sourcePath, resource);- KieBuilder kieBuilder = kieServices.newKieBuilder(kfs).buildAll();-- if (kieBuilder.getResults().hasMessages(Message.Level.ERROR)) {- Collection<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);- LOG.severe("Error in rule definition: " + resource);- for (Message error : errors) {- LOG.severe(error.getText());- }- // If compilation failed, remove rules from FileSystem so it won't fail on next pass here if any- kfs.delete("src/main/resources/" + sourcePath);- } else {- LOG.info("Added rule definition: " + resource);- }- } catch (Throwable t) {- LOG.log(- Level.SEVERE,- "Error in rule definition: " + resource,- t- );- // If compilation failed, remove rules from FileSystem so it won't fail on next pass here if any- kfs.delete("src/main/resources/" + sourcePath);- }- }-- @Override- public String toString() {- return "RuleEngine{" +- "factCount=" + currentFactCount +- "}";- }-}-diff --git a/agent/src/main/java/org/openremote/agent/rules/RuleExecutionLogger.java b/agent/src/main/java/org/openremote/agent/rules/RuleExecutionLogger.javadeleted file mode 100644index 13d36de44..000000000--- a/agent/src/main/java/org/openremote/agent/rules/RuleExecutionLogger.java+++ /dev/null@@ -1,137 +0,0 @@-package org.openremote.agent.rules;--import org.kie.api.definition.rule.Rule;-import org.kie.api.event.rule.BeforeMatchFiredEvent;-import org.kie.api.event.rule.DefaultAgendaEventListener;-import org.kie.api.runtime.rule.Match;-import org.openremote.agent.sensor.SensorState;-import org.openremote.agent.sensor.Sensor;--import java.util.List;-import java.util.Map;-import java.util.logging.Logger;--/**- * This class logs Drools rule execution. It is intended to assist the user in debugging Drools behavior.- */-public class RuleExecutionLogger extends DefaultAgendaEventListener {-- private static final Logger LOG = Logger.getLogger(RuleExecutionLogger.class.getName());-- public static Logger getLOG() {- return LOG;- }-- @Override- public void beforeMatchFired(BeforeMatchFiredEvent event) {- final Rule rule = event.getMatch().getRule();- String ruleName = rule.getName();-- String rulePackage = rule.getPackageName();- ruleName = "\"" + ruleName + "\" // (package " + rulePackage + ")";-- Match matchEvent = event.getMatch();- List<String> declarationIDs = matchEvent.getDeclarationIds();- List<Object> antecedents = matchEvent.getObjects();-- String declarationLog = "";- for (String declarationID : declarationIDs) {- Object declarationValue = matchEvent.getDeclarationValue(declarationID);- String declarationValueString = this.declarationValueToString(declarationValue);- if (declarationValue instanceof Sensor || declarationValue instanceof SensorState) {- declarationLog = String.format("%s\t\tDeclaration: \"%s\"\n\t\tValue:\n\t\t\t%s\n", declarationLog, declarationID, declarationValueString);- } else {- declarationLog = String.format("%s\t\tDeclaration: \"%s: %s\"\n", declarationLog, declarationID, declarationValueString);- }- }-- String objectLog = "";- for (Object antecedent : antecedents) {- String theClass = antecedent.getClass().getSimpleName();- String theValue = this.antecedentValueToString(antecedent);- objectLog = String.format("%s\t\tClass: \"%s\"\n\t\tFields: \n\t\t\t%s\n", objectLog, theClass, theValue);- }-- if (ruleName.startsWith("\"--")) {- LOG.finest(String.format("rule %s\n" +- "\tDeclarations \n%s" +- "\tLHS objects(antecedents)\n%s", ruleName, declarationLog, objectLog));- return;- }-- if (ruleName.startsWith("\"-")) {- LOG.fine(String.format("rule %s\n" +- "\tDeclarations \n%s" +- "\tLHS objects(antecedents)\n%s", ruleName, declarationLog, objectLog));- return;- }-- LOG.info(String.format("rule %s\n" +- "\tDeclarations \n%s" +- "\tLHS objects(antecedents)\n%s", ruleName, declarationLog, objectLog));- }-- /**- * This method converts a declarationValue into a string.- * The need for this method would be obviated if all our facts descended from- * a Fact class with a method to return the most salient value of a fact.- *- * @param antecedent - An object referenced by a drools LHS- */- private String antecedentValueToString(Object antecedent) {- String theValue = null;- if (antecedent != null) {- theValue = antecedent.toString();- }-- if (antecedent instanceof Sensor) //may be unnecessary if we never have raw sensor objects in WM- {- Sensor theSensor = (Sensor) antecedent;- String sensorName = theSensor.getSensorDefinition().getName();- theValue = String.format("Sensor: %s\n", sensorName);-- theValue = String.format("%s\t\tSensor Properties\n", theValue);- Map<String, String> sensorValues = theSensor.getSensorDefinition().getProperties();-- for (Map.Entry<String, String> entry : sensorValues.entrySet()) {- String entryName = entry.getKey();- String entryValue = entry.getValue();- theValue = String.format("%sName: \t\"%s\"\n\t\t\tValue: \t\"%s\"", theValue, entryName, entryValue);- }- }- if (antecedent instanceof SensorState) {- SensorState theSensorState = (SensorState) antecedent;- String sensorName = theSensorState.getSensorName();- String stateValue = theSensorState.getValue().toString(); //assumes all values can directly cast to String- theValue = String.format("Sensor name: \t\"%s\"\n\t\t\tState value: \t\"%s\"", sensorName, stateValue);- }-- return theValue;- }-- /**- * This method converts a declarationValue into a string.- * The need for this method would be obviated if all our facts descended from- * a Fact class with a method to return the unique identifier as a string.- *- * @param declarationValue - The object associated with a drools LHS declaration- */- private String declarationValueToString(Object declarationValue) {- String convertedDeclarationValue = null;- if (declarationValue != null) {- convertedDeclarationValue = declarationValue.toString();- }-- if (declarationValue instanceof Sensor) //may be unnecessary if we never have raw sensor objects in WM- {- convertedDeclarationValue = ((Sensor) declarationValue).getSensorDefinition().getName();- }- if (declarationValue instanceof SensorState) {- String sensorName = ((SensorState) declarationValue).getSensorName();- String sensorValue = ((SensorState) declarationValue).getValue().toString();- convertedDeclarationValue = String.format("Sensor Name: \"%s\"\n\t\t\tSensor Value: \"%s\"", sensorName, sensorValue);- }-- return convertedDeclarationValue;- }-}diff --git a/agent/src/main/java/org/openremote/agent/rules/RulePersistence.java b/agent/src/main/java/org/openremote/agent/rules/RulePersistence.javadeleted file mode 100644index 2bc5ff4ff..000000000--- a/agent/src/main/java/org/openremote/agent/rules/RulePersistence.java+++ /dev/null@@ -1,34 +0,0 @@-package org.openremote.agent.rules;--import java.util.HashMap;-import java.util.Map;-import java.util.logging.Logger;--public class RulePersistence {-- private static final Logger LOG = Logger.getLogger(RulePersistence.class.getName());-- // TODO: This should be persistent on disk- final protected Map<String, String> data = new HashMap<>();-- public void writeData(String key, Object value) {- LOG.fine("Writing '" + key + "': " + value);- data.put(key, value != null ? value.toString() : null);- }-- public String readData(String key) {- LOG.fine("Reading '" + key + "'");- return data.get(key);- }-- public String readData(String key, String defaultValue) {- LOG.fine("Reading '" + key + "', default: " + defaultValue);- return data.containsKey(key) ? data.get(key) : defaultValue;- }-- public void deleteData(String key) {- LOG.fine("Deleting '" + key + "'");- data.remove(key);- }--}diff --git a/agent/src/main/java/org/openremote/agent/rules/RulesProvider.java b/agent/src/main/java/org/openremote/agent/rules/RulesProvider.javadeleted file mode 100644index 1587551d1..000000000--- a/agent/src/main/java/org/openremote/agent/rules/RulesProvider.java+++ /dev/null@@ -1,12 +0,0 @@-package org.openremote.agent.rules;--import org.kie.api.KieServices;-import org.kie.api.io.Resource;--import java.util.stream.Stream;--public interface RulesProvider {-- Stream<Resource> getResources(KieServices kieServices);--}diff --git a/agent/src/main/java/org/openremote/agent/rules/SensorFacade.java b/agent/src/main/java/org/openremote/agent/rules/SensorFacade.javadeleted file mode 100644index da5d78eab..000000000--- a/agent/src/main/java/org/openremote/agent/rules/SensorFacade.java+++ /dev/null@@ -1,32 +0,0 @@-package org.openremote.agent.rules;--import org.openremote.agent.sensor.SensorState;-import org.openremote.agent.sensor.SensorStateUpdate;--import java.util.logging.Logger;--/**- * Provide access to all sensors from rules through {@link #name}.- */-public abstract class SensorFacade<T> {-- private static final Logger LOG = Logger.getLogger(SensorFacade.class.getName());-- protected SensorStateUpdate sensorStateUpdate;-- public void process(SensorStateUpdate sensorStateUpdate) {- this.sensorStateUpdate = sensorStateUpdate;- }-- protected void terminateAndReplaceWith(final SensorState newSensorState) {- sensorStateUpdate.terminate();- LOG.fine("Terminated sensor state update, dispatching new update: " + newSensorState);- Thread t = new Thread(- () -> sensorStateUpdate.getAgentContext().update(newSensorState)- );- t.start();- }-- protected abstract T name(String sensorName) throws Exception;-}-diff --git a/agent/src/main/java/org/openremote/agent/rules/SingleValueSensorFacade.java b/agent/src/main/java/org/openremote/agent/rules/SingleValueSensorFacade.javadeleted file mode 100644index a0f963fd4..000000000--- a/agent/src/main/java/org/openremote/agent/rules/SingleValueSensorFacade.java+++ /dev/null@@ -1,29 +0,0 @@-package org.openremote.agent.rules;--import org.openremote.agent.sensor.SensorState;-import org.openremote.agent.sensor.Sensor;--public abstract class SingleValueSensorFacade<T, U extends SensorState> extends SensorFacade<T> {-- @Override- public T name(String sensorName) throws Exception {- SensorState sensorState = sensorStateUpdate.getAgentContext().queryState(sensorName);-- if (sensorState instanceof Sensor.UnknownState) {- sensorState = createDefaultState(sensorState.getSensorID(), sensorState.getSensorName());- }-- try {- @SuppressWarnings("unchecked")- T result = createAdapter((U) sensorState);- return result;- } catch (ClassCastException ex) {- throw new Exception("Sensor type mismatch: " + sensorState, ex);- }- }-- protected abstract U createDefaultState(int sourceID, String sourceName);-- protected abstract T createAdapter(U sensorState);-}-diff --git a/agent/src/main/java/org/openremote/agent/rules/SwitchFacade.java b/agent/src/main/java/org/openremote/agent/rules/SwitchFacade.javadeleted file mode 100644index 961386cb7..000000000--- a/agent/src/main/java/org/openremote/agent/rules/SwitchFacade.java+++ /dev/null@@ -1,62 +0,0 @@-package org.openremote.agent.rules;--import org.openremote.agent.sensor.SensorState;-import org.openremote.agent.sensor.Sensor;-import org.openremote.agent.sensor.SwitchSensorState;--public class SwitchFacade extends SensorFacade<SwitchFacade.SwitchAdapter> {-- @Override- public SwitchAdapter name(String sensorName) throws Exception {- SensorState evt = sensorStateUpdate.getAgentContext().queryState(sensorName);-- if (evt instanceof Sensor.UnknownState) {- evt = new SwitchSensorState(- evt.getSensorID(),- evt.getSensorName(),- SwitchSensorState.State.OFF.serialize(),- SwitchSensorState.State.OFF- );- }-- if (evt instanceof SwitchSensorState) {- return new SwitchAdapter((SwitchSensorState) evt);- } else {- throw new Exception("Sensor is not switch type: " + sensorName);- }- }-- public class SwitchAdapter {-- private SwitchSensorState switchSensorState;-- private SwitchAdapter(SwitchSensorState switchSensorState) {- this.switchSensorState = switchSensorState;- }-- public void off() {- off(null);- }-- public void off(String value) {- if (value == null) {- value = SwitchSensorState.State.OFF.serialize();- }- SwitchSensorState newSwitchSensorState = switchSensorState.clone(value, SwitchSensorState.State.OFF);- terminateAndReplaceWith(newSwitchSensorState);- }-- public void on() {- on(null);- }-- public void on(String value) {- if (value == null) {- value = SwitchSensorState.State.ON.serialize();- }- SwitchSensorState newSwitchSensorState = switchSensorState.clone(value, SwitchSensorState.State.ON);- terminateAndReplaceWith(newSwitchSensorState);- }- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/CustomSensor.java b/agent/src/main/java/org/openremote/agent/sensor/CustomSensor.javadeleted file mode 100644index 2c957b7b2..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/CustomSensor.java+++ /dev/null@@ -1,196 +0,0 @@-package org.openremote.agent.sensor;--import org.openremote.agent.command.PullCommand;-import org.openremote.agent.command.PushCommand;-import org.openremote.agent.command.SensorUpdateCommand;-import org.openremote.agent.deploy.SensorDefinition;--import java.util.HashMap;-import java.util.Map;-import java.util.Set;-import java.util.logging.Logger;--/**- * A custom sensor operates on a finite set of explicit state values that it returns, see {@link DistinctStates}.- * TODO: Write more docs- */-public class CustomSensor extends Sensor {-- private static final Logger LOG = Logger.getLogger(CustomSensor.class.getName());-- final protected DistinctStates states;- final protected boolean strictStateMapping;-- /**- * This constructor allows subclasses to determine whether the distinct states are passed- * as sensor properties through the {@link PullCommand} and {@link PushCommand} interface.- * When the sensor's type (such as {@link SwitchSensor}) makes the available states explicit,- * it may not be necessary to pass the additional property information to- * {@link SensorUpdateCommand} implementations.- *- * @param updateCommand the command implementation that backs this sensor and can produce the current state- * @param states distinct state values and their mappings this sensor will return- * @param strictStateMapping Indicates whether this sensor instance should enforce strict state mapping rules -- when- * enabled, only state values explicitly declared for this sensor will be accepted and returned.- * If set to false, all values are allowed but those with value mappings will be converted.- */- public CustomSensor(SensorDefinition sensorDefinition, SensorUpdateCommand updateCommand, DistinctStates states, boolean strictStateMapping) {- super(sensorDefinition, updateCommand);- if (states == null) {- this.states = new DistinctStates();- } else {- this.states = states;- }- this.strictStateMapping = strictStateMapping;- }-- /**- * Constructs the state from the raw command output string. This implementation checks the- * incoming value for possible state mappings and returns the mapped state value where necessary.- * Arbitrary, non-declared states are rejected unless {@link #strictStateMapping} has been set- * to false. When set to true, an instance of {@link UnknownState} is returned for any- * non-declared state.- */- @Override- public SensorState process(String value) {- if (!states.hasState(value)) {- if (SensorState.isUnknownState(value)) {- return new UnknownState(this);- }-- if (strictStateMapping) {- LOG.warning("Update command's value is not consistent with '" + getSensorDefinition() + "': " + value);- return new UnknownState(this);- } else {- return createSensorState(value);- }- }-- if (!states.hasMapping(value)) {- return createSensorState(value);- } else {- return createSensorState(states.getMapping(value), value);- }- }-- /**- * Constructs state for this sensor with a given state value. Subclasses can override this- * implementation to provide their own specific state types.- *- * @param value state value- * @return new state instance associated with this sensor- */- protected SensorState createSensorState(String value) {- return new CustomSensorState(getSensorDefinition().getSensorID(), getSensorDefinition().getName(), value);- }-- /**- * Constructs state for this sensor with a given state value, and the originating value- * when state mapping (translation) was used. Subclasses can override this implementation to- * provide their own specific state types.- *- * @param value the translated (mapped) state value- * @param originalValue the original state value returned by the associated update command- * @return new state instance associated with this sensor- */- protected SensorState createSensorState(String value, String originalValue) {- return new CustomSensorState(getSensorDefinition().getSensorID(), getSensorDefinition().getName(), value, originalValue);- }-- /**- * Holds the distinct state values for a custom sensor and possible value mappings if configured.- * <p>- * Each state is available to {@link SensorUpdateCommand} implementers through the sensor- * properties passed via the {@link PullCommand} and {@link PushCommand} APIs. The expected- * state values can be found using a key 'state-1' for the first available state string to- * 'state-n' to the last expected state value.- * TODO This is no longer true, why would the implementers need that info anyway? It's the job of this class to shield them from state mappings!- */- public static class DistinctStates {-- private Map<String, String> states = new HashMap<>();-- /**- * Store an explicit state value without mapping.- */- public void addState(String state) {- states.put(state, null);- }-- /**- * Stores an explicit state value with mapping. When the update command returns the state- * value, it is automatically mapped to a new value to be consumed by UI widgets and other- * users of the sensor.- *- * @param state the state string returned by update command implementations- * @param mapping the value the state string is translated to by the sensor- */- public void addStateMapping(String state, String mapping) {- states.put(state, mapping);- }-- /**- * Indicates if the given state string is contained within this state collection- *- * @param value the requested state string- * @return true if the state string has been added, false otherwise- */- public boolean hasState(String value) {- return states.containsKey(value);- }-- /**- * Returns sensor's state mappings as a string. Implementation delegates to- * {@link Map#toString()}.- *- * @return all state mappings as a string- */- @Override- public String toString() {- return states.toString();- }-- /**- * Indicates if the given state string has a mapping in this state collection- *- * @param state the state string which mapping is requested- * @return true if the state string is mapped to another value in this state- * collection, false otherwise- */- public boolean hasMapping(String state) {- if (!hasState(state)) {- return false;- }- String mapping = states.get(state);- return mapping != null;- }-- /**- * Returns the mapped value of a state string.- *- * @param state the state string which mapping is requested- * @return returns the translated value of a given state string or {@link SensorState#UNKNOWN_VALUE}- */- public String getMapping(String state) {- String mapping = states.get(state);- if (mapping == null) {- return SensorState.UNKNOWN_VALUE;- }- return mapping;- }-- public Set<String> getAllStates() {- return states.keySet();- }- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorDefinition=" + getSensorDefinition() +- ", hasStrictStateMapping=" + strictStateMapping +- ", states=" + states +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/CustomSensorState.java b/agent/src/main/java/org/openremote/agent/sensor/CustomSensorState.javadeleted file mode 100644index eff9b6e18..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/CustomSensorState.java+++ /dev/null@@ -1,58 +0,0 @@-package org.openremote.agent.sensor;--/**- * Holds the original raw value and the result of processing {@link CustomSensor.DistinctStates}.- */-public class CustomSensorState extends SensorState<String> {-- private String value;- private String originalValue;-- public CustomSensorState(int sourceSensorID, String sourceSensorName, String value) {- super(sourceSensorID, sourceSensorName);- this.value = value;- this.originalValue = this.value;- }-- public CustomSensorState(int sourceSensorID, String sourceSensorName, String value, String originalValue) {- this(sourceSensorID, sourceSensorName, value);- this.originalValue = originalValue;- }-- public String getOriginalValue() {- return originalValue;- }-- @Override- public String getValue() {- return value;- }-- @Override- public void setValue(String value) {- this.value = value;- }-- @Override- public String serialize() {- return value;- }-- @Override- public CustomSensorState clone(String newValue) {- // TODO What is this?- throw new Error("NYI");- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorID=" + getSensorID() +- ", sensorName='" + getSensorName() + "'" +- ", timestamp=" + getTimestamp() +- ", value='" + getValue() + '\'' +- ", originalState='" + getOriginalValue() + '\'' +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/LevelSensor.java b/agent/src/main/java/org/openremote/agent/sensor/LevelSensor.javadeleted file mode 100644index 45df83fef..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/LevelSensor.java+++ /dev/null@@ -1,41 +0,0 @@-package org.openremote.agent.sensor;--import org.openremote.agent.command.SensorUpdateCommand;-import org.openremote.agent.deploy.SensorDefinition;--import java.util.logging.Logger;--public class LevelSensor extends RangeSensor {-- private static final Logger LOG = Logger.getLogger(LevelSensor.class.getName());-- public LevelSensor(SensorDefinition sensorDefinition, SensorUpdateCommand sensorUpdateCommand) {- super(sensorDefinition, sensorUpdateCommand, 0, 100);- }-- @Override- public SensorState process(String value) {- try {- return new LevelSensorState(- getSensorDefinition().getSensorID(),- getSensorDefinition().getName(),- new Integer(value.trim())- );- } catch (NumberFormatException e) {- if (!SensorState.isUnknownState(value)) {- LOG.warning("Level sensor '" + getSensorDefinition() + "' produced a non-integer value: " + value);- }- return new UnknownState(this);- }- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorDefinition=" + getSensorDefinition() +- ", minValue=" + getMinValue() +- ", maxValue=" + getMaxValue() +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/LevelSensorState.java b/agent/src/main/java/org/openremote/agent/sensor/LevelSensorState.javadeleted file mode 100644index 7ac812678..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/LevelSensorState.java+++ /dev/null@@ -1,57 +0,0 @@-package org.openremote.agent.sensor;--import java.util.logging.Logger;--/**- * Level sensor state is an integer value in the range of [0..100].- */-public class LevelSensorState extends RangeSensorState {-- private static final Logger LOG = Logger.getLogger(LevelSensorState.class.getName());-- public LevelSensorState(int sourceSensorID, String sourceSensorName, int value) {- super(sourceSensorID, sourceSensorName, validate(sourceSensorID, sourceSensorName, value), 0, 100);- }-- public LevelSensorState clone(int newValue) {- return new LevelSensorState(getSensorID(), getSensorName(), newValue);- }-- /**- * Validate range value to [0..100].- *- * @param sensorID originating sensor ID- * @param sensorName originating sensor name- * @return sensor value unless it is exceeding LEVEL limits in which case it has been limited- * to range [0..100]- */- static protected int validate(int sensorID, String sensorName, int value) {- if (value > 100) {- value = 100;- LOG.log(java.util.logging.Level.WARNING,- "A level sensor update was created with an invalid value : {0} (source = {1} - {2}). " +- "The value should be limited to maximum value of 100.", new Object[]{value, sensorID, sensorName}- );- }-- if (value < 0) {- value = 0;- LOG.log(java.util.logging.Level.WARNING,- "A level sensor udpatewas created with an invalid value : {0} (source = {1} - {2}). " +- "The value should be limited to minimum value of 0.", new Object[]{value, sensorID, sensorName}- );- }- return value;- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorID=" + getSensorID() +- ", sensorName='" + getSensorName() + "'" +- ", timestamp=" + getTimestamp() +- ", value='" + getValue() + "'" +- "}";- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/RangeSensor.java b/agent/src/main/java/org/openremote/agent/sensor/RangeSensor.javadeleted file mode 100644index a9543c663..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/RangeSensor.java+++ /dev/null@@ -1,60 +0,0 @@-package org.openremote.agent.sensor;--import org.openremote.agent.command.SensorUpdateCommand;-import org.openremote.agent.deploy.SensorDefinition;--import java.util.logging.Logger;--public class RangeSensor extends Sensor {-- private static final Logger LOG = Logger.getLogger(RangeSensor.class.getName());-- private int minValue;- private int maxValue;-- public RangeSensor(SensorDefinition sensorDefinition, SensorUpdateCommand sensorUpdateCommand, int minValue, int maxValue) {- super(sensorDefinition, sensorUpdateCommand);- if (minValue > maxValue)- throw new IllegalArgumentException("Sensor value min '" + minValue + "' is larger than max '" + maxValue + "'");- this.minValue = minValue;- this.maxValue = maxValue;- }-- public int getMaxValue() {- return maxValue;- }-- public int getMinValue() {- return minValue;- }-- @Override- protected SensorState process(String value) {- try {- return new RangeSensorState(- getSensorDefinition().getSensorID(),- getSensorDefinition().getName(),- new Integer(value.trim()),- getMinValue(),- getMaxValue()- );- } catch (NumberFormatException exception) {- if (!SensorState.isUnknownState(value)) {- LOG.warning("Range sensor '" + getSensorDefinition() + "' produced a non-integer value: " + value);- }- return new UnknownState(this);- }-- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorDefinition=" + getSensorDefinition() +- ", minValue=" + minValue +- ", maxValue=" + maxValue +- '}';- }-}--diff --git a/agent/src/main/java/org/openremote/agent/sensor/RangeSensorState.java b/agent/src/main/java/org/openremote/agent/sensor/RangeSensorState.javadeleted file mode 100644index 8c1e752e8..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/RangeSensorState.java+++ /dev/null@@ -1,69 +0,0 @@-package org.openremote.agent.sensor;--public class RangeSensorState extends SensorState<Integer> {-- private Integer rangeValue;- private Integer min;- private Integer max;-- public RangeSensorState(int sourceID, String sourceName, Integer value, Integer min, Integer max) {- super(sourceID, sourceName);- this.min = min;- this.max = max;- setValue(value);- }-- public Integer getMinValue() {- return min;- }-- public Integer getMaxValue() {- return max;- }-- @Override- public Integer getValue() {- return rangeValue;- }-- @Override- public void setValue(Integer value) {- // TODO: The LevelSensorState logs when boundaries are breached, why don't we log here?- if (value > max) {- this.rangeValue = max;- } else if (value < min) {- this.rangeValue = min;- } else {- this.rangeValue = value;- }- }-- @Override- public RangeSensorState clone(Integer newValue) {- if (newValue < getMinValue()) {- newValue = getMinValue();- } else if (newValue > getMaxValue()) {- newValue = getMaxValue();- }-- return new RangeSensorState(this.getSensorID(), this.getSensorName(), newValue, getMinValue(), getMaxValue());- }-- @Override- public String serialize() {- return Integer.toString(rangeValue);- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorID=" + getSensorID() +- ", sensorName='" + getSensorName() + "'" +- ", timestamp=" + getTimestamp() +- ", value=" + getValue() +- ", min=" + getMinValue() +- ", max=" + getMaxValue() +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/Sensor.java b/agent/src/main/java/org/openremote/agent/sensor/Sensor.javadeleted file mode 100644index 34f356b3f..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/Sensor.java+++ /dev/null@@ -1,280 +0,0 @@-package org.openremote.agent.sensor;--import org.openremote.agent.command.PullCommand;-import org.openremote.agent.command.PushCommand;-import org.openremote.agent.command.SensorUpdateCommand;-import org.openremote.agent.context.AgentContext;-import org.openremote.agent.deploy.SensorDefinition;--import java.security.AccessController;-import java.security.PrivilegedAction;-import java.util.logging.Level;-import java.util.logging.Logger;--/**- * Sensors create {@link SensorState}s, which represent the data obtained from devices.- * <p>- * A sensor is registered with a {@link AgentContext}. State updates are obtained- * either through pulling/polling or listening to devices that actively push their state- * changes.- * <p>- * A sensor linked with a {@link PullCommand} runs a new thread when started, and executes- * a periodic read.- * <p>- * A sensor linked with a {@link PushCommand} does not create threads, but delegates- * threading and calling back with values to the command implementation.- * <p>- * Each sensor can have list of meta-data properties, used by command implementors.- */-public abstract class Sensor {-- private static final Logger LOG = Logger.getLogger(Sensor.class.getName());-- final protected SensorDefinition sensorDefinition;- final protected SensorUpdateCommand sensorUpdateCommand;- protected AgentContext agentContext;-- /**- * This is a polling thread implementation for sensors that use {@link PullCommand}.- */- protected SensorReader sensorReader;-- protected Sensor(SensorDefinition sensorDefinition, SensorUpdateCommand sensorUpdateCommand) {- if (sensorUpdateCommand == null) {- throw new IllegalArgumentException("Sensor update command required: " + sensorDefinition);- }- this.sensorDefinition = sensorDefinition;- this.sensorUpdateCommand = sensorUpdateCommand;- }-- public SensorDefinition getSensorDefinition() {- return sensorDefinition;- }-- public SensorUpdateCommand getSensorUpdateCommand() {- return sensorUpdateCommand;- }-- public AgentContext getAgentContext() {- return agentContext;- }-- /**- * Indicates if this sensor is bound to a command that actively pushes new data.- */- public boolean isPushCommand() {- return sensorUpdateCommand instanceof PushCommand;- }-- /**- * Starts this sensor. When this sensor is bound to a push command, this invokes the- * {@link PushCommand#start(Sensor)} method. For {@link PullCommand} implementations,- * this will start a polling thread to invoke the {@link PullCommand#read(Sensor)} method.- */- public void start(AgentContext agentContext) {- LOG.info("Starting sensor: " + this);- this.agentContext = agentContext;- if (isPushCommand()) {- PushCommand pushCommand = (PushCommand) sensorUpdateCommand;- try {- pushCommand.start(this);- } catch (Throwable t) {- LOG.log(Level.SEVERE, "There was an implementation error in the push command associated with " +- " sensor '" + this + "'. The command implementation may not have started correctly.", t);- }- } else if (sensorUpdateCommand instanceof PullCommand) {- sensorReader = new SensorReader((PullCommand) sensorUpdateCommand);- sensorReader.start();- } else {- LOG.info("No action implemented for command type: " + sensorUpdateCommand);- }- }-- /**- * Stops this sensor. In case this sensor has been bound to a push command, this invokes the- * {@link PushCommand#stop(Sensor)} method. In case of a {@link PullCommand}, the polling thread- * is stopped.- */- public void stop() {- LOG.info("Stopping sensor: " + this);- agentContext = null;- if (isPushCommand()) {- PushCommand pushCommand = (PushCommand) sensorUpdateCommand;- try {- pushCommand.stop(this);- } catch (Throwable t) {- LOG.log(Level.SEVERE, "There was an implementation error in the push command associated with " +- " sensor '" + this + "'. The command implementation may not have stopped correctly.", t);- }- } else if (sensorReader != null) {- sensorReader.stop();- }- }-- /**- * Callback for {@link PushCommand} implementations. Before updating the agent context, the- * given value is first validated and/or transformed by concrete sensor implementation's- * {@link Sensor#process} method.- */- public void update(String state) {- if (agentContext == null) {- LOG.fine("Ignoring update, sensor is not running: " + getSensorDefinition());- return;- }- SensorState resultState = process(state);- LOG.fine("Update on ID " + getSensorDefinition().getSensorID() + ", input string: '" + state + "', result state: " + resultState);- agentContext.update(resultState);- }-- /**- * Callback to subclasses to apply their state validations and other processing- * if necessary. This method is called both when a value is pulled and when a- * command pushes a new sensor value into {@link AgentContext} state.- */- protected abstract SensorState process(String value);-- /**- * Handles the {@link PullCommand#read(Sensor)} polling.- * <p>- * TODO This is a major problem, every PullCommand uses a separate thread, we have hundreds of threads!- */- private class SensorReader implements Runnable {-- final protected PullCommand pullCommand;-- /**- * Indicates the device polling thread's run state. Notice that for immediate stop, setting- * this to false is not sufficient, but the thread also must be interrupted. See- * {@link SensorReader#stop}.- */- private volatile boolean pollingThreadRunning = true;- private Thread pollingThread;- private int interval;-- public SensorReader(PullCommand pullCommand) {- this.pullCommand = pullCommand;- interval = pullCommand.getPollingInterval() > 0- ? pullCommand.getPollingInterval()- : PullCommand.POLLING_INTERVAL;- LOG.info("Created polling thread interval '" + interval + "' for: " + sensorDefinition);- }-- /**- * Starts the device polling thread.- */- public void start() {- pollingThreadRunning = true;- pollingThread = new Thread(this);- pollingThread.start();- }-- /**- * Stops the device polling thread. Notice that stopping the thread will cause it to exit.- * The same thread cannot be resumed but a new thread will be created via- * {@link SensorReader#start()}.- */- public void stop() {- pollingThreadRunning = false;- try {- AccessController.doPrivilegedWithCombiner((PrivilegedAction<Void>) () -> {- pollingThread.interrupt();- return null;- });- } catch (SecurityException e) {- LOG.log(- Level.WARNING,- "Could not interrupt device polling thread ''{0}'' due to security constraints: {1}\n" +- "the thread will exit in {2} milliseconds...",- new Object[]{pollingThread.getName(), e.getMessage(), interval}- );- }- }-- /**- * Once every given interval defined in {@link PullCommand#POLLING_INTERVAL}, invokes the command.- * Depending on command implementation this may create a concrete request on the device to read- * current state, or it may return a cached value from memory.- */- @Override- public void run() {- while (pollingThreadRunning) {- LOG.fine("Polling: " + Sensor.this);- Sensor.this.update(read());- try {- Thread.sleep(this.interval);- } catch (InterruptedException e) {- pollingThreadRunning = false;- }- }- }-- /**- * Returns the current state of this sensor.- * <p>- * If the sensor is bound to a pull command implementation, the command is invoked --- * this may yield an active request using the connecting transport to device unless the- * command implementation caches certain values and returns them from memory.- * <p>- * In case of errors, {@link SensorState#UNKNOWN_VALUE} is returned.- * <p>- * This default read() implementation does not validate the input from protocol pull commands- * in any way (other than handling implementation errors that yield runtime exceptions).- * concrete subclasses should override and implement {@link Sensor#process(String)}- * to validate the inputs from commands and to ensure the sensor returns values that- * adhere to its datatype.- *- * @return sensor's value, according to its datatype and provided by commands or- * {@link SensorState#UNKNOWN_VALUE} if value cannot be found.- */- private String read() {- try {- return pullCommand.read(Sensor.this);- } catch (Throwable t) {- LOG.log(Level.SEVERE, "Implementation error in pull command: " + sensorUpdateCommand, t);- return SensorState.UNKNOWN_VALUE;- }- }- }-- /**- * A definition of a sensor state that can be used when either an error occurs in sensor- * implementation (or in the underlying protocol implementation) or if the initial device- * state has not been fetched yet.- * <p>- * The value returned by this state is defined in {@link #UNKNOWN_VALUE}.- */- public static class UnknownState extends SensorState<String> {-- public UnknownState(Sensor sensor) {- super(sensor.getSensorDefinition().getSensorID(), sensor.getSensorDefinition().getName());- }-- @Override- public String getValue() {- return serialize();- }-- @Override- public void setValue(String str) {- // NOOP- }-- @Override- public UnknownState clone(String ignored) {- return this;- }-- @Override- public String serialize() {- return UNKNOWN_VALUE;- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sourceId=" + getSensorID() +- ", source='" + getSensorName() + "'" +- "}";- }- }-}diff --git a/agent/src/main/java/org/openremote/agent/sensor/SensorState.java b/agent/src/main/java/org/openremote/agent/sensor/SensorState.javadeleted file mode 100644index 658c5a6ba..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/SensorState.java+++ /dev/null@@ -1,80 +0,0 @@-package org.openremote.agent.sensor;--import org.openremote.agent.context.AgentContext;--/**- * A state snapshot of a sensor, at a particular moment in time.- *- * @param <T> The type of value of this state snapshot.- */-public abstract class SensorState<T> {-- public static final String UNKNOWN_VALUE = "N/A";-- /**- * Helper method to allow subclasses to check if a given value matches the 'N/A' string that- * is used for uninitialized or error states in sensor implementations.- */- public static boolean isUnknownState(String value) {- return value.equals(UNKNOWN_VALUE);- }-- final protected long timestamp = System.currentTimeMillis();- final public int sensorID;- final public String sensorName;-- public SensorState(int sensorID, String sensorName) {- this.sensorID = sensorID;- this.sensorName = sensorName;- }-- public long getTimestamp() {- return timestamp;- }-- public Integer getSensorID() {- return sensorID;- }-- public String getSensorName() {- return sensorName;- }-- public abstract SensorState clone(T newValue);-- public abstract T getValue();-- public abstract void setValue(T value);-- /**- * This method implementation should return an appropriate string representation of the state value.- * This string will be returned by {@link AgentContext#queryValue}.- */- public abstract String serialize();-- /**- * Two sensor states are equal if they have the same sensor ID, sensor name, and value.- */- @Override- public boolean equals(Object o) {- if (o == null) {- return false;- }-- if (o.getClass() != this.getClass()) {- return false;- }-- SensorState that = (SensorState) o;-- return that.getSensorID().equals(this.getSensorID()) &&- that.getSensorName().equals(this.getSensorName()) &&- that.getValue().equals(this.getValue());- }-- @Override- public int hashCode() {- return getSensorID() + getSensorName().hashCode() + getValue().hashCode();- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/SensorStateUpdate.java b/agent/src/main/java/org/openremote/agent/sensor/SensorStateUpdate.javadeleted file mode 100644index 212c8a169..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/SensorStateUpdate.java+++ /dev/null@@ -1,53 +0,0 @@-package org.openremote.agent.sensor;--import org.openremote.agent.context.AgentContext;--import java.util.logging.Logger;--/**- * Before the {@link AgentContext} accepts a sensor state update, it- * executes all rules with a fresh instance of {@link SensorStateUpdate}.- * <p>- * Rules can terminate the update of the context, effectively cancelling the- * original sensor state update. This is the regular behavior when your rules- * write a sensor value through any {@link org.openremote.agent.rules.SensorFacade}.- */-public class SensorStateUpdate {-- private static final Logger LOG = Logger.getLogger(SensorStateUpdate.class.getName());-- private AgentContext agentContext;- private SensorState sensorState;- private boolean terminated = false;-- public SensorStateUpdate(AgentContext agentContext, SensorState evt) {- this.agentContext = agentContext;- this.sensorState = evt;- }-- public void terminate() {- LOG.fine("Terminating state update");- terminated = true;- }-- public boolean hasTerminated() {- return terminated;- }-- public AgentContext getAgentContext() {- return agentContext;- }-- public SensorState getSensorState() {- return sensorState;- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorState=" + sensorState +- ", terminated=" + terminated +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/SwitchSensor.java b/agent/src/main/java/org/openremote/agent/sensor/SwitchSensor.javadeleted file mode 100644index bbbad1466..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/SwitchSensor.java+++ /dev/null@@ -1,76 +0,0 @@-package org.openremote.agent.sensor;--import org.bouncycastle.util.Strings;-import org.openremote.agent.command.SensorUpdateCommand;-import org.openremote.agent.deploy.SensorDefinition;--import java.util.logging.Logger;--/**- * A boolean switch sensor type. This is a specific case of a state sensor with two 'on' or 'off'- * state strings. A switch sensor can be configured to map the default return values to other- * values ("open/close", "running/stoppped", etc.) or to translate return values to local- * languages.- */-public class SwitchSensor extends CustomSensor {-- private static final Logger LOG = Logger.getLogger(SwitchSensor.class.getName());-- /**- * Constructs a new switch sensor with given on/off state mapping. The distinct states should- * contain mapping <b>only</b> for 'on' and 'off' value in case of a switch.- * <p>- * The sensor implementation will return 'on or 'off' string values.- *- * @param producer the udpate command implementation that backs this sensor- * @param states state string mappings for the default 'on' and 'off' values- */- public SwitchSensor(SensorDefinition sensorDefinition, SensorUpdateCommand producer, DistinctStates states) {- super(sensorDefinition, producer, states, true);- }-- /**- * Constructs state with a given value, which must be either 'on' or 'off'.- * Any other value will cause {@link UnknownState} instance to be returned instead.- */- @Override- protected SensorState createSensorState(String value) {- return createSensorState(value, value);- }-- /**- * Constructs state with a given mapped (translated) value and the original- * value which was used for the translation.- * <p>- * The original value must be either 'on' or 'off' (case insensitive), otherwise a- * {@link UnknownState} is returned instead. The translated value can be any- * arbitrary string value.- */- @Override- protected SensorState createSensorState(String value, String originalValue) {- try {- return new SwitchSensorState(- getSensorDefinition().getSensorID(),- getSensorDefinition().getName(),- value,- SwitchSensorState.State.valueOf(Strings.toUpperCase(originalValue.trim())) // TODO WTF- );- } catch (IllegalArgumentException e) {- if (!SensorState.isUnknownState(originalValue)) {- LOG.warning(- "Switch sensor value must be 'on' or 'off', got '" + originalValue + "' in: " + getSensorDefinition()- );- }- return new UnknownState(this);- }- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorDefinition=" + getSensorDefinition() +- ", states=" + states +- '}';- }-}-diff --git a/agent/src/main/java/org/openremote/agent/sensor/SwitchSensorState.java b/agent/src/main/java/org/openremote/agent/sensor/SwitchSensorState.javadeleted file mode 100644index ff2038bf2..000000000--- a/agent/src/main/java/org/openremote/agent/sensor/SwitchSensorState.java+++ /dev/null@@ -1,80 +0,0 @@-package org.openremote.agent.sensor;--public class SwitchSensorState extends SensorState<String> {-- public enum State {-- ON("on"),- OFF("off");-- final private String serializedValue;-- State(String serializedValue) {- this.serializedValue = serializedValue;- }-- public String serialize() {- return serializedValue;- }- }-- private String value;- private State switchState;-- public SwitchSensorState(int sourceID, String sourceName, String value, State switchState) {- super(sourceID, sourceName);-- this.switchState = switchState;- this.value = value;- }-- public SwitchSensorState(int sourceID, String sourceName, State switchState) {- this(sourceID, sourceName, switchState.serialize(), switchState);- }-- public State getState() {- return switchState;- }-- public SwitchSensorState clone(String value, SwitchSensorState.State state) {- if (value == null) {- value = state.serialize();- }- return new SwitchSensorState(getSensorID(), getSensorName(), value, state);- }-- @Override- public SwitchSensorState clone(String newValue) {- if (newValue.equalsIgnoreCase(SwitchSensorState.State.ON.serialize())) {- return clone(null, SwitchSensorState.State.ON);- } else {- return clone(null, SwitchSensorState.State.OFF);- }- }-- @Override- public String getValue() {- return value;- }-- @Override- public void setValue(String value) {- this.value = value;- }-- @Override- public String serialize() {- return getValue();- }-- @Override- public String toString() {- return getClass().getSimpleName() + "{" +- "sensorID=" + getSensorID() +- ", sensorName='" + getSensorName() + "'" +- ", value='" + getValue() + '\'' +- ", switchState=" + switchState +- '}';- }-}-diff --git a/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol b/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocolnew file mode 100644index 000000000..3b4b0a97c--- /dev/null+++ b/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol@@ -0,0 +1,3 @@+org.openremote.agent.protocol.simulator.SimulatorProtocol+org.openremote.agent.protocol.macro.MacroProtocol+org.openremote.agent.protocol.trigger.TriggerProtocol\ No newline at end of filediff --git a/agent/src/main/resources/META-INF/services/org.openremote.agent3.protocol.Protocol b/agent/src/main/resources/META-INF/services/org.openremote.agent3.protocol.Protocoldeleted file mode 100644index f981c554a..000000000--- a/agent/src/main/resources/META-INF/services/org.openremote.agent3.protocol.Protocol+++ /dev/null@@ -1,3 +0,0 @@-org.openremote.agent3.protocol.simulator.SimulatorProtocol-org.openremote.agent3.protocol.macro.MacroProtocol-org.openremote.agent3.protocol.trigger.TriggerProtocol\ No newline at end of filediff --git a/agent/src/main/resources/org/openremote/agent/schemas/agent-3.xsd b/agent/src/main/resources/org/openremote/agent/schemas/agent-3.xsddeleted file mode 100644index 2204ba035..000000000--- a/agent/src/main/resources/org/openremote/agent/schemas/agent-3.xsd+++ /dev/null@@ -1,123 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"- xmlns="http://www.openremote.org/schemas/agent/3"- targetNamespace="http://www.openremote.org/schemas/agent/3">-- <xsd:element name="openremote">- <xsd:complexType>- <xsd:sequence>- <xsd:element ref="sensors"/>- <xsd:element ref="commands"/>- <xsd:element ref="config"/>- </xsd:sequence>- </xsd:complexType>- <xsd:unique name="uniqueIdsAccrossWholeDocument">- <xsd:selector xpath=".//*"/>- <xsd:field xpath="@id"/>- </xsd:unique>- </xsd:element>-- <xsd:element name="sensors">- <xsd:complexType>- <xsd:sequence>- <xsd:element ref="sensor" minOccurs="0" maxOccurs="unbounded"/>- </xsd:sequence>- </xsd:complexType>- </xsd:element>-- <xsd:element name="commands">- <xsd:complexType>- <xsd:sequence>- <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded"/>- </xsd:sequence>- </xsd:complexType>- </xsd:element>-- <xsd:simpleType name="idType">- <xsd:restriction base="xsd:int">- <xsd:minInclusive value="1"/>- </xsd:restriction>- </xsd:simpleType>-- <xsd:element name="sensor">- <xsd:complexType>- <xsd:sequence>- <xsd:group ref="sensorGroup" minOccurs="0" maxOccurs="unbounded"/>- </xsd:sequence>- <xsd:attribute name="id" type="idType" use="required"/>- <xsd:attribute name="type" type="sensorType" use="required"/>- <xsd:attribute name="name" type="xsd:string" use="required"/>- </xsd:complexType>- </xsd:element>-- <xsd:group name="sensorGroup">- <xsd:choice>- <xsd:element ref="include" minOccurs="0" maxOccurs="unbounded"/>- <xsd:element ref="state" minOccurs="0" maxOccurs="unbounded"/>- <xsd:element ref="min" minOccurs="0" maxOccurs="1"/>- <xsd:element ref="max" minOccurs="0" maxOccurs="1"/>- </xsd:choice>- </xsd:group>-- <xsd:element name="min">- <xsd:complexType>- <xsd:attribute name="value" type="xsd:int" use="required"/>- </xsd:complexType>- </xsd:element>-- <xsd:element name="max">- <xsd:complexType>- <xsd:attribute name="value" type="xsd:int" use="required"/>- </xsd:complexType>- </xsd:element>-- <xsd:element name="state">- <xsd:complexType>- <xsd:attribute name="name" use="required"/>- <xsd:attribute name="value" use="optional"/>- </xsd:complexType>- </xsd:element>-- <xsd:simpleType name="sensorType">- <xsd:restriction base="xsd:string">- <xsd:enumeration value="switch"/>- <xsd:enumeration value="level"/>- <xsd:enumeration value="range"/>- <xsd:enumeration value="color"/>- <xsd:enumeration value="custom"/>- </xsd:restriction>- </xsd:simpleType>-- <xsd:element name="command">- <xsd:complexType>- <xsd:sequence>- <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>- </xsd:sequence>- <xsd:attribute name="id" type="idType" use="required"/>- <xsd:attribute name="protocol" type="xsd:string" use="required"/>- </xsd:complexType>- </xsd:element>-- <xsd:element name="include">- <xsd:complexType>- <xsd:attribute name="type" type="xsd:string"/>- <xsd:attribute name="ref" type="idType"/>- </xsd:complexType>- </xsd:element>-- <xsd:element name="property">- <xsd:complexType>- <xsd:attribute name="name" type="xsd:string" use="required"/>- <xsd:attribute name="value" type="xsd:string" use="required"/>- </xsd:complexType>- </xsd:element>-- <xsd:element name="config">- <xsd:complexType>- <xsd:sequence>- <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>- </xsd:sequence>- </xsd:complexType>- </xsd:element>--</xsd:schema>diff --git a/agent/src/test/groovy/org/openremote/test/rules/ClimateControlTest.groovy b/agent/src/test/groovy/org/openremote/test/rules/ClimateControlTest.groovydeleted file mode 100644index a4c4cbce6..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/ClimateControlTest.groovy+++ /dev/null@@ -1,313 +0,0 @@-package org.openremote.test.rules--import org.kie.api.KieServices-import org.kie.api.io.Resource-import org.kie.api.runtime.KieSession-import org.openremote.agent.AgentService-import org.openremote.agent.rules.RulesProvider-import org.openremote.test.ContainerTrait-import spock.lang.Specification-import spock.lang.Unroll-import spock.util.concurrent.BlockingVariable-import spock.util.concurrent.PollingConditions-import spock.lang.Ignore--import java.util.stream.Stream--@Ignore // TODO Still time-sensitive and failing sometimes-class ClimateControlTest extends Specification implements ContainerTrait {-- def "Climate control basic test template"() {-- given: "a deployment with commands and sensors"- def deploymentXml = getClass().getResourceAsStream(- "/org/openremote/test/rules/climatecontrol/agent.xml"- )-- and: "some rules"- def rulesProvider = new RulesProvider() {- @Override- Stream<Resource> getResources(KieServices kieServices) {- Stream.of(- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/climatecontrol/ClimateControl.drl"- )- )- }- }-- and: "the started server"- def testCommandBuilder = new CustomTimeCommandBuilder();- def time = { $time -> testCommandBuilder.currentTime = $time }- def agentService = new AgentService(- deploymentXml,- testCommandBuilder,- rulesProvider,- "pseudo"- )- def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), [agentService])-- def sensor = { $sensor -> agentService.getContext().queryValue($sensor) }- def command = { $name, $arg -> agentService.getContext().getCommands().execute($name, $arg) }- def conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- KieSession ksession = agentService.getContext().getDeployment().getRuleEngine().getKnowledgeSession()- testCommandBuilder.setClock(ksession.getSessionClock())-- // TODO Write tests-- cleanup: "the server should be stopped"- stopContainer(container)- }-- def "Initial values check"() {-- given: "a deployment with commands and sensors"- def deploymentXml = getClass().getResourceAsStream(- "/org/openremote/test/rules/climatecontrol/agent.xml"- )-- and: "some rules"- def rulesProvider = new RulesProvider() {- @Override- Stream<Resource> getResources(KieServices kieServices) {- Stream.of(- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/climatecontrol/ClimateControl.drl"- )- )- }- }-- and: "the started server"- def testCommandBuilder = new CustomTimeCommandBuilder();- def agentService = new AgentService(- deploymentXml,- testCommandBuilder,- rulesProvider,- "pseudo"- )- testCommandBuilder.currentTime = "7"- def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), [agentService])-- def sensor = { $sensor -> agentService.getContext().queryValue($sensor) }- def command = { $name, $arg -> agentService.getContext().getCommands().execute($name, $arg) }-- when: "give some time for initialization rules"- def conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "check all defaults"- conditions.eventually {- // assert sensor("VR1.ET") == "09:00" // used in the old office project only- assert sensor("VR1.ET.inc") == "OFF"- assert sensor("VR1.ET.dec") == "OFF"- assert sensor("VETA.inc") == "OFF"- assert sensor("VETA.dec") == "OFF"- assert sensor("VETD.inc") == "OFF"- assert sensor("VETD.dec") == "OFF"- assert sensor("VR1.COMFORT") == "20.0°"- assert sensor("VR1.COMFORT.inc") == "OFF"- assert sensor("VR1.COMFORT.dec") == "OFF"- assert sensor("VR1.TEMPERATURE") == "16.0\u00B0" // ECO set by heating setpoint ECO rule- assert sensor("VR1.TEMPERATURE.inc") == "OFF"- assert sensor("VR1.TEMPERATURE.dec") == "OFF"- assert sensor("VNEXTACTION") == "Arrive"- assert sensor("VPERSONSENSETIME") == "-"- assert sensor("VLEAVES") == "3.0"- assert sensor("VSCORE") == "4"- assert Double.parseDouble(sensor("VHEATINGSETPOINT")) == 16- assert sensor("VWINDOW") == "Closed"- assert sensor("VADVICEDONE") == "OFF"- assert sensor("VSUMMER") == "No"- assert sensor("VADVICE") == "You're doing great!"- assert sensor("VACATION.inc") == "OFF"- assert sensor("VACATION.dec") == "OFF"- assert sensor("VACATION") == "0"- assert sensor("VTOTALSCORE") == "0"- assert sensor("VLEVEL") == "0"- assert sensor("VATA") == "-"- assert sensor("VATD") == "-"- assert sensor("VPRESENCE") == "No"- assert sensor("GVconfig") == "OpenRemote"- assert sensor("VArrivalBackground") == "on"- assert sensor("VDepartureBackground") == "on"- assert sensor("FS.Toutside") == "15°"- assert sensor("FS.Tinside") == "19.5°"- assert sensor("FS.PIR") == "off"- assert sensor("FS.Window") == "off"- assert sensor("VETA.Mon") == "09:00"- assert sensor("VETD.Mon") == "17:00"- assert sensor("VETA.Tue") == "09:00"- assert sensor("VETD.Tue") == "17:00"- assert sensor("VETA.Wed") == "09:00"- assert sensor("VETD.Wed") == "17:00"- assert sensor("VETA.Thu") == "09:00"- assert sensor("VETD.Thu") == "17:00"- assert sensor("VETA.Fri") == "09:00"- assert sensor("VETD.Fri") == "17:00"- assert sensor("VETA.Sat") == "09:00"- assert sensor("VETD.Sat") == "17:00"- assert sensor("VETA.Sun") == "09:00"- assert sensor("VETD.Sun") == "17:00"- }-- cleanup: "the server should be stopped"- stopContainer(container)- }-- @Unroll("test repeated #i time")- def "Person sense test"() {-- given: "a deployment with commands and sensors"- def deploymentXml = getClass().getResourceAsStream(- "/org/openremote/test/rules/climatecontrol/agent.xml"- )- def result = new BlockingVariable<String>()-- and: "some rules"- def rulesProvider = new RulesProvider() {- @Override- Stream<Resource> getResources(KieServices kieServices) {- Stream.of(- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/climatecontrol/ClimateControl.drl"- )- )- }- }-- and: "the started server"- def testCommandBuilder = new CustomTimeCommandBuilder();- def time = { $time -> testCommandBuilder.currentTime = $time }- time "8:25"- def agentService = new AgentService(- deploymentXml,- testCommandBuilder,- rulesProvider,- "pseudo"- )- def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), [agentService])-- def sensor = { $sensor -> agentService.getContext().queryValue($sensor) }- def command = { $name, $arg -> agentService.getContext().getCommands().execute($name, $arg) }-- KieSession ksession = agentService.getContext().getDeployment().getRuleEngine().getKnowledgeSession()- testCommandBuilder.setClock(ksession.getSessionClock())- time "8:26"-- when: "Set time before going to office"- def conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)- def dow = sensor("TimerEEE")- command "VETA.$dow", "09:00"- command "VETD.$dow", "17:00"-- then: "Check if there is no person"- conditions.eventually {- assert sensor("VNEXTACTION") == "Arrive"- assert sensor("FS.PIR") != "on"- assert sensor("VPERSONSENSE") == "0"- assert sensor("VPRESENCE") == "No"- assert sensor("VHEATING") == "ECO"- assert Double.parseDouble(sensor("VHEATINGSETPOINT")) == 16- assert sensor("VETA.$dow") == "09:00"- assert sensor("VETD.$dow") == "17:00"- }-- when: "now let's enter the office at 10 AM"- time "10:00:00"- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "check if heating is in standby"- conditions.eventually {- assert sensor("VPRESENCE") == "No"- assert sensor("VHEATING") == "Stand-by"- assert Double.parseDouble(sensor("VHEATINGSETPOINT")) == 19- assert sensor("VR1.TEMPERATURE") == "20.0°"- }-- when: "so go in"- command "FS.PIR", "on"- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "see if the arrival is registered"- conditions.eventually {- testCommandBuilder.incDroolsClock()- assert sensor("VNEXTACTION") == "Departure"- assert sensor("VATA") == "10:00"- assert sensor("VPRESENCE") == "Yes"- assert sensor("VHEATING") == "Comfort"- assert sensor("VR1.TEMPERATURE") == "20.0°"- assert Double.parseDouble(sensor("VHEATINGSETPOINT")) == 20- }-- when: "wait 5 sec"- time "10:00:05"- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "assure that PIR is idle"- conditions.eventually {- testCommandBuilder.incDroolsClock()- assert sensor("VPERSONSENSE") == "0"- assert sensor("FS.PIR") == "off"- }-- when: "Advance time 15m"- time "10:15"- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "Check if no presence"- conditions.eventually {- testCommandBuilder.incDroolsClock()- assert sensor("VPRESENCE") == "No"- assert sensor("VHEATING") == "Stand-by"- assert sensor("VR1.TEMPERATURE") == "20.0°"- assert Double.parseDouble(sensor("VHEATINGSETPOINT")) == 19- }-- when: "go home at 4PM"- time "16:00:00"- command "FS.PIR", "on"- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "wait for presence"- conditions.eventually {- testCommandBuilder.incDroolsClock()- assert sensor("VPERSONSENSETIME") == "16:00:00"- }-- when: "Go at midnight adjusting"- time "23:58:00"- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "check departure"- conditions.eventually {- testCommandBuilder.incDroolsClock()- assert sensor("VPRESENCE") == "No"- assert sensor("VATD") == "16:00"- assert sensor("VNEXTACTION") == "-"- assert sensor("VHEATING") == "ECO"- assert Double.parseDouble(sensor("VHEATINGSETPOINT")) == 16- assert sensor("VR1.TEMPERATURE") == "16.0°"- }-- when: "Check updated arrival and departure times"- time "23:59:00"- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "see if times schifted by half an hour"- conditions.eventually {- assert sensor("VETA.$dow") == "09:30"- assert sensor("VETD.$dow") == "16:30"- }-- cleanup: "the server should be stopped"- stopContainer(container)-- where:- i << (1..1)- }--}\ No newline at end of filediff --git a/agent/src/test/groovy/org/openremote/test/rules/CustomTimeCommandBuilder.java b/agent/src/test/groovy/org/openremote/test/rules/CustomTimeCommandBuilder.javadeleted file mode 100644index 019f1e7ae..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/CustomTimeCommandBuilder.java+++ /dev/null@@ -1,61 +0,0 @@-package org.openremote.test.rules;--import org.drools.core.time.impl.PseudoClockScheduler;-import org.openremote.agent.command.Command;-import org.openremote.agent.command.CommandBuilder;-import org.openremote.agent.command.PullCommand;-import org.openremote.agent.command.builtin.DateTimeCommand;-import org.openremote.agent.deploy.CommandDefinition;-import org.openremote.agent.sensor.Sensor;--import java.util.concurrent.TimeUnit;-import java.util.logging.Logger;--public class CustomTimeCommandBuilder extends CommandBuilder {-- private static final Logger LOG = Logger.getLogger(CustomTimeCommandBuilder.class.getName());-- public String currentTime;- public long currentTimeL;- private PseudoClockScheduler clock;-- public void setClock(PseudoClockScheduler droolsClock) {- clock = droolsClock;- clock.setStartupTime(currentTimeL);- }-- public long incDroolsClock() {- if(clock != null) {- clock.advanceTime(1, TimeUnit.SECONDS);- }- return clock.getCurrentTime();- }-- interface MyCustomCommand extends PullCommand {- @Override- default int getPollingInterval() {- return 1000; // We don't want polling to happen in "quick" tests (we get initial state poll)- }- }-- @Override- public Command build(CommandDefinition commandDefinition) {- if (commandDefinition.getProtocolType().equals("datetime")) {- return new MyCustomCommand() {- DateTimeCommand dtcmd = new DateTimeCommand(commandDefinition);-- @Override- public String read(Sensor sensor) {- String calc = dtcmd.calculateData(currentTime);- if(clock != null){- clock.advanceTime(dtcmd.getTime()-clock.getCurrentTime(), TimeUnit.MILLISECONDS);- }- currentTimeL = dtcmd.getTime();- return calc;- }- };-- }- return super.build(commandDefinition);- }-}\ No newline at end of filediff --git a/agent/src/test/groovy/org/openremote/test/rules/MixedWithErrorsTest.groovy b/agent/src/test/groovy/org/openremote/test/rules/MixedWithErrorsTest.groovydeleted file mode 100644index 5cf5c55d2..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/MixedWithErrorsTest.groovy+++ /dev/null@@ -1,67 +0,0 @@-package org.openremote.test.rules--import org.kie.api.KieServices-import org.kie.api.io.Resource-import org.openremote.agent.AgentService-import org.openremote.agent.rules.RulesProvider-import org.openremote.test.ContainerTrait-import spock.lang.Specification--import java.util.stream.Stream--/**- * Test deployment behavior when some of the rule definitions have- * errors or can't be deployed. Make sure the correct ones still- * operate.- */-class MixedWithErrorsTest extends Specification implements ContainerTrait {-- def "Execute good rules - ignore broken rules"() {-- given: "a deployment with commands and sensors"- def deploymentXml = getClass().getResourceAsStream(- "/org/openremote/test/rules/mixed-with-errors/agent.xml"- )-- and: "some rules"- def rulesProvider = new RulesProvider() {- @Override- Stream<Resource> getResources(KieServices kieServices) {- Stream.of(- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/mixed-with-errors/EventMod.drl"- ),- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/mixed-with-errors/IncorrectRule.drl"- ),- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/mixed-with-errors/BrokenDTable.csv"- ),- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/mixed-with-errors/DTableTest.csv"- )- )- }- }-- and: "the started server"- def testCommandBuilder = new TestCommandBuilder();- def agentService = new AgentService(- deploymentXml,- testCommandBuilder,- rulesProvider- )- def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), [agentService])-- when: "we wait a bit for initial state and rules to fire"- Thread.sleep(500)-- then: "the state should match"- agentService.getContext().queryValue(444) == "12345" // TODO This should be limited to max, which is 1000- agentService.getContext().queryValue(555) == "55"-- cleanup: "the server should be stopped"- stopContainer(container)- }-}diff --git a/agent/src/test/groovy/org/openremote/test/rules/PIDTest.groovy b/agent/src/test/groovy/org/openremote/test/rules/PIDTest.groovydeleted file mode 100644index aae1c58a3..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/PIDTest.groovy+++ /dev/null@@ -1,79 +0,0 @@-package org.openremote.test.rules--import org.kie.api.KieServices-import org.kie.api.io.Resource-import org.openremote.agent.AgentService-import org.openremote.agent.rules.RulesProvider-import org.openremote.test.ContainerTrait-import spock.lang.Specification-import spock.util.concurrent.PollingConditions--import java.util.stream.Stream--class PIDTest extends Specification implements ContainerTrait {-- def "PID controller basic test"() {-- given: "a deployment with commands and sensors"- def deploymentXml = getClass().getResourceAsStream(- "/org/openremote/test/rules/pid/agent.xml"- )-- and: "some rules"- def rulesProvider = new RulesProvider() {- @Override- Stream<Resource> getResources(KieServices kieServices) {- Stream.of(- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/pid/PID.drl"- )- )- }- }-- and: "the started server"- def testCommandBuilder = new TestCommandBuilder()- def agentService = new AgentService(- deploymentXml,- testCommandBuilder,- rulesProvider- )- def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), [agentService])-- def sensor = { $sensor -> Double.parseDouble(agentService.getContext().queryValue($sensor)) }- def command = { $name -> agentService.getContext().getCommands().execute($name) }- def conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)--- when: "we increase Sp"- // 2 ways of increasing the set point.- // Set the value of sensor directly:- //def customStateEvent = new CustomSensorState(358537, "PID.sp.inc", "ON");- //agentService.getContext().update(customStateEvent);- // Send a command linked with the button:- command("PID.sp.inc.ON")-- then: "set point should be 1.5"- conditions.eventually {- assert sensor("GV.PID.Sp") == 1.5- assert sensor("PID.Output") == 1.5- }-- when: "we decrease Sp"- command("PID.sp.dec.ON")- conditions = new PollingConditions(timeout: 10, initialDelay: 0.25)-- then: "the PID output should be 1.0"- conditions.eventually {- assert sensor("GV.PID.Sp") == 1 // set point- assert sensor("PID.Output") == 1 // PID output- }-- // TODO: how can I test if there is no overshot?- // TODO: how can I test if there are no oscillations?-- cleanup: "the server should be stopped"- stopContainer(container)- }-}diff --git a/agent/src/test/groovy/org/openremote/test/rules/RuleExecutionLoggerTest.groovy b/agent/src/test/groovy/org/openremote/test/rules/RuleExecutionLoggerTest.groovydeleted file mode 100644index db1c7eb8e..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/RuleExecutionLoggerTest.groovy+++ /dev/null@@ -1,116 +0,0 @@-package org.openremote.test.rules--import org.kie.api.KieBase-import org.kie.api.KieServices-import org.kie.api.builder.KieFileSystem-import org.kie.api.builder.model.KieSessionModel-import org.kie.api.runtime.KieContainer-import org.kie.api.runtime.KieSession-import org.kie.internal.io.ResourceFactory-import org.openremote.agent.sensor.CustomSensorState-import org.openremote.agent.rules.RuleExecutionLogger-import org.openremote.test.ContainerTrait-import spock.lang.Shared-import spock.lang.Specification--import java.util.logging.*--import static org.kie.api.builder.Message.Level.ERROR--class RuleExecutionLoggerTest extends Specification implements ContainerTrait {-- public static TEST_SENSOR_NAME = "SENSOR_NAME";-- @Shared- KieSession ksession-- def setup() {- def kieServices = KieServices.Factory.get()- def kieModuleModel = kieServices.newKieModuleModel()- def kieBaseModel = kieModuleModel.newKieBaseModel("OpenRemoteKBase")- .setDefault(true)- .setEqualsBehavior(org.kie.api.conf.EqualityBehaviorOption.EQUALITY)- def kieSessionModel = kieBaseModel.newKieSessionModel("OpenRemoteKSession")- .setDefault(true)- .setType(KieSessionModel.KieSessionType.STATEFUL)- KieFileSystem kfs = kieServices.newKieFileSystem()- kfs.writeKModuleXML(kieModuleModel.toXML())-- kfs.write(ResourceFactory.newClassPathResource("org/openremote/test/rules/simple/TestRuleFiring.drl")- );- def kieBuilder = kieServices.newKieBuilder(kfs).buildAll();-- if (kieBuilder.getResults().hasMessages(ERROR)) {- throw new RuntimeException("KIE builder has errors")- }-- KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId())- KieBase kb = kieContainer.getKieBase();- ksession = kb.newKieSession();- }-- def cleanup() {- if (ksession != null) {- ksession.dispose()- ksession = null;- }- }-- /**- * This test confirms the plumbing for the event listener is working.- * This test is testing the following behavior:- * The event listener detects rule activations.- * The listener fires "BeforeMatchFired" in response to rule activations.- * The listener is properly detecting and logging information about the rule (name, declarations, LHS, etc.).- */- def "Event listener plumbing"() {- given: "a custom state event"- CustomSensorState newState = new CustomSensorState(1, TEST_SENSOR_NAME, "ON");- ksession.insert(newState)-- and: "a logger of rule execution"- RuleExecutionLogger ruleExecutionLogger = new RuleExecutionLogger()- ksession.addEventListener(ruleExecutionLogger)- //add a handler so logging output can be stored in active memory- Logger ruleLogger = ruleExecutionLogger.getLOG()- def testLogHandler = new TestLogHandler()- ruleLogger.addHandler(testLogHandler);- ruleLogger.setLevel(Level.ALL);-- when: "rules are fired"- ksession.fireAllRules();-- String lastLog = String.format("rule \"%s\" // (package org.openremote.test.rules)\n" +- "\tDeclarations \n\t\tDeclaration: \"\$e\"\n\t\tValue:\n\t\t\tSensor Name: \"%s\"\n\t\t\tSensor Value: \"ON\"\n" +- "\tLHS objects(antecedents)\n\t\tClass: \"CustomSensorState\"\n\t\tFields: \n\t\t\tSensor name: \t\"%s\"\n\t\t\tState value: \t\"ON\"\n", "TestRuleFiring", TEST_SENSOR_NAME, TEST_SENSOR_NAME);-- then: "the execution should be logged"- testLogHandler.lastLevel == Level.INFO- testLogHandler.lastMessage == lastLog- }-- static class TestLogHandler extends Handler {-- Level lastLevel- String lastMessage;-- TestLogHandler() {- this.setLevel(Level.ALL);- this.setFormatter(new SimpleFormatter());- }-- @Override- void publish(LogRecord record) {- lastLevel = record.getLevel();- lastMessage = record.getMessage();- }-- @Override- void flush() {- }-- @Override- void close() {- }- }-}\ No newline at end of filediff --git a/agent/src/test/groovy/org/openremote/test/rules/SimpleRuleTest.groovy b/agent/src/test/groovy/org/openremote/test/rules/SimpleRuleTest.groovydeleted file mode 100644index 2abf91bd2..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/SimpleRuleTest.groovy+++ /dev/null@@ -1,82 +0,0 @@-package org.openremote.test.rules--import org.kie.api.KieServices-import org.kie.api.io.Resource-import org.openremote.agent.AgentService-import org.openremote.agent.rules.RulesProvider-import org.openremote.test.ContainerTrait-import spock.lang.Specification-import spock.util.concurrent.PollingConditions--import java.util.stream.Stream--/**- * Basic rule engine test, trigger a rule through an event.- * The rule dispatches a new event, replacing the original event.- */-class SimpleRuleTest extends Specification implements ContainerTrait {-- def "Sensor event replaced by rule-triggered event"() {-- given: "a deployment with commands and sensors"- def deploymentXml = getClass().getResourceAsStream(- "/org/openremote/test/rules/simple/agent.xml"- )-- and: "some rules"- def rulesProvider = new RulesProvider() {- @Override- Stream<Resource> getResources(KieServices kieServices) {- Stream.of(- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/simple/EventMod.drl"- )- )- }- }-- and: "the started server"- def agentService = new AgentService(- deploymentXml,- new TestCommandBuilder(),- rulesProvider- )- def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), [agentService])- def conditions = new PollingConditions(timeout: 10)-- expect: "the rules should immediately switch the sensor off again"- conditions.eventually {- assert agentService.getContext().queryValue(123) == "off"- }-- and: "the deployment model should work"- conditions.eventually {- def deployment = agentService.getContext().getDeployment()- deployment.getCommandDefinition(456).getCommandID() == 456- deployment.getCommandDefinition(123123) == null- deployment.getCommandDefinition("TestDevice", "TestCommand").getCommandID() == 456- deployment.getCommandDefinition("TestDevice", "NoSuchThing") == null- deployment.getCommandDefinition("NoSuchThing", "NoSuchThing") == null- deployment.getCommandDefinition("", "") == null- deployment.getCommandDefinition(null, "") == null- deployment.getCommandDefinition("", null) == null- deployment.getCommandDefinition(null, null) == null- deployment.getCommandDefinition("TestCommand").getCommandID() == 456- deployment.getCommandDefinition("NoSuchThing") == null- deployment.getCommandDefinition("") == null- deployment.getCommandDefinition(null) == null- deployment.getDevices().length == 1- deployment.getDevices()[0].getName() == "TestDevice"- deployment.getDevices()[0].getDeviceID() == 111- deployment.getDevice("TestDevice").getName() == "TestDevice"- deployment.getDevice("TestDevice").getDeviceID() == 111- deployment.getConfig().get("someString") == "BAR"- deployment.getConfig().get("someBoolean") == "true"- deployment.getConfig().get("someInteger") == "333"- }-- cleanup: "the server should be stopped"- stopContainer(container)- }-}diff --git a/agent/src/test/groovy/org/openremote/test/rules/TestCommandBuilder.java b/agent/src/test/groovy/org/openremote/test/rules/TestCommandBuilder.javadeleted file mode 100644index b30694bac..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/TestCommandBuilder.java+++ /dev/null@@ -1,51 +0,0 @@-package org.openremote.test.rules;--import org.openremote.agent.command.Command;-import org.openremote.agent.command.CommandBuilder;-import org.openremote.agent.command.ExecutableCommand;-import org.openremote.agent.command.PullCommand;-import org.openremote.agent.deploy.CommandDefinition;--import java.util.logging.Logger;--public class TestCommandBuilder extends CommandBuilder {-- private static final Logger LOG = Logger.getLogger(TestCommandBuilder.class.getName());-- public String lastExecutionArgument;-- interface TestPullCommand extends PullCommand {- @Override- default int getPollingInterval() {- return 10000; // We don't want polling to happen in "quick" tests (we get initial state poll)- }- }-- @Override- public Command build(CommandDefinition commandDefinition) {- Command command = super.build(commandDefinition);- if (command != null)- return command;-- if (!commandDefinition.getProtocolType().equals("test"))- throw new IllegalArgumentException("Don't know how to build protocol: " + commandDefinition.getProtocolType());-- switch(commandDefinition.getProperty("what-are-we-testing")) {- case "a-test-custom-state":- return (TestPullCommand) sensor -> "foo";- case "a-test-switch":- return (TestPullCommand) sensor -> "on";- case "a-test-range":- return (TestPullCommand) sensor -> "123";- case "a-test-level":- return (TestPullCommand) sensor -> "55";- case "an-executable-command":- return (ExecutableCommand) value -> {- LOG.info("### Executing " + commandDefinition + " with arg: " + value);- lastExecutionArgument = value;- };- default:- throw new UnsupportedOperationException("Can't build test command: " + commandDefinition);- }- }-}diff --git a/agent/src/test/groovy/org/openremote/test/rules/VacationTest.groovy b/agent/src/test/groovy/org/openremote/test/rules/VacationTest.groovydeleted file mode 100644index 259dfe072..000000000--- a/agent/src/test/groovy/org/openremote/test/rules/VacationTest.groovy+++ /dev/null@@ -1,96 +0,0 @@-package org.openremote.test.rules--import org.kie.api.KieServices-import org.kie.api.io.Resource-import org.openremote.agent.AgentService-import org.openremote.agent.rules.RulesProvider-import org.openremote.agent.sensor.CustomSensorState-import org.openremote.agent.sensor.SwitchSensorState-import org.openremote.test.ContainerTrait-import spock.lang.Specification--import java.util.stream.Stream--import static org.kie.api.io.ResourceType.DRL--class VacationTest extends Specification implements ContainerTrait {-- def "Vacation example"() {-- given: "a deployment with commands and sensors"- def deploymentXml = getClass().getResourceAsStream(- "/org/openremote/test/rules/vacation/agent.xml"- )-- and: "some rules"- def rulesProvider = new RulesProvider() {- @Override- Stream<Resource> getResources(KieServices kieServices) {- Stream.of(- kieServices.getResources().newClassPathResource(- "org/openremote/test/rules/vacation/Vacation.drl"- ).setResourceType(DRL)- )- }- }-- and: "the started server"- def testCommandBuilder = new TestCommandBuilder();- def agentService = new AgentService(- deploymentXml,- testCommandBuilder,- rulesProvider- )- def serverPort = findEphemeralPort()- def container = startContainer(defaultConfig(serverPort), [agentService])-- when: "the time of day is day"- def customStateEvent = new CustomSensorState(123, "time of day", "day");- agentService.getContext().update(customStateEvent);-- and: "we wait a bit for the rules to fire"- Thread.sleep(100);-- then: "the temperature change should be executed"- testCommandBuilder.lastExecutionArgument == "21"-- when: "the time of day is night"- customStateEvent = new CustomSensorState(123, "time of day", "night");- agentService.getContext().update(customStateEvent);-- and: "we wait a bit for the rules to fire"- Thread.sleep(100);-- then: "the temperature change should be executed"- testCommandBuilder.lastExecutionArgument == "18"-- when: "we go on vacation"- def switchEvent = new SwitchSensorState(789, "vacation start", "on", SwitchSensorState.State.ON);- agentService.getContext().update(switchEvent);-- and: "we wait a bit for the rules to fire"- Thread.sleep(100);-- then: "the temperature change should be executed"- testCommandBuilder.lastExecutionArgument == "15"-- when: "the time of day is day"- customStateEvent = new CustomSensorState(123, "time of day", "day");- agentService.getContext().update(customStateEvent);-- and: "we wait a bit for the rules to fire"- Thread.sleep(100);-- then: "the temperature change should be executed"- testCommandBuilder.lastExecutionArgument == "15"-- when: "we manually set the temperature"- agentService.getContext().getCommands().execute("temp", 19)-- then: "the temperature change should be executed"- testCommandBuilder.lastExecutionArgument == "19"-- cleanup: "the server should be stopped"- stopContainer(container)- }-}diff --git a/agent/src/test/resources/logging.properties b/agent/src/test/resources/logging.propertiesdeleted file mode 100644index b7e6bb9eb..000000000--- a/agent/src/test/resources/logging.properties+++ /dev/null@@ -1,38 +0,0 @@-# Used in test runs--handlers=java.util.logging.ConsoleHandler, org.openremote.manager.server.syslog.SyslogService-java.util.logging.ConsoleHandler.formatter=org.openremote.container.util.LogFormatter--# Set this to FINEST to see all messages on console-java.util.logging.ConsoleHandler.level=FINEST--.level=INFO--# Set this to FINEST to receive all messages in the syslog service-org.openremote.level=FINEST--# Set to FINE to log full exception stack traces-org.openremote.container.web.WebServiceExceptions.level=FINE--# Low-level debugging-org.openremote.container.message.MessageBrokerContext.level=INFO-org.hibernate.level=WARNING-org.hibernate.cfg.beanvalidation.TypeSafeActivator.level=SEVERE-com.zaxxer.hikari.level=WARNING-javax.management.level=WARNING-org.xnio.level=WARNING-org.apache.camel.management.level=WARNING-org.apache.camel.impl.converter.DefaultTypeConverter.level=WARNING-org.apache.camel.impl.DefaultShutdownStrategy.level=SEVERE-com.google.gwt.place.shared.PlaceHistoryHandler.level=SEVERE--# Set to SEVERE to log invalid access tokens-org.keycloak.adapters.BearerTokenRequestAuthenticator.level=SEVERE--# Set this to FINEST to log outgoing HTTP traffic-org.apache.http.level=WARNING-org.apache.http.impl.conn.DefaultClientConnection.level=WARNING--# Set this to FINEST to log SQL execution-org.hibernate.SQL.level=WARNING-org.hibernate.type.descriptor.sql.BasicBinder.level=WARNINGdiff --git a/agent/src/test/resources/org/openremote/test/rules/climatecontrol/ClimateControl.drl b/agent/src/test/resources/org/openremote/test/rules/climatecontrol/ClimateControl.drldeleted file mode 100644index 8c7d2ddaf..000000000--- a/agent/src/test/resources/org/openremote/test/rules/climatecontrol/ClimateControl.drl+++ /dev/null@@ -1,1355 +0,0 @@-package org.openremote.agent.test.rules;--import java.util.concurrent.*;-import java.util.Date;-import java.text.SimpleDateFormat;-import java.io.*;-import org.openremote.agent.sensor.*;--global org.openremote.agent.command.Commands commands;-global org.openremote.agent.rules.RulePersistence persistence;--declare SensorState- @role(event)-end--rule "-PSB: Init"-salience 10-then- commands.execute("VR1.ET", persistence.readData("VR1.ET","--:--"));- commands.execute("VR1.ET.inc", "OFF");- commands.execute("VR1.ET.dec", "OFF");- commands.execute("VETA.inc", "OFF");- commands.execute("VETA.dec", "OFF");- commands.execute("VETD.inc", "OFF");- commands.execute("VETD.dec", "OFF");- commands.execute("VR1.COMFORT",persistence.readData("VR1.COMFORT","20.0\u00B0"));- commands.execute("VR1.COMFORT.inc","OFF");- commands.execute("VR1.COMFORT.dec","OFF");- commands.execute("VR1.TEMPERATURE","19.5\u00B0");- commands.execute("VR1.TEMPERATURE.inc","OFF");- commands.execute("VR1.TEMPERATURE.dec","OFF");- commands.execute("VNEXTACTION",persistence.readData("VNEXTACTION","-")); // Earlier arrive with reset- commands.execute("VPERSONSENSETIME","-");- commands.execute("VLEAVES", "1.0");- commands.execute("VSCORE", "0");- commands.execute("VHEATINGSETPOINT", "16");- commands.execute("VWINDOW","Closed");- commands.execute("VADVICEDONE", "OFF");- commands.execute("VSUMMER", "No");- commands.execute("VADVICE", "You're doing great!");- commands.execute("VACATION.inc", "OFF");- commands.execute("VACATION.dec", "OFF");- commands.execute("VACATION", persistence.readData("VACATION", "0"));- commands.execute("VTOTALSCORE",persistence.readData("VTOTALSCORE", "0"));- commands.execute("VLEVEL", persistence.readData("VLEVEL", "0"));- commands.execute("VATA", persistence.readData("VATA","-"));- commands.execute("VATD", persistence.readData("VATD","-"));- commands.execute("VPRESENCE","No");- commands.execute("GVconfig",persistence.readData("GVconfig", "OpenRemote"));- commands.execute("VArrivalBackground", "on");- commands.execute("VDepartureBackground", "off");-end--rule "-PSB: Init ETA when empty"-salience 9-when- SensorState(sensorName matches "VETA.*", $s: sensorName, value=="")-then- commands.execute($s, persistence.readData($s, "09:00"));-end--rule "-PSB: Init ETD when empty"-salience 8-when- SensorState(sensorName matches "VETD.*", $s: sensorName, value=="")-then- commands.execute($s, persistence.readData($s, "17:00"));-end--rule "--Show timers"-salience 10-// timer(int:100)-when- SensorState(sensorName=="TimerEEEE", $a:value!="N/A")- SensorState(sensorName=="Timerd", $b:value!="N/A")- SensorState(sensorName=="TimerHH", $d:value!="N/A")- SensorState(sensorName=="TimerMMM", $c:value!="N/A")- SensorState(sensorName=="TimerEEE", value!="N/A")-then- LOG.info("Sensor clock is: "+$a+" "+$b+" "+$c+" "+$d);- LOG.info("Drools SessionClock() is: "+(new java.util.Date(drools.getWorkingMemory().getSessionClock().getCurrentTime())).toString());-end--rule "--PSB: store values"-timer(int: 2s)-when-(- SensorState($s:sensorName matches "VET.*", $v:value!="", eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VACATION", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VTOTALSCORE", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VLEVEL", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VR1.COMFORT", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VATA", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VATD", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VNEXTACTION", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VR1.ET", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VETA", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName=="VETD", $v:value, eval(!persistence.readData($s,"").equals($v))) ||- SensorState($s:sensorName matches "^GV.*", $v:value, eval(!persistence.readData($s,"").equals($v)))-)-then- LOG.fine($s+" old value: "+persistence.readData($s,"||")+"; new value:"+$v.toString());- persistence.writeData($s, $v);-end--rule "-PSB: VR1.ET Inc"- timer(int:300ms) // debounce & protect double click-when- SensorState(sensorName == "VR1.ET", $v: value)- SensorState(sensorName == "VR1.ET.inc" , value == "ON")-then- commands.execute("VR1.ET", util.shiftTime($v.toString(), 5));- commands.execute("VR1.ET.inc", "off");- commands.execute("VR1.ET.dec", "OFF");-end--rule "-PSB: VETA Inc"- timer(int:300ms) // debounce & protect double click-when- SensorState(sensorName == "VETA", $v: value)- SensorState(sensorName == "VETA.inc" , value == "ON")-then- commands.execute("VETA", util.shiftTime($v.toString(), 5));- commands.execute("VETA.inc", "off");- commands.execute("VETA.dec", "OFF");-end--rule "-PSB: VETD Inc"- timer(int:300ms) // debounce & protect double click-when- SensorState(sensorName == "VETD", $v: value)- SensorState(sensorName == "VETD.inc" , value == "ON")-then- commands.execute("VETD", util.shiftTime($v.toString(), 5));- commands.execute("VETD.inc", "off");- commands.execute("VETD.dec", "OFF");-end--rule "-PSB: VR1.ET Dec"- timer(int:300ms)-when- SensorState(sensorName == "VR1.ET", $v: value)- SensorState(sensorName == "VR1.ET.dec" , value == "ON")-then- commands.execute("VR1.ET", util.shiftTime($v.toString(), -15));- commands.execute("VR1.ET.inc", "OFF");- commands.execute("VR1.ET.dec", "off");-end--rule "-PSB: VETA Dec"- timer(int:300ms)-when- SensorState(sensorName == "VETA", $v: value)- SensorState(sensorName == "VETA.dec" , value == "ON")-then- commands.execute("VETA", util.shiftTime($v.toString(), -15));- commands.execute("VETA.inc", "OFF");- commands.execute("VETA.dec", "off");-end--rule "-PSB: VETD Dec"- timer(int:300ms)-when- SensorState(sensorName == "VETD", $v: value)- SensorState(sensorName == "VETD.dec" , value == "ON")-then- commands.execute("VETD", util.shiftTime($v.toString(), -15));- commands.execute("VETD.inc", "OFF");- commands.execute("VETD.dec", "off");-end--rule "PSB: VUSERSCHEDULECHANGES change counter"- timer(int: 30s) // Wait 30s to mark user's schedule change-when-(- SensorState($s:sensorName == "VR1.ET.inc" , value == "off") ||- SensorState($s:sensorName == "VR1.ET.dec" , value == "off") ||- SensorState($s:sensorName == "VETA.inc" , value == "off") ||- SensorState($s:sensorName == "VETA.dec" , value == "off") ||- SensorState($s:sensorName == "VETD.inc" , value == "off") ||- SensorState($s:sensorName == "VETD.dec" , value == "off")-)-then- // off - changed by user- // OFF - idle state after restart- commands.execute($s, "OFF");- int cnt = 0;- try{- cnt = Integer.parseInt(persistence.readData("VUSERSCHEDULECHANGES","0"));- }finally{- cnt += 1;- persistence.writeData("VUSERSCHEDULECHANGES", cnt);- }-end--rule "PSB: set departure time on manual VR1.ET change"- salience 10- timer(int: 300ms)-when- SensorState(sensorName == "VR1.ET", $v: value)-(- SensorState(sensorName == "VR1.ET.inc" , value == "ON") ||- SensorState(sensorName == "VR1.ET.dec" , value == "ON") ||- SensorState(sensorName == "VETD.inc", value == "ON") ||- SensorState(sensorName == "VETD.dec", value == "ON")-)- SensorState(sensorName == "VNEXTACTION", value == "-")-then- commands.execute("VNEXTACTION", "Departure");-end--rule "PSB: VR1.COMFORT inc"- timer(int:300ms)-when- SensorState(sensorName == "VR1.COMFORT", $v: value, eval(util.parseDouble(value) < 24))- SensorState(sensorName == "VR1.COMFORT.inc" , value == "ON")-then- commands.execute("VR1.COMFORT.inc","off");- commands.execute("VR1.COMFORT.dec","OFF");- commands.execute("VR1.COMFORT", util.shiftDouble($v.toString(), 0.5, "\u00B0"));-end--rule "PSB: VR1.COMFORT dec"- timer(int:300ms)-when- SensorState(sensorName == "VR1.COMFORT", $v: value, eval(util.parseDouble(value) > 18))- SensorState(sensorName == "VR1.COMFORT.dec" , value == "ON")-then- commands.execute("VR1.COMFORT.inc","OFF");- commands.execute("VR1.COMFORT.dec","off");- commands.execute("VR1.COMFORT", util.shiftDouble($v.toString(), -0.5, "\u00B0"));-end--rule "PSB: VR1.COMFORT INC/dec" // needed when change on the boundary- salience -10- timer(int:300ms)-when- SensorState(sensorName == "VR1.COMFORT.inc" , value == "ON")-then- commands.execute("VR1.COMFORT.inc","off");- commands.execute("VR1.COMFORT.dec","OFF");-end--rule "PSB: VR1.COMFORT inc/DEC" // needed when change on the boundary- salience -10- timer(int:300ms)-when- SensorState(sensorName == "VR1.COMFORT.dec" , value == "ON")-then- commands.execute("VR1.COMFORT.inc","OFF");- commands.execute("VR1.COMFORT.dec","off");-end--rule "PSB: VR1.TEMPERATURE inc"- timer(int:300ms)-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName == "VR1.TEMPERATURE", $v: value, eval(util.parseDouble(value) <26))- SensorState(sensorName == "VR1.TEMPERATURE.inc" , value == "ON")-then- commands.execute("VR1.TEMPERATURE.inc","off");- commands.execute("VR1.TEMPERATURE.dec","OFF"); // Do not increase change counter- commands.execute("VR1.TEMPERATURE", util.shiftDouble($v.toString(), 0.5, "\u00B0"));-end--rule "PSB: VR1.TEMPERATURE dec"- timer(int:300ms)-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName == "VR1.TEMPERATURE", $v: value, eval(util.parseDouble(value) > 16)) // Lower temp limit- SensorState(sensorName == "VR1.TEMPERATURE.dec" , value == "ON")-then- commands.execute("VR1.TEMPERATURE.inc","OFF");- commands.execute("VR1.TEMPERATURE.dec","off");- commands.execute("VR1.TEMPERATURE", util.shiftDouble($v.toString(), -0.5, "\u00B0"));-end--rule "PSB: VR1.TEMPERATURE INC/dec" // needed when on the boundary and in summer- salience -10- timer(int:300ms)-when- SensorState(sensorName == "VR1.TEMPERATURE.inc" , value == "ON")-then- commands.execute("VR1.TEMPERATURE.inc","off");- commands.execute("VR1.TEMPERATURE.dec","OFF");-end--rule "PSB: VR1.TEMPERATURE inc/DEC" // needed when on the boundary and in summer- salience -10- timer(int:300ms)-when- SensorState(sensorName == "VR1.TEMPERATURE.dec" , value == "ON")-then- commands.execute("VR1.TEMPERATURE.inc","OFF");- commands.execute("VR1.TEMPERATURE.dec","off");-end--rule "PSB: VR1.TEMPERATURE change counter"- timer(int: 30s) // Wait 30s to mark user's temperature change-when-(- SensorState($s:sensorName == "VR1.TEMPERATURE.inc" , value == "off") ||- SensorState($s:sensorName == "VR1.TEMPERATURE.dec" , value == "off") ||- SensorState($s:sensorName == "VR1.COMFORT.inc" , value == "off") ||- SensorState($s:sensorName == "VR1.COMFORT.dec" , value == "off")-)-then- // off - changed by user- // OFF - idle state after restart- commands.execute($s, "OFF");- int cnt = 0;- try{- cnt = Integer.parseInt(persistence.readData("VSETTEMPCHANGES","0"));- }finally{- cnt += 1;- persistence.writeData("VSETTEMPCHANGES", cnt);- }-end--rule "PSB: VR1.TEMPERATURE change summer"-salience 10-when- SensorState(sensorName=="VSUMMER", value=="Yes")-(- SensorState(sensorName == "VR1.TEMPERATURE.inc" , $s: sensorName, value == "ON") ||- SensorState(sensorName == "VR1.TEMPERATURE.dec", $s: sensorName, value == "ON")-)-then- commands.execute($s, "OFF");-end--rule "PSB: set departure on manual TEMPERATURE change after expected attendance"-salience 10- timer(int:300ms)-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName == "VR1.ET", $et: value)-(- SensorState(sensorName == "VR1.TEMPERATURE.inc" , value == "ON") ||- SensorState(sensorName == "VR1.TEMPERATURE.dec" , value == "ON")-)- SensorState(sensorName == "VNEXTACTION", value == "-")-then- // Set departure time when temp manually adjusted after leave- commands.execute("VNEXTACTION", "Departure");- commands.execute("VR1.ET", util.shiftTime($et.toString(), 60));- commands.execute("VETD", util.shiftTime($et.toString(), 60));-end--rule "-PSB: Move ETA to ET at midnight"-when- SensorState(sensorName=="TimerEEE", $e:value)- SensorState(sensorName=="TimerHH",$h:value,eval(util.parseTimestamp(value) >= util.parseTimestamp("00:02"))) // Wait 2 minutes to be sure that $e is OK- SensorState(sensorName matches ("VETA."+$e), eval(util.parseTimestamp(value) > util.parseTimestamp($h)), $va:value)- SensorState(sensorName matches ("VETD."+$e), $vd: value)- SensorState(sensorName=="VNEXTACTION", value=="-")- SensorState(sensorName=="VACATION", eval(Integer.parseInt(value.toString())==0))-then- commands.execute("VR1.ET", $va.toString());- commands.execute("VETA", $va.toString());- commands.execute("VETD", $vd.toString());- commands.execute("VNEXTACTION", "Arrive");-end--rule "-Move ETA ETD for current day"-when- SensorState(sensorName=="TimerEEE", $e:value)- SensorState(sensorName matches ("VETA."+$e), $va:value)- SensorState(sensorName matches ("VETD."+$e), $vd: value)-then- commands.execute("VETA", $va.toString());- commands.execute("VETD", $vd.toString());-end--rule "-PSB: reset VATA"-when- SensorState(sensorName=="VNEXTACTION", value=="Arrive")-then- commands.execute("VATA","-");-end--rule "-PSB: reset VATD"-when- SensorState(sensorName=="VATA",value=="-")-then- commands.execute("VATD","-");-end--rule "PSB: decrease vacation counter at midnight"-when- $timer: SensorState(sensorName=="TimerHH", value!="N/A", eval(value.toString().substring(0,5).equals("00:00"))) // more reliable than timer(cron: )- SensorState(sensorName=="VACATION", $v: value, eval(Integer.parseInt(value.toString())>0), this before [2m] $timer)-then- commands.execute("VACATION", Integer.parseInt($v.toString())-1);-end--rule "PSB: reset action at midnight"-when- SensorState(sensorName=="TimerHH", value!="N/A", eval(value.toString().substring(0,5).equals("00:00"))) // more reliable than timer(cron: )-then- commands.execute("VR1.ET", "-");- commands.execute("VNEXTACTION", "-");-end--rule "-PSB: Move ETD to ET at arrive init"-// This one is needed for cases when system is restart after arrive time-when- SensorState(sensorName=="TimerEEE",$e:value)- SensorState(sensorName=="TimerHH",$h:value)- SensorState(sensorName matches ("VETA."+$e), eval(util.parseTimestamp(value) <= util.parseTimestamp($h)), eval(value.toString().length()==5))- SensorState(sensorName matches ("VETD."+$e), $vd:value, eval(value.toString().length()==5))-// SensorState(sensorName=="VNEXTACTION", value=="-")- SensorState(sensorName=="VR1.ET", value == "--:--")-then- commands.execute("VR1.ET", $vd.toString());- commands.execute("VETD", $vd.toString());- commands.execute("VNEXTACTION", "Departure");-end--rule "-PSB: Move ETD to ET at arrive"-when- SensorState(sensorName=="TimerEEE",$e:value)- SensorState(sensorName=="TimerHH",$h:value)- SensorState(sensorName=="VNEXTACTION", value=="Arrive")- SensorState(sensorName matches ("VETD."+$e), $vd:value)- SensorState(sensorName=="VETA", value != "-", value != "--:--", value != "status")- SensorState(sensorName=="VETA", eval(util.parseTimestamp(value) < util.parseTimestamp($h)))- SensorState(sensorName=="VACATION", eval(Integer.parseInt(value.toString())==0))-then- commands.execute("VR1.ET", $vd.toString());- commands.execute("VNEXTACTION", "Departure");-end--rule "PSB: actual arrival time earlier when temperature increased and person detected"-timer(int: 10s) // Prevent glitch at midnight reset-when- // Before attendance schedule- SensorState(sensorName=="TimerHH",$h:value)- SensorState(sensorName=="VNEXTACTION", value=="Arrive")- // Temperature increased manually (higher than ECO)- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VR1.COMFORT", $vc: value)- SensorState(sensorName=="VR1.TEMPERATURE", eval(util.parseDouble(value) > java.lang.Math.max(util.parseDouble($vc)-5.0, 16.0)))- // Person detected- SensorState(sensorName=="VPERSONSENSE", value == "1")- SensorState(sensorName=="VATA",value=="-")-then- commands.execute("VR1.ET", $h.toString().substring(0,5));-end--rule "PSB: fetch actual arrival time"-when- SensorState(sensorName=="TimerHH", $h:value)- SensorState(sensorName=="VATA", value == "-")- SensorState(sensorName=="VNEXTACTION", value=="Departure")- SensorState(sensorName=="VPERSONSENSE", value=="1")-then- commands.execute("VATA", $h.toString().substring(0,5));-end--rule "PSB: fetch earlier actual arrival time up to 30 min v02"-when- SensorState(sensorName=="TimerHH", $h:value, eval(util.parseTimestamp(value) >= util.parseTimestamp("04:30"))) // Earliest time of arrival is 4:30 AM- SensorState(sensorName=="VATA", value == "-")- SensorState(sensorName=="VNEXTACTION", value=="Arrive")- SensorState(sensorName=="VPERSONSENSE", value=="1")- SensorState(sensorName=="VETA", value != "-", value != "--:--")- SensorState(sensorName=="VETA", eval(util.parseTimestamp(util.shiftTime(value,-30)) <= util.parseTimestamp($h)))-then- commands.execute("VATA", $h.toString().substring(0,5));-end--rule "PSB: Move - to ET at end of work"-timer(int: 1s) // avoid racing-when- SensorState(sensorName=="TimerHH",$h:value)- SensorState(sensorName=="VETD", value != "-", value != "--:--")- SensorState(sensorName=="VETD", eval(util.parseTimestamp(value) < util.parseTimestamp($h)))- SensorState(sensorName=="VNEXTACTION", value=="Departure")-then- commands.execute("VR1.ET", "-");- commands.execute("VNEXTACTION", "-");-end--rule "PSB: Move - to ET on vacation"-when- SensorState(sensorName=="VACATION", eval(Integer.parseInt(value.toString())>0))-then- commands.execute("VR1.ET", "-");- commands.execute("VNEXTACTION", "-");-end--rule "PSB: fetch actual departure time"-when- SensorState(sensorName=="VATA", value != "-")- SensorState(sensorName=="VATD", value == "-")- SensorState(sensorName=="VNEXTACTION", value=="-")- SensorState(sensorName=="VPERSONSENSETIME", $v:value, eval(value.toString().length()>4))-then- commands.execute("VATD", $v.toString().substring(0,5));- commands.execute("VPERSONSENSETIME","-");-end--rule "PSB: fetch later departure time"-when- SensorState(sensorName=="TimerEEE",$e:value)- SensorState(sensorName=="VNEXTACTION", value=="-")- SensorState(sensorName matches ("VETD."+$e), $vd:value)- SensorState(sensorName=="VATA", value != "-")- SensorState(sensorName=="VATD", value != "-")- SensorState(sensorName=="VPERSONSENSETIME", $v:value, eval(value.toString().length()>4),- eval(util.parseTimestamp(value)<=util.parseTimestamp(util.shiftTime($vd,15))), // Till 15 min after scheduled departure- eval(util.parseTimestamp(value)<=util.parseTimestamp("23:55"))) // Till 23:55 - does not wrap on midnight- SensorState(sensorName=="VACATION", eval(Integer.parseInt(value.toString())==0))-then- commands.execute("VATD", $v.toString().substring(0,5));- commands.execute("VPERSONSENSETIME","-");-end--rule "PSB: adjust estimated times at midnight"-when- SensorState(sensorName=="TimerEEE", $e: value)- $timer: SensorState(sensorName=="TimerHH", value!="N/A", eval(value.toString().substring(0,5).equals("23:58"))) // more reliable than timer(cron: )- SensorState(sensorName matches ("VETD."+$e), $ved:value, this before [1m] $timer) // Loop cut- SensorState(sensorName matches ("VETA."+$e), $vea:value, this before [1m] $timer)- SensorState(sensorName=="VATD", $vd:value, value!="-")- SensorState(sensorName=="VATA", $va:value, value!="-")- SensorState(sensorName=="VACATION", eval(Integer.parseInt(value.toString())==0))-then- Double alpha = 2.0/(3+1); // 3 stays for 3 days exponential average- long nt = (long) (alpha*util.parseTimestamp($va) + (1-alpha)*util.parseTimestamp($vea));- commands.execute("VETA."+$e.toString(), util.formatTimestamp(nt));- LOG.fine("EA="+$vea.toString()+" AA="+$va.toString()+" NA="+ util.formatTimestamp(nt));- nt = (long) (alpha*util.parseTimestamp($vd) + (1-alpha)*util.parseTimestamp($ved));- commands.execute("VETD."+$e.toString(), util.formatTimestamp(nt));- LOG.fine("ED="+$ved.toString()+" AD="+$vd.toString()+" ND="+ util.formatTimestamp(nt));-end--rule "--PSB: move sense"-when- SensorState($s:sensorName=="FS.PIR", value=="on")- SensorState(sensorName=="TimerHH", $h:value)-then- LOG.info("Move sense on "+$s+" @"+$h);- commands.execute("VPERSONSENSETIME", $h.toString());-end--rule "--pir echo"-when- SensorState(sensorName=="FS.PIR", $v:value)- SensorState(sensorName=="TimerHH", $h:value)-then- LOG.info("PIR state "+$v.toString()+" @"+$h);-end--rule "-PSB: person sense"-when- SensorState($s:sensorName=="FS.PIR", value=="on")- SensorState(sensorName=="VPERSONSENSE", value!="1")-then- commands.execute("VPERSONSENSE", "1");-end--rule "-PSB: no person sense"-timer(int: 2s)-when- SensorState(sensorName=="FS.PIR", value!="on")- SensorState(sensorName=="VPERSONSENSE", value!="0")-then- commands.execute("VPERSONSENSE", "0");-end--rule "-PSB: window open sense"-when- SensorState(sensorName=="FS.Window", value=="on")-then- commands.execute("VWINDOW","Open");-end--rule "-PSB: window closed sense"-when- SensorState(sensorName=="FS.Window", value=="off")-then- commands.execute("VWINDOW","Closed");-end--rule "--FS outside temperature sense"-when- SensorState(sensorName=="FS.Toutside", $v: value)-then- commands.execute("VOUTSIDE", $v.toString() );- LOG.fine("Fake outside temperature: "+$v.toString() );-end--rule "--FS inside temperature sense"-when- SensorState(sensorName=="FS.Tinside", $v: value)-then- LOG.fine("Fake inside temperature: "+ $v.toString() );- commands.execute("VROOMTEMPERATURE", $v.toString() );-end--rule "PSB: Presence"-when- SensorState(sensorName == "VPERSONSENSE", value == "1")- SensorState(sensorName=="VNEXTACTION", value=="Departure") // within expected attendance schedule-then- commands.execute("VPRESENCE","Yes");-end--rule "PSB: Absence when 30 min no movement"-timer(int: 30m)-when- SensorState(sensorName == "VPERSONSENSE", value == "0")- SensorState(sensorName=="VNEXTACTION", value=="Departure") // within expected attendance schedule-then- commands.execute("VPRESENCE","No");-end--rule "PSB: Absence after 15 min v02"-timer(int: 15m)-when- SensorState(sensorName == "VPERSONSENSE", value == "0")-then- commands.execute("VPRESENCE","No");-end--rule "-PSB: Absence after scheduled presence time"-when- SensorState(sensorName=="VNEXTACTION", value!="Departure") // outsidse expected attendance schedule-then- commands.execute("VPRESENCE","No");-end--rule "-PSB: heating ECO"-when-(- SensorState(sensorName=="VNEXTACTION", value!="Departure") || // outsidse expected attendance schedule- SensorState(sensorName=="VSUMMER", value=="Yes")-)-then- commands.execute("VHEATING","ECO");-end--rule "-PSB: heating Stand-by from ECO"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VNEXTACTION", value=="Departure") // within expected attendance schedule- SensorState(sensorName=="VPRESENCE", value=="No")- SensorState(sensorName=="VHEATING", value == "ECO")- SensorState(sensorName=="VR1.COMFORT", $vc: value)-then- commands.execute("VR1.TEMPERATURE", $vc.toString());- commands.execute("VHEATING", "Stand-by");-end--rule "-PSB: heating Stand-by from ECO preheating 30 min v02"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VNEXTACTION", value=="Arrive") // within expected attendance schedule- SensorState(sensorName=="VHEATING", value == "ECO")- SensorState(sensorName=="VR1.COMFORT", $vc: value)-- SensorState(sensorName=="TimerHH", $h:value, eval(util.parseTimestamp(value) >= util.parseTimestamp("04:30"))) // Earliest time of arrival is 4:30 AM- SensorState(sensorName=="VETA", value != "-", value != "--:--")- SensorState(sensorName=="VETA", eval(util.parseTimestamp(util.shiftTime(value,-30)) <= util.parseTimestamp($h)))-then- commands.execute("VR1.TEMPERATURE", $vc.toString());- commands.execute("VHEATING", "Stand-by");-end--rule "-PSB: heating Stand-by from Comfort"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VNEXTACTION", value=="Departure") // within expected attendance schedule- SensorState(sensorName=="VPRESENCE", value=="No")- SensorState(sensorName=="VHEATING", value == "Comfort")- SensorState(sensorName=="VR1.COMFORT", $vc: value)- SensorState(sensorName=="VR1.TEMPERATURE", value==$vc) // Only when no manual temperature increase-then- commands.execute("VHEATING","Stand-by");-end--rule "-PSB: heating Comfort on presence"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VPRESENCE", value=="Yes")- SensorState(sensorName=="VR1.COMFORT", $v: value)-then- commands.execute("VHEATING","Comfort");- commands.execute("VR1.TEMPERATURE", $v.toString());-end--rule "-PSB: heating Comfort on temperature increase"-timer(int: 1s) // debounce-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VR1.COMFORT", $vc: value)- SensorState(sensorName=="VR1.TEMPERATURE", eval(util.parseDouble(value) > util.parseDouble($vc)))- SensorState(sensorName=="VHEATING", value != "Comfort")-then- commands.execute("VHEATING","Comfort");-end--rule "-PSB: heating setpoint ECO"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATING", value=="ECO")- SensorState(sensorName=="VR1.COMFORT", $v: value)-then- String s = $v.toString();- Double t;- try{- t = java.lang.Math.max(16.0, Double.parseDouble(s.substring(0,s.length()-1))-5); // 5 degrees below comfort- } catch (NumberFormatException e){- t = 16.0;- }- commands.execute("VHEATINGSETPOINT", String.format("%.1f",t));- commands.execute("VR1.TEMPERATURE", String.format("%.1f\u00B0",t));-end--rule "-PSB: heating setpoint ECO summer"-when- SensorState(sensorName=="VSUMMER", value=="Yes")- SensorState(sensorName=="VHEATING", value=="ECO")- SensorState(sensorName=="VR1.COMFORT", $v: value)-then- String s = $v.toString();- Double t = java.lang.Math.max(16.0, Double.parseDouble(s.substring(0,s.length()-1))-5); // 5 degrees below comfort- commands.execute("VHEATINGSETPOINT", String.format("%.1f",t));- commands.execute("VR1.TEMPERATURE", "-");-end--rule "-PSB: heating setpoint Stand-by"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATING", value=="Stand-by")- SensorState(sensorName=="VR1.COMFORT", $v: value)- SensorState(sensorName=="VR1.TEMPERATURE", value==$v) // When temperature changed manually keep it till ECO-then- String s = $v.toString();- Double t = java.lang.Math.max(16.0, Double.parseDouble(s.substring(0,s.length()-1))-1); // 1 degree below comfort- commands.execute("VHEATINGSETPOINT", String.format("%.1f",t));- commands.execute("VR1.TEMPERATURE", s); // But the user is not aware as on display there is comfort-end--rule "-PSB: heating setpoint Comfort"-timer(int: 1s) // avoid race between "VHEATING" & "VR1.TEMPERATURE"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATING", value=="Comfort")- SensorState(sensorName=="VR1.TEMPERATURE", $v: value) // set by rule "PSB: heating Comfort" to VR1.COMFORT or manually-then- String s = $v.toString();- Double t = java.lang.Math.max(16.0, Double.parseDouble(s.substring(0,s.length()-1)));- commands.execute("VHEATINGSETPOINT", String.format("%.1f",t));-end--rule "-PSB: leaves 0"-when- SensorState(sensorName=="VLEAVES", value=="0.0")-then- commands.execute("VLEAF1", "l0.png");- commands.execute("VLEAF2", "l0.png");- commands.execute("VLEAF3", "l0.png");-end--rule "-PSB: leaves 0.5"-when- SensorState(sensorName=="VLEAVES", value=="0.5")-then- commands.execute("VLEAF1", "l1.png");- commands.execute("VLEAF2", "l0.png");- commands.execute("VLEAF3", "l0.png");-end--rule "-PSB: leaves 1"-when- SensorState(sensorName=="VLEAVES", value=="1.0")-then- commands.execute("VLEAF1", "l2.png");- commands.execute("VLEAF2", "l0.png");- commands.execute("VLEAF3", "l0.png");-end--rule "-PSB: leaves 1.5"-when- SensorState(sensorName=="VLEAVES", value=="1.5")-then- commands.execute("VLEAF1", "l2.png");- commands.execute("VLEAF2", "l1.png");- commands.execute("VLEAF3", "l0.png");-end--rule "-PSB: leaves 2"-when- SensorState(sensorName=="VLEAVES", value=="2.0")-then- commands.execute("VLEAF1", "l2.png");- commands.execute("VLEAF2", "l2.png");- commands.execute("VLEAF3", "l0.png");-end--rule "-PSB: leaves 2.5"-when- SensorState(sensorName=="VLEAVES", value=="2.5")-then- commands.execute("VLEAF1", "l2.png");- commands.execute("VLEAF2", "l2.png");- commands.execute("VLEAF3", "l1.png");-end--rule "-PSB: leaves 3"-when- SensorState(sensorName=="VLEAVES", value=="3.0")-then- commands.execute("VLEAF1", "l2.png");- commands.execute("VLEAF2", "l2.png");- commands.execute("VLEAF3", "l2.png");-end--rule "-PSB: energy efficiency 1"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 23)) // Comfort+- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="No")-then- commands.execute("VLEAVES", "0.0");- commands.execute("VSCORE", 0);-end--rule "-PSB: energy efficiency 2"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 23)) // Comfort+- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes")- SensorState(sensorName=="VWINDOW", value=="Open")-then- commands.execute("VLEAVES", "0.5");- commands.execute("VSCORE", 0);-end--// v02-rule "-PSB: energy efficiency 2-1 v02"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Open")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) < 23)) // Comfort, Comfort-, Comfort--- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="No")- SensorState(sensorName=="VOUTSIDE", $t: value)- SensorState(sensorName=="VR1.TEMPERATURE", eval(util.parseDouble($t) < util.parseDouble(value))) // Lower outside temperature-then- commands.execute("VLEAVES", "0.5");- commands.execute("VSCORE", 0);-end--rule "-PSB: energy efficiency 2-2 v02"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Closed")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 23)) // Comfort+- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="No")-then- commands.execute("VLEAVES", "0.5");- commands.execute("VSCORE", 0);-end--rule "-PSB: energy efficiency 2-3 v02"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Closed")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) < 23), eval(Double.parseDouble(value.toString()) >= 18)) // Comfort, Comfort-, Comfort--, not eco- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="No")-then- commands.execute("VLEAVES", "1.0");- commands.execute("VSCORE", 0);-end-// v02--rule "-PSB: energy efficiency 3"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 21), eval(Double.parseDouble(value.toString()) < 23)) // Comfort- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="No")-then- commands.execute("VLEAVES", "1.0");- commands.execute("VSCORE", 0);-end--rule "-PSB: energy efficiency 4"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Open") // Added because otherwise it overrules efficiency 11- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 21), eval(Double.parseDouble(value.toString()) < 23)) // Comfort- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes")-then- commands.execute("VLEAVES", "1.0");- commands.execute("VSCORE", 0);-end--rule "-PSB: energy efficiency 5"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATING", value=="Stand-by")- SensorState(sensorName=="VPRESENCE", value=="No")- SensorState(sensorName=="VWINDOW", value=="Open")-then- commands.execute("VLEAVES", "1.0");- commands.execute("VSCORE", 0);-end--rule "-PSB: energy efficiency 6"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 23)) // Comfort+- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes")- SensorState(sensorName=="VWINDOW", value=="Open")-then- commands.execute("VLEAVES", "1.0");- commands.execute("VSCORE", 0);-end--rule "-PSB: energy efficiency 7"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Open")- SensorState(sensorName=="VHEATING", value=="Stand-by")- SensorState(sensorName=="VPRESENCE", value=="No")- SensorState(sensorName=="VOUTSIDE", $t: value)- SensorState(sensorName=="VR1.TEMPERATURE", eval(util.parseDouble($t) < util.parseDouble(value))) // Lower outside temperature-then- commands.execute("VLEAVES", "1.5");- commands.execute("VSCORE", 1);-end--rule "-PSB: energy efficiency 8"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Open")- SensorState(sensorName=="VHEATING", value=="ECO")- SensorState(sensorName=="VPRESENCE", value=="No")- SensorState(sensorName=="VOUTSIDE", $t: value)- SensorState(sensorName=="VR1.TEMPERATURE", eval(util.parseDouble($t) < util.parseDouble(value))) // Lower outside temperature-then- commands.execute("VLEAVES", "1.5");- commands.execute("VSCORE", 1);-end--rule "-PSB: energy efficiency 9"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Closed")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 23)) // Comfort+- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes")-then- commands.execute("VLEAVES", "1.5");- commands.execute("VSCORE", 1);-end--rule "-PSB: energy efficiency 10"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Open")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 20), eval(Double.parseDouble(value.toString()) < 21)) // Comfort-- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes")- SensorState(sensorName=="VOUTSIDE", $t: value)- SensorState(sensorName=="VR1.TEMPERATURE", eval(util.parseDouble($t) < util.parseDouble(value))) // Lower outside temperature-then- commands.execute("VLEAVES", "1.5");- commands.execute("VSCORE", 1);-end--rule "-PSB: energy efficiency 11"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Closed")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 21), eval(Double.parseDouble(value.toString()) < 23)) // Comfort- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes")-then- commands.execute("VLEAVES", "2.0");- commands.execute("VSCORE", 2);-end--rule "-PSB: energy efficiency 12 v02"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Closed")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) >= 20), eval(Double.parseDouble(value.toString()) < 21)) // Comfort-- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes") // v02-then- commands.execute("VLEAVES", "2.5");- commands.execute("VSCORE", 3);-end--rule "-PSB: energy efficiency 13"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Open")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) < 20)) // Comfort--- SensorState(sensorName=="VHEATING", value!="ECO") // needed because of race- SensorState(sensorName=="VPRESENCE", value=="Yes")- SensorState(sensorName=="VOUTSIDE", $t: value)- SensorState(sensorName=="VR1.TEMPERATURE", eval(util.parseDouble($t) >= util.parseDouble(value))) // Higher outside temperature-then- commands.execute("VLEAVES", "3.0");- commands.execute("VSCORE", 4);-end--rule "-PSB: energy efficiency 14"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Closed")- SensorState(sensorName=="VHEATING", value=="ECO")- SensorState(sensorName=="VPRESENCE", value=="No")-then- commands.execute("VLEAVES", "3.0");- commands.execute("VSCORE", 4);-end--rule "-PSB: energy efficiency 15"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VWINDOW", value=="Closed")- SensorState(sensorName=="VHEATINGSETPOINT", eval(Double.parseDouble(value.toString()) < 20)) // Comfort--- SensorState(sensorName=="VPRESENCE", value=="Yes") // No important IMHO-then- commands.execute("VLEAVES", "3.0");- commands.execute("VSCORE", 4);-end--rule "-PSB: energy efficiency Summer"-when- SensorState(sensorName=="VSUMMER", value=="Yes")-then- commands.execute("VLEAVES", "3.0");- commands.execute("VSCORE", 4);-end--rule "--PSB: increase total score every 15m"-when- $timer: SensorState(sensorName=="TimerHH", value!="N/A", eval(Integer.parseInt(value.toString().substring(3,5)) % 15 == 0)) // more reliable than timer(cron: )- SensorState(sensorName=="VSCORE", $s: value)- SensorState(sensorName=="VTOTALSCORE", $ts: value, this before [1m] $timer)-then- commands.execute("VTOTALSCORE", Integer.parseInt($ts.toString())+Integer.parseInt($s.toString()));-end--rule "PSB: reward"-when- $ts: SensorState(sensorName=="VTOTALSCORE", $s: value, eval(Integer.parseInt(value.toString()) >= 1000))- SensorState(sensorName=="VLEVEL", $l: value, this before [1m] $ts)-then- Integer i = Integer.parseInt($s.toString());- commands.execute("VTOTALSCORE", i-1000); // Reset score- commands.execute("VLEVEL", Integer.parseInt($l.toString())+1);-end--rule "--PSB: display totalscore"-when- SensorState(sensorName=="VTOTALSCORE", $ts: value)-then- commands.execute("VTOTALSCOREdisp", $ts+" / 1000");-end--rule "PSB: summer"-timer(int: 1h)-when-// SensorState(sensorName=="VR1.COMFORT", $sp: value)-// SensorState(sensorName=="VOUTSIDE", value!="", eval(util.parseDouble($sp) <= util.parseDouble(value) )) // Outside temp higher than set point- SensorState(sensorName=="VOUTSIDE", $o:value) // Only for logging- SensorState(sensorName=="YT.summer", value=="0") // Y-con test- SensorState(sensorName=="VSUMMER", value!="Yes")-then- LOG.fine("Summer is ON; outside="+$o.toString());- commands.execute("VSUMMER", "Yes");-end--rule "PSB: no summer"-timer(int: 1h)-when-// SensorState(sensorName=="VR1.COMFORT", $sp: value)-// SensorState(sensorName=="VOUTSIDE", value!="", eval(util.parseDouble($sp) > util.parseDouble(value) )) // Outside temp lower than set point- SensorState(sensorName=="VOUTSIDE", $o:value) // Only for logging- SensorState(sensorName=="YT.summer", value=="1") // Y-con test- SensorState(sensorName=="VSUMMER", value!="No")-then- LOG.fine("Summer is OFF; outside="+$o.toString());- commands.execute("VSUMMER", "No");-end--rule "-PSB: advice 1"-when- SensorState(sensorName=="VWINDOW", value=="Open")- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VHEATINGSETPOINT", $sp: value)- SensorState(sensorName=="VOUTSIDE", value!="", eval(Double.parseDouble($sp.toString()) > util.parseDouble(value) )) // Outside temp lower than set point-then- commands.execute("VADVICE", "It's more energy efficient to close the windows when it is colder outside than it is inside");- commands.execute("VADVICEDONE", "OFF");- insert(new AdviceGiven("It's more energy efficient to close the windows when it is colder outside than it is inside"));-end--rule "-PSB: advice 1 done"-when- SensorState(sensorName=="VHEATINGSETPOINT", $sp: value)-(- SensorState(sensorName=="VWINDOW", value=="Closed") ||- SensorState(sensorName=="VOUTSIDE", value!="", eval(Double.parseDouble($sp.toString()) <= util.parseDouble(value) )) // Outside temp lower than set point-)- SensorState(sensorName=="VADVICE",eval(value.toString().substring(0,9).equals("It's more")))-then- commands.execute("VADVICE", "You're doing great!");- commands.execute("VADVICEDONE", "OFF");-end--rule "-PSB: advice 2"-when- SensorState(sensorName=="VSUMMER", value=="No")- SensorState(sensorName=="VR1.COMFORT", eval(util.parseDouble(value) > 20.5)) // Average is 20 hardcoded or from sensor?-then- commands.execute("VADVICE", "Your comfort temperature is set higher than average. You can adjust it on the settings page.");- commands.execute("VADVICEDONE", "OFF");- insert(new AdviceGiven("Your comfort temperature is set higher than average. You can adjust it on the settings page."));-end--rule "-PSB: advice 2 done"-when- SensorState(sensorName=="VR1.COMFORT", eval(util.parseDouble(value) <= 20.5)) // Average is 20 hardcoded or from sensor?- SensorState(sensorName=="VADVICE",eval(value.toString().substring(0,12).equals("Your comfort")))-then- commands.execute("VADVICE", "You're doing great!");- commands.execute("VADVICEDONE", "OFF");-end--rule "-PSB: advice 3"-when-// irregular attendence-then- commands.execute("VADVICEDONE", "OFF");-end--rule "-PSB: advice 4"-when-(- SensorState(sensorName=="VADVICEDONE", value=="ON") ||- SensorState(sensorName=="VSUMMER", value=="Yes")-)-then- commands.execute("VADVICE", "You're doing great!");- commands.execute("VADVICEDONE", "OFF");- insert(new AdviceGiven("You're doing great!"));-end--declare AdviceGiven- @role(event)- @expires(10m)- advice : String-end--rule "-PSB: advices given counter"-when- SensorState(sensorName=="VADVICE", value!="", value!="You're doing great!")- //AdviceGiven(advice!="You're doing great!") // This one fires with the same advice-then- int cnt = 0;- try{- cnt = Integer.parseInt(persistence.readData("VADVICEGIVEN","0"));- }finally{- cnt += 1;- persistence.writeData("VADVICEGIVEN", cnt);- }-end--rule "-PSB: vacation inc"- timer(int:300ms)-when- SensorState(sensorName=="VACATION", $v: value)- SensorState(sensorName=="VACATION.inc", value=="ON")-then- commands.execute("VACATION", Integer.parseInt($v.toString())+1);- commands.execute("VACATION.inc", "OFF");-end--rule "-PSB: vacation dec"- timer(int:300ms)-when- SensorState(sensorName=="VACATION", $v: value, eval(Integer.parseInt(value.toString()) > 0))- SensorState(sensorName=="VACATION.dec", value=="ON")-then- commands.execute("VACATION", Integer.parseInt($v.toString())-1);- commands.execute("VACATION.dec", "OFF");-end--rule "-PSB: vacation inc/dec" // needed so the ON value does not hang- salience -10- timer(int:300ms)-when- SensorState(sensorName matches "VACATION...c", $s: sensorName, value=="ON")-then- commands.execute($s, "OFF");-end--rule "PSB: start next week stats"- timer(cron: 0 0 0 ? * 1) // Every Sunday morning at midnight-when- // Time scheduled- Number($arrive: longValue>0) from accumulate(SensorState(sensorName matches "VETA.*", $a:value), sum(util.parseTimestamp($a)))- Number($departure: longValue>0) from accumulate(SensorState(sensorName matches "VETD.*", $d:value), sum(util.parseTimestamp($d)))-then- persistence.writeData("VSETTEMPCHANGES4" ,persistence.readData("VSETTEMPCHANGES3","0"));- persistence.writeData("VSETTEMPCHANGES3" ,persistence.readData("VSETTEMPCHANGES2","0"));- persistence.writeData("VSETTEMPCHANGES2" ,persistence.readData("VSETTEMPCHANGES1","0"));- persistence.writeData("VSETTEMPCHANGES1" ,persistence.readData("VSETTEMPCHANGES","0"));- persistence.writeData("VSETTEMPCHANGES" , "0");-- persistence.writeData("VUSERSCHEDULECHANGES4" ,persistence.readData("VUSERSCHEDULECHANGES3","0"));- persistence.writeData("VUSERSCHEDULECHANGES3" ,persistence.readData("VUSERSCHEDULECHANGES2","0"));- persistence.writeData("VUSERSCHEDULECHANGES2" ,persistence.readData("VUSERSCHEDULECHANGES1","0"));- persistence.writeData("VUSERSCHEDULECHANGES1" ,persistence.readData("VUSERSCHEDULECHANGES","0"));- persistence.writeData("VUSERSCHEDULECHANGES" , "0");-- persistence.writeData("VADVICEGIVEN4" ,persistence.readData("VADVICEGIVEN3","0"));- persistence.writeData("VADVICEGIVEN3" ,persistence.readData("VADVICEGIVEN2","0"));- persistence.writeData("VADVICEGIVEN2" ,persistence.readData("VADVICEGIVEN1","0"));- persistence.writeData("VADVICEGIVEN1" ,persistence.readData("VADVICEGIVEN","0"));- persistence.writeData("VADVICEGIVEN" , "0");-- // Time scheduled- long minutes = ($departure-$arrive)/60000;- long hours = minutes/60;-- persistence.writeData("VHOURSPRESENT4" ,persistence.readData("VHOURSPRESENT3","0:00"));- persistence.writeData("VHOURSPRESENT3" ,persistence.readData("VHOURSPRESENT2","0:00"));- persistence.writeData("VHOURSPRESENT2" ,persistence.readData("VHOURSPRESENT1","0:00"));- persistence.writeData("VHOURSPRESENT1" , String.format("%2d:%02d", hours, minutes%60));-end--// New StrijpS 2016--rule "-PSB16: Full Timer"-when- SensorState(sensorName=="TimerEEEE", $EEEE:value)- SensorState(sensorName=="Timerd", $d: value)- SensorState(sensorName=="TimerMMM", $MMM:value)-then- commands.execute("VTimer", $EEEE.toString()+" "+$d.toString()+" "+$MMM.toString()+". I will be:");-end--rule "-PSB16: background arrival on"-when- SensorState(sensorName=="TimerHH", $h:value)- SensorState(sensorName=="VETA", eval(util.parseTimestamp(value) > util.parseTimestamp($h)) )- SensorState(sensorName=="VArrivalBackground", value!="on")-then- commands.execute("VArrivalBackground", "on");-end--rule "-PSB16: background departure on"-when- SensorState(sensorName=="TimerHH", $h:value)- SensorState(sensorName=="VETD", eval(util.parseTimestamp(value) > util.parseTimestamp($h)) )- SensorState(sensorName=="VDepartureBackground", value!="on")-then- commands.execute("VDepartureBackground", "on");-end--rule "-PSB16: background arrival off"-when- SensorState(sensorName=="TimerHH", $h:value)- SensorState(sensorName=="VETA", eval(util.parseTimestamp(value) <= util.parseTimestamp($h)) )- SensorState(sensorName=="VArrivalBackground", value!="off")-then- commands.execute("VArrivalBackground", "off");-end--rule "-PSB16: background departure off"-when- SensorState(sensorName=="TimerHH", $h:value)- SensorState(sensorName=="VETD", eval(util.parseTimestamp(value) <= util.parseTimestamp($h)) )- SensorState(sensorName=="VDepartureBackground", value!="off")-then- commands.execute("VDepartureBackground", "off");-end--// Fake sensors start--rule "-Fake sensors init"-then- commands.execute("FS.Toutside", "15\u00B0");- commands.execute("FS.Tinside", "19.5\u00B0");- commands.execute("FS.PIR", "off");- commands.execute("FS.Window", "off");-end--rule "--Fake sensors Toutside inc"- timer(int:300ms)-when- SensorState(sensorName == "FS.Toutside", $v: value, eval(util.parseDouble(value) < 50))- SensorState(sensorName == "FS.Toutside.inc" , value == "on")-then- commands.execute("FS.Toutside.inc","off");- commands.execute("FS.Toutside", util.shiftDouble($v.toString(), 0.1, "\u00B0"));-end--rule "--Fake sensors Toutside dec"- timer(int:300ms)-when- SensorState(sensorName == "FS.Toutside", $v: value, eval(util.parseDouble(value) > -40))- SensorState(sensorName == "FS.Toutside.dec" , value == "on")-then- commands.execute("FS.Toutside.dec","off");- commands.execute("FS.Toutside", util.shiftDouble($v.toString(), -0.1, "\u00B0"));-end--rule "--Fake sensors Tinside inc"- timer(int:300ms)-when- SensorState(sensorName == "FS.Tinside", $v: value, eval(util.parseDouble(value) < 40))- SensorState(sensorName == "FS.Tinside.inc" , value == "on")-then- commands.execute("FS.Tinside.inc","off");- commands.execute("FS.Tinside", util.shiftDouble($v.toString(), 0.1, "\u00B0"));-end--rule "--Fake sensors Tinside dec"- timer(int:300ms)-when- SensorState(sensorName == "FS.Tinside", $v: value, eval(util.parseDouble(value) > 0))- SensorState(sensorName == "FS.Tinside.dec" , value == "on")-then- commands.execute("FS.Tinside.dec","off");- commands.execute("FS.Tinside", util.shiftDouble($v.toString(), -0.1, "\u00B0"));-end--rule "--Fake sensors PIR off"- timer(int: 2s)-when- SensorState(sensorName=="FS.PIR", value=="on")-then- commands.execute("FS.PIR", "off");-end--// Fake sensors end\ No newline at end of filediff --git a/agent/src/test/resources/org/openremote/test/rules/climatecontrol/agent.xml b/agent/src/test/resources/org/openremote/test/rules/climatecontrol/agent.xmldeleted file mode 100755index 435e37303..000000000--- a/agent/src/test/resources/org/openremote/test/rules/climatecontrol/agent.xml+++ /dev/null@@ -1,1061 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<openremote xmlns="http://www.openremote.org/schemas/agent/3">- <sensors>- <sensor id="358442" name="VETD.Sun" type="custom">- <include type="command" ref="2549" />- </sensor>- <sensor id="358443" name="VETA.Fri" type="custom">- <include type="command" ref="2565" />- </sensor>- <sensor id="358444" name="VETA.dec" type="custom">- <include type="command" ref="2544" />- </sensor>- <sensor id="358445" name="VACATION.inc" type="custom">- <include type="command" ref="2552" />- </sensor>- <sensor id="358446" name="VETD.Mon" type="custom">- <include type="command" ref="2576" />- </sensor>- <sensor id="358447" name="VETA.Thu" type="custom">- <include type="command" ref="2542" />- </sensor>- <sensor id="358448" name="VETA.Mon" type="custom">- <include type="command" ref="2545" />- </sensor>- <sensor id="358449" name="VETD.Wed" type="custom">- <include type="command" ref="2559" />- </sensor>- <sensor id="358450" name="VETD.inc" type="custom">- <include type="command" ref="2558" />- </sensor>- <sensor id="358451" name="VETD" type="custom">- <include type="command" ref="2574" />- </sensor>- <sensor id="358452" name="VACATION" type="custom">- <include type="command" ref="2575" />- </sensor>- <sensor id="358453" name="TimerMMM" type="custom">- <include type="command" ref="2569" />- </sensor>- <sensor id="358454" name="VPRESENCE" type="custom">- <include type="command" ref="2541" />- <state name="Yes" value="Yes" />- <state name="No" value="No" />- </sensor>- <sensor id="358455" name="VPERSONSENSETIME" type="custom">- <include type="command" ref="2577" />- </sensor>- <sensor id="358456" name="VR1.ET.dec" type="custom">- <include type="command" ref="2547" />- </sensor>- <sensor id="358457" name="TimerEEEE" type="custom">- <include type="command" ref="2553" />- </sensor>- <sensor id="358458" name="VPERSONSENSE" type="custom">- <include type="command" ref="2556" />- </sensor>- <sensor id="358459" name="VETA.Sat" type="custom">- <include type="command" ref="2548" />- </sensor>- <sensor id="358460" name="VR1.ET" type="custom">- <include type="command" ref="2562" />- </sensor>- <sensor id="358461" name="VETD.dec" type="custom">- <include type="command" ref="2557" />- </sensor>- <sensor id="358462" name="VETA.inc" type="custom">- <include type="command" ref="2564" />- </sensor>- <sensor id="358463" name="VETA.Sun" type="custom">- <include type="command" ref="2572" />- </sensor>- <sensor id="358464" name="VATA" type="custom">- <include type="command" ref="2573" />- </sensor>- <sensor id="358465" name="VNEXTACTION" type="custom">- <include type="command" ref="2539" />- </sensor>- <sensor id="358466" name="VETA" type="custom">- <include type="command" ref="2568" />- </sensor>- <sensor id="358467" name="VArrivalBackground" type="custom">- <include type="command" ref="2561" />- <state name="off" value="off" />- <state name="on" value="on" />- </sensor>- <sensor id="358468" name="VTimer" type="custom">- <include type="command" ref="2543" />- </sensor>- <sensor id="358469" name="TimerHH" type="custom">- <include type="command" ref="2567" />- </sensor>- <sensor id="358470" name="VDepartureBackground" type="custom">- <include type="command" ref="2571" />- <state name="off" value="off" />- <state name="on" value="on" />- </sensor>- <sensor id="358471" name="VETD.Sat" type="custom">- <include type="command" ref="2554" />- </sensor>- <sensor id="358472" name="VETD.Thu" type="custom">- <include type="command" ref="2550" />- </sensor>- <sensor id="358473" name="Timerd" type="custom">- <include type="command" ref="2540" />- </sensor>- <sensor id="358474" name="VACATION.dec" type="custom">- <include type="command" ref="2555" />- </sensor>- <sensor id="358475" name="VETD.Tue" type="custom">- <include type="command" ref="2551" />- </sensor>- <sensor id="358476" name="VR1.ET.inc" type="custom">- <include type="command" ref="2566" />- </sensor>- <sensor id="358477" name="VETA.Wed" type="custom">- <include type="command" ref="2560" />- </sensor>- <sensor id="358478" name="TimerEEE" type="custom">- <include type="command" ref="2570" />- </sensor>- <sensor id="358479" name="VETD.Fri" type="custom">- <include type="command" ref="2546" />- </sensor>- <sensor id="358480" name="VATD" type="custom">- <include type="command" ref="2538" />- </sensor>- <sensor id="358481" name="VETA.Tue" type="custom">- <include type="command" ref="2537" />- </sensor>- <sensor id="358482" name="VTOTALSCOREr" type="range">- <include type="command" ref="2584" />- <min value="0" />- <max value="1000" />- </sensor>- <sensor id="358483" name="VTOTALSCORE" type="custom">- <include type="command" ref="2584" />- </sensor>- <sensor id="358484" name="VLEVEL" type="custom">- <include type="command" ref="2581" />- </sensor>- <sensor id="358485" name="VLEAF1" type="custom">- <include type="command" ref="2583" />- <state name="l1.png" value="l1.png" />- <state name="l2.png" value="l2.png" />- <state name="l0.png" value="l0.png" />- </sensor>- <sensor id="358486" name="VTOTALSCOREdisp" type="custom">- <include type="command" ref="2580" />- </sensor>- <sensor id="358487" name="VSCORE" type="custom">- <include type="command" ref="2586" />- </sensor>- <sensor id="358488" name="VLEAVES" type="custom">- <include type="command" ref="2582" />- </sensor>- <sensor id="358489" name="VLEAF3" type="custom">- <include type="command" ref="2579" />- <state name="l1.png" value="l1.png" />- <state name="l2.png" value="l2.png" />- <state name="l0.png" value="l0.png" />- </sensor>- <sensor id="358490" name="VLEAF2" type="custom">- <include type="command" ref="2585" />- <state name="l1.png" value="l1.png" />- <state name="l2.png" value="l2.png" />- <state name="l0.png" value="l0.png" />- </sensor>- <sensor id="358491" name="VSUMMER" type="custom">- <include type="command" ref="2599" />- <state name="Yes" value="Yes" />- <state name="No" value="No" />- </sensor>- <sensor id="358492" name="VADVICEDONE" type="custom">- <include type="command" ref="2598" />- </sensor>- <sensor id="358493" name="VR1.COMFORT.inc" type="custom">- <include type="command" ref="2592" />- </sensor>- <sensor id="358494" name="VR1.COMFORT" type="custom">- <include type="command" ref="2590" />- </sensor>- <sensor id="358495" name="VOUTSIDE" type="custom">- <include type="command" ref="2597" />- </sensor>- <sensor id="358496" name="VWINDOW" type="custom">- <include type="command" ref="2595" />- <state name="Open" value="Open" />- <state name="Closed" value="Closed" />- </sensor>- <sensor id="358497" name="VHEATINGSETPOINT" type="custom">- <include type="command" ref="2587" />- </sensor>- <sensor id="358498" name="VR1.TEMPERATURE.inc" type="custom">- <include type="command" ref="2591" />- </sensor>- <sensor id="358499" name="VR1.COMFORT.dec" type="custom">- <include type="command" ref="2593" />- </sensor>- <sensor id="358500" name="VROOMTEMPERATURE" type="custom">- <include type="command" ref="2594" />- </sensor>- <sensor id="358501" name="VHEATING" type="custom">- <include type="command" ref="2588" />- </sensor>- <sensor id="358502" name="VR1.TEMPERATURE.dec" type="custom">- <include type="command" ref="2596" />- </sensor>- <sensor id="358503" name="VR1.TEMPERATURE" type="custom">- <include type="command" ref="2589" />- </sensor>- <sensor id="358504" name="VADVICE" type="custom">- <include type="command" ref="2600" />- </sensor>- <sensor id="358505" name="GVconfig" type="custom">- <include type="command" ref="2601" />- </sensor>- <sensor id="358525" name="PID.sp.dec" type="custom">- <include type="command" ref="2625" />- </sensor>- <sensor id="358526" name="PID.kd.inc" type="custom">- <include type="command" ref="2606" />- </sensor>- <sensor id="358527" name="PID.db.inc" type="custom">- <include type="command" ref="2622" />- </sensor>- <sensor id="358528" name="PID.kp.dec" type="custom">- <include type="command" ref="2608" />- </sensor>- <sensor id="358529" name="PID.Se" type="custom">- <include type="command" ref="2609" />- </sensor>- <sensor id="358530" name="PID.ki.dec" type="custom">- <include type="command" ref="2620" />- </sensor>- <sensor id="358531" name="GV.PID.Sp" type="custom">- <include type="command" ref="2610" />- </sensor>- <sensor id="358532" name="PID.Output" type="custom">- <include type="command" ref="2615" />- </sensor>- <sensor id="358533" name="PID.db.dec" type="custom">- <include type="command" ref="2613" />- </sensor>- <sensor id="358534" name="GV.PID.Ki" type="custom">- <include type="command" ref="2604" />- </sensor>- <sensor id="358535" name="PID.kd.dec" type="custom">- <include type="command" ref="2612" />- </sensor>- <sensor id="358536" name="GV.PID.Db" type="custom">- <include type="command" ref="2624" />- </sensor>- <sensor id="358537" name="PID.sp.inc" type="custom">- <include type="command" ref="2626" />- </sensor>- <sensor id="358538" name="GV.PID.Kp" type="custom">- <include type="command" ref="2603" />- </sensor>- <sensor id="358539" name="PID.kp.inc" type="custom">- <include type="command" ref="2628" />- </sensor>- <sensor id="358540" name="PID.ki.inc" type="custom">- <include type="command" ref="2623" />- </sensor>- <sensor id="358541" name="GV.PID.Kd" type="custom">- <include type="command" ref="2602" />- </sensor>- <sensor id="358542" name="FS.Toutside" type="custom">- <include type="command" ref="2638" />- </sensor>- <sensor id="358543" name="FS.Toutside.inc" type="custom">- <include type="command" ref="2635" />- </sensor>- <sensor id="358544" name="FS.Tinside.dec" type="custom">- <include type="command" ref="2641" />- </sensor>- <sensor id="358545" name="FS.Tinside" type="custom">- <include type="command" ref="2632" />- </sensor>- <sensor id="358546" name="FS.Toutside.dec" type="custom">- <include type="command" ref="2640" />- </sensor>- <sensor id="358547" name="FS.Tinside.inc" type="custom">- <include type="command" ref="2642" />- </sensor>- <sensor id="358548" name="FS.PIR" type="switch">- <include type="command" ref="2631" />- <state name="on" />- <state name="off" />- </sensor>- <sensor id="358549" name="FS.Window" type="switch">- <include type="command" ref="2630" />- <state name="on" />- <state name="off" />- </sensor>- </sensors>- <commands>- <command id="2537" protocol="virtual">- <property name="address" value="vetatuesday" />- <property name="command" value="status" />- <property name="name" value="VETA.Tue" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2538" protocol="virtual">- <property name="address" value="VATD" />- <property name="command" value="status" />- <property name="name" value="VATD" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2539" protocol="virtual">- <property name="address" value="VNEXTACTION" />- <property name="command" value="status" />- <property name="name" value="VNEXTACTION" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2541" protocol="virtual">- <property name="address" value="VPRESENCE" />- <property name="command" value="status" />- <property name="name" value="VPRESENCE" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2542" protocol="virtual">- <property name="address" value="vetathursday" />- <property name="command" value="status" />- <property name="name" value="VETA.Thu" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2543" protocol="virtual">- <property name="address" value="VTimer" />- <property name="command" value="status" />- <property name="name" value="VTimer" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2544" protocol="virtual">- <property name="address" value="vetaalldec" />- <property name="command" value="ON" />- <property name="name" value="VETA.dec" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2545" protocol="virtual">- <property name="address" value="vetamonday" />- <property name="command" value="status" />- <property name="name" value="VETA.Mon" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2546" protocol="virtual">- <property name="address" value="vetdfriday" />- <property name="command" value="status" />- <property name="name" value="VETD.Fri" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2547" protocol="virtual">- <property name="address" value="vretdec" />- <property name="command" value="ON" />- <property name="name" value="VR1.ET.dec" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2548" protocol="virtual">- <property name="address" value="vetasat" />- <property name="command" value="status" />- <property name="name" value="VETA.Sat" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2549" protocol="virtual">- <property name="address" value="vetdsun" />- <property name="command" value="status" />- <property name="name" value="VETD.Sun" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2550" protocol="virtual">- <property name="address" value="vetdthursday" />- <property name="command" value="status" />- <property name="name" value="VETD.Thu" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2551" protocol="virtual">- <property name="address" value="vetdtuesday" />- <property name="command" value="status" />- <property name="name" value="VETD.Tue" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2552" protocol="virtual">- <property name="address" value="VABSENTinc" />- <property name="command" value="ON" />- <property name="name" value="VACATION.inc" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2554" protocol="virtual">- <property name="address" value="vetdsat" />- <property name="command" value="status" />- <property name="name" value="VETD.Sat" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2555" protocol="virtual">- <property name="address" value="VABSENTdec" />- <property name="command" value="ON" />- <property name="name" value="VACATION.dec" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2556" protocol="virtual">- <property name="address" value="VPERSONSENSE" />- <property name="command" value="status" />- <property name="name" value="VPERSONSENSE" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2557" protocol="virtual">- <property name="address" value="vetdalldec" />- <property name="command" value="ON" />- <property name="name" value="VETD.dec" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2558" protocol="virtual">- <property name="address" value="vetdallinc" />- <property name="command" value="ON" />- <property name="name" value="VETD.inc" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2559" protocol="virtual">- <property name="address" value="vetdwendsday" />- <property name="command" value="status" />- <property name="name" value="VETD.Wed" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2560" protocol="virtual">- <property name="address" value="vetawendsday" />- <property name="command" value="status" />- <property name="name" value="VETA.Wed" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2561" protocol="virtual">- <property name="address" value="VArrivalBackground" />- <property name="command" value="status" />- <property name="name" value="VArrivalBackground" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2562" protocol="virtual">- <property name="address" value="vret" />- <property name="command" value="status" />- <property name="name" value="VR1.ET" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2564" protocol="virtual">- <property name="address" value="vetaallinc" />- <property name="command" value="ON" />- <property name="name" value="VETA.inc" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2565" protocol="virtual">- <property name="address" value="vetafriday" />- <property name="command" value="status" />- <property name="name" value="VETA.Fri" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2566" protocol="virtual">- <property name="address" value="vretinc" />- <property name="command" value="ON" />- <property name="name" value="VR1.ET.inc" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2568" protocol="virtual">- <property name="address" value="vetaall" />- <property name="command" value="status" />- <property name="name" value="VETA" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2571" protocol="virtual">- <property name="address" value="VDepartureBackground" />- <property name="command" value="status" />- <property name="name" value="VDepartureBackground" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2572" protocol="virtual">- <property name="address" value="vetasun" />- <property name="command" value="status" />- <property name="name" value="VETA.Sun" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2573" protocol="virtual">- <property name="address" value="VATA" />- <property name="command" value="status" />- <property name="name" value="VATA" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2574" protocol="virtual">- <property name="address" value="vetdall" />- <property name="command" value="status" />- <property name="name" value="VETD" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2575" protocol="virtual">- <property name="address" value="VABSENT" />- <property name="command" value="status" />- <property name="name" value="VACATION" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2576" protocol="virtual">- <property name="address" value="vetdmonday" />- <property name="command" value="status" />- <property name="name" value="VETD.Mon" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2577" protocol="virtual">- <property name="address" value="VPERSONSENSETIME" />- <property name="command" value="status" />- <property name="name" value="VPERSONSENSETIME" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2578" protocol="virtual">- <property name="address" value="VTOTALSCOREinc" />- <property name="command" value="status" />- <property name="name" value="VTOTALSCORE.inc" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2579" protocol="virtual">- <property name="address" value="vleafthree" />- <property name="command" value="status" />- <property name="name" value="VLEAF3" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2580" protocol="virtual">- <property name="address" value="VTOTALSCOREdisp" />- <property name="command" value="status" />- <property name="name" value="VTOTALSCOREdisp" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2581" protocol="virtual">- <property name="address" value="VLEVEL" />- <property name="command" value="status" />- <property name="name" value="VLEVEL" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2582" protocol="virtual">- <property name="address" value="VLEAVES" />- <property name="command" value="status" />- <property name="name" value="VLEAVES" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2583" protocol="virtual">- <property name="address" value="vleafone" />- <property name="command" value="status" />- <property name="name" value="VLEAF1" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2584" protocol="virtual">- <property name="address" value="VTOTALSCORE" />- <property name="command" value="status" />- <property name="name" value="VTOTALSCORE" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2585" protocol="virtual">- <property name="address" value="vleaftwo" />- <property name="command" value="status" />- <property name="name" value="VLEAF2" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2586" protocol="virtual">- <property name="address" value="VSCORE" />- <property name="command" value="status" />- <property name="name" value="VSCORE" />- <property name="urn:openremote:device-command:device-name" value="Efficiency" />- <property name="urn:openremote:device-command:device-id" value="35479" />- </command>- <command id="2587" protocol="virtual">- <property name="address" value="VHEATINGSETPOINT" />- <property name="command" value="status" />- <property name="name" value="VHEATINGSETPOINT" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2588" protocol="virtual">- <property name="address" value="VHEATING" />- <property name="command" value="status" />- <property name="name" value="VHEATING" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2589" protocol="virtual">- <property name="address" value="vrtemperature" />- <property name="command" value="status" />- <property name="name" value="VR1.TEMPERATURE" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2590" protocol="virtual">- <property name="address" value="vrcomfort" />- <property name="command" value="status" />- <property name="name" value="VR1.COMFORT" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2591" protocol="virtual">- <property name="address" value="vrtemperatureinc" />- <property name="command" value="ON" />- <property name="name" value="VR1.TEMPERATURE.inc" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2592" protocol="virtual">- <property name="address" value="vrcomfortinc" />- <property name="command" value="ON" />- <property name="name" value="VR1.COMFORT.inc" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2593" protocol="virtual">- <property name="address" value="vrcomfortdec" />- <property name="command" value="ON" />- <property name="name" value="VR1.COMFORT.dec" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2594" protocol="virtual">- <property name="address" value="VROOMTEMPERATURE" />- <property name="command" value="status" />- <property name="name" value="VROOMTEMPERATURE" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2595" protocol="virtual">- <property name="address" value="VWINDOW" />- <property name="command" value="status" />- <property name="name" value="VWINDOW" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2596" protocol="virtual">- <property name="address" value="vrtemperaturedec" />- <property name="command" value="ON" />- <property name="name" value="VR1.TEMPERATURE.dec" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2597" protocol="virtual">- <property name="address" value="VOUTSIDE" />- <property name="command" value="status" />- <property name="name" value="VOUTSIDE" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2598" protocol="virtual">- <property name="address" value="VADVICEDONE" />- <property name="command" value="ON" />- <property name="name" value="VADVICEDONE" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2599" protocol="virtual">- <property name="address" value="VSUMMER" />- <property name="command" value="status" />- <property name="name" value="VSUMMER" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2600" protocol="virtual">- <property name="address" value="VADVICE" />- <property name="command" value="status" />- <property name="name" value="VADVICE" />- <property name="urn:openremote:device-command:device-name" value="Heating" />- <property name="urn:openremote:device-command:device-id" value="35480" />- </command>- <command id="2601" protocol="virtual">- <property name="address" value="GVconfig" />- <property name="command" value="status" />- <property name="name" value="GVconfig" />- <property name="urn:openremote:device-command:device-name" value="Config" />- <property name="urn:openremote:device-command:device-id" value="35481" />- </command>- <command id="2602" protocol="virtual">- <property name="address" value="pidkd" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Kd" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2603" protocol="virtual">- <property name="address" value="pidkp" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Kp" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2604" protocol="virtual">- <property name="address" value="pidki" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Ki" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2605" protocol="virtual">- <property name="address" value="piddbinc" />- <property name="command" value="ON" />- <property name="name" value="PID.db.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2606" protocol="virtual">- <property name="address" value="pidkdinc" />- <property name="command" value="status" />- <property name="name" value="PID.kd.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2607" protocol="virtual">- <property name="address" value="pidkiinc" />- <property name="command" value="ON" />- <property name="name" value="PID.ki.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2608" protocol="virtual">- <property name="address" value="kpdec" />- <property name="command" value="status" />- <property name="name" value="PID.kp.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2609" protocol="virtual">- <property name="address" value="pidse" />- <property name="command" value="status" />- <property name="name" value="PID.Se" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2610" protocol="virtual">- <property name="address" value="pidsp" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Sp" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2611" protocol="virtual">- <property name="address" value="pidkidec" />- <property name="command" value="ON" />- <property name="name" value="PID.ki.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2612" protocol="virtual">- <property name="address" value="pidkddec" />- <property name="command" value="status" />- <property name="name" value="PID.kd.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2613" protocol="virtual">- <property name="address" value="piddbdec" />- <property name="command" value="status" />- <property name="name" value="PID.db.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2614" protocol="virtual">- <property name="address" value="pidkddec" />- <property name="command" value="ON" />- <property name="name" value="PID.kd.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2615" protocol="virtual">- <property name="address" value="pidoutput" />- <property name="command" value="status" />- <property name="name" value="PID.Output" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2616" protocol="virtual">- <property name="address" value="pidkdinc" />- <property name="command" value="ON" />- <property name="name" value="PID.kd.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2617" protocol="virtual">- <property name="address" value="pidspdec" />- <property name="command" value="ON" />- <property name="name" value="PID.sp.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2618" protocol="virtual">- <property name="address" value="piddbdec" />- <property name="command" value="ON" />- <property name="name" value="PID.db.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2619" protocol="virtual">- <property name="address" value="pidspinc" />- <property name="command" value="ON" />- <property name="name" value="PID.sp.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2620" protocol="virtual">- <property name="address" value="pidkidec" />- <property name="command" value="status" />- <property name="name" value="PID.ki.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2621" protocol="virtual">- <property name="address" value="kpinc" />- <property name="command" value="ON" />- <property name="name" value="PID.kp.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2622" protocol="virtual">- <property name="address" value="piddbinc" />- <property name="command" value="status" />- <property name="name" value="PID.db.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2623" protocol="virtual">- <property name="address" value="pidkiinc" />- <property name="command" value="status" />- <property name="name" value="PID.ki.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2624" protocol="virtual">- <property name="address" value="piddb" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Db" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2625" protocol="virtual">- <property name="address" value="pidspdec" />- <property name="command" value="status" />- <property name="name" value="PID.sp.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2626" protocol="virtual">- <property name="address" value="pidspinc" />- <property name="command" value="status" />- <property name="name" value="PID.sp.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2627" protocol="virtual">- <property name="address" value="kpdec" />- <property name="command" value="ON" />- <property name="name" value="PID.kp.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2628" protocol="virtual">- <property name="address" value="kpinc" />- <property name="command" value="status" />- <property name="name" value="PID.kp.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2629" protocol="virtual">- <property name="address" value="fsoutsideinc" />- <property name="command" value="on" />- <property name="name" value="FS.Toutside.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2630" protocol="virtual">- <property name="address" value="fswindow" />- <property name="command" value="status" />- <property name="name" value="FS.Window" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2631" protocol="virtual">- <property name="address" value="fspir" />- <property name="command" value="status" />- <property name="name" value="FS.PIR" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2632" protocol="virtual">- <property name="address" value="fstinside" />- <property name="command" value="status" />- <property name="name" value="FS.Tinside" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2633" protocol="virtual">- <property name="address" value="fsoutsidedec" />- <property name="command" value="on" />- <property name="name" value="FS.Toutside.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2634" protocol="virtual">- <property name="address" value="fstinsidedec" />- <property name="command" value="on" />- <property name="name" value="FS.Tinside.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2635" protocol="virtual">- <property name="address" value="fsoutsideinc" />- <property name="command" value="status" />- <property name="name" value="FS.Toutside.inc" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2636" protocol="virtual">- <property name="address" value="fspir" />- <property name="command" value="on" />- <property name="name" value="FS.PIR.ON" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2637" protocol="virtual">- <property name="address" value="fswindow" />- <property name="command" value="on" />- <property name="name" value="FS.Window.(ON)" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2638" protocol="virtual">- <property name="address" value="fsoutside" />- <property name="command" value="status" />- <property name="name" value="FS.Toutside" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2639" protocol="virtual">- <property name="address" value="fswindow" />- <property name="command" value="off" />- <property name="name" value="FS.Window.(OFF)" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2640" protocol="virtual">- <property name="address" value="fsoutsidedec" />- <property name="command" value="status" />- <property name="name" value="FS.Toutside.dec" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2641" protocol="virtual">- <property name="address" value="fstinsidedec" />- <property name="command" value="status" />- <property name="name" value="FS.Tinside.dec" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2642" protocol="virtual">- <property name="address" value="fstinsideinc" />- <property name="command" value="status" />- <property name="name" value="FS.Tinside.inc" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2643" protocol="virtual">- <property name="address" value="fspir" />- <property name="command" value="off" />- <property name="name" value="FS.PIR.OFF" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2644" protocol="virtual">- <property name="address" value="fstinsideinc" />- <property name="command" value="on" />- <property name="name" value="FS.Tinside.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="Fake sensors" />- <property name="urn:openremote:device-command:device-id" value="35488" />- </command>- <command id="2540" protocol="datetime">- <property name="timezone" value="Europe/Amsterdam" />- <property name="command" value="date" />- <property name="pollingInterval" value="1m" />- <property name="format" value="d" />- <property name="name" value="Timerd" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2553" protocol="datetime">- <property name="timezone" value="Europe/Amsterdam" />- <property name="command" value="date" />- <property name="pollingInterval" value="1m" />- <property name="format" value="EEEE" />- <property name="name" value="TimerEEEE" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2567" protocol="datetime">- <property name="timezone" value="Europe/Amsterdam" />- <property name="command" value="date" />- <property name="pollingInterval" value="1m" />- <property name="format" value="HH:mm:ss" />- <property name="name" value="TimerHH" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2569" protocol="datetime">- <property name="timezone" value="Europe/Amsterdam" />- <property name="command" value="date" />- <property name="pollingInterval" value="1m" />- <property name="format" value="MMM" />- <property name="name" value="TimerMMM" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- <command id="2570" protocol="datetime">- <property name="timezone" value="Europe/Amsterdam" />- <property name="command" value="date" />- <property name="pollingInterval" value="1m" />- <property name="format" value="EEE" />- <property name="name" value="TimerEEE" />- <property name="urn:openremote:device-command:device-name" value="Times" />- <property name="urn:openremote:device-command:device-id" value="35478" />- </command>- </commands>- <config>- </config>-</openremote>-diff --git a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/BrokenDTable.csv b/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/BrokenDTable.csvdeleted file mode 100644index a8eeec069..000000000--- a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/BrokenDTable.csv+++ /dev/null@@ -1,14 +0,0 @@---, ,Ruleset, Cannot find the ruleset on this one-, ,Import, org.openremote.agent.sensors.SensorState--- ,RuleTable,Event Mod-, ,CONDITION,ACTION-, ,sensorState: SensorState,-,(descriptions),sensorID,sensorState.setSensorID($param);-,Case, Sensor Source ID, New Source ID-,Fire Alarm,555,5555-,Ice Age,666,6666-,Comfort,777,7777diff --git a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/DTableTest.csv b/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/DTableTest.csvdeleted file mode 100644index 1ff1ce14a..000000000--- a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/DTableTest.csv+++ /dev/null@@ -1,15 +0,0 @@---Ruleset, My CSV Rules Examples-Import, org.openremote.agent.sensor.SensorState-Variables, org.openremote.agent.rules.RangeFacade ranges---,RuleTable,Modify Range Values in Decision Table-,CONDITION,ACTION-,sensorState: SensorState,-(descriptions),$name : sensorName,"ranges.name($name).value($param);"-Case, SensorState Source, New Value-Fire Alarm,"TestSensor555",55-Ice Age,"TestSensor666",6666-Comfort,"TestSensor777",-77diff --git a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/EventMod.drl b/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/EventMod.drldeleted file mode 100644index 03d42fb9b..000000000--- a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/EventMod.drl+++ /dev/null@@ -1,12 +0,0 @@-package org.openremote.test.rules;--import org.openremote.agent.sensor.*;--global org.openremote.agent.rules.RangeFacade ranges;--rule "Modify Level State Above Max"-when- SensorState( sensorID == 444, $name : sensorName )-then- ranges.name($name).value( 12345 );-enddiff --git a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/IncorrectRule.drl b/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/IncorrectRule.drldeleted file mode 100644index adf7f234a..000000000--- a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/IncorrectRule.drl+++ /dev/null@@ -1,10 +0,0 @@-package org.openremote.test.rules;--import org.openremote.agent.sensor.*;--rule "Incorrect Event Modification Attempt"-when- $sensorState : SensorState( sensorID == 123 )-then- $sensorState.setFooBarBazOoops( 321 );-enddiff --git a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/agent.xml b/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/agent.xmldeleted file mode 100755index e4c679c83..000000000--- a/agent/src/test/resources/org/openremote/test/rules/mixed-with-errors/agent.xml+++ /dev/null@@ -1,30 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<openremote xmlns="http://www.openremote.org/schemas/agent/3">-- <sensors>- <sensor id="444" type="range" name="TestSensor444">- <include type="command" ref="456"/>- <min value="0"/>- <max value="1000"/>- </sensor>- <sensor id="555" type="range" name="TestSensor555">- <include type="command" ref="456"/>- <min value="0"/>- <max value="1000"/>- </sensor>- </sensors>-- <commands>- <command id="456" protocol="test">- <property name="name" value="TestCommand"/>- <property name="what-are-we-testing" value="a-test-range"/>- <property name="urn:openremote:device-command:device-name" value="TestDevice"/>- <property name="urn:openremote:device-command:device-id" value="111"/>- </command>- </commands>-- <config>- </config>--</openremote>-diff --git a/agent/src/test/resources/org/openremote/test/rules/pid/PID.drl b/agent/src/test/resources/org/openremote/test/rules/pid/PID.drldeleted file mode 100644index ef9d7c05a..000000000--- a/agent/src/test/resources/org/openremote/test/rules/pid/PID.drl+++ /dev/null@@ -1,196 +0,0 @@-package org.openremote.agent.test.rules;--import java.util.concurrent.*;-import java.util.Date;-import java.text.SimpleDateFormat;-import java.io.*;-import org.openremote.agent.sensor.*;--global org.openremote.agent.command.Commands commands;-global org.openremote.agent.rules.RulePersistence persistence;--declare SensorState- @role(event)-end--// PID controller start--rule "-PID: init"-then- commands.execute("GV.PID.Kp",persistence.readData("GV.PID.Kp", "0.6"));- commands.execute("GV.PID.Ki",persistence.readData("GV.PID.Ki", "0.3"));- commands.execute("GV.PID.Kd",persistence.readData("GV.PID.Kd", "0.0"));- commands.execute("GV.PID.Db",persistence.readData("GV.PID.Db", "0.0"));- commands.execute("GV.PID.Sp",persistence.readData("GV.PID.Sp", "1.0"));-end--// PID UI--rule "-PID: increase Kp"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Kp", $v: value)- SensorState($s:sensorName=="PID.kp.inc", value=="ON")-then- commands.execute("GV.PID.Kp", String.format("%.1f", Double.parseDouble($v.toString())+0.1) );- commands.execute($s, "off");-end--rule "-PID: decrease Kp"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Kp", $v: value)- SensorState($s:sensorName=="PID.kp.dec", value=="ON")-then- commands.execute("GV.PID.Kp", String.format("%.1f", Double.parseDouble($v.toString())-0.1) );- commands.execute($s, "off");-end--rule "-PID: increase Ki"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Ki", $v: value)- SensorState($s:sensorName=="PID.ki.inc", value=="ON")-then- commands.execute("GV.PID.Ki", String.format("%.1f", Double.parseDouble($v.toString())+0.1) );- commands.execute($s, "off");-end--rule "-PID: decrease Ki"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Ki", $v: value)- SensorState($s:sensorName=="PID.ki.dec", value=="ON")-then- commands.execute("GV.PID.Ki", String.format("%.1f", Double.parseDouble($v.toString())-0.1) );- commands.execute($s, "off");-end--rule "-PID: increase Kd"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Kd", $v: value)- SensorState($s:sensorName=="PID.kd.inc", value=="ON")-then- commands.execute("GV.PID.Kd", String.format("%.1f", Double.parseDouble($v.toString())+0.1) );- commands.execute($s, "off");-end--rule "-PID: decrease Kd"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Kd", $v: value)- SensorState($s:sensorName=="PID.kd.dec", value=="ON")-then- commands.execute("GV.PID.Kd", String.format("%.1f", Double.parseDouble($v.toString())-0.1) );- commands.execute($s, "off");-end--rule "-PID: increase Db"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Db", $v: value)- SensorState($s:sensorName=="PID.db.inc", value=="ON")-then- commands.execute("GV.PID.Db", String.format("%.1f", Double.parseDouble($v.toString())+0.1) );- commands.execute($s, "off");-end--rule "-PID: decrease Db"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Db", $v: value)- SensorState($s:sensorName=="PID.db.dec", value=="ON")-then- commands.execute("GV.PID.Db", String.format("%.1f", Double.parseDouble($v.toString())-0.1) );- commands.execute($s, "off");-end--rule "PID: increase Sp"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Sp", $v: value)- SensorState($s:sensorName=="PID.sp.inc", value=="ON")-then- commands.execute("GV.PID.Sp", String.format("%.1f", Double.parseDouble($v.toString())+0.5) );- commands.execute($s, "off");-end--rule "PID: decrease Sp"- timer(int:300ms)-when- SensorState(sensorName=="GV.PID.Sp", $v: value)- SensorState($s:sensorName=="PID.sp.dec", value=="ON")-then- commands.execute("GV.PID.Sp", String.format("%.1f", Double.parseDouble($v.toString())-0.5) );- commands.execute($s, "off");-end--rule "-PID: reset inc/dec"- salience -10- timer(int: 1s)-when- SensorState($s: sensorName matches "^PID......c$", value!="off")-then- commands.execute($s, "off");-end--// PID algorithm--declare PIDVars-// Input==Output;- output: double- iterm: double- prevInput: double- outMin: double- outMax: double- active: Boolean-end--rule "-PID: algo init"-then- PIDVars pv = new PIDVars();- pv.setActive(true);- pv.setOutMax(100);- pv.setOutMin(-100);- insert(pv);-end--rule "--PID: compute"- timer(int: 0 10) // 10 times faster than the implemented one-when- $pv: PIDVars(active==true)- SensorState(sensorName=="GV.PID.Kp", $kp: value)- SensorState(sensorName=="GV.PID.Ki", $ki: value)- SensorState(sensorName=="GV.PID.Kd", $kd: value)- SensorState(sensorName=="GV.PID.Sp", $sp: value)- SensorState(sensorName=="GV.PID.Db", $db: value)-then- double error = Double.parseDouble($sp.toString() ) - $pv.getOutput();- double kp = Double.parseDouble($kp.toString());- double ki = Double.parseDouble($ki.toString()); // * sample time in sec- double kd = Double.parseDouble($kd.toString()); // / sample time in sec- double sp = Double.parseDouble($sp.toString());- double db = Double.parseDouble($db.toString());-- double iterm = $pv.getIterm() + (ki * error);- if(iterm > $pv.getOutMax() ) iterm = $pv.getOutMax();- else if(iterm < $pv.getOutMin() ) iterm = $pv.getOutMin();- $pv.setIterm( iterm );-- //double dInput = (Input - lastInput);- double dInput = ($pv.getOutput() - $pv.getPrevInput() );- $pv.setPrevInput($pv.getOutput());-- // Compute PID Output- double output = kp * error + $pv.getIterm()- kd * dInput;- if(output > $pv.getOutMax()) output = $pv.getOutMax();- else if(output < $pv.getOutMin()) output = $pv.getOutMin();- $pv.setOutput(output);-- commands.execute("PID.Se", String.format("%.4f", error) );- commands.execute("PID.Output", String.format("%.4f", output) );- // LOG.fine($pv.toString() + " error: "+String.format("%f", Double.parseDouble($sp.toString() ) - $pv.getOutput()));-end--// PID enddiff --git a/agent/src/test/resources/org/openremote/test/rules/pid/agent.xml b/agent/src/test/resources/org/openremote/test/rules/pid/agent.xmldeleted file mode 100644index 7cb732fa6..000000000--- a/agent/src/test/resources/org/openremote/test/rules/pid/agent.xml+++ /dev/null@@ -1,250 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<openremote xmlns="http://www.openremote.org/schemas/agent/3">- <sensors>- <sensor id="358525" name="PID.sp.dec" type="custom">- <include type="command" ref="2625" />- </sensor>- <sensor id="358526" name="PID.kd.inc" type="custom">- <include type="command" ref="2606" />- </sensor>- <sensor id="358527" name="PID.db.inc" type="custom">- <include type="command" ref="2622" />- </sensor>- <sensor id="358528" name="PID.kp.dec" type="custom">- <include type="command" ref="2608" />- </sensor>- <sensor id="358529" name="PID.Se" type="custom">- <include type="command" ref="2609" />- </sensor>- <sensor id="358530" name="PID.ki.dec" type="custom">- <include type="command" ref="2620" />- </sensor>- <sensor id="358531" name="GV.PID.Sp" type="custom">- <include type="command" ref="2610" />- </sensor>- <sensor id="358532" name="PID.Output" type="custom">- <include type="command" ref="2615" />- </sensor>- <sensor id="358533" name="PID.db.dec" type="custom">- <include type="command" ref="2613" />- </sensor>- <sensor id="358534" name="GV.PID.Ki" type="custom">- <include type="command" ref="2604" />- </sensor>- <sensor id="358535" name="PID.kd.dec" type="custom">- <include type="command" ref="2612" />- </sensor>- <sensor id="358536" name="GV.PID.Db" type="custom">- <include type="command" ref="2624" />- </sensor>- <sensor id="358537" name="PID.sp.inc" type="custom">- <include type="command" ref="2626" />- </sensor>- <sensor id="358538" name="GV.PID.Kp" type="custom">- <include type="command" ref="2603" />- </sensor>- <sensor id="358539" name="PID.kp.inc" type="custom">- <include type="command" ref="2628" />- </sensor>- <sensor id="358540" name="PID.ki.inc" type="custom">- <include type="command" ref="2623" />- </sensor>- <sensor id="358541" name="GV.PID.Kd" type="custom">- <include type="command" ref="2602" />- </sensor>- </sensors>- <commands>- <command id="2602" protocol="virtual">- <property name="address" value="pidkd" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Kd" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2603" protocol="virtual">- <property name="address" value="pidkp" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Kp" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2604" protocol="virtual">- <property name="address" value="pidki" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Ki" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2605" protocol="virtual">- <property name="address" value="piddbinc" />- <property name="command" value="ON" />- <property name="name" value="PID.db.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2606" protocol="virtual">- <property name="address" value="pidkdinc" />- <property name="command" value="status" />- <property name="name" value="PID.kd.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2607" protocol="virtual">- <property name="address" value="pidkiinc" />- <property name="command" value="ON" />- <property name="name" value="PID.ki.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2608" protocol="virtual">- <property name="address" value="kpdec" />- <property name="command" value="status" />- <property name="name" value="PID.kp.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2609" protocol="virtual">- <property name="address" value="pidse" />- <property name="command" value="status" />- <property name="name" value="PID.Se" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2610" protocol="virtual">- <property name="address" value="pidsp" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Sp" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2611" protocol="virtual">- <property name="address" value="pidkidec" />- <property name="command" value="ON" />- <property name="name" value="PID.ki.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2612" protocol="virtual">- <property name="address" value="pidkddec" />- <property name="command" value="status" />- <property name="name" value="PID.kd.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2613" protocol="virtual">- <property name="address" value="piddbdec" />- <property name="command" value="status" />- <property name="name" value="PID.db.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2614" protocol="virtual">- <property name="address" value="pidkddec" />- <property name="command" value="ON" />- <property name="name" value="PID.kd.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2615" protocol="virtual">- <property name="address" value="pidoutput" />- <property name="command" value="status" />- <property name="name" value="PID.Output" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2616" protocol="virtual">- <property name="address" value="pidkdinc" />- <property name="command" value="ON" />- <property name="name" value="PID.kd.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2617" protocol="virtual">- <property name="address" value="pidspdec" />- <property name="command" value="ON" />- <property name="name" value="PID.sp.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2618" protocol="virtual">- <property name="address" value="piddbdec" />- <property name="command" value="ON" />- <property name="name" value="PID.db.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2619" protocol="virtual">- <property name="address" value="pidspinc" />- <property name="command" value="ON" />- <property name="name" value="PID.sp.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2620" protocol="virtual">- <property name="address" value="pidkidec" />- <property name="command" value="status" />- <property name="name" value="PID.ki.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2621" protocol="virtual">- <property name="address" value="kpinc" />- <property name="command" value="ON" />- <property name="name" value="PID.kp.inc.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2622" protocol="virtual">- <property name="address" value="piddbinc" />- <property name="command" value="status" />- <property name="name" value="PID.db.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2623" protocol="virtual">- <property name="address" value="pidkiinc" />- <property name="command" value="status" />- <property name="name" value="PID.ki.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2624" protocol="virtual">- <property name="address" value="piddb" />- <property name="command" value="status" />- <property name="name" value="GV.PID.Db" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2625" protocol="virtual">- <property name="address" value="pidspdec" />- <property name="command" value="status" />- <property name="name" value="PID.sp.dec" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2626" protocol="virtual">- <property name="address" value="pidspinc" />- <property name="command" value="status" />- <property name="name" value="PID.sp.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2627" protocol="virtual">- <property name="address" value="kpdec" />- <property name="command" value="ON" />- <property name="name" value="PID.kp.dec.ON" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- <command id="2628" protocol="virtual">- <property name="address" value="kpinc" />- <property name="command" value="status" />- <property name="name" value="PID.kp.inc" />- <property name="urn:openremote:device-command:device-name" value="PID" />- <property name="urn:openremote:device-command:device-id" value="35487" />- </command>- </commands>- <config>- </config>-</openremote>-diff --git a/agent/src/test/resources/org/openremote/test/rules/simple/EventMod.drl b/agent/src/test/resources/org/openremote/test/rules/simple/EventMod.drldeleted file mode 100644index d0c077705..000000000--- a/agent/src/test/resources/org/openremote/test/rules/simple/EventMod.drl+++ /dev/null@@ -1,12 +0,0 @@-package org.openremote.test.rules;--import org.openremote.agent.sensor.*;--global org.openremote.agent.rules.SwitchFacade switches;--rule "Modify Switch State"-when- $switch : SwitchSensorState(sensorID == 123)-then- switches.name($switch.getSensorName()).off();-enddiff --git a/agent/src/test/resources/org/openremote/test/rules/simple/TestRuleFiring.drl b/agent/src/test/resources/org/openremote/test/rules/simple/TestRuleFiring.drldeleted file mode 100644index 428fc04f8..000000000--- a/agent/src/test/resources/org/openremote/test/rules/simple/TestRuleFiring.drl+++ /dev/null@@ -1,12 +0,0 @@-package org.openremote.test.rules;--import org.openremote.agent.sensor.*;-import org.openremote.agent.rules.*--rule "TestRuleFiring"-when- $e: SensorState(sensorName == RuleExecutionLoggerTest.TEST_SENSOR_NAME)-then-// Do Nothing-end-diff --git a/agent/src/test/resources/org/openremote/test/rules/simple/agent.xml b/agent/src/test/resources/org/openremote/test/rules/simple/agent.xmldeleted file mode 100755index 1f720d204..000000000--- a/agent/src/test/resources/org/openremote/test/rules/simple/agent.xml+++ /dev/null@@ -1,29 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<openremote xmlns="http://www.openremote.org/schemas/agent/3">-- <sensors>- <sensor id="123" type="switch" name="TestSensor">- <include type="command" ref="456"/>- <state name="on"/>- <state name="off"/>- </sensor>- </sensors>-- <commands>- <command id="456" protocol="test">- <property name="name" value="TestCommand"/>- <property name="what-are-we-testing" value="a-test-switch"/>- <property name="urn:openremote:device-command:device-name" value="TestDevice"/>- <property name="urn:openremote:device-command:device-id" value="111"/>- <property name="urn:ooma:special" value="WindowSensorCommand"/>- </command>- </commands>-- <config>- <property name="someString" value="BAR"/>- <property name="someBoolean" value="true"/>- <property name="someInteger" value="333"/>- </config>--</openremote>-diff --git a/agent/src/test/resources/org/openremote/test/rules/vacation/Vacation.drl b/agent/src/test/resources/org/openremote/test/rules/vacation/Vacation.drldeleted file mode 100644index 285a030ec..000000000--- a/agent/src/test/resources/org/openremote/test/rules/vacation/Vacation.drl+++ /dev/null@@ -1,68 +0,0 @@-package org.openremote.test.rules;--global org.openremote.agent.command.Commands commands;--import org.openremote.agent.sensor.*;--/*- * This example demonstrates creation of new facts from within the rules, in this- * case a vacation object that can be used to determine differing behavior on event- * actions.- */--declare Vacation- onVacation : boolean-end--/* Insert a new vacation fact */--rule "I'm going on vacation"-when- SensorState ( sensorName == "vacation start" )-then- Vacation vacation = new Vacation();- insert ( vacation );-end--/* Retract the vacation fact */--rule "I'm back from vacation"-when- SensorState ( sensorName == "vacation end" )- $vacation : Vacation()-then- retract ( $vacation );-end--/* Set night temperatures differently depending on presence of vacation fact */--rule "Set Night Temperature"-when- CustomSensorState( sensorName == "time of day", value == "night" ) and not Vacation()-then- commands.execute("temp", 18);-end--rule "Set Night Temperature when on Vacation"-when- CustomSensorState ( sensorName == "time of day", value == "night" ) and exists Vacation()-then- commands.execute("temp", 15);-end--/* Set day temperatures differently depending on the presence of vacation fact */--rule "Set Day Temperature"-when- CustomSensorState ( sensorName == "time of day", value == "day" ) and not Vacation()-then- commands.execute("temp", 21);-end--rule "Set Day Temperature when on Vacation"-when- SensorState ( sensorName == "time of day", value == "day" ) and exists Vacation()-then- commands.execute("temp", 15);-end-diff --git a/agent/src/test/resources/org/openremote/test/rules/vacation/agent.xml b/agent/src/test/resources/org/openremote/test/rules/vacation/agent.xmldeleted file mode 100755index 8eb67801d..000000000--- a/agent/src/test/resources/org/openremote/test/rules/vacation/agent.xml+++ /dev/null@@ -1,20 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<openremote xmlns="http://www.openremote.org/schemas/agent/3">-- <sensors>- </sensors>-- <commands>- <command id="456" protocol="test">- <property name="name" value="temp"/>- <property name="what-are-we-testing" value="an-executable-command"/>- <property name="urn:openremote:device-command:device-name" value="TestDevice"/>- <property name="urn:openremote:device-command:device-id" value="111"/>- </command>- </commands>-- <config>- </config>--</openremote>-diff --git a/manager/server/src/main/java/org/openremote/manager/server/Main.java b/manager/server/src/main/java/org/openremote/manager/server/Main.javaindex 753736ac8..61dca9e85 100644--- a/manager/server/src/main/java/org/openremote/manager/server/Main.java+++ b/manager/server/src/main/java/org/openremote/manager/server/Main.java@@ -19,7 +19,7 @@*/package org.openremote.manager.server;-import org.openremote.agent3.protocol.Protocol;+import org.openremote.agent.protocol.Protocol;import org.openremote.container.Container;import org.openremote.container.ContainerService;import org.openremote.container.message.MessageBrokerService;diff --git a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.javaindex 4a6931b74..a2688a9f6 100644--- a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java@@ -20,8 +20,8 @@package org.openremote.manager.server.agent;import org.apache.camel.builder.RouteBuilder;-import org.openremote.agent3.protocol.Protocol;-import org.openremote.agent3.protocol.ProtocolAssetService;+import org.openremote.agent.protocol.Protocol;+import org.openremote.agent.protocol.ProtocolAssetService;import org.openremote.container.Container;import org.openremote.container.ContainerService;import org.openremote.container.message.MessageBrokerService;@@ -47,8 +47,8 @@ import java.util.logging.Logger;import java.util.stream.Collectors;import java.util.stream.Stream;-import static org.openremote.agent3.protocol.Protocol.ACTUATOR_TOPIC;-import static org.openremote.agent3.protocol.Protocol.DeploymentStatus.*;+import static org.openremote.agent.protocol.Protocol.ACTUATOR_TOPIC;+import static org.openremote.agent.protocol.Protocol.DeploymentStatus.*;import static org.openremote.container.persistence.PersistenceEvent.PERSISTENCE_TOPIC;import static org.openremote.manager.server.asset.AssetPredicates.isPersistenceEventForAssetType;import static org.openremote.manager.server.asset.AssetPredicates.isPersistenceEventForEntityType;diff --git a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.javaindex ae2968183..391f429a9 100644--- a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetProcessingService.java@@ -20,7 +20,7 @@package org.openremote.manager.server.asset;import org.apache.camel.builder.RouteBuilder;-import org.openremote.agent3.protocol.Protocol;+import org.openremote.agent.protocol.Protocol;import org.openremote.container.Container;import org.openremote.container.ContainerService;import org.openremote.container.message.MessageBrokerService;@@ -46,7 +46,7 @@ import java.util.function.Consumer;import java.util.logging.Level;import java.util.logging.Logger;-import static org.openremote.agent3.protocol.Protocol.SENSOR_QUEUE;+import static org.openremote.agent.protocol.Protocol.SENSOR_QUEUE;import static org.openremote.manager.server.event.EventService.INCOMING_EVENT_TOPIC;import static org.openremote.manager.server.event.EventService.getWebsocketAuth;import static org.openremote.model.asset.agent.AgentLink.getAgentLink;@@ -56,7 +56,7 @@ import static org.openremote.model.asset.agent.AgentLink.getAgentLink;* <p>* {@link AttributeEvent}s can come from various sources:* <ul>- * <li>Protocol ({@link org.openremote.agent3.protocol.AbstractProtocol#updateLinkedAttribute})</li>+ * <li>Protocol ({@link org.openremote.agent.protocol.AbstractProtocol#updateLinkedAttribute})</li>* <li>User/Client initiated ({@link #updateAttributeValue})</li>* <li>Rules ({@link org.openremote.model.rules.Assets#dispatch})</li>* </ul>@@ -87,7 +87,7 @@ import static org.openremote.model.asset.agent.AgentLink.getAgentLink;* <h2>Agent service processing logic</h2>* <p>* When the attribute event came from a Protocol (i.e. generated by a call from- * {@link org.openremote.agent3.protocol.AbstractProtocol#updateLinkedAttribute} then+ * {@link org.openremote.agent.protocol.AbstractProtocol#updateLinkedAttribute} then* the agent service will ignore the message and just pass it onto the next consumer.* <p>* When the attribute event came from any other source then the agent service will check if it relates@@ -97,8 +97,8 @@ import static org.openremote.model.asset.agent.AgentLink.getAgentLink;* {@link AssetState.ProcessingStatus#ERROR} and the message will not be able to progress through the processing chain.* <p>* If the message is for a valid linked agent then an {@link AttributeEvent} is sent on the- * {@link org.openremote.agent3.protocol.AbstractProtocol#ACTUATOR_TOPIC} which the protocol will receive in- * {@link org.openremote.agent3.protocol.AbstractProtocol#processLinkedAttributeWrite} for execution on an actual device or+ * {@link org.openremote.agent.protocol.AbstractProtocol#ACTUATOR_TOPIC} which the protocol will receive in+ * {@link org.openremote.agent.protocol.AbstractProtocol#processLinkedAttributeWrite} for execution on an actual device or* service 'things'.* <p>* This means that a protocol implementation is responsible for producing a new {@link AttributeEvent} to@@ -288,7 +288,7 @@ public class AssetProcessingService extends RouteBuilder implements ContainerSer* This is the entry point for any attribute value change event in the entire system.* <p>* Ingestion is asynchronous, through either- * {@link org.openremote.agent3.protocol.Protocol#SENSOR_QUEUE} or {@link #ASSET_QUEUE}.+ * {@link org.openremote.agent.protocol.Protocol#SENSOR_QUEUE} or {@link #ASSET_QUEUE}.* <p>* This deals with single attribute value changes and pushes them through the attribute event* processing chain where each consumer is given the opportunity to consume the event or allowdiff --git a/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.java b/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.javaindex ab5e1f4d3..afb2ef668 100644--- a/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/concurrent/ManagerExecutorService.java@@ -19,7 +19,7 @@*/package org.openremote.manager.server.concurrent;-import org.openremote.agent3.protocol.ProtocolExecutorService;+import org.openremote.agent.protocol.ProtocolExecutorService;import org.openremote.container.Container;import org.openremote.container.concurrent.ContainerExecutor;import org.openremote.container.concurrent.ContainerScheduledExecutor;diff --git a/manager/server/src/main/java/org/openremote/manager/server/rules/RuleExecutionLogger.java b/manager/server/src/main/java/org/openremote/manager/server/rules/RuleExecutionLogger.javaindex 4c95ab04f..a021ca196 100644--- a/manager/server/src/main/java/org/openremote/manager/server/rules/RuleExecutionLogger.java+++ b/manager/server/src/main/java/org/openremote/manager/server/rules/RuleExecutionLogger.java@@ -1,14 +1,30 @@+/*+ * Copyright 2017, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */package org.openremote.manager.server.rules;import org.kie.api.definition.rule.Rule;import org.kie.api.event.rule.BeforeMatchFiredEvent;import org.kie.api.event.rule.DefaultAgendaEventListener;import org.kie.api.runtime.rule.Match;-import org.openremote.agent.sensor.Sensor;-import org.openremote.agent.sensor.SensorState;import java.util.List;-import java.util.Map;import java.util.function.Supplier;import java.util.logging.Logger;@@ -45,11 +61,14 @@ public class RuleExecutionLogger extends DefaultAgendaEventListener {for (String declarationID : declarationIDs) {Object declarationValue = matchEvent.getDeclarationValue(declarationID);String declarationValueString = this.declarationValueToString(declarationValue);+ /* TODO Update for v3if (declarationValue instanceof Sensor || declarationValue instanceof SensorState) {declarationLog = String.format("%s\t\tDeclaration: \"%s\"\n\t\tValue:\n\t\t\t%s\n", declarationLog, declarationID, declarationValueString);} else {declarationLog = String.format("%s\t\tDeclaration: \"%s: %s\"\n", declarationLog, declarationID, declarationValueString);}+ */+ declarationLog = String.format("%s\t\tDeclaration: \"%s: %s\"\n", declarationLog, declarationID, declarationValueString);}String objectLog = "";@@ -91,6 +110,7 @@ public class RuleExecutionLogger extends DefaultAgendaEventListener {theValue = antecedent.toString();}+ /* TODO Update for v3if (antecedent instanceof Sensor) //may be unnecessary if we never have raw sensor objects in WM{Sensor theSensor = (Sensor) antecedent;@@ -112,6 +132,7 @@ public class RuleExecutionLogger extends DefaultAgendaEventListener {String stateValue = theSensorState.getValue().toString(); //assumes all values can directly cast to StringtheValue = String.format("Sensor name: \t\"%s\"\n\t\t\tState value: \t\"%s\"", sensorName, stateValue);}+ */return theValue;}@@ -129,6 +150,7 @@ public class RuleExecutionLogger extends DefaultAgendaEventListener {convertedDeclarationValue = declarationValue.toString();}+ /* TODO Update for v3if (declarationValue instanceof Sensor) //may be unnecessary if we never have raw sensor objects in WM{convertedDeclarationValue = ((Sensor) declarationValue).getSensorDefinition().getName();@@ -138,6 +160,7 @@ public class RuleExecutionLogger extends DefaultAgendaEventListener {String sensorValue = ((SensorState) declarationValue).getValue().toString();convertedDeclarationValue = String.format("Sensor Name: \"%s\"\n\t\t\tSensor Value: \"%s\"", sensorName, sensorValue);}+ */return convertedDeclarationValue;}diff --git a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.javaindex 4dad60409..799167e09 100644--- a/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java+++ b/manager/server/src/main/java/org/openremote/manager/server/setup/builtin/ManagerDemoSetup.java@@ -20,16 +20,16 @@package org.openremote.manager.server.setup.builtin;import com.vividsolutions.jts.geom.Coordinate;-import org.openremote.agent3.protocol.macro.MacroAction;-import org.openremote.agent3.protocol.macro.MacroProtocol;-import org.openremote.agent3.protocol.simulator.SimulatorProtocol;-import org.openremote.agent3.protocol.simulator.element.ColorSimulatorElement;-import org.openremote.agent3.protocol.simulator.element.DecimalSimulatorElement;-import org.openremote.agent3.protocol.simulator.element.IntegerSimulatorElement;-import org.openremote.agent3.protocol.simulator.element.SwitchSimulatorElement;-import org.openremote.agent3.protocol.trigger.TriggerProtocol;-import org.openremote.agent3.protocol.trigger.TriggerType;-import org.openremote.agent3.protocol.trigger.time.TimeTriggerProperty;+import org.openremote.agent.protocol.macro.MacroAction;+import org.openremote.agent.protocol.macro.MacroProtocol;+import org.openremote.agent.protocol.simulator.SimulatorProtocol;+import org.openremote.agent.protocol.simulator.element.ColorSimulatorElement;+import org.openremote.agent.protocol.simulator.element.DecimalSimulatorElement;+import org.openremote.agent.protocol.simulator.element.IntegerSimulatorElement;+import org.openremote.agent.protocol.simulator.element.SwitchSimulatorElement;+import org.openremote.agent.protocol.trigger.TriggerProtocol;+import org.openremote.agent.protocol.trigger.TriggerType;+import org.openremote.agent.protocol.trigger.time.TimeTriggerProperty;import org.openremote.container.Container;import org.openremote.manager.server.asset.ServerAsset;import org.openremote.manager.server.setup.AbstractManagerSetup;@@ -46,9 +46,9 @@ import java.time.ZonedDateTime;import java.util.Arrays;import java.util.List;-import static org.openremote.agent3.protocol.macro.MacroProtocol.META_MACRO_ACTION_INDEX;-import static org.openremote.agent3.protocol.macro.MacroProtocol.PROPERTY_MACRO_ACTION;-import static org.openremote.agent3.protocol.trigger.TriggerConfiguration.*;+import static org.openremote.agent.protocol.macro.MacroProtocol.META_MACRO_ACTION_INDEX;+import static org.openremote.agent.protocol.macro.MacroProtocol.PROPERTY_MACRO_ACTION;+import static org.openremote.agent.protocol.trigger.TriggerConfiguration.*;import static org.openremote.model.asset.AssetMeta.*;import static org.openremote.model.asset.AssetType.*;import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;diff --git a/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy b/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovyindex 28b7c720b..45e359d45 100644--- a/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy+++ b/manager/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy@@ -2,7 +2,7 @@ package org.openremote.testimport com.google.common.collect.Listsimport org.drools.core.time.impl.PseudoClockScheduler-import org.openremote.agent3.protocol.Protocol+import org.openremote.agent.protocol.Protocolimport org.openremote.container.Containerimport org.openremote.container.ContainerServiceimport org.openremote.container.message.MessageBrokerServicediff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovyindex ff4be902e..d83d0c629 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetDatapointTest.groovy@@ -1,7 +1,7 @@package org.openremote.test.assetsimport org.openremote.model.value.Values-import org.openremote.agent3.protocol.simulator.SimulatorProtocol+import org.openremote.agent.protocol.simulator.SimulatorProtocolimport org.openremote.manager.server.asset.AssetStorageServiceimport org.openremote.manager.server.datapoint.AssetDatapointServiceimport org.openremote.manager.server.setup.SetupServicediff --git a/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy b/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovyindex 75fdf2bab..45967998c 100644--- a/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/assets/AssetProcessingTest.groovy@@ -1,10 +1,9 @@package org.openremote.test.assets-import org.openremote.agent3.protocol.AbstractProtocol+import org.openremote.agent.protocol.AbstractProtocolimport org.openremote.manager.server.asset.AssetProcessingServiceimport org.openremote.manager.server.asset.AssetStorageServiceimport org.openremote.manager.server.asset.ServerAsset-import org.openremote.manager.server.rules.RulesServiceimport org.openremote.manager.server.setup.SetupServiceimport org.openremote.manager.server.setup.builtin.KeycloakDemoSetupimport org.openremote.manager.server.setup.builtin.ManagerDemoSetupdiff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovyindex babafc041..0ecee8c34 100644--- a/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/BasicProtocolTest.groovy@@ -19,8 +19,8 @@*/package org.openremote.test.protocol-import org.openremote.agent3.protocol.AbstractProtocol-import org.openremote.agent3.protocol.Protocol+import org.openremote.agent.protocol.AbstractProtocol+import org.openremote.agent.protocol.Protocolimport org.openremote.manager.server.agent.AgentServiceimport org.openremote.manager.server.asset.AssetProcessingServiceimport org.openremote.manager.server.asset.AssetStorageService