Search in sources :

Example 1 with MachineAdapterException

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

the class IntelBoardSubscriptionMachineAdapter method addDataSubscription.

/*
	 * Adds new data subscription into the list.
	 */
@Override
public synchronized UUID addDataSubscription(IDataSubscription subscription) throws MachineAdapterException {
    if (subscription == null) {
        //$NON-NLS-1$
        throw new IllegalArgumentException("Subscription is null");
    }
    List<PDataNode> subscriptionNodes = new ArrayList<PDataNode>();
    // Add new data subscription.
    if (!this.dataSubscriptions.containsKey(subscription.getId())) {
        // Make sure that new subscription contains valid nodes.
        for (PDataNode node : subscription.getSubscriptionNodes()) {
            if (!this.dataNodes.containsKey(node.getNodeId())) {
                //$NON-NLS-1$
                throw new MachineAdapterException("Node doesn't exist for this adapter");
            }
            subscriptionNodes.add(this.dataNodes.get(node.getNodeId()));
        }
        // Create new subscription.
        WorkshopDataSubscription newSubscription = new WorkshopDataSubscription(this, subscription.getName(), subscription.getUpdateInterval(), subscriptionNodes, spillway);
        this.dataSubscriptions.put(newSubscription.getId(), newSubscription);
        new Thread(newSubscription).start();
        return newSubscription.getId();
    }
    return null;
}
Also used : PDataNode(com.ge.dspmicro.machinegateway.types.PDataNode) WorkshopDataSubscription(com.ge.predix.solsvc.workshop.types.WorkshopDataSubscription) ArrayList(java.util.ArrayList) MachineAdapterException(com.ge.dspmicro.machinegateway.api.adapter.MachineAdapterException)

Aggregations

MachineAdapterException (com.ge.dspmicro.machinegateway.api.adapter.MachineAdapterException)1 PDataNode (com.ge.dspmicro.machinegateway.types.PDataNode)1 WorkshopDataSubscription (com.ge.predix.solsvc.workshop.types.WorkshopDataSubscription)1 ArrayList (java.util.ArrayList)1