90 likes | 203 Views
BACI Properties Mount2 example. Bogdan Jeram (bjeram@eso.org) European Southern Observatory. July 2005. ESO. Properties in IDL. properties are defined in baci.idl (we have to include it!) introduced in component interface as IDL readonly attributes
E N D
BACI PropertiesMount2 example Bogdan Jeram (bjeram@eso.org) European Southern Observatory July 2005 ESO
Properties in IDL • properties are defined in baci.idl (we have to include it!) • introduced in component interface as IDL readonly attributes • component interface has to derive from: ACS::CharacteristicComponent Running ACS
Mount2 IDL http://websqa.hq.eso.org/bin/viewcvs.cgi/ACS/LGPL/CommonSoftware/acscourse/ws/idl/acscourseMount.idl?rev=HEAD&content-type=text/vnd.viewcvs-markup interface Mount2 : ACS::CharacteristicComponent { void objfix (in double az, in double elev); readonly attribute ACS::RWdouble cmdAz; readonly attribute ACS::RWdouble cmdEl; readonly attribute ACS::ROdouble actAz; readonly attribute ACS::ROdouble actEl; }; Running ACS
Properties in C++ • Implemented in baci library • header file per property type. Example: baciROdouble.h baciRWdouble.h baciROpattern.h Running ACS
Component header file http://websqa.hq.eso.org/bin/viewcvs.cgi/ACS/LGPL/CommonSoftware/acscourse/ws/include/acscourseMount2Impl.h?rev=HEAD&content-type=text/vnd.viewcvs-markup includes: #include <baciCharacteristicComponentImpl.h> header file for each property type Examples: #include <baciROdouble.h> #include <baciRWdouble.h> Namespace: baci(using namespace baci) Running ACS
Component header file • Class implementation has to inherit: • CharacteriticComponentImpl (common functionality) • from idl generated skeleton: POA_ACSCOURSE_MOUNT::Mount1 • constructor: with 2 parameters: • Mount2Impl(const ACE_CString &name, maci::ContainerServices *containerServices); • Member for each property. Examples: SmartPropertyPointer<RWdouble> m_cmdAz_sp; SmartPropertyPointer<ROdouble> m_actAz_sp; • Accessor methods. Examples: ACS::RWdouble_ptr cmdEl () throw (CORBA::SystemException); ACS::ROdouble_ptr actAz () throw (CORBA::SystemException); Running ACS
Component Implementation http://websqa.hq.eso.org/bin/viewcvs.cgi/ACS/LGPL/CommonSoftware/acscourse/ws/src/acscourseMount2Impl.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup #include <acscourseMount2Impl.h> #include <iostream> using namespace std; Mount2Impl::Mount2Impl( const ACE_CString &_name, maci::ContainerServices *containerServices) : CharacteristicComponentImpl(_name, containerServices), m_cmdAz_sp(new RWdouble(_name+":cmdAz", getComponent()),this), m_cmdEl_sp(new RWdouble(_name+":cmdEl", getComponent()),this), m_actAz_sp(new ROdouble(_name+":actAz", getComponent()),this), m_actEl_sp(new ROdouble(_name+":actEl", getComponent()),this) { ACS_TRACE("::Mount2Impl::Mount2Impl"); } Mount2Impl::~Mount2Impl() { purposes ACS_TRACE("::Mount2Impl::~Mount2Impl"); } Running ACS
Accessor methods implementation • returns “property” ACS::RWdouble_ptr Mount2Impl::cmdAz () throw (CORBA::SystemException) { if (m_cmdAz_sp == 0) { return ACS::RWdouble::_nil(); } ACS::RWdouble_var prop = ACS::RWdouble::_narrow(m_cmdAz_sp->getCORBAReference()); return prop._retn(); } Running ACS
Functional methods implementation void Mount2Impl::objfix (CORBA::Double az, CORBA::Double elev) throw (CORBA::SystemException) { ACS_TRACE("::Mount2Impl::objfix"); unsigned long long timestamp; m_cmdAz_sp->getDevIO()->write(az, timestamp); m_cmdEl_sp->getDevIO()->write(elev, timestamp); ACS_SHORT_LOG((LM_INFO,"Received objfix command. Az: %f El: %f", az, elev)); } Running ACS