Search in sources :

Example 1 with StateSpace

use of de.prob.statespace.StateSpace in project prob2 by bendisposto.

the class UnitAnalysis method run.

public CompoundPrologTerm run(final String filename) throws IOException, ModelTranslationError {
    StateSpace s = api.eventb_load(filename);
    final ActivateUnitPluginCommand activatePlugin = new ActivateUnitPluginCommand();
    GetPluginResultCommand pluginResultCommand = new GetPluginResultCommand("Grounded Result State");
    s.execute(activatePlugin, pluginResultCommand);
    return pluginResultCommand.getResult();
}
Also used : StateSpace(de.prob.statespace.StateSpace) GetPluginResultCommand(de.prob.animator.command.GetPluginResultCommand) ActivateUnitPluginCommand(de.prob.animator.command.ActivateUnitPluginCommand)

Example 2 with StateSpace

use of de.prob.statespace.StateSpace in project prob2 by bendisposto.

the class SimpleLoadTest method testLoadBFile.

@Test
public void testLoadBFile() throws IOException, ModelTranslationError {
    StateSpace s = api.b_load("src" + File.separator + "test" + File.separator + "resources" + File.separator + "tla" + File.separator + "Foo.mch");
    assertNotNull(s);
    s.kill();
}
Also used : StateSpace(de.prob.statespace.StateSpace) Test(org.junit.Test)

Example 3 with StateSpace

use of de.prob.statespace.StateSpace in project prob2 by bendisposto.

the class SimpleLoadTest method testLoadTLAFileChoose.

@Test
public void testLoadTLAFileChoose() throws IOException, ModelTranslationError {
    StateSpace s = api.tla_load("src" + File.separator + "test" + File.separator + "resources" + File.separator + "tla" + File.separator + "Choose.tla");
    assertNotNull(s);
    s.kill();
}
Also used : StateSpace(de.prob.statespace.StateSpace) Test(org.junit.Test)

Example 4 with StateSpace

use of de.prob.statespace.StateSpace in project prob2 by bendisposto.

the class StateSpaceProvider method loadFromCommand.

public StateSpace loadFromCommand(final AbstractModel model, final AbstractElement mainComponent, final Map<String, String> preferences, final AbstractCommand loadCmd) {
    StateSpace s = ssProvider.get();
    s.setModel(model, mainComponent);
    List<AbstractCommand> cmds = new ArrayList<>();
    for (Entry<String, String> pref : preferences.entrySet()) {
        cmds.add(new SetPreferenceCommand(pref.getKey(), pref.getValue()));
    }
    try {
        s.execute(new ComposedCommand(cmds));
        s.execute(loadCmd);
        s.execute(new StartAnimationCommand());
    } catch (Exception e) {
        s.kill();
        throw e;
    }
    return s;
}
Also used : StartAnimationCommand(de.prob.animator.command.StartAnimationCommand) StateSpace(de.prob.statespace.StateSpace) AbstractCommand(de.prob.animator.command.AbstractCommand) ArrayList(java.util.ArrayList) SetPreferenceCommand(de.prob.animator.command.SetPreferenceCommand) ComposedCommand(de.prob.animator.command.ComposedCommand)

Example 5 with StateSpace

use of de.prob.statespace.StateSpace in project prob2 by bendisposto.

the class RulesCheckerTest method testExecuteAllOperations.

@Test
public void testExecuteAllOperations() throws IOException {
    StateSpace s = api.brules_load(dir + "RulesMachineExample.rmch");
    Trace trace = new Trace(s);
    RulesChecker rulesChecker = new RulesChecker(trace);
    rulesChecker.init();
    rulesChecker.executeAllOperations();
    for (Entry<AbstractOperation, OperationStatus> entry : rulesChecker.getOperationStates().entrySet()) {
        OperationStatus state = entry.getValue();
        if (entry.getKey().getName().equals("RULE_BasedOnRuleWithViolations")) {
            assertEquals(RuleStatus.NOT_CHECKED, state);
        } else {
            assertTrue(state.isExecuted());
        }
    }
}
Also used : Trace(de.prob.statespace.Trace) StateSpace(de.prob.statespace.StateSpace) AbstractOperation(de.be4.classicalb.core.parser.rules.AbstractOperation) OperationStatus(de.prob.model.brules.OperationStatus) RulesChecker(de.prob.model.brules.RulesChecker) Test(org.junit.Test)

Aggregations

StateSpace (de.prob.statespace.StateSpace)10 Test (org.junit.Test)8 Trace (de.prob.statespace.Trace)4 RulesChecker (de.prob.model.brules.RulesChecker)2 AbstractOperation (de.be4.classicalb.core.parser.rules.AbstractOperation)1 AbstractCommand (de.prob.animator.command.AbstractCommand)1 ActivateUnitPluginCommand (de.prob.animator.command.ActivateUnitPluginCommand)1 ComposedCommand (de.prob.animator.command.ComposedCommand)1 GetPluginResultCommand (de.prob.animator.command.GetPluginResultCommand)1 SetPreferenceCommand (de.prob.animator.command.SetPreferenceCommand)1 StartAnimationCommand (de.prob.animator.command.StartAnimationCommand)1 OperationStatus (de.prob.model.brules.OperationStatus)1 ArrayList (java.util.ArrayList)1