Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorepaen2013-07-12 03:21:40 -0400
committerepaen2013-07-12 10:42:41 -0400
commitd9149c07da6e79281b8f7b03805e79e409391ea3 (patch)
treee88d60100ec6bd7f79c4c7f5550600526eccaecf /runtime/org.eclipse.etrice.runtime.java/src/org/eclipse
parentd65e1d1bdd43feadb43261b85aac2d8aef5e089c (diff)
downloadorg.eclipse.etrice-d9149c07da6e79281b8f7b03805e79e409391ea3.tar.gz
org.eclipse.etrice-d9149c07da6e79281b8f7b03805e79e409391ea3.tar.xz
org.eclipse.etrice-d9149c07da6e79281b8f7b03805e79e409391ea3.zip
Initial commit of AspectJ trace logging library and example project
based on HelloWorld tutorial Change-Id: Ieee4607f12a0846e764ee55df47d23d29edb75b9
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src/org/eclipse')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/debugging/MSCLogger.java239
1 files changed, 122 insertions, 117 deletions
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 047aeb40d..b16f347de 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
@@ -1,117 +1,122 @@
-/*******************************************************************************
- * Copyright (c) 2010 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
- *
- * CONTRIBUTORS:
- * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-
-package org.eclipse.etrice.runtime.java.debugging;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Thomas Schuetz
- *
- * MSCLogger implements logging of sync and async MSCs into a file
- * MSC-format is that of Trace2UML (http://trace2uml.tigris.org/)
- *
- */
-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 synchronized void addMessageAsyncOut(String source, String target, String message){
- createLine(source, " >-- ", target, message);
- }
-
- public synchronized void addMessageAsyncIn(String source, String target, String message){
- createLine(source, " --> ", target, message);
- }
-
-
- public synchronized void addMessageSyncCall(String source, String target, String message){
- createLine(source, " ==> ", target, message);
- }
-
- public synchronized void addMessageSyncReturn(String source, String target, String message){
- createLine(source, " <== ", target, message);
- }
-
-
- public synchronized void addActorState(String actor, String 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(){
- if (is_open){
- try{
- // Create file
- FileWriter fstream = new FileWriter("tmp/log/"+path+msc_name+".seq");
- BufferedWriter out = new BufferedWriter(fstream);
- //saveMSC(out);
- saveMSCforTrace2UML(out);
- out.close();
- }catch (Exception e){//Catch exception if any
- System.err.println("Error: " + e.getMessage());
- }
- }
- is_open = false;
- }
-
- private void saveMSCforTrace2UML(BufferedWriter out){
- try {
- out.write("#generated MSC for Trace2UML");
- out.newLine();
- for (String cmd : getCommandList()){
- out.write(cmd);
- out.newLine();
- }
- } catch (IOException e) {
- System.err.println("Error: " + e.getMessage());
- }
-
- }
-
- public List<String> getCommandList() {
- 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;
- private boolean is_open = false;
-
-}
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+
+package org.eclipse.etrice.runtime.java.debugging;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Thomas Schuetz
+ *
+ * MSCLogger implements logging of sync and async MSCs into a file
+ * MSC-format is that of Trace2UML (http://trace2uml.tigris.org/)
+ *
+ */
+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 synchronized void addMessageAsyncOut(String source, String target, String message){
+ createLine(source, " >-- ", target, message);
+ }
+
+ public synchronized void addMessageAsyncIn(String source, String target, String message){
+ createLine(source, " --> ", target, message);
+ }
+
+
+ public synchronized void addMessageSyncCall(String source, String target, String message){
+ createLine(source, " ==> ", target, message);
+ }
+
+ public synchronized void addMessageSyncReturn(String source, String target, String message){
+ createLine(source, " <== ", target, message);
+ }
+
+
+ public synchronized void addMessageCreate(String source, String target){
+ createLine(source, " (!) ", target, "");
+ }
+
+
+ public synchronized void addActorState(String actor, String 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(){
+ if (is_open){
+ try{
+ // Create file
+ FileWriter fstream = new FileWriter("tmp/log/"+path+msc_name+".seq");
+ BufferedWriter out = new BufferedWriter(fstream);
+ //saveMSC(out);
+ saveMSCforTrace2UML(out);
+ out.close();
+ }catch (Exception e){//Catch exception if any
+ System.err.println("Error: " + e.getMessage());
+ }
+ }
+ is_open = false;
+ }
+
+ private void saveMSCforTrace2UML(BufferedWriter out){
+ try {
+ out.write("#generated MSC for Trace2UML");
+ out.newLine();
+ for (String cmd : getCommandList()){
+ out.write(cmd);
+ out.newLine();
+ }
+ } catch (IOException e) {
+ System.err.println("Error: " + e.getMessage());
+ }
+
+ }
+
+ public List<String> getCommandList() {
+ 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;
+ private boolean is_open = false;
+
+}

Back to the top