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