use of org.openmuc.framework.data.BooleanValue in project OpenMUC by isc-konstanz.
the class ModbusChannelGroup method setChannelValues.
public void setChannelValues(BitVector bitVector, List<ChannelRecordContainer> containers) {
for (ModbusChannel channel : channels) {
long receiveTime = System.currentTimeMillis();
// determine start index of the registers which contain the values of the channel
int index = channel.getStartAddress() - getStartAddress();
BooleanValue value = new BooleanValue(bitVector.getBit(index));
ChannelRecordContainer container = searchContainer(channel.getChannelAddress(), containers);
container.setRecord(new Record(value, receiveTime));
}
}
use of org.openmuc.framework.data.BooleanValue in project OpenMUC by isc-konstanz.
the class InputPin method read.
@Read
public void read(List<GpioChannel> channels, String samplingGroup) throws ConnectionException {
long samplingTime = System.currentTimeMillis();
for (GpioChannel channel : channels) {
PinState state = pin.getState();
Value value;
if (!channel.isInverted()) {
value = new BooleanValue(state.isHigh());
} else {
value = new BooleanValue(state.isLow());
}
channel.setRecord(new Record(value, samplingTime, Flag.VALID));
}
}
use of org.openmuc.framework.data.BooleanValue in project OpenMUC by isc-konstanz.
the class Iec60870DataHandling method binaryCounterReading.
private static Record binaryCounterReading(String dataType, long timestamp, InformationElement informationElement) {
IeBinaryCounterReading quality = (IeBinaryCounterReading) informationElement;
Record record = null;
Set<org.openmuc.j60870.ie.IeBinaryCounterReading.Flag> flags = quality.getFlags();
switch(// iv ca cy
dataType) {
case "iv":
record = new Record(new BooleanValue(flags.contains(IeBinaryCounterReading.Flag.INVALID)), timestamp);
break;
case "ca":
record = new Record(new BooleanValue(flags.contains(IeBinaryCounterReading.Flag.COUNTER_ADJUSTED)), timestamp);
break;
case "cy":
record = new Record(new BooleanValue(flags.contains(IeBinaryCounterReading.Flag.CARRY)), timestamp);
break;
default:
}
return record;
}
use of org.openmuc.framework.data.BooleanValue in project OpenMUC by isc-konstanz.
the class DbAccess method queryRecords.
/**
* Retrieves data from database and adds it to records
*/
public List<Record> queryRecords(StringBuilder sb, ValueType valuetype) {
// retrieve numeric values from database and add them to the records list
List<Record> records = new ArrayList<>();
String sql = sb.toString();
try (ResultSet resultSet = dbConnector.createStatementWithConnection().executeQuery(sql)) {
while (resultSet.next()) {
if (valuetype == ValueType.STRING) {
Record rc = new Record(new StringValue(resultSet.getString(VALUE)), resultSet.getTimestamp("time").getTime(), Flag.VALID);
records.add(rc);
} else if (valuetype == ValueType.BYTE_ARRAY) {
Record rc = new Record(new ByteArrayValue(resultSet.getBytes(VALUE)), resultSet.getTimestamp("time").getTime(), Flag.VALID);
records.add(rc);
} else if (valuetype == ValueType.BOOLEAN) {
Record rc = new Record(new BooleanValue(resultSet.getBoolean(VALUE)), resultSet.getTimestamp("time").getTime(), Flag.VALID);
records.add(rc);
} else {
Record rc = new Record(new DoubleValue(resultSet.getDouble(VALUE)), resultSet.getTimestamp("time").getTime(), Flag.VALID);
records.add(rc);
}
}
} catch (SQLException e) {
logger.error(MessageFormat.format("Error executing SQL: \n{0}", sql), e.getMessage());
}
return records;
}
use of org.openmuc.framework.data.BooleanValue in project OpenMUC by isc-konstanz.
the class OpcChannel method setValue.
@Override
public void setValue(AttributeContext context, VariableNode node, DataValue value) throws UaException {
Variant variant = value.getValue();
Record record = null;
switch(getValueType()) {
case BOOLEAN:
record = new Record(new BooleanValue((Boolean) variant.getValue()), value.getServerTime().getUtcTime());
break;
case BYTE:
record = new Record(new ByteValue((Byte) variant.getValue()), value.getServerTime().getUtcTime());
break;
case SHORT:
record = new Record(new ShortValue((Short) variant.getValue()), value.getServerTime().getUtcTime());
break;
case INTEGER:
record = new Record(new IntValue((Integer) variant.getValue()), value.getServerTime().getUtcTime());
break;
case LONG:
record = new Record(new LongValue((Long) variant.getValue()), value.getServerTime().getUtcTime());
break;
case FLOAT:
record = new Record(new FloatValue((Float) variant.getValue()), value.getServerTime().getUtcTime());
break;
case DOUBLE:
record = new Record(new DoubleValue((Double) variant.getValue()), value.getServerTime().getUtcTime());
break;
default:
record = new Record(new StringValue((String) variant.getValue()), value.getServerTime().getUtcTime());
break;
}
setRecord(record);
}
Aggregations