use of org.openhab.binding.stiebelheatpump.protocol.Request in project openhab1-addons by openhab.
the class CommunicationService method categorizeHeatPumpConfiguration.
/**
* This method categorize the heat pump configuration into setting, sensor
* and status
*
* @return true if heat pump configuration for version could be found and
* loaded
*/
private boolean categorizeHeatPumpConfiguration() {
for (Request request : heatPumpConfiguration) {
logger.debug("Request : Name -> {}, Description -> {} , RequestByte -> {}", request.getName(), request.getDescription(), DatatypeConverter.printHexBinary(new byte[] { request.getRequestByte() }));
if (request.getName().equalsIgnoreCase("Version")) {
versionRequest = request;
logger.debug("Loaded Request : " + versionRequest.getDescription());
continue;
}
for (RecordDefinition record : request.getRecordDefinitions()) {
if (record.getDataType() == Type.Settings && !heatPumpSettingConfiguration.contains(request)) {
heatPumpSettingConfiguration.add(request);
}
if (record.getDataType() == Type.Status && !heatPumpStatusConfiguration.contains(request)) {
heatPumpStatusConfiguration.add(request);
}
if (record.getDataType() == Type.Sensor && !heatPumpSensorConfiguration.contains(request)) {
heatPumpSensorConfiguration.add(request);
}
}
}
if (versionRequest == null) {
logger.debug("version request could not be found in configuration");
return false;
}
return true;
}
use of org.openhab.binding.stiebelheatpump.protocol.Request in project openhab1-addons by openhab.
the class ConfigParser method parseConfig.
/**
* This method loads a List of Request objects from xml file
*
* @param fileName
* file object to load the object from
* @return List of Requests
*/
public List<Request> parseConfig(String fileName) {
logger.debug("Parsing heat pump configuration file {}.", fileName);
try {
JAXBContext context = JAXBContext.newInstance(Requests.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
Requests configuration = (Requests) unmarshaller.unmarshal(stream);
List<Request> requests = configuration.getRequests();
return requests;
} catch (JAXBException e) {
logger.debug("Parsing failed {}. " + e.toString(), fileName);
throw new RuntimeException(e);
}
}
Aggregations