summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerzy ZAGORSKI <xendoo@gmail.com>2010-05-31 14:24:26 +0200
committerJerzy ZAGORSKI <xendoo@gmail.com>2010-06-04 16:56:03 +0200
commit4f22d04d05afd56267f402606b85e2a7f56d7b3d (patch)
tree56d8c422fa4b602c6e2ddc17623cc1920c0f9177
parent9feb5c8e1dfdeb09b23c6ccda73ab89b145bf877 (diff)
downloadscilab-4f22d04d05afd56267f402606b85e2a7f56d7b3d.zip
scilab-4f22d04d05afd56267f402606b85e2a7f56d7b3d.tar.gz
Changed logging to apache commons
Change-Id: I2ef778473a55c696aa478c765f3612e9d4653bac
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AbstractElement.java5
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AnnotationElement.java8
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/BlockElement.java21
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/DiagramElement.java10
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/ImportMdl.java7
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/InputPortElement.java11
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/LineElement.java10
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/Logger.java22
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/OutputPortElement.java11
9 files changed, 44 insertions, 61 deletions
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AbstractElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AbstractElement.java
index a65e917..994241b 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AbstractElement.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AbstractElement.java
@@ -1,5 +1,8 @@
1package org.scilab.modules.xcos.simulink; 1package org.scilab.modules.xcos.simulink;
2 2
3public class AbstractElement<T> { 3public class AbstractElement<T> {
4 4 /**
5 * Default constructor
6 */
7 protected AbstractElement() { }
5} 8}
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AnnotationElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AnnotationElement.java
index 0924c4c..e50fb73 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AnnotationElement.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/AnnotationElement.java
@@ -17,12 +17,8 @@ public class AnnotationElement extends AbstractElement<TextBlock>{
17 17
18 public Object decode(SimulinkAnnotation from, Object object) { 18 public Object decode(SimulinkAnnotation from, Object object) {
19 // TODO Auto-generated method stub 19 // TODO Auto-generated method stub
20 try { 20 LogFactory.getLog(AnnotationElement.class).trace("From " + from.getName() + ":");
21 Logger.toFile("From " + from.getName() + ":"); 21 LogFactory.getLog(AnnotationElement.class).trace(from.getParameterNames().toString());
22 Logger.toFile(from.getParameterNames().toString());
23 } catch(IOException e1) {
24 LogFactory.getLog(BlockElement.class).error(e1);
25 }
26 return null; 22 return null;
27 } 23 }
28 24
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/BlockElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/BlockElement.java
index 6695246..a333050 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/BlockElement.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/BlockElement.java
@@ -4,6 +4,7 @@ import java.io.IOException;
4import java.util.HashMap; 4import java.util.HashMap;
5import java.util.Map; 5import java.util.Map;
6 6
7import org.apache.commons.logging.Log;
7import org.apache.commons.logging.LogFactory; 8import org.apache.commons.logging.LogFactory;
8import org.scilab.modules.xcos.block.BasicBlock; 9import org.scilab.modules.xcos.block.BasicBlock;
9import org.scilab.modules.xcos.block.BlockFactory; 10import org.scilab.modules.xcos.block.BlockFactory;
@@ -18,7 +19,10 @@ import edu.tum.cs.simulink.model.SimulinkInPort;
18import edu.tum.cs.simulink.model.SimulinkOutPort; 19import edu.tum.cs.simulink.model.SimulinkOutPort;
19 20
20public class BlockElement extends AbstractElement<BasicBlock> { 21public class BlockElement extends AbstractElement<BasicBlock> {
22
21 private SimulinkBlock base; 23 private SimulinkBlock base;
24 private static final Log LOG = LogFactory.getLog(BlockElement.class);
25
22 /** Map from index to blocks */ 26 /** Map from index to blocks */
23 private final Map<Integer, BasicBlock> blocks; 27 private final Map<Integer, BasicBlock> blocks;
24 /** 28 /**
@@ -38,13 +42,11 @@ public class BlockElement extends AbstractElement<BasicBlock> {
38 if (block == null) { 42 if (block == null) {
39 block = BlockFactory.createBlock(from.getId()); 43 block = BlockFactory.createBlock(from.getId());
40 } 44 }
41 45 if (LOG.isTraceEnabled()) {
42 try { 46 LOG.trace("From " + from.getName() + ":");
43 Logger.toFile("From " + base.getName() + ":"); 47 LOG.trace(from.getParameterNames().toString());
44 Logger.toFile(base.getParameterNames().toString());
45 } catch(IOException e1) {
46 LogFactory.getLog(BlockElement.class).error(e1);
47 } 48 }
49
48 /* 50 /*
49 * TODO: SimulinkBlock decoding, parameters etc. 51 * TODO: SimulinkBlock decoding, parameters etc.
50 */ 52 */
@@ -83,7 +85,10 @@ public class BlockElement extends AbstractElement<BasicBlock> {
83 */ 85 */
84 double minimalYaxisValue = 0.0; 86 double minimalYaxisValue = 0.0;
85 int i=0; 87 int i=0;
86 88 if (LOG.isTraceEnabled()) {
89 LOG.trace("From " + base.getName() + " subblocks:");
90 LOG.trace(base.getSubBlocks().toString());
91 }
87 UnmodifiableIterator<SimulinkBlock> blockIter = base.getSubBlocks().iterator(); 92 UnmodifiableIterator<SimulinkBlock> blockIter = base.getSubBlocks().iterator();
88 while(blockIter.hasNext()) { 93 while(blockIter.hasNext()) {
89 SimulinkBlock data = blockIter.next(); 94 SimulinkBlock data = blockIter.next();
@@ -99,7 +104,7 @@ public class BlockElement extends AbstractElement<BasicBlock> {
99 104
100 if (cell != null) { 105 if (cell != null) {
101 // FIXME: How to create subsystem in existing block? 106 // FIXME: How to create subsystem in existing block?
102 block.getParentDiagram().addCell(cell); //not that way for sure 107 //block.getParentDiagram().addCell(cell); //not that way for sure
103 } 108 }
104 i++; 109 i++;
105 } 110 }
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/DiagramElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/DiagramElement.java
index 5bbf554..5d64a7d 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/DiagramElement.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/DiagramElement.java
@@ -4,6 +4,7 @@ import java.io.IOException;
4import java.util.HashMap; 4import java.util.HashMap;
5import java.util.Map; 5import java.util.Map;
6 6
7import org.apache.commons.logging.Log;
7import org.apache.commons.logging.LogFactory; 8import org.apache.commons.logging.LogFactory;
8import org.scilab.modules.xcos.block.BasicBlock; 9import org.scilab.modules.xcos.block.BasicBlock;
9import org.scilab.modules.xcos.graph.XcosDiagram; 10import org.scilab.modules.xcos.graph.XcosDiagram;
@@ -20,6 +21,7 @@ import edu.tum.cs.simulink.model.SimulinkModel;
20public class DiagramElement extends AbstractElement<XcosDiagram> { 21public class DiagramElement extends AbstractElement<XcosDiagram> {
21 22
22 private SimulinkModel base; 23 private SimulinkModel base;
24 private static final Log LOG = LogFactory.getLog(DiagramElement.class);
23 25
24 /** Map from index to blocks */ 26 /** Map from index to blocks */
25 private final Map<Integer, BasicBlock> blocks; 27 private final Map<Integer, BasicBlock> blocks;
@@ -47,11 +49,9 @@ public class DiagramElement extends AbstractElement<XcosDiagram> {
47 49
48 public void decodeDiagram(XcosDiagram diag) throws SimulinkFormatException { 50 public void decodeDiagram(XcosDiagram diag) throws SimulinkFormatException {
49 // fill all diagram parameters 51 // fill all diagram parameters
50 try { 52 if (LOG.isTraceEnabled()) {
51 Logger.toFile("From " + base.getName() + ":"); 53 LOG.trace("From " + base.getName() + ":");
52 Logger.toFile(base.getParameterNames().toString()); 54 LOG.trace(base.getParameterNames().toString());
53 } catch(IOException e1) {
54 LogFactory.getLog(BlockElement.class).error(e1);
55 } 55 }
56 decodeObjs(diag); 56 decodeObjs(diag);
57 } 57 }
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/ImportMdl.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/ImportMdl.java
index 7a5584d..e063489 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/ImportMdl.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/ImportMdl.java
@@ -16,9 +16,13 @@ import edu.tum.cs.simulink.model.SimulinkOutPort;
16 16
17import org.apache.commons.logging.LogFactory; 17import org.apache.commons.logging.LogFactory;
18import org.scilab.modules.xcos.graph.XcosDiagram; 18import org.scilab.modules.xcos.graph.XcosDiagram;
19import org.scilab.modules.xcos.simulink.Logger;
20import org.scilab.modules.xcos.simulink.DiagramElement; 19import org.scilab.modules.xcos.simulink.DiagramElement;
21 20
21/**
22 *
23 * main simulink entry point class
24 *
25 */
22public class ImportMdl { 26public class ImportMdl {
23 /** 27 /**
24 * fromFile is a function that reads .mdl file, and logs all the model, blocks 28 * fromFile is a function that reads .mdl file, and logs all the model, blocks
@@ -37,7 +41,6 @@ public class ImportMdl {
37 XcosDiagram into = diagram.decode(model, null); 41 XcosDiagram into = diagram.decode(model, null);
38 } catch(SimulinkFormatException e1) { 42 } catch(SimulinkFormatException e1) {
39 LogFactory.getLog(ImportMdl.class).error(e1); 43 LogFactory.getLog(ImportMdl.class).error(e1);
40 Logger.toFile("EE: diagram.decode exception");
41 } 44 }
42 } 45 }
43 /** 46 /**
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/InputPortElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/InputPortElement.java
index 764cf6c..64445e2 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/InputPortElement.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/InputPortElement.java
@@ -3,6 +3,7 @@ package org.scilab.modules.xcos.simulink;
3import java.io.IOException; 3import java.io.IOException;
4import java.util.Iterator; 4import java.util.Iterator;
5 5
6import org.apache.commons.logging.Log;
6import org.apache.commons.logging.LogFactory; 7import org.apache.commons.logging.LogFactory;
7import org.scilab.modules.xcos.port.BasicPort; 8import org.scilab.modules.xcos.port.BasicPort;
8 9
@@ -12,19 +13,17 @@ import edu.tum.cs.simulink.model.SimulinkLine;
12 13
13public class InputPortElement { 14public class InputPortElement {
14 15
16 private static final Log LOG = LogFactory.getLog(InputPortElement.class);
17
15 public InputPortElement(SimulinkBlock base) { 18 public InputPortElement(SimulinkBlock base) {
16 // TODO Auto-generated constructor stub 19 // TODO Auto-generated constructor stub
17 } 20 }
18 21
19 public BasicPort decode(SimulinkInPort simulinkInPort, Object object) { 22 public BasicPort decode(SimulinkInPort simulinkInPort, Object object) {
20 // TODO Auto-generated method stub 23 // TODO Auto-generated method stub
21 try { 24 if (LOG.isTraceEnabled()) {
22 Logger.toFile("InPort: " + simulinkInPort.toString()); 25 LOG.trace("InPort" + simulinkInPort.toString());
23 //Logger.toFile(simulinkOutPort.getParameterNames().toString());
24 } catch(IOException e1) {
25 LogFactory.getLog(BlockElement.class).error(e1);
26 } 26 }
27
28 /* 27 /*
29 * Set in line 28 * Set in line
30 */ 29 */
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/LineElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/LineElement.java
index db78ca4..12dfe60 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/LineElement.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/LineElement.java
@@ -2,6 +2,7 @@ package org.scilab.modules.xcos.simulink;
2 2
3import java.io.IOException; 3import java.io.IOException;
4 4
5import org.apache.commons.logging.Log;
5import org.apache.commons.logging.LogFactory; 6import org.apache.commons.logging.LogFactory;
6import org.scilab.modules.xcos.link.BasicLink; 7import org.scilab.modules.xcos.link.BasicLink;
7 8
@@ -9,13 +10,12 @@ import edu.tum.cs.simulink.model.SimulinkLine;
9 10
10public class LineElement extends AbstractElement<BasicLink>{ 11public class LineElement extends AbstractElement<BasicLink>{
11 12
13 private static final Log LOG = LogFactory.getLog(LineElement.class);
14
12 public void decode(SimulinkLine simulinkLine) { 15 public void decode(SimulinkLine simulinkLine) {
13 // TODO Auto-generated method stub 16 // TODO Auto-generated method stub
14 try { 17 if (LOG.isTraceEnabled()) {
15 Logger.toFile("Line: " + simulinkLine.toString()); 18 LOG.trace("Line: " + simulinkLine.toString());
16 //Logger.toFile(simulinkOutPort.getParameterNames().toString());
17 } catch(IOException e1) {
18 LogFactory.getLog(BlockElement.class).error(e1);
19 } 19 }
20 } 20 }
21 21
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/Logger.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/Logger.java
deleted file mode 100644
index 7d5c0cf..0000000
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/Logger.java
+++ /dev/null
@@ -1,22 +0,0 @@
1package org.scilab.modules.xcos.simulink;
2
3import java.io.*;
4
5import org.scilab.modules.jvm.utils.ScilabConstants;
6
7public class Logger {
8 public static void toFile(String logs) throws IOException {
9 // FIXME: just for xendo purposes
10 final String homePath = ScilabConstants.SCIHOME.toString();
11 PrintWriter outputStream = null;
12 try {
13 boolean append = true;
14 outputStream = new PrintWriter(new FileWriter(new File(homePath + '/' + "simimplogs"), append));
15 outputStream.println(logs);
16 } finally {
17 if (outputStream != null) {
18 outputStream.close();
19 }
20 }
21 }
22}
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/OutputPortElement.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/OutputPortElement.java
index 16700df..8a57b31 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/OutputPortElement.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/simulink/OutputPortElement.java
@@ -3,6 +3,7 @@ package org.scilab.modules.xcos.simulink;
3import java.io.IOException; 3import java.io.IOException;
4import java.util.Iterator; 4import java.util.Iterator;
5 5
6import org.apache.commons.logging.Log;
6import org.apache.commons.logging.LogFactory; 7import org.apache.commons.logging.LogFactory;
7import org.scilab.modules.xcos.port.BasicPort; 8import org.scilab.modules.xcos.port.BasicPort;
8 9
@@ -12,19 +13,17 @@ import edu.tum.cs.simulink.model.SimulinkOutPort;
12 13
13public class OutputPortElement { 14public class OutputPortElement {
14 15
16 private static final Log LOG = LogFactory.getLog(OutputPortElement.class);
17
15 public OutputPortElement(SimulinkBlock base) { 18 public OutputPortElement(SimulinkBlock base) {
16 // TODO Auto-generated constructor stub 19 // TODO Auto-generated constructor stub
17 } 20 }
18 21
19 public BasicPort decode(SimulinkOutPort simulinkOutPort, Object object) { 22 public BasicPort decode(SimulinkOutPort simulinkOutPort, Object object) {
20 // TODO Auto-generated method stub 23 // TODO Auto-generated method stub
21 try { 24 if (LOG.isTraceEnabled()) {
22 Logger.toFile("OutPort: " + simulinkOutPort.toString()); 25 LOG.trace("InPort" + simulinkOutPort.toString());
23 //Logger.toFile(simulinkOutPort.getParameterNames().toString());
24 } catch(IOException e1) {
25 LogFactory.getLog(BlockElement.class).error(e1);
26 } 26 }
27
28 /* 27 /*
29 * Set out lines 28 * Set out lines
30 */ 29 */