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  2011  2012  2013  2014  <20152016  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  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Begginer with EPICSv4
From: "Kasemir, Kay" <[email protected]>
To: Ricardo Herrero <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Wed, 25 Feb 2015 13:47:16 +0000
Hi:

Regarding Java vs. C++, it is helpful to be somewhat bilingual when studying the V4 docs/API/examples.
As far as I understand, many of the ideas were initially developed in Java, which I think was a great approach because it allowed to concentrate on the basic idea and network protocol without worrying about details of operating system independent threads, memory handling, ..  The Requester, ChannelRequester, ChannelGetRequester, MonitorRequester, .. started out as Java interfaces, and I'm pretty sure I saw example code that basically had one "MyRequester" that implemented several of those interfaces in one class.
At some point, the C++ implementations then overtook the original Java API. The pvDatabase support that helps implement the V4 server side first appeared in C++. If you want your V4 server to reside within a V4 IOC, you naturally need to use the C++ code.

Transitioning to C++, you need to use virtual base classes if you want YourRequester to implement for example both the ChannelRequester and MonitorRequester, since each of those in turn is based on the plain Requester and you'd otherwise end up with YourRequester <-- (ChannelRequester::Requester, MonitorRequester::Requester). You also need to use the shared_pointer templates which provide somewhat of a Java garbage collection equivalent in C++. When you need to single-step through your code in a debugger, the Java version will be much more obvious. The "element = monitor.poll()" in Java will be just that:

class MyMonitorRequester implements MonitorRequester
{
   public void monitorEvent(Monitor monitor)
   {
	MonitorElement element;
	while ((element = monitor.poll()) != null)

If you look at the same in C++, you'll single-step through several shared_ptr related include files just for the '=':

void MyMonitorRequester::monitorEvent(MonitorPtr const & monitor)
{
    shared_ptr<MonitorElement> update;
    while ((update = monitor->poll()))

Thanks,
Kay



On Feb 25, 2015, at 3:56 AM, Ricardo Herrero <[email protected]>
 wrote:
> Thank you all!
> 
> You all have given me so much information, I have to review and study the different codes you have told me and I will try to study the C++ code. At last I will try to implement it in Java, but I´ll give a try first in C++ to see what´s going on. Thank you all again, when I´m done with it, I will tell you, and surely I will have more questions.
> 
> Regards, Ricardo
> 
> 
> 
> El 2015-02-24 20:41, [email protected] escribió:
>> Hi Ricardo,
>> Kay's and Matt's advice is good.
>> The best way for you to get started is to look at the examples. I see
>> you've been looking at the Java examples, but I suggest you look at
>> the C++ code too. There are more examples there of what you're trying
>> to do.
>> Using monitors sounds like the right thing for you to be doing.
>> For the server-side you should definitely use pvDatabase. This will
>> avoid you having to write a lot of server code. pvDatabaseCPP has been
>> around for a while and a number of people have successfully used it
>> (e.g Kay's neutron server). There are a number of good examples in
>> pvDatabaseCPP. I'd start from exampleServer.
>> Marty Kraimer's also been developing pvDatabaseJava. Marty said today
>> this is now usable, so if you want to do Java you might try it out,
>> but bear you'll probably be the first real user. I've had a quick look
>> and there are some simple examples there in pvDatabaseJava/example.
>> I've just built it now and given the ExampleDatabase and HelloExample
>> examples a quick try and at a first look these seems to work OK.
>> You'll have to clone it from SourceForge:
>> hg clone http://hg.code.sf.net/p/epics-pvdata/pvDatabaseJava
>> You can get the latest of other modules there too.
>> There's not a client library yet, but there are a number of examples
>> of clients. There are those in pvAccessCPP (e.g. pvget has a monitored
>> version) as well as those in pvDatabaseCPP. I used longArrayMonitor in
>> arrayPerformance to get started with my clients.
>> There's also the neutron server/client mentioned  and another simple
>> client/server example I wrote, ntndarrayServer, in alphaCPP (clone in
>> the same way as pvDatabaseJava).
>> Just copy one of the examples and modify the requesters or if you use
>> the client.* code in ntndarrayServer you can create a MonitorCallback
>> and implement the processElement method. ntndarrayServer was just some
>> test code, but it may be a fast way to get going if you're going to do
>> a C++ client.
>> If you have any more questions I'll be happy to answer them.
>> Good luck.
>> Dave



References:
Begginer with EPICSv4 Ricardo Herrero
Re: Begginer with EPICSv4 Kasemir, Kay
RE: Begginer with EPICSv4 david.hickin
RE: Begginer with EPICSv4 Ricardo Herrero

Navigate by Date:
Prev: RE: Begginer with EPICSv4 Ricardo Herrero
Next: problem with pointGreyApp.exe using AD 2-1 Alireza Panna
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Begginer with EPICSv4 Ricardo Herrero
Next: Support for an HPLC pump manufactured by SSI tom.cobb
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·