Changeset 172 for trunk


Ignore:
Timestamp:
12/02/05 15:41:41 (19 years ago)
Author:
boris
Message:
  • added an instrumentation option for enabling tracing the OMC calls
Location:
trunk/org.modelica.mdt
Files:
1 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt/src/org/modelica/mdt/internal/omcproxy/OMCProxy.java

    r165 r172  
    55import java.io.FileReader;
    66import java.io.IOException;
     7import java.util.StringTokenizer;
    78import java.util.Vector;
    89
    910import org.eclipse.core.resources.IFile;
     11import org.eclipse.core.runtime.Platform;
    1012import org.modelica.mdt.MdtPlugin;
    1113import org.modelica.mdt.core.IModelicaClass;
     
    2426    private static boolean hasInitialized = false;
    2527    private static boolean systemLibraryLoaded = false;
     28   
     29    private static boolean traceOMCCalls = false;
     30    static
     31    {
     32        /* load debug options and set debug flag variables accordingly */
     33        String value = Platform.getDebugOption
     34            ("org.modelica.mdt/trace/omcCalls");
     35        if (value != null && value.equalsIgnoreCase("true"))
     36        {
     37            traceOMCCalls = true;
     38        }
     39       
     40    }
    2641
    2742    /**
     
    291306        }
    292307       
     308        logOMCCall(exp);       
    293309        retval = omcc.sendExpression(exp);
     310        logOMCReply(retval);
    294311       
    295312        return retval;
    296313    }
     314   
     315    /**
     316     * loggs the expression send to OMC if the
     317     * tracing flag (traceOMCCalls) is set
     318     *
     319     * @param expression the expression that is about to be sent to OMC
     320     */
     321    private static void logOMCCall(String expression)
     322    {
     323        if (!traceOMCCalls)
     324        {
     325            return;
     326        }
     327        System.out.println(">> " + expression);
     328    }
     329
     330    /**
     331     * loggs the reply resived from OMC if
     332     * the tracing flag (traceOMCCalls) is set
     333     *
     334     * @param reply the reply recieved from the OMC
     335     */
     336    private static void logOMCReply(String reply)
     337    {
     338        if (!traceOMCCalls)
     339        {
     340            return;
     341        }
     342
     343        StringTokenizer tokenizer = new StringTokenizer(reply, "\n");
     344       
     345        while (tokenizer.hasMoreTokens())
     346        {
     347            System.out.println("<< " + tokenizer.nextToken());
     348        }
     349    }
     350
    297351   
    298352    public static void loadSystemLibrary()
Note: See TracChangeset for help on using the changeset viewer.