Skip to content

Commit

Permalink
Merge pull request #15 from scaleoutsoftware/br-dev-workbenchfix
Browse files Browse the repository at this point in the history
Address init context inconsistency
  • Loading branch information
ripleyb authored Jan 30, 2024
2 parents 4fefa0b + c5aea00 commit c2b65a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Development/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'com.scaleoutsoftware.digitaltwin'
version '3.0.5'
version '3.0.6'

sourceCompatibility = JavaVersion.VERSION_12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void init( ) {
_simulationProcessors = new ConcurrentHashMap<>();
_messageProcessorValueTypes = new ConcurrentHashMap<>();
_modelInstances = new ConcurrentHashMap<>();
_alertProviders = new ConcurrentHashMap<>();
_alertProviders = new ConcurrentHashMap<>();
_simulationSchedulers = new ConcurrentHashMap<>();
_realTimeTimers = new ConcurrentHashMap<>();
_gson = new Gson();
Expand All @@ -76,9 +76,6 @@ void addDigitalTwin(String digitalTwinModelName, MessageProcessor digitalTwinMes

void addTimer(String modelName, String id, String timerName, TimerType type, Duration interval, TimerHandler handler) {
ConcurrentHashMap<String,TwinProxy> modelInstances = _modelInstances.get(modelName);
if(modelInstances == null) {
modelInstances = new ConcurrentHashMap<>();
}
TwinProxy proxy = modelInstances.get(id);
SimulationScheduler scheduler = _simulationSchedulers.get(modelName);
if (scheduler != null) {
Expand Down Expand Up @@ -268,18 +265,19 @@ public void recordAlertMessage(String model, String alertProvider, AlertMessage
}

public void createInstance(String modelName, String id, DigitalTwinBase instance) {
TwinProxy proxy = new TwinProxy(instance);
ConcurrentHashMap<String,TwinProxy> modelInstances = _modelInstances.get(modelName);
if(modelInstances == null) {
modelInstances = new ConcurrentHashMap<>();
}
modelInstances.put(id, proxy);
InitContext initContext = new WorkbenchInitContext(this, instance, modelName, id);
instance.init(initContext);
SimulationScheduler scheduler = _simulationSchedulers.get(modelName);
TwinProxy proxy = new TwinProxy(instance);
if(scheduler != null) {
proxy.setProxyState(ProxyState.Active);
scheduler.addInstance(proxy);
}
ConcurrentHashMap<String,TwinProxy> modelInstances = _modelInstances.get(modelName);
if(modelInstances == null) {
modelInstances = new ConcurrentHashMap<>();
}
modelInstances.put(id, proxy);
_modelInstances.put(modelName, modelInstances);
}
Expand Down

0 comments on commit c2b65a3

Please sign in to comment.