public void execute(JobExecutionContext context)
throws JobExecutionException {
// get the reference to the Stick
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
String serialPort = (String) dataMap.get("SerialPort");
OceanicValueSelector valueSelector = (OceanicValueSelector) dataMap.get("ValueSelector");
OceanicBinding theBinding = (OceanicBinding) dataMap.get("Binding");
theBinding.lockSerialDevices();
SerialDevice serialDevice = theBinding.serialDevices.get(serialPort);
String response = null;
if(serialDevice != null) {
response = serialDevice.requestResponse(valueSelector.name());
logger.debug("Requested '{}' from the oceanic unit, got '{}' back",valueSelector.name(),response);
}
theBinding.unlockSerialDevices();
// process response etc
if(response!=null) {
for (OceanicBindingProvider provider : theBinding.providers) {
for (String itemName : provider.getItemNames()) {
String itemSerialPort = provider.getSerialPort(itemName);
OceanicValueSelector itemSelector = OceanicValueSelector.getValueSelector(provider.getValueSelector(itemName),ValueSelectorType.GET);
if (itemSerialPort.equals(serialPort) && itemSelector.equals(valueSelector)) {
if(serialDevice.cachedValues.get(valueSelector)==null || !serialDevice.cachedValues.get(valueSelector).equals(response)) {
serialDevice.cachedValues.put(valueSelector, response);
State value;
try {
value = createStateForType(valueSelector,response);