Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2011-03-19 21:57:26 -0400
committerThomas Schuetz2011-03-19 21:57:26 -0400
commitdc242108796a124db8dd32aaea8177fe8b573944 (patch)
treec7205ffbe83ca25b86c9af91540434bff8833cf5
parentae805dd7cece349d888f0a68a4229a0f881785f7 (diff)
downloadorg.eclipse.etrice-dc242108796a124db8dd32aaea8177fe8b573944.tar.gz
org.eclipse.etrice-dc242108796a124db8dd32aaea8177fe8b573944.tar.xz
org.eclipse.etrice-dc242108796a124db8dd32aaea8177fe8b573944.zip
added filter for MSCLogger
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCFilter.java61
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCLogger.java26
2 files changed, 82 insertions, 5 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCFilter.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCFilter.java
new file mode 100644
index 000000000..6ed703b67
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCFilter.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+
+
+package org.eclipse.etrice.runtime.java.debugging;
+
+import java.util.ArrayList;
+
+/**
+ * @author Thomas Schuetz
+ *
+ * Simple filtering that can be applied to MSCLogger to make the MSCs
+ *
+ * TODO: this is only a temporary solution for the current file based MSCLogger
+ */
+
+public class MSCFilter {
+
+ public MSCFilter() {
+ filterList = new ArrayList<FilterItem>();
+ }
+
+
+ public void addFilter(FilterItem filter){
+ filterList.add(filter);
+ }
+
+ public boolean applyTo(String text){
+ for (FilterItem item : filterList){
+ if (text.startsWith(item.filter)) return true;
+ }
+ return false;
+ }
+
+ public String reduceString(String string){
+ if (filterList.size()==1)
+ return string.replaceFirst(filterList.get(0).filter, "");
+ else
+ return string;
+ }
+
+ private ArrayList<FilterItem> filterList= null;
+
+ // Sub classes
+ public static class FilterItem{
+ private boolean exclude = false;
+ private String filter = null;
+ public FilterItem(String filter, boolean exclude) {
+ super();
+ this.exclude = exclude;
+ this.filter = filter;
+ }
+ }
+
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCLogger.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCLogger.java
index e50a371ae..f72001398 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCLogger.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCLogger.java
@@ -31,30 +31,41 @@ public class MSCLogger {
public void setMSC(String msc_name, String path){
this.msc_name = msc_name;
this.path = path;
+ filter = new MSCFilter();
}
public synchronized void open(){
is_open = true;
}
+
public void addMessageAsyncOut(String source, String target, String message){
- getCommandList().add( new String ("\t"+source+" >-- "+target+ " " +message) );
+ createLine(source, " >-- ", target, message);
}
public void addMessageAsyncIn(String source, String target, String message){
- getCommandList().add( new String ("\t"+source+" --> "+target+ " " +message) );
+ createLine(source, " --> ", target, message);
}
+
public void addMessageSyncCall(String source, String target, String message){
- getCommandList().add( new String ("\t"+source+" ==> "+target+ " " +message) );
+ createLine(source, " ==> ", target, message);
}
public void addMessageSyncReturn(String source, String target, String message){
- getCommandList().add( new String ("\t"+source+" <== "+target+ " " +message) );
+ createLine(source, " <== ", target, message);
}
+
public void addActorState(String actor, String state){
- getCommandList().add( new String ("\t"+actor+" >>> "+state) );
+ if (filter.applyTo(actor))
+ getCommandList().add( new String ("\t"+filter.reduceString(actor)+" >>> "+state) );
+ }
+
+ private void createLine(String source, String mid, String target, String message) {
+ if (filter.applyTo(source) && filter.applyTo(target)) {
+ getCommandList().add( new String ("\t"+filter.reduceString(source)+mid+filter.reduceString(target)+ " " +message) );
+ }
}
public synchronized void close(){
@@ -91,8 +102,13 @@ public class MSCLogger {
return commandList;
}
+ public MSCFilter getMSCFilter(){
+ return filter;
+ }
+
private List<String> commandList = new ArrayList<String>();
+ private MSCFilter filter = null;
private String path = null;
private String msc_name = null;

Back to the top