Search in sources :

Example 1 with PDataValue

use of com.ge.dspmicro.machinegateway.types.PDataValue in project predix-machine-template-adapter-edison by PredixDev.

the class IntelBoardSubscriptionMachineAdapter method buildEnvelope.

private PDataValue buildEnvelope(WorkshopDataNodeIntel node, Object value) {
    PEnvelope envelope = new PEnvelope(value);
    PDataValue pDataValue = new PDataValue(node.getNodeId(), envelope);
    pDataValue.setNodeName(node.getName());
    pDataValue.setAddress(node.getAddress());
    return pDataValue;
}
Also used : PDataValue(com.ge.dspmicro.machinegateway.types.PDataValue) PEnvelope(com.ge.dspmicro.machinegateway.types.PEnvelope)

Example 2 with PDataValue

use of com.ge.dspmicro.machinegateway.types.PDataValue in project predix-machine-template-adapter-edison by PredixDev.

the class IntelBoardSubscriptionMachineAdapter method readData.

/*
	 * Reads data from data cache. Data cache always contains latest values.
	 */
@Override
public PDataValue readData(UUID nodeId) throws MachineAdapterException {
    WorkshopDataNodeIntel node = this.dataNodes.get(nodeId);
    if ("IN".equals(node.getNodePinDir())) {
        //$NON-NLS-1$
        // String nodeType = node.getNodeType();
        PDataValue pDataValue = new PDataValue(nodeId);
        float value = node.readValue();
        pDataValue = buildEnvelope(node, value);
        List<TriggerNode> triggerNodes = node.getTriggerNodes();
        if (triggerNodes != null && triggerNodes.size() > 0) {
            for (TriggerNode tNode : triggerNodes) {
                WorkshopDataNodeIntel triggerNode = getNodeByName(tNode.getNodeName());
                // String valExp = tNode.getNodeValueExpression();
                String evalExp = //$NON-NLS-1$
                tNode.getNodeValueExpression().replaceAll(//$NON-NLS-1$
                "#NODE_VALUE#", pDataValue.getValue().getValue().toString());
                double evalResult = eval(evalExp);
                if ("DIGITAL".equals(triggerNode.getNodePinType().toUpperCase())) {
                    //$NON-NLS-1$
                    if (triggerNode.getNodeType().equals("LED")) {
                        triggerNode.getGroveLED().write((int) evalResult);
                    }
                }
            }
        }
        return pDataValue;
    } else {
        return null;
    }
}
Also used : PDataValue(com.ge.dspmicro.machinegateway.types.PDataValue) TriggerNode(com.ge.predix.solsvc.workshop.config.TriggerNode) WorkshopDataNodeIntel(com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel)

Aggregations

PDataValue (com.ge.dspmicro.machinegateway.types.PDataValue)2 PEnvelope (com.ge.dspmicro.machinegateway.types.PEnvelope)1 TriggerNode (com.ge.predix.solsvc.workshop.config.TriggerNode)1 WorkshopDataNodeIntel (com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel)1