EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: using the JCA extension
From: Thomas Pelaia II <[email protected]>
To: Sharon Lackey <[email protected]>
Cc: [email protected]
Date: Wed, 29 Mar 2006 12:55:13 -0500
The value that you are getting from the dbr is really a Java array.

You should check the component type of your array unless you already know the type.  In XAL we have a wrapper for JCA which takes care of the storing the DBR value in a way that makes it easy to use.  Below is a source clipping from our DBR adaptor class demonstrating how we store the DBR value.  In this case, newArray is the DBR value that you are trying to print in your example.

        final Class componentType = newArray.getClass().getComponentType();

        

        if ( componentType == null ) {
            throw new IllegalArgumentException("Argument must be an array!");
        }

        

        if ( componentType == Byte.TYPE ) {
            return byteStore( (byte[])newArray );
        }
        else if ( componentType == Short.TYPE ) {
            return shortStore( (short[])newArray );
        }
        else if ( componentType == Integer.TYPE ) {
            return intStore( (int[])newArray );
        }
        else if ( componentType == Float.TYPE ) {
            return floatStore( (float[])newArray );
        }
        else if ( componentType == Double.TYPE ) {
            return doubleStore( (double[])newArray );
        }
        else if ( componentType == java.lang.String.class ) {
            return stringStore( (String[])newArray );
        }
        else {
            throw new IllegalArgumentException("Argument type does not match an accepted array type!");            
        }


-tom




On Mar 29, 2006, at 12:24 PM, Sharon Lackey wrote:

I am trying to use the JCA extension from the binary download.   I have tried it on windows and on Fermi Scientific Linux and get the same result.   I’m using the example Java program to connect to a channel from the virtual linac IOC.  The channel connects without error but when I read the value it is unintelligible.  Here is what I’m doing in Java…

 

 

   try {

        JCALibrary jca= JCALibrary.getInstance();

        Context ctxt= jca.createContext(JCALibrary.JNI_SINGLE_THREADED);

        ctxt.printInfo();    

        // Create the Channel to connect to the PV.

        Channel ch= ctxt.createChannel("win32:CM1:intensityM");

            // send the request and wait 5.0 seconds for the channel to connect to the PV.

        try{

            ctxt.pendIO(5.0);}

        catch(Exception ex){

           System.out.println(ex.getMessage());

        }

   

            // If we're here, then everything went fine.

            // Display basic information about the channel.

        DBR reading = ch.get();

 

        System.out.println("getValue="+reading.getValue());

        

            System.out.println(ch.getElementCount());

            System.out.println("type="+ch.get().getType());

      

            System.out.println(ch.get().getValue());

 

 

        ch.printInfo();

         // We have no clue on whether the channel has been found and connected.

        // until the connection callback is called.

        //

        System.out.println("intensityM = "+ch.get().getValue());

 

        ch.destroy();

        ctxt.destroy();

      } catch(CAException caEx) {

        System.err.println("A Error occured: "+caEx);

      }

   

 

And here is the output….

 

CLASS : gov.aps.jca.jni.SingleThreadedContext

PREEMPTIVE_CALLBACK : true

ADDR_LIST :

AUTO_ADDR_LIST : true

CONNECTION_TIMEOUT : 30.0

BEACON_PERIOD : 15.0

REPEATER_PORT : 5065

SERVER_PORT : 5064

MAX_ARRAY_BYTES : 16384

EVENT_DISPATCHER: gov.aps.jca.event.DirectEventDispatcher@19b49e6

getValue=[D@14a9972

1

type=gov.aps.jca.dbr.DBRType[DBR_DOUBLE=6]

[D@a01335

CHANNEL  : win32:CM1:intensityM

TYPE     : gov.aps.jca.dbr.DBRType[DBR_DOUBLE=6]

COUNT    : 1

STATE    : gov.aps.jca.Channel$ConnectionState[CONNECTED=2]

HOSTNAME : juno.fnal.gov:5064

READ     : true

WRITE    : true

intensityM = [D@14d3343

 

 

Anyone know what I’m doing wrong???

 

Thanks,

Sharon Lackey

 




References:
using the JCA extension Sharon Lackey

Navigate by Date:
Prev: RE: gateway enum writes Jeff Hill
Next: EPICS Meeting Agenda Dalesio, Leo `Bob`
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: using the JCA extension Sharon Lackey
Next: EPICS Meeting Agenda Dalesio, Leo `Bob`
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·