import java.nio.channels.FileLock;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
}
public boolean subscribe(String name) throws FMILException {
- // Safety check
- int vr = variableMap.get(name);
- if(vr == 0) return false;
- if(!subscriptionSet.add(name)) return false;
- subscribedNames.add(name);
- System.err.println("subscribed : " + name + " => " + subscribedNames.size());
- subscription.add(vr);
- subscribe(new int[] { vr });
- return true;
+ synchronized(syncObject) {
+ // Safety check
+ int vr = variableMap.get(name);
+ if(vr == 0) return false;
+ if(!subscriptionSet.add(name)) return false;
+ subscribedNames.add(name);
+ subscription.add(vr);
+ subscribe(new int[] { vr });
+ return true;
+ }
}
public FMIL() {
synchronized(syncObject) {
try {
-
+
double[] results = new double[subscription.size()];
- return getSubscribedResults_(getModelIDNew(), results);
-
+ Arrays.fill(results, Double.NaN);
+
+ return getSubscribedResults_(getModelIDNew(), results);
} catch (UnsatisfiedLinkError err) {
throw new FMILException(UNSATISFIED_LINK);
} catch (Exception e) {