Hi Rolf
This is how you can get your Monitor to return the String from the ENUM channel:
Monitor monitor = channel.addMonitor(DBR_String.TYPE, 1,Monitor.VALUE, new MonitorListener(){
@Override
public void monitorChanged(MonitorEvent ev) {
try {
DBR_String s = (DBR_String) ev.getDBR().convert(DBR_String.TYPE);
String string = s.getStringValue()[0];
System.out.println("Value: "+string);
} catch (CAStatusException e) {
e.printStackTrace();
}
}});
Regards
Simon
On 4/1/10 6:58 AM, rolf wrote:
> I am trying to work with Java Channel access (JCA 2.3.2 and CAJ
> 1.1.5b). I may have blinders on, but the only documentation I can find
> is the APS tutorial and the JCA javadoc (for JCA 2.1.2). If there is
> anything else, could someone please point me to it.
>
> My specific problem:
> I have a MonitorListener, which delivers a MonitorEvent on a PV value
> change.
> The MonitorEvent gives me DBR, from which I want to get the new value as
> a String.
>
> My code looks like this:
>
> DBR dbr = evt.getDBR();
> DBR dbr2 = dbr.convert(DBRType.CTRL_STRING);
> String[] s = ((DBRString) dbr2).getStringValue();
>
> s[0] contains the correct value for all DBR types, with the exception of
> enumerated types, where it has an empty string.
> What am I doing wrong?
- Navigate by Date:
- Prev:
Can edm local PVs take the value of an edm calc? Zelazny, Michael Stanley
- Next:
Re: create arrays in EDM Jovan Loncar
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: JCA type conversion J. Lewis Muir
- Next:
create arrays in EDM Jovan Loncar
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|