Search in sources :

Example 6 with BooleanValue

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));
    }
}
Also used : ChannelRecordContainer(org.openmuc.framework.driver.spi.ChannelRecordContainer) BooleanValue(org.openmuc.framework.data.BooleanValue) Record(org.openmuc.framework.data.Record)

Example 7 with BooleanValue

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));
    }
}
Also used : PinState(com.pi4j.io.gpio.PinState) BooleanValue(org.openmuc.framework.data.BooleanValue) Value(org.openmuc.framework.data.Value) BooleanValue(org.openmuc.framework.data.BooleanValue) Record(org.openmuc.framework.data.Record) Read(org.openmuc.framework.driver.annotation.Read)

Example 8 with BooleanValue

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;
}
Also used : IeBinaryCounterReading(org.openmuc.j60870.ie.IeBinaryCounterReading) BooleanValue(org.openmuc.framework.data.BooleanValue) Record(org.openmuc.framework.data.Record) Flag(org.openmuc.framework.data.Flag)

Example 9 with BooleanValue

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;
}
Also used : DoubleValue(org.openmuc.framework.data.DoubleValue) SQLException(java.sql.SQLException) BooleanValue(org.openmuc.framework.data.BooleanValue) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) Record(org.openmuc.framework.data.Record) ByteArrayValue(org.openmuc.framework.data.ByteArrayValue) StringValue(org.openmuc.framework.data.StringValue)

Example 10 with BooleanValue

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);
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) ByteValue(org.openmuc.framework.data.ByteValue) ShortValue(org.openmuc.framework.data.ShortValue) DoubleValue(org.openmuc.framework.data.DoubleValue) BooleanValue(org.openmuc.framework.data.BooleanValue) LongValue(org.openmuc.framework.data.LongValue) Record(org.openmuc.framework.data.Record) FloatValue(org.openmuc.framework.data.FloatValue) StringValue(org.openmuc.framework.data.StringValue) IntValue(org.openmuc.framework.data.IntValue)

Aggregations

BooleanValue (org.openmuc.framework.data.BooleanValue)14 Record (org.openmuc.framework.data.Record)10 DoubleValue (org.openmuc.framework.data.DoubleValue)8 FloatValue (org.openmuc.framework.data.FloatValue)8 StringValue (org.openmuc.framework.data.StringValue)8 ByteArrayValue (org.openmuc.framework.data.ByteArrayValue)7 ByteValue (org.openmuc.framework.data.ByteValue)7 IntValue (org.openmuc.framework.data.IntValue)7 LongValue (org.openmuc.framework.data.LongValue)7 ShortValue (org.openmuc.framework.data.ShortValue)7 Value (org.openmuc.framework.data.Value)3 ArrayList (java.util.ArrayList)2 ChannelRecordContainer (org.openmuc.framework.driver.spi.ChannelRecordContainer)2 ServerModel (com.beanit.iec61850bean.ServerModel)1 PinState (com.pi4j.io.gpio.PinState)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)1 Test (org.junit.jupiter.api.Test)1 ArgumentSyntaxException (org.openmuc.framework.config.ArgumentSyntaxException)1