Beispiel #1
0
    def disconnect(self):
        '''
        Override this method.
        '''
        global CALLBACKS
        
        #tell threads to stop
        self.running = 0
        #give them a few seconds to stop executing
        sleep(2)
        
        #first destroy all consumers
        self.getLogger().logInfo("Disconnecting all administrative consumers...")
        for key in self.channels.keys():
            self.channels[key][CONSUMER].disconnect()

        #next notify all callbacks that we're shutting down
        self.getLogger().logInfo("Disconnecting all registered callbacks...")
        for cb in CALLBACKS:
            try:
                cb.done("The ACSEventAdmin is shutting down.",
                        Completion(long(0), long(0), long(0), []),
                        CBDescOut(long(0), long(0)))
            except:
                self.getLogger().logWarning("Failed to invoke done method on a callback!")
                print_exc()

        #now delete member data
        self.channels = {}
        CALLBACKS = []

        PySimpleClient.disconnect(self)
        return
Beispiel #2
0
class TestStorageMethods(unittest.TestCase):
    def test_full(self):
        self.client = PySimpleClient()
        self.storage = self.client.getComponent("STORAGE")

        self.storage.clearAllData()

        targets = []
        images = []
        for i in range(10):
            targets.append(TYPES.Target(i, TYPES.Position(10.0, 45.0), 2))
            image = bytearray()
            for j in range(1000000):
                image.append(j % 256)
            images.append(bytes(image))
        proposal = TYPES.Proposal(0, targets, 0)
        self.storage.storeObservation(proposal, images)

        id = self.storage.getNextValidId()
        print "ID", id
        self.assertEqual(1, id, "Checking ID")

        result = self.storage.getObservation(0)
        self.assertEqual(10, len(result), "Number of observations")

        self.storage.clearAllData()

        self.client.releaseComponent(self.storage._get_name())
Beispiel #3
0
def set_array_frec():
    client = PySimpleClient()
    master = client.getComponent("CONTROL/MASTER")
    arrayList = master.getAutomaticArrayComponents() + master.getManualArrayComponents()
    for array in arrayList:
        master.destroyArray(array.ComponentName)
    arrayList = []    
    antennas = master.getAvailableAntennas()
    master.createManualArray(antennas)
    arrayList = master.getAutomaticArrayComponents() +  master.getManualArrayComponents()
    if ( arrayList != 1 ):
        if( len(arrayList) == 0):
            print "Could not create an array!!"
            client.releaseComponent("CONTROL/MASTER")
            sys.exit(0)
        else:
            print "Could not destroy previosly arrays and create a new fresh array!"
            client.releaseComponent("CONTROL/MASTER")
            sys.exist(0)
    currentArray = client.getComponent(arrayList[0].ComponentName)
    client.releaseComponent("CONTROL/MASTER")
    setArrayName(currentArray.getArrayName())
    array = getArray()
    tp = array.getTotalPowerObservingMode()
    return tp
Beispiel #4
0
 def subsystemsOffline(self, subsystem):
     from Acspy.Clients.SimpleClient import PySimpleClient
     client = PySimpleClient()
     mcI = client._ContainerServices__importComponentStubs(comp_type="IDL:alma/ACS/MasterComponent:1.0")
     subsystem = client.getComponent(subsystem)
     subsystem.doTransition(mcI.SUBSYSEVENT_SHUTDOWNPASS1)
     (state, flag) = self.__waitForSubsystemState(subsystem._get_currentStateHierarchy(), "AVAILABLE.OFFLINE.PRESHUTDOWN", 300)
     if flag is False:
         return (state, flag)
     subsystem.doTransition(mcI.SUBSYSEVENT_SHUTDOWNPASS2)
     (state, flag) =  self.__waitForSubsystemState(subsystem._get_currentStateHierarchy(), "AVAILABLE.OFFLINE.SHUTDOWN", 300)
     if flag is False:
         return (state, flag)
     return (state, flag)
Beispiel #5
0
 def __init__(self):
     try:
         #This stuff is only for get the antennas of a manual array
         from Acspy.Clients.SimpleClient import PySimpleClient
         c = PySimpleClient()
         master = c.getComponent('CONTROL/MASTER')
         arrayname  =  master.getManualArrays()
         array = c.getComponent('CONTROL/'+arrayname[0])
         self.antennalist = array.getAntennas()
         self.logger = getLogger()
         del master
         del array
         c.disconnect()
     except Exception, e:
         print e
 def setUp(self):
     """
     Test case fixture.
     """
     self.client = PySimpleClient("ServerRepresentationTest")
     self.simulator = self.client.getComponent("SIMULATION_SERVER")
     self.lamp = self.client.getComponent("LAMP_ACCESS")
 def checkOnline(self):
     masters_states = []
     from Acspy.Clients.SimpleClient import PySimpleClient
     masters_comps = self.parser.get_masters_from_execconfig()
     for master in masters_comps:
         client = PySimpleClient()
         subsystem = client.getComponent(master)
         currentStateHierarchy = subsystem._get_currentStateHierarchy()
         state = currentStateHierarchy.get_sync()
         #if (state[0][1] is 'OPERATIONAL'):
         masters_states.append([master,state[0][1]])
     for state in masters_states:
         if(state[1] == 'OPERATIONAL'):
             print state
             pass
         else:
             return state
     return "OK"
class EventSubscriberImplTestPy(unittest.TestCase):

	################################################
	# lifecycle
	################################################
	
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceEventSubscriberImpl"
		self.simpleClient.getLogger().logInfo("pyUnitTestEventSubscriberImpl.EventSubscriberImplTestPy.setUp()...")
        self.simpleClient.getLogger().logInfo("Get component " + self.componentName)
        self.component = self.simpleClient.getComponent(self.componentName)
	#__pPp__	    	           
	
	def tearDown(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestEventSubscriberImpl.EventSubscriberImplTestPy.tearDown()...")
		self.simpleClient.getLogger().logInfo("Releasing component " + self.componentName)
		self.simpleClient.releaseComponent(self.componentName)
		self.simpleClient.disconnect()
Beispiel #9
0
 def __init__(self, compname, comp_type):
     BaseRepresentation.__init__(self, compname)
     self.comp_type = comp_type
     self.simulator = None
     self.client = PySimpleClient()
     self.simulator = None
     try: 
        self.simulator = self.client.getDefaultComponent("IDL:alma/ACSSim/Simulator:1.0")
     except NoDefaultComponentEx, ex:
        # fine, no Simulator Server component defined in the CDB
        pass
Beispiel #10
0
	def run(self):
		self.simpleClient = PySimpleClient.getInstance()
		self.ccinstance = self.simpleClient.getDefaultComponent("IDL:alma/CSATCONTROL_MODULE/CSATControl:1.0")
		self.csinstance = self.simpleClient.getDefaultComponent("IDL:alma/CSATSTATUS_MODULE/CSATStatus:1.0")
		self.cupd = coorUpdater(self.ra,self.dec,self.csinstance)
		self.iupd = imgUpdater(self.img,self.ccinstance)
		self.csinstance.on()
		self.cupd.start()
		if(self.video):
			self.iupd.start()
		gtk.main()
Beispiel #11
0
    def __init__(self, name="ACS Event Admin Client"):
        '''
        Just call superclass constructors here.
        '''
        PySimpleClient.__init__(self, name)

        #dictionary which consists of all active channels
        #the keys here are the channelNames in string format
        self.channels = {}
        
        #so long as this evaluates to true, the thread continues executing
        self.running = 1

        #start a new thread to continuously look for new channels in the naming
        #service
        self.getLogger().logInfo("Creating a thread to poll the CORBA Naming Service for new channels...")

        #Get the Naming Service helper class
        self.nt = NameTree.nameTree(getORB())
        
        start_new_thread(self.pollNamingService, ())
        return    
 def get_mgr_instance(self,antenna):
     '''
     Get dinamic component instance
     '''
     from Acspy.Clients.SimpleClient import PySimpleClient
     mgr = None
     sys.stdout = open("/dev/null", "w")
     client = PySimpleClient("CAN STATUS")
     sys.stdout = sys.__stdout__
     deployed_mgrs = client.availableComponents(type_wildcard='IDL:alma/Control/AmbManager:1.0')
     for deployed_mgr in deployed_mgrs:
         if deployed_mgr.name.__contains__(antenna) :
             print "Trying to get ambManager from  %s" % antenna
             try:
                 mgr= client.getDynamicComponent(deployed_mgr.name, deployed_mgr.type, deployed_mgr.code, deployed_mgr.container_name)
             except maciErrType.CannotGetComponentEx, e:
                 print e[0].shortDescription
                 sys.exit(-1)
             except Exception, e:
                 print e
                 sys.exit(-1)
             break
Beispiel #13
0
def mostRecentAsdm(date=None) :
    if date == None :
        date='%4.2d-%2.2d-%2.2d'%(time.gmtime()[0], time.gmtime()[1], time.gmtime()[2])
    client = PySimpleClient()
    archConn = client.getComponent('ARCHIVE_CONNECTION')
    archOp = archConn.getOperational('XMLQueryTest')
    uids = archOp.queryRecent('ASDM',date+'T00:00:00.000')
    asdm_name=[]
    for uid in uids:
        result = archOp.retrieveDirty(uid)
        dataSet = ArchivedAsdm(result.xmlString)
        dateOfCreation =  dataSet.getDateOfCreation()
        if dataSet.isAsdm() & (dateOfCreation==date):
            asdm_name.append("%s \t%s" % (dateOfCreation,uid))
    asdm_name.sort()
    client.releaseComponent('ARCHIVE_CONNECTION')
    client.disconnect()
    if len(asdm_name) == 0 :
        print 'there are no asdms for %s' % date
        return None
    else :
        return asdm_name[-1].split('\t')[1]
Beispiel #14
0
def mostRecentAsdm(date = None):
    '''
    Get the most recent Asdm, given a date. 
    If the date is None, it takes the  actual hour.

    return asdm or None
    '''
    from Acspy.Clients.SimpleClient import PySimpleClient
    from ArchivedAsdm import ArchivedAsdm
    if date == None :
        date_T = '%4.2d-%2.2d-%2.2dT00:00:00.000' % (gmtime()[0] , gmtime()[1] , gmtime()[2])
        date  = '%4.2d-%2.2d-%2.2d'% (gmtime()[0] , gmtime()[1] , gmtime()[2]) 
    else:
        date_T = '%4.2d-%2.2d-%2.2dT%2.2d:00:00.00' % (date[0] , date[1] , date[2] , date[3])
        date  = '%4.2d-%2.2d-%2.2d'% (date[0] , date[1] , date[2]) 
    client = PySimpleClient()
    archConn = client.getComponent('ARCHIVE_CONNECTION')
    archOp = archConn.getOperational('XMLQueryTest')
    uids = archOp.queryRecent('ASDM' , date_T)
    print "Connection entablish with archive ..."
    asdm_name = []
    for uid in uids:
        print "Checking date of " +str(uid),
        result = archOp.retrieveDirty(uid)
        dataSet = ArchivedAsdm(result.xmlString)
        dateOfCreation =  dataSet.getDateOfCreation()
        print "  created: "+str(dataSet.getDateTimeOfCreation()),
        if dataSet.isAsdm() & (dateOfCreation==date):
            asdm_name.append("%s \t%s" % (dataSet.getDateTimeOfCreation() , uid))
            print " --> is an asdm!",
        print ""
    asdm_name.sort()
    client.releaseComponent('ARCHIVE_CONNECTION')
    client.disconnect()
    if len(asdm_name) == 0 :
        print 'There are no asdms for %s' % date
        return None
    else :
        return asdm_name[-1].split('\t')[1]
 def _setup_acs_client(self):
     self._my_acs_client = PySimpleClient()
     self._logger = self._my_acs_client.getLogger()
     self._logger.setLevel(self._verbosity)
        self.logger.logInfo(self.name + " started")
        assert (self.map.isProcessing(self.compName))
        if self.activate:
            self.map.aboutToActivate(self.compName)
        else:
            self.map.aboutToDeactivate(self.compName)
        assert (self.map.isProcessing(self.compName))
        self.logger.logInfo(self.name + " processing " + self.compName)
        if self.activate:
            self.map.activated(self.compName)
        else:
            self.map.deactivated(self.compName)
        self.logger.logInfo(self.name + " processed " + self.compName)


simpleClient = PySimpleClient("acspyTestContainerActivationMap")

map = ContainerActivationMap(simpleClient.getLogger())

# Simulate the starting of the activation of multiple components
simpleClient.getLogger().logInfo(
    "Testing activation of components from the main thread...")
for i in range(1000):
    name = "TestComponent_" + str(i)
    map.aboutToActivate(name)
    if not map.isProcessing(name):
        simpleClient.getLogger().logError("The map does not contain " + name)
        assert (map.numOfProcessingItems() == i + 1)
# And then their termination of their activation
for i in range(1000):
    name = "TestComponent_" + str(i)
Beispiel #17
0
- Accessing (remote) components.
- Converting (ACS Error System) CORBA exceptions into their related Python exception helper classes.
- Logging (ACS Error System) CORBA exceptions.

LINKS
- <a href="../../idl/html/interfaceHelloWorld_1_1HelloWorld.html">HelloWorld IDL Documentation</a>
'''

import ACSErrTypeCommon
import ACSErrTypeCommonImpl

# Import the acspy.PySimpleClient class
from Acspy.Clients.SimpleClient import PySimpleClient

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

try:
    # Get the standard HelloWorld device
    hw = simpleClient.getComponent("HELLOWORLD1")
    simpleClient.getLogger().logInfo("Trying to invoke bad method")
    hw.badMethod()

except ACSErrTypeCommon.UnknownEx, e:
    simpleClient.getLogger().logCritical(
        "Caught an ACSException...don't worry because this SHOULD happen.")
    helperException = ACSErrTypeCommonImpl.UnknownExImpl(exception=e)
    helperException.Print()
    helperException.log(simpleClient.getLogger())
    # Release it
    simpleClient.releaseComponent("HELLOWORLD1")
Beispiel #18
0
class ComponentUtilTest(unittest.TestCase):
    """
    This test requires ACS running with the testacsproperties CDB and
    the myC cpp container up
    """
    def setUp(self):
        self._my_acs_client = PySimpleClient()
        logger = self._my_acs_client.getLogger()
        logger.setLevel(logging.WARNING)
        # disable annoying output from the tests

    def tearDown(self):
        self._my_acs_client.disconnect()

    def test_get_enum_prop_dict(self):

        my_component = self._my_acs_client.getComponent(
            "TEST_PROPERTIES_COMPONENT", True)

        enum_prop = my_component._get_EnumTestROProp()

        decoded = component_util.get_enum_prop_dict(enum_prop)
        expected_value = {'0': 'STATE1', '1': 'STATE2', '2': 'STATE3'}
        self.assertEqual(expected_value, decoded)

        enum_prop = my_component._get_EnumTestRWProp()

        decoded = component_util.get_enum_prop_dict(enum_prop)
        expected_value = {'0': 'STATE1', '1': 'STATE2', '2': 'STATE3'}
        self.assertEqual(expected_value, decoded)

        self._my_acs_client.releaseComponent("TEST_PROPERTIES_COMPONENT")

    def test_get_property_type(self):
        my_component = self._my_acs_client.getComponent(
            "TEST_PROPERTIES_COMPONENT", True)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_EnumTestROProp()._NP_RepositoryId),
            PropertyType.OBJECT)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_EnumTestRWProp()._NP_RepositoryId),
            PropertyType.OBJECT)

        PropertyType.OBJECT

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_doubleROProp()._NP_RepositoryId),
            PropertyType.DOUBLE)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_floatSeqRWProp()._NP_RepositoryId),
            PropertyType.FLOAT_SEQ)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_longSeqRWProp()._NP_RepositoryId),
            PropertyType.LONG_SEQ)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_uLongLongRWProp()._NP_RepositoryId),
            PropertyType.LONG_LONG)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_uLongLongRWProp()._NP_RepositoryId),
            PropertyType.LONG_LONG)
        self.assertEqual(
            component_util.get_property_type(
                my_component._get_doubleRWProp()._NP_RepositoryId),
            PropertyType.DOUBLE)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_uLongROProp()._NP_RepositoryId),
            PropertyType.LONG)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_booleanROProp()._NP_RepositoryId),
            PropertyType.BOOL)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_doubleSeqROProp()._NP_RepositoryId),
            PropertyType.DOUBLE_SEQ)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_longLongROProp()._NP_RepositoryId),
            PropertyType.LONG_LONG)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_patternROProp()._NP_RepositoryId),
            PropertyType.BIT_FIELD)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_uLongRWProp()._NP_RepositoryId),
            PropertyType.LONG)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_booleanRWProp()._NP_RepositoryId),
            PropertyType.BOOL)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_doubleSeqRWProp()._NP_RepositoryId),
            PropertyType.DOUBLE_SEQ)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_longLongRWProp()._NP_RepositoryId),
            PropertyType.LONG_LONG)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_patternRWProp()._NP_RepositoryId),
            PropertyType.BIT_FIELD)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_uLongSeqROProp()._NP_RepositoryId),
            PropertyType.LONG_SEQ)

        self.assertRaises(
            UnsupporterPropertyTypeError, component_util.get_property_type,
            my_component._get_booleanSeqROProp()._NP_RepositoryId)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_floatROProp()._NP_RepositoryId),
            PropertyType.FLOAT)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_longROProp()._NP_RepositoryId),
            PropertyType.LONG)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_stringROProp()._NP_RepositoryId),
            PropertyType.STRING)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_uLongSeqRWProp()._NP_RepositoryId),
            PropertyType.LONG_SEQ)

        self.assertRaises(
            UnsupporterPropertyTypeError, component_util.get_property_type,
            my_component._get_booleanSeqRWProp()._NP_RepositoryId)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_floatRWProp()._NP_RepositoryId),
            PropertyType.FLOAT)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_longRWProp()._NP_RepositoryId),
            PropertyType.LONG)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_stringRWProp()._NP_RepositoryId),
            PropertyType.STRING)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_floatSeqROProp()._NP_RepositoryId),
            PropertyType.FLOAT_SEQ)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_longSeqROProp()._NP_RepositoryId),
            PropertyType.LONG_SEQ)

        self.assertEqual(
            component_util.get_property_type(
                my_component._get_uLongLongROProp()._NP_RepositoryId),
            PropertyType.LONG_LONG)

    def test_is_archive_delta_enabled(self):

        # First test the cases when it should be false
        self.assertFalse(component_util.is_archive_delta_enabled(None))
        self.assertFalse(component_util.is_archive_delta_enabled(False))
        self.assertFalse(component_util.is_archive_delta_enabled("0"))
        self.assertFalse(component_util.is_archive_delta_enabled("0.0"))
        self.assertFalse(component_util.is_archive_delta_enabled(0))
        self.assertFalse(component_util.is_archive_delta_enabled(0.0))
Beispiel #19
0
class FrontEndTest(unittest.TestCase):
    """
    This test requires ACS running with the testacsproperties CDB and
    the myC cpp container up
    """
    def setUp(self):
        self._my_acs_client = PySimpleClient()
        self._my_acs_client.getLogger().setLevel(logging.CRITICAL)
        self._front_end = FrontEnd(RecorderConfig(), self._my_acs_client)
        self.__my_component_id = "TEST_PROPERTIES_COMPONENT"

    def test_is_acs_client_ok(self):
        self.assertTrue(self._front_end.is_acs_client_ok)

    def test_update_acs_client(self):
        other_client = PySimpleClient()
        other_client.getLogger().setLevel(logging.CRITICAL)
        self._front_end.update_acs_client(other_client)
        self.assertTrue(self._front_end.is_acs_client_ok)
        self._front_end.start_recording()
        yet_other_client = PySimpleClient()
        yet_other_client.getLogger().setLevel(logging.CRITICAL)
        self._front_end.update_acs_client(yet_other_client)
        self._front_end.stop_recording()

    def test_start_recording(self):
        self._front_end.start_recording()
        self.assertTrue(self._front_end.is_recording)
        self._front_end.stop_recording()

        self._my_acs_client.getComponent(self.__my_component_id, True)
        self._front_end.start_recording()
        self.assertTrue(self._front_end.is_recording)
        self._front_end.stop_recording()
        self._my_acs_client.releaseComponent(self.__my_component_id)

    def test_process_component(self):
        self._my_acs_client.getComponent(self.__my_component_id, True)

        self._front_end.process_component(self.__my_component_id)

        self._my_acs_client.releaseComponent(self.__my_component_id)

        self.assertRaises(CannotAddComponentException,
                          self._front_end.process_component, "I_DO_NOT_EXIST")

    def test_remove_wrong_components(self):
        self._my_acs_client.getComponent(self.__my_component_id, True)
        self._front_end.start_recording()

        time.sleep(3)

        self._my_acs_client.releaseComponent(self.__my_component_id)

        time.sleep(10)

        self._front_end.stop_recording()

    def tearDown(self):
        self._front_end.cancel()
        self._front_end = None
Beispiel #20
0
# MA 02111-1307  USA
#

from Acspy.Clients.SimpleClient import PySimpleClient
from sys                        import argv
from sys                        import exit
from sys                        import stdout
from TMCDB                      import MonitorCollector
from TMCDB                      import propertySerailNumber
from omniORB                    import any
import MonitorErrImpl
import MonitorErr
import time

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

mc = simpleClient.getComponent(argv[1])

try:
    tc =   simpleClient.getComponent('MC_TEST_PROPERTIES_COMPONENT')
    psns =[propertySerailNumber('doubleROProp',    ['1' ]),
           propertySerailNumber('floatROProp',     ['2' ]),
           propertySerailNumber('longROProp',      ['3' ]),
           propertySerailNumber('uLongROProp',     ['4' ]),
           propertySerailNumber('patternROProp',   ['5' ]),
           propertySerailNumber('stringROProp',    ['6' ]),
           propertySerailNumber('longLongROProp',  ['7' ]),
           propertySerailNumber('uLongLongROProp', ['8' ]),
           propertySerailNumber('booleanROProp',   ['9' ]),
           propertySerailNumber('doubleSeqROProp', ['10']),
Beispiel #21
0
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#
# @(#) $Id: acspyTestContainer.py,v 1.10 2005/05/26 17:23:26 dfugate Exp $

"""
Test component services via a component. In short, this provides complete
testing of the container.
"""

from Acspy.Clients.SimpleClient import PySimpleClient
import acspytest
from time import sleep

simpleClient = PySimpleClient()

#test an immortal component first
print "Testing TESTCOMPONENT (i.e., immortal components)"
test = simpleClient.getComponent("TESTCOMPONENT")
test.sayHello()
val = test.testServices()
if not val:
    print "TESTCOMPONENT.testServices() FAILED!!!"

#test a mortal component next
print "Testing TESTCOMPONENT1 (i.e., mortal components)"
test1 = simpleClient.getComponent("TESTCOMPONENT1")
test1.sayHello()
val = test1.testServices()
if not val:
Beispiel #22
0
class MotorImplTestPy(unittest.TestCase):

	################################################
	# lifecycle
	################################################
	
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceMotorImpl"
		self.simpleClient.getLogger().logInfo("pyUnitTestMotorImpl.MotorImplTestPy.setUp()...")
        self.simpleClient.getLogger().logInfo("Get component " + self.componentName)
        self.component = self.simpleClient.getComponent(self.componentName)
	#__pPp__	    	           
	
	def tearDown(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestMotorImpl.MotorImplTestPy.tearDown()...")
		self.simpleClient.getLogger().logInfo("Releasing component " + self.componentName)
		self.simpleClient.releaseComponent(self.componentName)
		self.simpleClient.disconnect()
	#__pPp__       
        
	################################################
	# test methods
	################################################
	
	def testMove(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestMotorImpl.MotorImplTestPy.testMove()...")
		response = None
		response = self.component.move()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testStandby(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestMotorImpl.MotorImplTestPy.testStandby()...")
		response = None
		response = self.component.standby()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testOnline(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestMotorImpl.MotorImplTestPy.testOnline()...")
		response = None
		response = self.component.online()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testOff(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestMotorImpl.MotorImplTestPy.testOff()...")
		response = None
		response = self.component.off()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testSetup(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestMotorImpl.MotorImplTestPy.testSetup()...")
		response = None
		val = 'emptyString'
		timeout = 0
		response = self.component.setup(val, timeout)
		# no return is expected, response should be None
		assert response is None
Beispiel #23
0
      implementation located in ACS/LGPL/CommonSoftware/acsQoS/ws/test.
"""

from Acspy.Clients.SimpleClient import PySimpleClient
import Acspy.Common.QoS as QofS
import sys


def exitGracefully(client):
    client.releaseComponent("TEST_QOS_COMPONENT")
    client.disconnect()
    sys.exit()


# instantiate the simple client
mySimpleClient = PySimpleClient()

# get the test component used for the method invocations that we invoke to test timeouts
testQoSComponent = mySimpleClient.getComponent("TEST_QOS_COMPONENT")

# first, call method on the servant with no QoS timeout set
try:
    testQoSComponent.echo(0, 1000)
    print "Method w/o timeout executed successfully."

except Exception, e:
    print "ERROR 0: timeout exception caught on method invocation when not expected."
    exitGracefully(mySimpleClient)

# test setting/resetting of a (local) timeout and also test invocation of a method
# (with a timeout set) that doesn't exceed the time out
Beispiel #24
0
#!/usr/bin/env python
from Acspy.Clients.SimpleClient import PySimpleClient

remoteComponent = "MOUNT2_LOOP"

#Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

#Get the MOUNT1 Mount device
mount = simpleClient.getComponent(remoteComponent)

#Get the actAz property
actAzProperty = mount._get_actAz()

#Get the current value of the property
(azm, compl) = actAzProperty.get_sync()
print "MOUNT actual azimuth: ", azm

#Cleanly disconnect
simpleClient.releaseComponent(remoteComponent)
simpleClient.disconnect()
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307  USA
#
# @(#) $Id: acspyexmplTestPyContainer.py,v 1.8 2006/10/25 14:10:28 bjeram Exp $
"""
Test very simple components.
"""

from Acspy.Clients.SimpleClient import PySimpleClient

simpleClient = PySimpleClient()

try:
    #test an immortal cob first
    print "Testing HELLODEMO1 (i.e., immortal components)"
    test1 = simpleClient.getComponent("HELLODEMO1")
    print test1.sayHello()
    print test1.sayHelloWithParameters("I'm an 'inString'", 3.14)

    print
    print "Now test HELLODEMO2 (i.e., non-immortal components)"
    test2 = simpleClient.getComponent("HELLODEMO2")
    print test2.sayHello()
    print test2.sayHelloWithParameters("I'm an 'inString'", 3.14)

    print
                "completionFromCompletion has thrown an UNEXPECTED exception")
            ex2.log(self.logger)

        addComplHelperMethods(comp)

        if comp.isErrorFree() == 1:
            self.logger.logInfo("Completion Ok, without error trace")
        else:
            self.logger.logInfo("Completion with error trace (UNEXPECTED)")
            comp.log(self.logger)


#-----------------------------------------------------------------------------
if __name__ == "__main__":

    client = PySimpleClient("acspyexmplClientErrorComponent")

    print("starting acspyexmplClientErrorComponent")
    # Here we instantiate the object used to show examples of error handling.
    # Each method call demonstrate one aspect of error hanlding.
    # See the class documentation for details.
    try:
        print("Creating ClientErrorComponent")
        clientErrorComponent = ClientErrorComponent(client, argv[1])

        #Call the displayMessage() method existing in the interface for ErrorComponent
        clientErrorComponent.TestOk()
        clientErrorComponent.TestReceiveRemoteException()
        clientErrorComponent.TestReceiveRemoteCompletion()
        clientErrorComponent.testExceptionFromCompletion()
        clientErrorComponent.testTypeException()
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceEventSubscriberImpl"
		self.simpleClient.getLogger().logInfo("pyUnitTestEventSubscriberImpl.EventSubscriberImplTestPy.setUp()...")
    catch it and call processEvent(...) which will hopefully have been overriden.
    '''
    global count
    
    if count < 5:
        count = count + 1
        LOGGER.logInfo('The temperature difference is ' + str(someParam.absoluteDiff))
        
    return
#------------------------------------------------------------------------------
if __name__ == "__main__":
    
    print 'Making sure there is a fridge available...'
    
    #Start publishing events through a C++ Supplier
    simpleClient = PySimpleClient()
    aFridge = simpleClient.getComponent("FRIDGE1")
    aFridge.on()

    #Create a FridgeConsumer
    simpleClient.getLogger().logInfo('Creating FridgeConsumer')
    g = Consumer(FRIDGE.CHANNELNAME_FRIDGE)

    #Subscribe to temperatureDataBlockEvent events and register this handler to process
    #those events
    g.addSubscription(FRIDGE.temperatureDataBlockEvent, fridgeDataHandler)

    #Let the Notification Service know we are ready to start processing events.
    g.consumerReady()

    #After five events have been received, disconnect from the channel
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#

from Acspy.Clients.SimpleClient import PySimpleClient
from sys                        import argv
from sys                        import exit
from TMCDB                      import MonitorCollector
from TMCDB                      import propertySerailNumber
import MonitorErrImpl
import MonitorErr

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

mc = simpleClient.getComponent(argv[1])

# Test Case 1: Register collocated device with multiple serial non registrable
#              Test EH(registerCollocatedMonitoredDeviceWithMultipleSerial): RegisteringDeviceProblem"
print "Test Case 1: Register collocated device with multiple serial non registrable"
print "--------------------------------------------"
try:
    psns =[propertySerailNumber('asds', ['12124']),propertySerailNumber('sdfsfs', ['3432535'])]
    mc.registerCollocatedMonitoredDeviceWithMultipleSerial('FAKE_DEVICE', psns)
    print " TEST FAIL: FAKE_DEVICE registered"
except MonitorErr.RegisteringDeviceProblemEx, _ex:
    ex = MonitorErrImpl.RegisteringDeviceProblemExImpl(exception=_ex)
    ex.Print();
    print " TEST SUCCESS: FAKE_DEVICE not registered"
Beispiel #30
0
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#
# @(#) $Id: acssimGenericTest.py,v 1.3 2006/03/16 00:03:02 dfugate Exp $
#------------------------------------------------------------------------------

'''
Quite possibly the most generic component client throughout ALMA software.
'''
from sys import argv
import ACS
from Acspy.Clients.SimpleClient import PySimpleClient

compName = argv[1]
compMethod = argv[2]

print "Parameters to this generic test script are:", argv[1], argv[2]

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()
comp = simpleClient.getComponent(compName)

try:
    joe = eval("comp." + argv[2])
    print "The evaluated return value is:", joe
except Exception, e:
    print "The exception that occured was:", e
    
simpleClient.releaseComponent(compName)
simpleClient.disconnect()
Beispiel #31
0
class SCJavaImpTestPy(unittest.TestCase):

	################################################
	# lifecycle
	################################################
	
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceSCJavaImp"
		self.simpleClient.getLogger().logInfo("pyUnitTestSCJavaImp.SCJavaImpTestPy.setUp()...")
        self.simpleClient.getLogger().logInfo("Get component " + self.componentName)
        self.component = self.simpleClient.getComponent(self.componentName)
	#__pPp__	    	           
	
	def tearDown(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestSCJavaImp.SCJavaImpTestPy.tearDown()...")
		self.simpleClient.getLogger().logInfo("Releasing component " + self.componentName)
		self.simpleClient.releaseComponent(self.componentName)
		self.simpleClient.disconnect()
	#__pPp__       
        
	################################################
	# test methods
	################################################
	
	def testReset(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestSCJavaImp.SCJavaImpTestPy.testReset()...")
		response = None
		response = self.component.reset()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testStatus(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestSCJavaImp.SCJavaImpTestPy.testStatus()...")
		response = None
		response = self.component.status()
		# a return is expected, response should be not None
		assert response is not None
	#__pPp__
			    
	def testGetPosition(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestSCJavaImp.SCJavaImpTestPy.testGetPosition()...")
		response = None
		response = self.component.getPosition()
		# a return is expected, response should be not None
		assert response is not None
	#__pPp__
			    
	def testSensorType(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestSCJavaImp.SCJavaImpTestPy.testSensorType()...")
		response = None
		response = self.component.sensorType()
		# a return is expected, response should be not None
		assert response is not None
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceTRDJavaImp"
		self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.setUp()...")
Beispiel #33
0
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceSCJavaImp"
		self.simpleClient.getLogger().logInfo("pyUnitTestSCJavaImp.SCJavaImpTestPy.setUp()...")
magicNumber = int(argv[2])


def myHandler(ts, device, parameter, value):
    '''
    '''
    global count
    if count < magicNumber:
        count = count + 1
    return


#create the consumer
myConsumer = ArchiveConsumer(myHandler)
myConsumer.consumerReady()
#activate the component which will publish the events automatically
joe = PySimpleClient()
ps = joe.getComponent("TEST_PS_1")
#give the consumer a chance to receive the events
sleep(int(argv[1]))

#shutdown everything cleanly
myConsumer.disconnect()
joe.releaseComponent("TEST_PS_1")
joe.disconnect()

if count == magicNumber:
    print "Test passed!"
else:
    print "Test failed:", count
Beispiel #35
0
from Acspy.Clients.SimpleClient import PySimpleClient

client = PySimpleClient()


def test_component_and_interface():
    comp = client.getDynamicComponent(
        'comp',
        "IDL:cta/example/ExampleComponent:1.0",
        None,
        "aragornContainer")

    # see if comp has value propoerty
    comp.value

    # test if comp has a set() method
    comp.set(123)
Beispiel #36
0
 def setUp(self):
     self._my_acs_client = PySimpleClient()
     self._my_acs_client.getLogger().setLevel(logging.CRITICAL)
     self._front_end = FrontEnd(RecorderConfig(), self._my_acs_client)
     self.__my_component_id = "TEST_PROPERTIES_COMPONENT"
Beispiel #37
0
class DCSImplTestPy(unittest.TestCase):

	################################################
	# lifecycle
	################################################
	
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceDCSImpl"
		self.simpleClient.getLogger().logInfo("pyUnitTestDCSImpl.DCSImplTestPy.setUp()...")
        self.simpleClient.getLogger().logInfo("Get component " + self.componentName)
        self.component = self.simpleClient.getComponent(self.componentName)
	#__pPp__	    	           
	
	def tearDown(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestDCSImpl.DCSImplTestPy.tearDown()...")
		self.simpleClient.getLogger().logInfo("Releasing component " + self.componentName)
		self.simpleClient.releaseComponent(self.componentName)
		self.simpleClient.disconnect()
	#__pPp__       
        
	################################################
	# test methods
	################################################
	
	def testSendCommand(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestDCSImpl.DCSImplTestPy.testSendCommand()...")
		response = None
		commandName = 'emptyString'
		parameterList = 'emptyString'
		cb = CBstring()
		desc = CBDescIn()
		response = self.component.sendCommand(commandName, parameterList, cb, desc)
		# a return is expected, response should be not None
		assert response is not None
Beispiel #38
0
 def setUp(self):
     self._my_acs_client = PySimpleClient()
     logger = self._my_acs_client.getLogger()
     logger.setLevel(logging.WARNING)
Beispiel #39
0
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307  USA
#

from Acspy.Clients.SimpleClient import PySimpleClient
from sys import argv
from sys import exit
from TMCDB import MonitorCollector
from TMCDB import propertySerailNumber
from omniORB import any
import MonitorErrImpl
import MonitorErr
import time

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

mc = simpleClient.getComponent(argv[1])

try:
    tc = simpleClient.getComponent('MC_TEST_COMPONENT')
    psns = [
        propertySerailNumber('doubleSeqProp', ['12124']),
        propertySerailNumber('doubleProp', ['3432535'])
    ]
    mc.registerMonitoredDeviceWithMultipleSerial('MC_TEST_COMPONENT', psns)
    tc.reset()
    mc.startMonitoring('MC_TEST_COMPONENT')
    time.sleep(10)
    #Change archiving interval to 2 seconds instead of 1
    mc.set_archiving_interval('MC_TEST_COMPONENT', 'doubleProp', 20000000)
Beispiel #40
0
from subprocess import *
import ACSErrTypeCommon
import ACSErrTypeCommonImpl
import sys
import time

# Import the acspy.PySimpleClient class
from Acspy.Clients.SimpleClient import PySimpleClient
from Acspy.Nc.Consumer import Consumer
from Control import CHANNELNAME_CONTROLSYSTEM
from Control import ExecBlockStartedEvent
from Control import ExecBlockEndedEvent

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()
simpleClient.getLogger().logInfo("Simple client instantiated.")

global started
global ended

def handlerStarted(event):
    global started
    started += 1
    print event.execId
    print event.sbId
    print event.sessionId
    print event.arrayName
    print event.startTime
    return
Beispiel #41
0
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#
# @(#) $Id: acsncTestConSup.py,v 1.6 2006/03/08 17:50:44 dfugate Exp $

"""
"""

from Acspy.Clients.SimpleClient import PySimpleClient
from sys                        import argv
from time                       import sleep

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

consumer = simpleClient.getComponent(argv[1])


if len(argv)==3:
    supplier = simpleClient.getComponent(argv[2])
    supplier.sendEvents(10)
else:
    sleep(10)

sleep(50)


simpleClient.releaseComponent(argv[1])
sleep(2)
class StandaloneRecorder(object):
    """
    A property recorder that works as an stand-alone application

    """
    def __init__(self, recorder_config, verbosity):
        '''
        Ctor

        @param recorder_config: the configuration of the recorder
        @type recorder_config: RecorderConfig
        @param verbosity: the verbosity level
        (logging.WARNING, logging.DEBUG, etc) of the logger
        @type verbosity: int
        '''
        self._verbosity = verbosity
        self._recorder_config = recorder_config

        self._setup_acs_client()
        self._setup_front_end()
        self.__canceled = False

        self._logger.info('Property recorder up')

    def _setup_acs_client(self):
        self._my_acs_client = PySimpleClient()
        self._logger = self._my_acs_client.getLogger()
        self._logger.setLevel(self._verbosity)

    def _setup_front_end(self):
        self._front_end = FrontEnd(self._recorder_config, self._my_acs_client)

    def make_new_acs_client(self):
        '''
        Will make a new ACS client and replace the existing one

        To be used to recover from ACS restarts.
        @raise CORBAProblemExImpl: if the client cannot be created.
        '''
        self._setup_acs_client()
        self._front_end.update_acs_client(self._my_acs_client)

    def start(self):
        '''
        The property recorded will start to record properties

        @raises RuntimeError: if the recorder is cancelled
        '''
        if self.__canceled:
            raise RuntimeError("The recorded is cancelled")

        self._front_end.start_recording()
        self._logger.info('Recording start')

    def stop(self):
        '''
        The property recorded will stop to record properties

        All the monitors are stopped, the components are unregistered
        @raises RuntimeError: if the recorder is cancelled
        '''
        if self.__canceled:
            raise RuntimeError("The recorded is cancelled")
        self._front_end.stop_recording()
        self._logger.info('Recording stop')

    def close(self):
        '''
        Closes the property recorder, ready to be destroyed

        All the resources will be freed and the connection with
        ACS closed. The recorder will be cancelled from now on,
        Meaning that the recorder is not anymore usable and
        is ready to be destroyed
        '''
        if not self.__canceled:
            self._logger.info('Switching off property recorder')
            self.stop()
            self._front_end.cancel()
            self._front_end = None
            self._recorder_config = None
            self._my_acs_client.disconnect()
            self._my_acs_client = None
            self.__canceled = True

    def is_acs_client_ok(self):
        '''
        Checks if the ACS client is OK or not.

        When not OK, this typically means that ACS is
        down. This lets the client know when a new client should be created
        @return: if the client is OK or not
        @rtype: bool
        '''
        return self._front_end.is_acs_client_ok

    def print_config(self):
        '''
        Prints into the logger the existing configuration
        '''
        self._logger.debug('Property Recorder Configuration'
                           '\n--------------------------------------\n' +
                           pprint.pformat(vars(self._recorder_config)) +
                           '\n--------------------------------------')
Beispiel #43
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307  USA
#
# @(#) $Id: javaSupplierComponent.py,v 1.1 2008/05/23 12:53:45 eallaert Exp $
"""
"""
from Acspy.Clients.SimpleClient import PySimpleClient
from time import sleep
import sys

simpleClient = PySimpleClient()
sleep(5)

print "Getting the Supplier"
sys.stdout.flush()
mySupplierComp = simpleClient.getComponent("SUPPLIERCOMP1")

print "Sending events"
sys.stdout.flush()
for i in range(50):
    mySupplierComp.sendEvents(1)
    sleep(1)

simpleClient.releaseComponent("SUPPLIERCOMP1")

print "Finished sending events"
Beispiel #44
0
#!/usr/bin/env python

from Acspy.Clients.SimpleClient import PySimpleClient

simpleClient = PySimpleClient.getInstance()

ncBench = simpleClient.getComponent("NC_DDS_SUPPLIER")

ncBench.runTest(10,1000)

simpleClient.releaseComponent("NC_DDS_SUPPLIER")
simpleClient.disconnect()

Beispiel #45
0
'''
Tests a callback void method.
'''
from sys import argv
from time import sleep
from Acspy.Clients.SimpleClient import PySimpleClient
from Acspy.Common.Callbacks     import CBvoid
from ACS import CBDescIn

compName = argv[1]
compMethod = argv[2]

print "Parameters to this generic test script are:", argv[1:]

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()
comp = simpleClient.getComponent(compName)

myCB = CBvoid()
myCorbaCB = simpleClient.activateOffShoot(myCB)
myDescIn = CBDescIn(0L, 0L, 0L)

joe = eval("comp." + compMethod + "(myCorbaCB, myDescIn)")
print "Method executed...now just waiting on CB status"

for i in range(0, 50):
    if myCB.status == 'DONE':
        print "The callback has finished!"
        break
    else:
        sleep(1)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#
# @(#) $Id: javaSupplierComponent.py,v 1.1 2008/05/23 12:53:45 eallaert Exp $
"""
"""
from Acspy.Clients.SimpleClient import PySimpleClient
from time import sleep
import sys

simpleClient = PySimpleClient()
sleep(5)

print "Getting the Supplier"
sys.stdout.flush()
mySupplierComp = simpleClient.getComponent("SUPPLIERCOMP1")


print "Sending events"
sys.stdout.flush()
for i in range(50):
    mySupplierComp.sendEvents(1)
    sleep(1)

simpleClient.releaseComponent("SUPPLIERCOMP1")
Beispiel #47
0
import datetime
import numpy as np
from Acspy.Clients.SimpleClient import PySimpleClient

print "Getting python client ..."
c = PySimpleClient()
names = []
tmcdb = c.getComponent('TMCDBAccess')

for i in range(1,17):
    names.append('CORR/CDP_NODE/N%s' % str(i).zfill(2))
names.append('CORR/CDP_MASTER')
print "Start profiling ..."
prof = {}
for comp_name in names:
    print "Getting: %s" % comp_name
    t0 = datetime.datetime.utcnow()
    node = c.getComponent(comp_name)
    t1 = datetime.datetime.utcnow()
    delta = (t1 - t0)#.total_seconds()
    prof[comp_name] = (delta.microseconds + 0.0 + (delta.seconds + delta.days * 24 * 3600) * 10 ** 6) / 10 ** 6

print "\nStats in seconds [s]\n"
for comp, delta in prof.items():
    print "%s => %f" % (comp, delta)

values = np.array(prof.values())
print "\nStats [s]\n"
print "min:  %f" % ((values.min()))
print "max:  %f" % ((values.max()))
print "mean: %f" % ((values.mean()))
Beispiel #48
0
#! /usr/bin/env python

from sys import argv
from time import sleep
from Acspy.Clients.SimpleClient import PySimpleClient
import ACS
import time, os

simpleClient = PySimpleClient()
cdb_mount = simpleClient.getComponent("COMP99") 

sleep(10)

simpleClient.releaseComponent("COMP99")


                "completionFromCompletion has thrown an UNEXPECTED exception")
            ex2.log(self.logger)

        addComplHelperMethods(comp)

        if comp.isErrorFree() == 1:
            self.logger.logInfo("Completion Ok, without error trace")
        else:
            self.logger.logInfo("Completion with error trace (UNEXPECTED)")
            comp.log(self.logger)


#-----------------------------------------------------------------------------
if __name__ == "__main__":

    client = PySimpleClient()

    print("starting acspyexmplClientErrorComponent")
    # Here we instantiate the object used to show examples of error handling.
    # Each method call demonstrate one aspect of error hanlding.
    # See the class documentation for details.
    try:
        print("Creating ClientErrorComponent")
        clientErrorComponent = ClientErrorComponent(client, argv[1])

        #Call the displayMessage() method existing in the interface for ErrorComponent
        clientErrorComponent.TestOk()
        clientErrorComponent.TestReceiveRemoteException()
        clientErrorComponent.TestReceiveRemoteCompletion()
        clientErrorComponent.testExceptionFromCompletion()
        clientErrorComponent.testTypeException()
class TRDJavaImpTestPy(unittest.TestCase):

	################################################
	# lifecycle
	################################################
	
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceTRDJavaImp"
		self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.setUp()...")
        self.simpleClient.getLogger().logInfo("Get component " + self.componentName)
        self.component = self.simpleClient.getComponent(self.componentName)
	#__pPp__	    	           
	
	def tearDown(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.tearDown()...")
		self.simpleClient.getLogger().logInfo("Releasing component " + self.componentName)
		self.simpleClient.releaseComponent(self.componentName)
		self.simpleClient.disconnect()
	#__pPp__       
        
	################################################
	# test methods
	################################################
	
	def testGetRAB(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.testGetRAB()...")
		response = None
		type = 0
		response = self.component.getRAB(type)
		# a return is expected, response should be not None
		assert response is not None
	#__pPp__
			    
	def testCreateReport(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.testCreateReport()...")
		response = None
		rep = report()
		response = self.component.createReport(rep)
		# a return is expected, response should be not None
		assert response is not None
	#__pPp__
			    
	def testGetReportsList(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.testGetReportsList()...")
		response = None
		response = self.component.getReportsList()
		# a return is expected, response should be not None
		assert response is not None
	#__pPp__
			    
	def testGetReport(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.testGetReport()...")
		response = None
		id = 0
		response = self.component.getReport(id)
		# a return is expected, response should be not None
		assert response is not None
Beispiel #51
0
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307  USA
#

from Acspy.Clients.SimpleClient import PySimpleClient
from sys import argv
from sys import exit
from TMCDB import MonitorCollector
from TMCDB import propertySerailNumber
import MonitorErrImpl
import MonitorErr

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

mc = simpleClient.getComponent(argv[1])

print "Test EH(registerMonitoredDeviceWithMultipleSerial): RegisteringDeviceProblem - not activated"
try:
    psns = [
        propertySerailNumber('asds', ['12124']),
        propertySerailNumber('sdfsfs', ['3432535'])
    ]

    mc.registerMonitoredDeviceWithMultipleSerial('FAKE_DEVICE', psns)
except MonitorErr.RegisteringDeviceProblemEx, _ex:
    ex = MonitorErrImpl.RegisteringDeviceProblemExImpl(exception=_ex)
    ex.Print()
import sys
import time
from Acspy.Clients.SimpleClient import PySimpleClient

remoteComponentName = "TESTMAXMSGSIZE"

# Loop and call the sendSequence method on the component
# making the size of the sequence sent larger w/ each iteration
# at some point, the ORB should fail because omniorb's max
# msg size will have been exceeded.

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

while 1:
    try:
        characters = "1"

        # Get the test component by name
        remoteComponent = simpleClient.getComponent(remoteComponentName)

        for i in range(0, 22):
            print "Length being sent: ", len(characters)
            remoteComponent.sendSequence(characters)
            characters = characters + characters

        simpleClient.releaseComponent(remoteComponentName)
    except:
        print "FAILED to send: ", len(characters)
        time.sleep(1)
Beispiel #53
0
class MoreComponentUtilTest(unittest.TestCase):
    """
    Test the integration of the component utilities
    """
    def setUp(self):
        self._my_acs_client = PySimpleClient()
        logger = self._my_acs_client.getLogger()
        logger.setLevel(logging.WARNING)

    def tearDown(self):
        self._my_acs_client.disconnect()

    def test_is_characteristic_component(self):
        my_component = self._my_acs_client.getComponent(
            "TEST_PROPERTIES_COMPONENT", True)
        self.assertTrue(
            component_util.is_characteristic_component(my_component))
        # Now check a component that is not characteristic
        my_component2 = self._my_acs_client.getComponent("TIMER1", True)
        self.assertFalse(
            component_util.is_characteristic_component(my_component2))

    def test_is_python_char_component(self):
        my_component = self._my_acs_client.getComponent(
            "TEST_PROPERTIES_PYTHON", True)
        self.assertTrue(component_util.is_python_char_component(my_component))
        # Now check a component that is not characteristic

        my_component2 = self._my_acs_client.getComponent("TIMER1", True)

        self.assertRaises(AttributeError,
                          component_util.is_python_char_component,
                          my_component2)

        my_component3 = self._my_acs_client.getComponent(
            "TEST_PROPERTIES_COMPONENT", True)

        self.assertFalse(
            component_util.is_python_char_component(my_component3))

    def test_is_a_property_recorder_component(self):
        my_component = self._my_acs_client.getComponent(
            "propertyRecorder1", True)
        self.assertTrue(
            component_util.is_a_property_recorder_component(my_component))
        # Now check a component that is not characteristic
        my_component2 = self._my_acs_client.getComponent("TIMER1", True)
        self.assertFalse(
            component_util.is_a_property_recorder_component(my_component2))

    def test_is_component_state_ok(self):
        my_component = self._my_acs_client.getComponent(
            "TEST_PROPERTIES_COMPONENT", True)
        self.assertTrue(component_util.is_component_state_ok(my_component))
Beispiel #54
0
parser.add_option("--levelMax", dest="levelMax", type=float, default=5.0,
    help="White level in dBm for when not using fullscale option [default 5.0] (note optimal levels for TDM and FDM observations are 3.8 and 2.4 dBm respectively, so if you go below these expect to white-out a lot!)")

parser.add_option("--levelMin", dest="levelMin", type=float, default=-2.0, 
    help="Black level in dBm for when not using fullscale option [default -2.0]")

(options, args) = parser.parse_args()

print 'finding configured antennas'


# get_configured_antennas:
if options.antennaList == 'All':
    from Acspy.Clients.SimpleClient import PySimpleClient
    client = PySimpleClient("ping_abm")
    ant_info = client.availableComponents(type_wildcard='IDL:alma/Control/Antenna:1.0', activated=1)
    availableAnts = []
    notAvailableAntennas = []
    if len(ant_info) > 0:
    	for antenna_info in ant_info:
	    try:
		name = antenna_info.name
		antenna = client.getComponentNonSticky(antenna_info.name)
		name.split('/')
		antName = name.split('/')[1]
                sys.stdout.write(antName+'\r')
#                sys.stdout.flush()
                print antName
                if str(antenna.getState())=="Shutdown":
                    notAvailableAntennas.append(antenna[1])                
Beispiel #55
0
- Accessing (remote) components.
- Using PySimpleClient to create and reference dynamic components.
- Manipulating default parameters of ContainerServices methods.

LINKS
- <a href="../../idl/html/interfaceHelloWorld_1_1HelloWorld.html">HelloWorld IDL Documentation</a>
'''

# Import command-line arguments
from sys import argv

# Import the SimpleClient class
from Acspy.Clients.SimpleClient import PySimpleClient

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

# Obtain a reference to a dynamic component using the ContainerServices
# getComponent method.
hwRef = simpleClient.getDynamicComponent(
    None, "IDL:alma/acsexmplHelloWorld/HelloWorld:1.0",
    "acsexmplHelloWorldImpl", str(argv[1]))

if hwRef != None:
    simpleClient.getLogger().logInfo("Retrieved valid reference from manager.")
    #Do something useful with the reference.
    hwRef.displayMessage()
    simpleClient.getLogger().logInfo(
        "Method of dynamic component successfully invoked. Have a nice day!")
else:
    simpleClient.getLogger().logAlert("Bad reference retrieved from manager")
Beispiel #56
0
from Acspy.Util import ACSCorba
import CDB
import xml.dom.minidom
import datetime
import numpy as np

from Acspy.Clients.SimpleClient import PySimpleClient
client = PySimpleClient()
all_comp = client.availableComponents()
#
# DAL
#
dal = ACSCorba.cdb()
#
# WDAL
#
cdb_obj = ACSCorba.getClient().getService('CDB')
dal_ = cdb_obj._narrow(CDB.WDAL)

prof = {}
prof_wdal = {}
for comp in all_comp:
    print comp.name
    curl = "MACI/Components/"+comp.name
    #
    # DAO
    #
    t0 = datetime.datetime.utcnow()
    xmlstring = dal.get_DAO(curl)
    t1 = datetime.datetime.utcnow()
    delta = (t1 - t0)#.total_seconds()
Beispiel #57
0
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceNexstarImpl"
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.setUp()...")
Beispiel #58
0
from optparse import OptionParser
 
parser = OptionParser()
parser.add_option("-f", "--frequency", dest="skyFreq",
                       metavar='SkyFreq',
                       help="The desired sky frequency for the beacon")

(options, args) = parser.parse_args()
if options.skyFreq == None:
	print "You must specify a sky frequency use the \"-f\" option"
	sys.exit(-1)

options.skyFreq = float(options.skyFreq)

# Check with the Control Master to see what arrays are in existence
client = PySimpleClient()
master = client.getComponent("CONTROL/MASTER")

arrayList = master.getAutomaticArrayComponents() + \
            master.getManualArrayComponents()
client.releaseComponent("CONTROL/MASTER")

if len(arrayList) != 1:
    if len(arrayList) == 0:
        print "Error: No Arrays in existence, unable to set frequency"
    else:
        print "Error: Multiple arrays detected...are you sure your at the ATF"
    sys.exit


array = client.getComponent(arrayList[0].ComponentName)
Beispiel #59
0
class NexstarImplTestPy(unittest.TestCase):

	################################################
	# lifecycle
	################################################
	
	def setUp(self):
		self.simpleClient = PySimpleClient()
		self.componentName = "testInstanceNexstarImpl"
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.setUp()...")
        self.simpleClient.getLogger().logInfo("Get component " + self.componentName)
        self.component = self.simpleClient.getComponent(self.componentName)
	#__pPp__	    	           
	
	def tearDown(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.tearDown()...")
		self.simpleClient.getLogger().logInfo("Releasing component " + self.componentName)
		self.simpleClient.releaseComponent(self.componentName)
		self.simpleClient.disconnect()
	#__pPp__       
        
	################################################
	# test methods
	################################################
	
	def testImage(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.testImage()...")
		response = None
		exposure = double()
		response = self.component.image(exposure)
		# a return is expected, response should be not None
		assert response is not None
	#__pPp__
			    
	def testLock(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.testLock()...")
		response = None
		response = self.component.lock()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testUnlock(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.testUnlock()...")
		response = None
		response = self.component.unlock()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testOn(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.testOn()...")
		response = None
		response = self.component.on()
		# no return is expected, response should be None
		assert response is None
	#__pPp__
			    
	def testOff(self):
		self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.testOff()...")
		response = None
		response = self.component.off()
		# no return is expected, response should be None
		assert response is None