Ignore:
Timestamp:
10/21/05 14:26:18 (19 years ago)
Author:
remar
Message:
  • init() now fetches object reference by reading a file in $TEMP.. much nicer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt/src/org/modelica/mdt/corba/ModeqCommunicationImplementation.java

    r74 r85  
    11package org.modelica.mdt.corba;
     2
     3import java.io.BufferedReader;
     4import java.io.File;
     5import java.io.FileReader;
    26
    37import org.modelica.mdt.MdtPlugin;
    48import org.omg.CORBA.ORB;
    59
     10/**
     11 *
     12 * @author Andreas Remar
     13 *
     14 */
    615public class ModeqCommunicationImplementation
    716{
     
    1019    static boolean hasInitialized = false;
    1120   
    12     public static void init(String args[])
     21    public static void init(String args[]) throws Exception
    1322    {
    1423        try
    1524        {
     25            String fileName = System.getenv("TEMP");
     26            fileName += "\\openmodelica.objid";
     27            File f = new File(fileName);
     28            String stringifiedObjectReference = null;
     29            if(f.exists())
     30            {
     31                FileReader fr = new FileReader(f);
     32                BufferedReader br = new BufferedReader(fr);
     33               
     34                stringifiedObjectReference = br.readLine();
     35            }
     36            else
     37            {
     38                /* this is the ugly stuff, fix it */
     39                System.out.println("Filen existerar ju inte!");
     40                throw new Exception("Herrejävlar");
     41            }
     42           
    1643            orb = ORB.init(args, null);
    17             org.omg.CORBA.Object obj = orb.string_to_object("IOR:010000001b00000049444c3a4d6f646571436f6d6d756e69636174696f6e3a312e30000002000000000000002b000000010100000a0000003132372e302e302e3100cf05130000002f323137322f313132393732353635312f5f30000100000024000000010000000100000001000000140000000100000001000100000000000901010000000000");
     44            org.omg.CORBA.Object obj = orb.string_to_object(stringifiedObjectReference);
    1845            omcc = ModeqCommunicationHelper.narrow(obj);
    1946        }
     
    2148        {
    2249            MdtPlugin.log(e);
     50            throw new Exception("Unable to initialize communication with OMC");
    2351        }
    2452        hasInitialized = true;
    2553    }
    2654
    27     public static String sendExpression(String exp)
     55    public static String sendExpression(String exp) throws Exception
    2856    {
    2957        String retval = null;
     
    3260        {
    3361            // System.out.println("Initializing CORBA interface");
    34             init(null);
     62            try
     63            {
     64                init(null);
     65            }
     66            catch(Exception e)
     67            {
     68                throw new Exception("Unable to initialize communication with OMC");
     69            }
    3570            sendExpression("loadModel(Modelica)");
    3671        }
     
    4883    }
    4984
    50     public static String sendClass(String exp)
     85    public static String sendClass(String exp) throws Exception
    5186    {
    5287        String retval = null;
     
    5489        if(hasInitialized == false)
    5590        {
    56             init(null);
    57             sendExpression("loadModel(Modelica");
     91            try
     92            {
     93                init(null);
     94            }
     95            catch(Exception e)
     96            {
     97                throw new Exception("Unable to initialize communication with OMC");
     98            }
     99            sendExpression("loadModel(Modelica)");
    58100        }
    59101       
Note: See TracChangeset for help on using the changeset viewer.