X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 06 Nov 2007 05:37 PM by  anon
Problem using export bridge assistant
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
06 Nov 2007 05:37 PM
    I am trying to include ENVI function into my code and using export bridge assistant to create the dll, howver when i open the helloworldex2_define.pro, it give this error: idl source object helloworldex2 cannot be resolve. The project can be open. my helloworldex2__define.pro as follow FUNCTION helloworldex2::HelloFrom,who IF(N_ELEMENTS(who) NE 0) THEN BEGIN ENVI_OPEN_FILE,'c:/test' message = " Hello" RETURN, message FUNCTION helloworldex2::INIT RETURN,1 END PRO helloworldex2__define struct = { helloworldex2, $ who: ' ' , $ message: ' ' $ } END I think the envi function is causing the problem. Any idea?

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Nov 2007 05:37 PM
    This is an incomplete example, because I am using the Java-IDL Export Bridge, not the COM-IDL Export Bridge, and because I am using the 'java_IDL_connect' object, not an object of a custom class built with the IDL Bridge Assistant. However, I bet, if you were to change your 'helloworldex2::HelloFrom' method to execute 'message = BSTATS1_FUNCTION( )' that you would not get an error. Here, I think, are two critical elements to the Java-IDL-Export-Bridge/ENVI interface: 1) ENVI code in this interface will not run until initial calls to: ENVI, /RESTORE_BASE_SAVE_FILES and: ENVI_BATCH_INIT are made. These calls should ideally be made in the 'Init' method of any custom export bridge class you create. But they can just as well be made in the ENVI-based procedures or functions that you call from methods in your custom class. (There is no harm in redundant calls to these ENVI procedures; they return doing nothing, if they detect that the ENVI libraries are already loaded.) 2) Contrary to ENVI documentation, do NOT call ENVI_BATCH_EXIT in any ENVI-based routines you write or in the body of any export bridge class methods you implement. The example below is the simplest possible modification of an example ENVI programming app that Tech Support frequently uses for demonstration, called by the simplest possible modification to the IDL Connectivity Bridges manual Java-IDL Connect Object example, 'hello_example.java'. The ENVI+IDL source code example: ; Just demonstrates ENVI_STATS_DO_IT text output using the built-in ; ENVI example data file 'bhtmref.img' FUNCTION bstats1_function ; Restore the core file and initialize ENVI envi, /RESTORE_BASE_SAVE_FILES envi_batch_init ; Routine file-opening calls envi_open_file, filepath('bhtmref.img', SUBDIR=['products', 'envi43', 'data']), $ R_FID = fid ; NOTE: THE FILEPATH IS VALID ONLY FOR ENVI 4.3!!! if (fid eq -1) then return, -1 envi_file_query, fid, NS=ns, NL=nl, NB=nb ; Set the DIMS and POS to process all bands of the image dims = [-1, 0, ns-1 , 0, nl-1] pos = lindgen(nb) ; Calculate the basic statistics envi_doit, 'envi_stats_doit', FID=fid, POS=pos, DIMS=dims, DMIN=dmin, $ DMAX=dmax, MEAN=mean, STDV=stdv, COMP_FLAG=1 print, dmin, dmax, mean, stdv return, stdv ; Just to demonstrate returning a value to the Bridge ; DO NOT UNCOMMENT - DO NOT EXIT ENVI!!! ;ENVI_BATCH_EXIT, /NO_CONFIRM END The Java Class that can run the above: NOTE: MUST USE IDL 6.3's 'javaidlb.jar' ARCHIVE! import com.idl.javaidl.*; public class ExJavaEnviExportBridge implements JIDLOutputListener { java_IDL_connect ostock; public ExJavaEnviExportBridge( ) { ostock = new java_IDL_connect( ); ostock.createObject( ); ostock.addIDLOutputListener( this ); ostock.executeString("stdv = bstats1_function()"); ostock.executeString("print, stdv"); } // cleanup private void destroyWrapper( ) { ostock.destroyObject( ); } public void IDLoutput(JIDLObjectI arg0, String sMessage) { System.out.println( sMessage ); } public static void main(String[] args) { ExJavaEnviExportBridge example = new ExJavaEnviExportBridge( ); example.destroyWrapper( ); } }

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Nov 2007 05:37 PM
    The function method 'helloworldex2::HelloFrom' that you pasted in this Forum message is missing an END statement. Besides that, you will find that ENVI programming requires several initialization steps before the command ENVI_OPEN_FILE (or any other ENVI programming routine) will work. At the very least you would need to have calls like: ENVI, /RESTORE_BASE_SAVE_FILES ENVI_BATCH_INIT prefacing your other work in ENVI. You probably need to review the documentation in the 'ENVI Programmer's Guide -> Batch Mode' section in order to get an example to work. As you are testing your new 'helloworldex2' example class at the IDL command line, you will want to test it first in a brand new IDLDE-only session (i.e. an 'idlde' that is NOT started by ENVI+IDL). To simulate the state of your eventual DLL, you do not want to have ENVI-specific libraries preloaded in your test IDL process. James Jones

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Nov 2007 05:37 PM
    I have added compile_opt idl2 ENVI, / RESTORE_BASE_SAVE_FILES however, the error still persisit. I have read, that IDL object is support in export bridge assistant, but i think ENVI object are not support .. Any idea? thanks

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Nov 2007 05:37 PM
    ENVI is not an object; it is just a relatively large library load. It is also a library with a lot of GUI widget-based functionality, and widgets, especially ones, whose behavior the programmer cannot tightly control (like ENVI's), pose some potential risks for missed or colliding event handling. I think, however, that you should be able to make calls like "ENVI, /RESTORE_BASE_SAVE_FILES", "ENVI_OPEN_FILE", "ENVI_GET_DATA" and many, many others - all the same kinds of calls that ENVI programmers might include in any ENVI batch program designed to run in the background with no interactivity. I will have to experiment now, though. I will let you know the results of my experiment bbefore the weekend is out, I hope. Be sure, by the way, to test your ENVI batch program outside of the Java-IDL Connectivity Bridge, before you test the bridge. James Jones
    You are not authorized to post a reply.