Search in sources :

Example 1 with WorkshopDataNodeIntel

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);
    }
}
Also used : JsonDataNode(com.ge.predix.solsvc.workshop.config.JsonDataNode) WorkshopDataNodeIntel(com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel)

Example 2 with WorkshopDataNodeIntel

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

Example 3 with WorkshopDataNodeIntel

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;
}
Also used : UUID(java.util.UUID) WorkshopDataNodeIntel(com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel)

Aggregations

WorkshopDataNodeIntel (com.ge.predix.solsvc.workshop.types.WorkshopDataNodeIntel)3 PDataValue (com.ge.dspmicro.machinegateway.types.PDataValue)1 JsonDataNode (com.ge.predix.solsvc.workshop.config.JsonDataNode)1 TriggerNode (com.ge.predix.solsvc.workshop.config.TriggerNode)1 UUID (java.util.UUID)1