[pidcontroller] Improve logging (#11312)
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
This commit is contained in:
parent
0d5ecd3417
commit
0363ba4588
|
@ -72,10 +72,12 @@ public class PIDControllerTriggerHandler extends BaseTriggerModuleHandler implem
|
||||||
private @Nullable String iInspector;
|
private @Nullable String iInspector;
|
||||||
private @Nullable String dInspector;
|
private @Nullable String dInspector;
|
||||||
private @Nullable String eInspector;
|
private @Nullable String eInspector;
|
||||||
|
private ItemRegistry itemRegistry;
|
||||||
|
|
||||||
public PIDControllerTriggerHandler(Trigger module, ItemRegistry itemRegistry, EventPublisher eventPublisher,
|
public PIDControllerTriggerHandler(Trigger module, ItemRegistry itemRegistry, EventPublisher eventPublisher,
|
||||||
BundleContext bundleContext) {
|
BundleContext bundleContext) {
|
||||||
super(module);
|
super(module);
|
||||||
|
this.itemRegistry = itemRegistry;
|
||||||
this.eventPublisher = eventPublisher;
|
this.eventPublisher = eventPublisher;
|
||||||
|
|
||||||
Configuration config = module.getConfiguration();
|
Configuration config = module.getConfiguration();
|
||||||
|
@ -154,14 +156,14 @@ public class PIDControllerTriggerHandler extends BaseTriggerModuleHandler implem
|
||||||
try {
|
try {
|
||||||
input = getItemValueAsNumber(inputItem);
|
input = getItemValueAsNumber(inputItem);
|
||||||
} catch (PIDException e) {
|
} catch (PIDException e) {
|
||||||
logger.warn("Input item: {}", e.getMessage());
|
logger.warn("Input item: {}: {}", inputItem.getName(), e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setpoint = getItemValueAsNumber(setpointItem);
|
setpoint = getItemValueAsNumber(setpointItem);
|
||||||
} catch (PIDException e) {
|
} catch (PIDException e) {
|
||||||
logger.warn("Setpoint item: {}", e.getMessage());
|
logger.warn("Setpoint item: {}: {}", setpointItem.getName(), e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +182,12 @@ public class PIDControllerTriggerHandler extends BaseTriggerModuleHandler implem
|
||||||
|
|
||||||
private void updateItem(@Nullable String itemName, double value) {
|
private void updateItem(@Nullable String itemName, double value) {
|
||||||
if (itemName != null) {
|
if (itemName != null) {
|
||||||
|
try {
|
||||||
|
itemRegistry.getItem(itemName);
|
||||||
eventPublisher.post(ItemEventFactory.createCommandEvent(itemName, new DecimalType(value)));
|
eventPublisher.post(ItemEventFactory.createCommandEvent(itemName, new DecimalType(value)));
|
||||||
|
} catch (ItemNotFoundException e) {
|
||||||
|
logger.warn("Item doesn't exist: {}", itemName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,8 +216,7 @@ public class PIDControllerTriggerHandler extends BaseTriggerModuleHandler implem
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new PIDException(
|
throw new PIDException("Not a number: " + setpointState.getClass().getSimpleName() + ": " + setpointState);
|
||||||
"Item type is not a number: " + setpointState.getClass().getSimpleName() + ": " + setpointState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue