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;
}
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;
}
}
Aggregations