当前位置: 首页>>代码示例>>Java>>正文


Java DataValue.getValue方法代码示例

本文整理汇总了Java中org.eclipse.milo.opcua.stack.core.types.builtin.DataValue.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java DataValue.getValue方法的具体用法?Java DataValue.getValue怎么用?Java DataValue.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.milo.opcua.stack.core.types.builtin.DataValue的用法示例。


在下文中一共展示了DataValue.getValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeDataValue

import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; //导入方法依赖的package包/类
public void writeDataValue(DataValue value) throws UaSerializationException {
    if (value == null) {
        buffer.writeByte(0);
    } else {
        int mask = 0x00;

        if (value.getValue() != null && value.getValue().isNotNull()) mask |= 0x01;
        if (!StatusCode.GOOD.equals(value.getStatusCode())) mask |= 0x02;
        if (!DateTime.MIN_VALUE.equals(value.getSourceTime())) mask |= 0x04;
        if (!DateTime.MIN_VALUE.equals(value.getServerTime())) mask |= 0x08;

        buffer.writeByte(mask);

        if ((mask & 0x01) == 0x01) writeVariant(value.getValue());
        if ((mask & 0x02) == 0x02) writeStatusCode(value.getStatusCode());
        if ((mask & 0x04) == 0x04) writeDateTime(value.getSourceTime());
        if ((mask & 0x08) == 0x08) writeDateTime(value.getServerTime());
    }
}
 
开发者ID:eclipse,项目名称:milo,代码行数:20,代码来源:OpcUaBinaryStreamEncoder.java

示例2: run

import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; //导入方法依赖的package包/类
@Override
public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throws Exception {
    registerCustomCodec();

    // synchronous connect
    client.connect().get();

    // synchronous read request via VariableNode
    VariableNode node = client.getAddressSpace().createVariableNode(
        new NodeId(2, "HelloWorld/CustomDataTypeVariable"));

    logger.info("DataType={}", node.getDataType().get());

    DataValue value = node.readValue().get();
    logger.info("Value={}", value);

    Variant variant = value.getValue();
    ExtensionObject xo = (ExtensionObject) variant.getValue();

    CustomDataType decoded = xo.decode();
    logger.info("Decoded={}", decoded);

    future.complete(client);
}
 
开发者ID:eclipse,项目名称:milo,代码行数:25,代码来源:ReadCustomDataTypeNodeExample.java

示例3: read

import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; //导入方法依赖的package包/类
@Override
public void read(ReadContext context, Double maxAge, TimestampsToReturn timestamps, List<ReadValueId> readValueIds) {
    List<DataValue> results = Lists.newArrayListWithCapacity(readValueIds.size());

    for (ReadValueId id : readValueIds) {
        ServerNode node = nodeManager.get(id.getNodeId());

        if (node != null) {
            DataValue value = node.readAttribute(
                new AttributeContext(context),
                id.getAttributeId(),
                timestamps,
                id.getIndexRange()
            );

            if (logger.isTraceEnabled()) {
                Variant variant = value.getValue();
                Object o = variant != null ? variant.getValue() : null;
                logger.trace("Read value={} from attributeId={} of {}",
                    o, id.getAttributeId(), id.getNodeId());
            }

            results.add(value);
        } else {
            results.add(new DataValue(new StatusCode(StatusCodes.Bad_NodeIdUnknown)));
        }
    }

    context.complete(results);
}
 
开发者ID:eclipse,项目名称:milo,代码行数:31,代码来源:TestNamespace.java

示例4: extract

import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T extract(DataValue value) throws UaException {
    Variant variant = value.getValue();
    if (variant == null) return null;

    Object o = variant.getValue();
    if (o == null) return null;

    try {
        return (T) o;
    } catch (ClassCastException e) {
        throw new UaException(StatusCodes.Bad_TypeMismatch);
    }
}
 
开发者ID:eclipse,项目名称:milo,代码行数:15,代码来源:AttributeUtil.java

示例5: validateDataType

import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; //导入方法依赖的package包/类
static DataValue validateDataType(ExpandedNodeId dataType, DataValue value) throws UaException {
    Variant variant = value.getValue();
    if (variant == null) return value;

    Object o = variant.getValue();
    if (o == null) throw new UaException(StatusCodes.Bad_TypeMismatch);

    Class<?> expected = TypeUtil.getBackingClass(dataType);

    Class<?> actual = o.getClass().isArray() ?
        o.getClass().getComponentType() : o.getClass();

    if (expected == null) {
        throw new UaException(StatusCodes.Bad_TypeMismatch);
    } else {
        if (!expected.isAssignableFrom(actual)) {
            /*
             * Writing a ByteString to a UByte[] is explicitly allowed by the spec.
             */
            if (o instanceof ByteString && expected == UByte.class) {
                ByteString byteString = (ByteString) o;

                return new DataValue(
                    new Variant(byteString.uBytes()),
                    value.getStatusCode(),
                    value.getSourceTime(),
                    value.getServerTime());
            } else if (expected == Variant.class) {
                // allow to write anything to a Variant
                return value;
            } else {
                throw new UaException(StatusCodes.Bad_TypeMismatch);
            }
        }
    }

    return value;
}
 
开发者ID:eclipse,项目名称:milo,代码行数:39,代码来源:AttributeWriter.java

示例6: toVariant

import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; //导入方法依赖的package包/类
@Converter
public static Variant toVariant(final DataValue value) {
	return value.getValue();
}
 
开发者ID:ctron,项目名称:de.dentrassi.camel.milo,代码行数:5,代码来源:ValueConverter.java


注:本文中的org.eclipse.milo.opcua.stack.core.types.builtin.DataValue.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。