use of com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel in project predix-machine-template-adapter-edison by PredixDev.
the class IntelBoardSubscriptionMachineAdapter method createNodes.
/*
* ##################################### # Private methods #
* #####################################
*/
/**
* Generates random nodes
*
* @param count
* of nodes
*/
private void createNodes(List<JsonDataNode> nodes) {
for (JsonDataNode jsonNode : nodes) {
_logger.info("Creating Node : " + jsonNode.getNodeName() + " Pin : " + jsonNode.getNodePin());
WorkshopDataNodeIntel node = new WorkshopDataNodeIntel(this.uuid, jsonNode);
// Create a new node and put it in the cache.
this.dataNodes.put(node.getNodeId(), node);
}
}
use of com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel 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;
}
}
use of com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel in project predix-machine-template-adapter-edison by PredixDev.
the class IntelBoardSubscriptionMachineAdapter method getNodeByName.
/**
* @param nodeName
* -
* @return -
*/
public WorkshopDataNodeIntel getNodeByName(String nodeName) {
Iterator<UUID> iter = this.dataNodes.keySet().iterator();
while (iter.hasNext()) {
UUID key = iter.next();
WorkshopDataNodeIntel node = this.dataNodes.get(key);
if (nodeName.equals(node.getName())) {
return node;
}
}
return null;
}
Aggregations