def __init__(self): # pragma: NO COVER ''' Components derived from ContainerServices must invoke this constructor! Automatically taken care of in PySimpleClient objects. Parameters: None Raises: Nothing ''' #Name of this component if applicable self.__name = None #Name of this component container if applicable self.__contname = None #Token given to us by manager self.__token = None #Handle give to us by manager self.__handle = None #Logger for this client self.__logger = None #Provides access to the ACS CDB self.__cdb_access = CDBaccess() #The real container/client method(s) invoked by this classes methods. #In doing this, we can hide the container/client completely as long #as it invokes the setAll(...) method. self.activateOffShootMethod = None
def get_cdb_access(): # pragma: NO COVER ''' This function is only around to fix some problems with pydoc documentation issues. That is, CDBaccess() cannot be called globally or everything NC-related breaks. ''' global _cdb_access if _cdb_access == None: _cdb_access = CDBaccess() return _cdb_access
def __init__(self, name, charCompRef): ''' Constructor Params: - name is the quite literally the name of the property - charCompRef is the characteristic component object which contains this property Returns: Nothing Raises: Nothing. ''' #just call the superclass constructor Property.__init__(self, name, charCompRef) #setup a default value for all attributes self.cdbDict = {} try: #need access to the CDB to determine characteristics of this property cdbAccess = CDBaccess() #make sure the entry exists first of all... t_xml = cdbAccess.getField( "alma/" + self._get_characteristic_component_name()) #create an xml helper object xml_obj = XmlObject(xmlString=t_xml) #get the top-level element xml_obj = xml_obj.firstChild t_prop_name = self._get_name().split('/')[1] #get the property we're looking for xml_obj = xml_obj.getElementsByTagName(t_prop_name)[0] #setup the CDB dict using attributes found within the CDB for attr in xml_obj.attributes.keys(): self.cdbDict[attr] = xml_obj.getAttribute(attr) except: #print_exc() self.getLogger().logWarning( "Some problem occurred when attempting to retrieve data from the ACS CDB for: alma/" + self._get_characteristic_component_name() + "/" + self._get_name().split('/')[1]) return
# later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more # details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Software Foundation, Inc., # 675 Massachusetts Ave, Cambridge, MA 02139, USA. Correspondence concerning # ALMA should be addressed as follows: # # Internet email: [email protected] #------------------------------------------------------------------------ from Acspy.Common.CDBAccess import CDBaccess print "------------------------------------------------------------------" print "Creating CDBaccess..." g = CDBaccess() print "------------------------------------------------------------------" print "Invoking getField on CDB/alma/MOUNT1" h = g.getField("alma/MOUNT1") if h == None: print "There was some sort of problem getting the XML record" print "------------------------------------------------------------------" print "Invoking getElement on actAz property of CDB/alma/MOUNT1" h = g.getElement("alma/MOUNT1", "MOUNT/actAz") print "Alarm high off is: ", h[0]['alarm_high_off'] print "------------------------------------------------------------------" print "Done!"
#storage for "static data" that can be shared between components _GLOBALS = {} #namespace of individual components COMPONENTS_NS = {} COMPONENTS_NS_LIST = {} #described simulated behavior of the components _COMP_PROXIES = {} #maps component names to component instances _COMP_REFS = {} #first get access to the CDB CDB_ACCESS = CDBaccess() #each key in this dictionary consists of the stingified channel and the value #is a supplier object for said channel. _SUPPLIERS_DICT = {} #------------------------------------------------------------------------------ def addComponent(comp_name, comp_ref): ''' Adds a component to the singled dictionary contained within this module. This is in place to be called by the simulator framework and probably isn't of much use to end-users. Parameters: comp_name - name of the component in string format