Skip to content

Commit

Permalink
DeploymenFBEvaluator syncs time
Browse files Browse the repository at this point in the history
With this change the DeploymentFBEvaluator tries to set the faketime of
the evaluator device so that evaluated fbs in 4diac IDE and fbs in the
device share the same time base.
  • Loading branch information
azoitl committed Jun 20, 2024
1 parent 8803ade commit e17ff2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public void writeFBParameter(final String value, final FBDeploymentData deployme
deviceManagementInteractor.writeFBParameter(resource, value, deploymentData, varDeclaration);
}

public void writeDeviceParameter(final String name, final String value) throws DeploymentException {
deviceManagementInteractor.writeDeviceParameter(resource.getDevice(), name, value);
}

public Resource getResource() {
return resource;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Martin Erich Jobst
* Copyright (c) 2023, 2024 Martin Erich Jobst
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -28,6 +28,7 @@
import org.eclipse.fordiac.ide.model.eval.Evaluator;
import org.eclipse.fordiac.ide.model.eval.EvaluatorException;
import org.eclipse.fordiac.ide.model.eval.fb.FBEvaluator;
import org.eclipse.fordiac.ide.model.eval.function.StandardFunctions;
import org.eclipse.fordiac.ide.model.eval.variable.Variable;
import org.eclipse.fordiac.ide.model.libraryElement.Event;
import org.eclipse.fordiac.ide.model.libraryElement.FB;
Expand All @@ -45,6 +46,7 @@

public class DeploymentFBEvaluator<T extends FBType> extends FBEvaluator<T> {

private static final String FAKE_TIME_DEV_PARAM_NAME = "FakeTime"; //$NON-NLS-1$
private DeploymentEvaluatorSharedState sharedState;
private FBDeploymentData deploymentData;
private Map<String, MonitoringElement> monitoringElements;
Expand Down Expand Up @@ -118,6 +120,7 @@ public void evaluate(final Event event) throws EvaluatorException {
try {
writeVariables(getType().getInterfaceList().getInputVars());
writeVariables(getType().getInterfaceList().getInOutVars());
sharedState.writeDeviceParameter(FAKE_TIME_DEV_PARAM_NAME, StandardFunctions.NOW_MONOTONIC().toString());
sharedState.triggerEvent(monitoringElements.get(event.getName()));
pollWatches();
} catch (final DeploymentException e) {
Expand Down

0 comments on commit e17ff2a

Please sign in to comment.