EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  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  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: PV Mapping Using Java Annotations
From: "J. Lewis Muir" <[email protected]>
To: Mitch McCuiston <[email protected]>
Cc: [email protected]
Date: Tue, 11 Jan 2011 12:12:30 -0600
On 1/11/11 10:42 AM, Mitch McCuiston wrote:
>  Hi Lewis,
> 
> The reason I wanted to use annotations is so that I could use AOP to
> instrument my classes intead with CA code intead of repeatedly writing
> it for each PV backed object.  For example, if you wanted to implement a
> callback that would be executed when an PV monitor fired you would
> typically do the following in JCA/CAJ.
> 
> 1.  Create a context.
> 2.  Create a channel to the PV you want to monitor.
> 3.  Create the monitor and map it to the java method you would like to
> callback to.
> 4.  Convert PV types to Java types when necessary.
> 5.  Execute pendIO calls when necessary.
> 6.  Write code to tear down the channel once you're done.
> 
> I feel like this is a manual process that could be automated for the
> majority of cases.  If you just define the mapping of the callback
> method to the PV you are monitoring (with annotations in my case) you
> can use AOP to instrument your class with the rest of the code.  The
> monitor case is almost identical to a Message Driven Bean/POJO in the
> J2EE world except your using a PV name instead of a JMS destination
> name.  I also like the fact that my Java abstractions are decoupled from
> the CA code, which makes things like JUnit testing much easier.

Hi, Mitch.

OK, I see what you're trying to do.

I still prefer regular Java code.  For example, with a good EpicsPv
implementation, I could do something like this to monitor an EPICS PV's
value:

  EpicsClient client = new EpicsClient();
  EpicsPv ringCurrent = client.newPv("ioc23:RingCurrent");
  ringCurrent.monitored();
  ringCurrent.addPropertyChangeListener("value",
    new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent event) {
        System.out.println("Ring current: " + event.getNewValue());
      }
    });

I think in your annotations approach, this would be:

  @PV(name="ioc23:RingCurrent", accessType=PVAccessType.MONITOR)
  public void printRingCurrent(double value) {
    System.out.println("Ring current: " + value);
  }

This is a simple example, but to me the problem is that you're moving
your code into annotations which makes it harder to understand what's
going on and makes it less flexible.

It's harder to understand because I have to look up the PV annotation
implementation to figure out how it works.

It's less flexible because I can't change the annotations at run-time.
What happens if I want to stop monitoring the ring current PV in the
above example?  In the no-annotations approach, I just call
"ringCurrent.unmonitored()".  In the annotations approach, how would I
do this?

Still, your annotations approach might be easier to use in some
situations.  If I just want to set up a "callback" or do a simple get or
put, I just know, "When the PV changes, this annotated method gets
called with the new value," or, "When I call this method, it will set or
get the PV value," and it just works.

Lewis

References:
PV Mapping Using Java Annotations Mitch McCuiston
Re: PV Mapping Using Java Annotations J. Lewis Muir
Re: PV Mapping Using Java Annotations Mitch McCuiston

Navigate by Date:
Prev: Re: PV Mapping Using Java Annotations Mitch McCuiston
Next: Re: CSS Data Browser Plot Problem Kasemir, Kay
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: PV Mapping Using Java Annotations Mitch McCuiston
Next: RE: PV Mapping Using Java Annotations Carcassi, Gabriele
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·