Skip to content

Commit

Permalink
Logging exceptions of Atomic proposition evaluation.
Browse files Browse the repository at this point in the history
JPF scheduler takes max number of process iterations in its constructor.
  • Loading branch information
keznikl committed Jun 28, 2013
1 parent bfc4719 commit 6cfcb73
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import cz.cuni.mff.d3s.deeco.exceptions.KRExceptionAccessError;
import cz.cuni.mff.d3s.deeco.knowledge.ISession;
import cz.cuni.mff.d3s.deeco.logging.Log;
import cz.cuni.mff.d3s.deeco.ltl.AtomicProposition;

import cz.cuni.mff.d3s.deeco.ltl.CommlinkDEECoJPF;
Expand Down Expand Up @@ -97,10 +98,13 @@ public Object getSingle(String knowledgeId) {
return v.get(0);
}

// TODO: manage via runtime event listener mechanism (to be done) instead
public void onStart() {
evaluatePropositions = true;
tryEvaluatePropositions();
}

// TODO: manage via runtime event listener mechanism (to be done) instead
public void onStop() {
evaluatePropositions = false;
}
Expand All @@ -109,8 +113,15 @@ private void tryEvaluatePropositions() {
if (evaluatePropositions) {
for (AtomicProposition ap : propositions) {
// propositionToEvaluate.get(...) might return null
if (propositionToEvaluate.get(ap.getName()) == true)
propositionValues.put(ap.getName(), ap.evaluate(this));
if (propositionToEvaluate.get(ap.getName()) == true) {
boolean value = propositionValues.get(ap.getName());
try {
value = ap.evaluate(this);
} catch (Exception e) {
Log.e("Atomic proposition evaluation failed (" + ap.getName() + ").");
}
propositionValues.put(ap.getName(), value);
}
}

// send names of atomic propositions into JPF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
public class MultithreadedSchedulerJPF extends Scheduler {

private Set<Thread> threads;

int maxPeriodIterations = 0;

public MultithreadedSchedulerJPF() {
this(0);
}

public MultithreadedSchedulerJPF(int maxPeriodIterations) {
super();
this.threads = new HashSet<Thread>();
this.maxPeriodIterations = maxPeriodIterations;

// JPF optimization -> earlier class loading via a clinit call (in the single threaded part)
// reduces the state space
Expand All @@ -43,10 +49,10 @@ public synchronized void start() {
//System.out.println("[DEBUG] max period = " + maxPeriod);

if (!running) {
// let every process run for the number of times its period P fits into 2*P_max
// let every process run for the number of times its period P fits into maxPeriodIterations*P_max
for (SchedulableProcess sp : periodicProcesses) {
long spPeriod = ((ProcessPeriodicSchedule) sp.scheduling).interval;
long repeatCount = (2*maxPeriod) / spPeriod + 1;
long repeatCount = (maxPeriodIterations*maxPeriod) / spPeriod + 1;

//System.out.println("[DEBUG] period = " + spPeriod + ", repeat count = " + repeatCount);

Expand Down

0 comments on commit 6cfcb73

Please sign in to comment.