use of io.openems.api.device.nature.DeviceNature in project openems by OpenEMS.
the class SimulatorReadChannel method required.
@Override
public SimulatorReadChannel<T> required() {
super.required();
if (parent() instanceof DeviceNature) {
DeviceNature parent = (DeviceNature) parent();
parent.setAsRequired(this);
}
return this;
}
use of io.openems.api.device.nature.DeviceNature in project openems by OpenEMS.
the class EssClusterNature method loadEss.
private void loadEss() {
Set<DeviceNature> natures = repo.getDeviceNatures();
JsonArray essIds;
try {
essIds = esss.value();
// remove old ess
for (SymmetricEssNature ess : this.essList) {
soc.removeChannel(ess.soc());
gridMode.removeChannel(ess.gridMode());
systemState.removeChannel(ess.systemState());
allowedCharge.removeChannel(ess.allowedCharge());
allowedDischarge.removeChannel(ess.allowedDischarge());
allowedApparent.removeChannel(ess.allowedApparent());
activePower.removeChannel(ess.activePower());
reactivePower.removeChannel(ess.reactivePower());
apparentPower.removeChannel(ess.apparentPower());
maxNominalPower.removeChannel(ess.maxNominalPower());
capacity.removeChannel(ess.capacity());
setWorkState.removeChannel(ess.setWorkState());
power.removeEss(ess);
}
essList.clear();
if (essIds != null && isInitialized) {
for (DeviceNature nature : natures) {
if (nature instanceof SymmetricEssNature) {
if (essIds.toString().contains(nature.id())) {
SymmetricEssNature ess = (SymmetricEssNature) nature;
essList.add(ess);
soc.addChannel(ess.soc());
gridMode.addChannel(ess.gridMode());
systemState.addChannel(ess.systemState());
allowedCharge.addChannel(ess.allowedCharge());
allowedDischarge.addChannel(ess.allowedDischarge());
allowedApparent.addChannel(ess.allowedApparent());
activePower.addChannel(ess.activePower());
reactivePower.addChannel(ess.reactivePower());
apparentPower.addChannel(ess.apparentPower());
maxNominalPower.addChannel(ess.maxNominalPower());
capacity.addChannel(ess.capacity());
setWorkState.addChannel(ess.setWorkState());
power.addEss(ess);
}
}
}
// capacity.channelUpdated(null, null);
}
} catch (InvalidValueException e) {
log.error("esss value is invalid!", e);
}
}
use of io.openems.api.device.nature.DeviceNature in project openems by OpenEMS.
the class FeneconPersistence method addChannelValueToQueue.
/**
* Add a channel value to the send queue
*
* @param channel
* @param valueOpt
*/
private void addChannelValueToQueue(Channel channel, Optional<?> valueOpt) {
// Ignore anything that is not a ReadChannel
if (!(channel instanceof ReadChannel<?>)) {
return;
}
ReadChannel<?> readChannel = (ReadChannel<?>) channel;
// Ignore channels that shall not be persisted
if (readChannel.isDoNotPersist()) {
return;
}
// Read and format value from channel
FieldValue<?> fieldValue;
if (!valueOpt.isPresent()) {
fieldValue = new NullFieldValue();
} else {
Object value = valueOpt.get();
if (value instanceof Number) {
fieldValue = new NumberFieldValue((Number) value);
} else if (value instanceof String) {
fieldValue = new StringFieldValue((String) value);
} else if (value instanceof Inet4Address) {
fieldValue = new StringFieldValue(((Inet4Address) value).getHostAddress());
} else if (value instanceof Boolean) {
fieldValue = new NumberFieldValue(((Boolean) value) ? 1 : 0);
} else if (value instanceof ChannelEnum) {
fieldValue = new NumberFieldValue(((ChannelEnum) value).getValue());
} else if (value instanceof DeviceNature || value instanceof JsonElement || value instanceof Map || value instanceof Set || value instanceof List || value instanceof ThingMap) {
// ignore
return;
} else {
log.warn("FENECON Persistence for value type [" + value.getClass().getName() + "] of channel [" + channel.address() + "] is not implemented.");
return;
}
}
// Add timestamp + value to queue
synchronized (queue) {
queue.put(readChannel.address(), fieldValue);
}
}
use of io.openems.api.device.nature.DeviceNature in project openems by OpenEMS.
the class KebaDevice method receive.
/**
* Forward message to deviceNature
*/
public void receive(String message) {
for (DeviceNature nature : this.getDeviceNatures()) {
if (nature instanceof KebaDeviceNature) {
KebaDeviceNature kebaNature = (KebaDeviceNature) nature;
kebaNature.receive(message);
}
}
}
use of io.openems.api.device.nature.DeviceNature in project openems by OpenEMS.
the class ModbusReadChannel method required.
@Override
public ReadChannel<T> required() {
super.required();
if (parent() instanceof DeviceNature) {
DeviceNature parent = (DeviceNature) parent();
parent.setAsRequired(this);
}
return super.required();
}
Aggregations