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_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())
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 __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
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)
def setUp(self): self._my_acs_client = PySimpleClient() logger = self._my_acs_client.getLogger() logger.setLevel(logging.WARNING)
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 setUp(self): self.simpleClient = PySimpleClient() self.componentName = "testInstanceStopWatchLightImpl" self.simpleClient.getLogger().logInfo("pyUnitTestStopWatchLightImpl.StopWatchLightImplTestPy.setUp()...")
"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()
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
def __init__(self, site_type): self.log = HMILog(title=__name__) self.log.info([['y', " - TmpTest - "], ['g', site_type]]) self.site_type = site_type self.tel_ids = tel_ids[site_type] self.redis = redis.StrictRedis(host='localhost', port=redis_port[site_type], db=0) self.redPipe = self.redis.pipeline() self.loop_sleep = 4 # rnd_seed = 10987268332 rnd_seed = getTime() self.rnd_gen = Random(rnd_seed) # Create a client and the ArraySupervisor component client = PySimpleClient() supervisor = client.getComponent("ArraySupervisor") config = sb.Configuration( sb.InstrumentConfiguration(sb.PointingMode(2, sb._divergent(2)), sb.Subarray([], [])), "camera", "rta") coords = sb.Coordinates(3, sb.GalacticCoordinates(10, 10)) observing_mode = sb.ObservingMode( sb.Slewing(1), sb.ObservingType(2, sb.GridSurvey(1, 1, 1))) src = sb.Source("source", sb.placeholder, sb.High, sb.RegionOfInterest(100), observing_mode, coords) obs = sb.ObservingConditions(sb.DateTime(1), 60, 1, sb.Quality(1, 1, 1), sb.Weather(1, 1, 1, 1)) ob = sb.ObservationBlock("ob", src, obs, "guiACS_sched_blocks_script0", 0) # ob.observing_conditions.duration = 20 print 'xxxxxxxx', obs, '------', ob.observing_conditions.duration schedulingBlock = sb.SchedulingBlock("sb", sb.Proposal("id"), config, [ob]) # Submit the scheduling block to the array supervisor print "Submit the scheduling block to the array supervisor" comp = supervisor.putSchedulingBlock(schedulingBlock) # Print the command execution completion print comp print "" # Retrieve the ids of all scheduling blocks currently running on the array supervisor print "" print "Retrieve the ids of all scheduling blocks currently running on the array supervisor" active = supervisor.listSchedulingBlocks() while True: active = supervisor.listSchedulingBlocks() for block_name in active: status = supervisor.getSchedulingBlockStatus(block_name) opstatus = supervisor.getSbOperationStatus(block_name) phases = opstatus.ob_statuses[0].phases for p in phases: print 'xxx', block_name, p self.log.info([['y', " - active_scheduling_blocks - "], ['g', active, '-> '], ['y', status, ' '], ['p', opstatus]]) if len(active) == 0: break sleep(.5) # # Read the status of the scheduling block with the id "sb" # print "Read the status of the scheduling block with the id 'sb'" # status = supervisor.getSchedulingBlockStatus("sb") # print status # print "" # # Read the operation status of the scheduling block with the id "sb" # print "Read the operation status of the scheduling block with the id 'sb'" # opstatus = supervisor.getSbOperationStatus("sb") # print opstatus # print "" # active_scheduling_blocks = supervisor.listSchedulingBlocks() # print active_scheduling_blocks # zz = jsonAcs.classFactory.defaultValues[sb.SchedulingBlock] # print zz # print '--------------------------------' # for block in zz.observation_blocks: # block.observing_conditions.duration = 30 # .observing_conditions # print zz.observation_blocks # zz = jsonAcs.encode(zz) # sb3 = jsonAcs.decode(zz) # sb3.id = 'sb3' # supervisor.putSchedulingBlock(sb3) # active_scheduling_blocks = supervisor.listSchedulingBlocks() # self.log.info([['y', " - active_scheduling_blocks - "], # ['g', active_scheduling_blocks]]) # while len(active_scheduling_blocks) > 0: # self.log.info([['y', " - active_scheduling_blocks - "], # ['g', active_scheduling_blocks]]) # sleep(.5) # active_scheduling_blocks = supervisor.listSchedulingBlocks() # print 'ended!', active_scheduling_blocks # # self.init() # # gevent.spawn(self.loop) return
def __init__(self, site_type): self.log = my_log(title=__name__) self.log.info([['y', " - MockSched - "], ['g', site_type]]) self.site_type = site_type self.tel_ids = tel_ids[site_type] self.debug = False self.expire = 86400 # one day self.cycle_blocks = [] self.acs_blocks = dict() self.acs_blocks['sched_block'] = dict() self.acs_blocks['metadata'] = dict() self.active_sched_block = 0 self.client = PySimpleClient() self.supervisor = self.client.getComponent("ArraySupervisor") # print 'got ArraySupervisor ............' self.n_sched_block = [5, 15] self.max_n_obs_block = 7 if self.site_type == "N" else 32 self.max_n_obs_block = min(self.max_n_obs_block, len(self.tel_ids)) # self.max_n_obs_block = len(self.tel_ids) self.loop_sleep = 4 self.az_min_max = [0, 360] self.zen_min_max_tel = [0, 70] self.zen_min_max_pnt = [0, 20] rnd_seed = getTime() rnd_seed = 10987268332 self.rnd_gen = Random(rnd_seed) print 'xxxxxxxxxxx' active = self.supervisor.listSchedulingBlocks() print '-----', active self.cancel_sched_blocks(active[0]) print 'sleep...' sleep(10) print 'check...' print '---', len( self.supervisor.getSbOperationStatus(active[0]).ob_statuses ), '------------', self.supervisor.getSbOperationStatus(active[0]).ob_statuses print '---', self.supervisor.getSbOperationStatus(active[0] ).ob_statuses[-1].status activeNow = self.supervisor.listSchedulingBlocks() print 'active now ....', activeNow # self.threads = [] # run_event = threading.Event() # run_event.set() # t = threading.Thread(target=self.loop, args = (run_event,)) # t.start() # self.threads.append(t) # try: # while 1: # sleep(.1) # except KeyboardInterrupt: # run_event.clear() # for t in self.threads: # t.join() return
def setUp(self): self.simpleClient = PySimpleClient() self.componentName = "testInstanceBasicAntennaJavaImpl" self.simpleClient.getLogger().logInfo("pyUnitTestBasicAntennaJavaImpl.BasicAntennaJavaImplTestPy.setUp()...")
def setUp(self): self.simpleClient = PySimpleClient() self.componentName = "testInstanceEventSubscriberImpl" self.simpleClient.getLogger().logInfo("pyUnitTestEventSubscriberImpl.EventSubscriberImplTestPy.setUp()...")
def setUp(self): self.simpleClient = PySimpleClient() self.componentName = "testInstanceTRDJavaImp" self.simpleClient.getLogger().logInfo("pyUnitTestTRDJavaImp.TRDJavaImpTestPy.setUp()...")
def setUp(self): self.simpleClient = PySimpleClient() self.componentName = "testInstanceNexstarImpl" self.simpleClient.getLogger().logInfo("pyUnitTestNexstarImpl.NexstarImplTestPy.setUp()...")
# MA 02111-1307 USA # # @(#) $Id: acsncTestConSup.py,v 1.6 2006/03/08 17:50:44 dfugate Exp $ """ """ from Acspy.Common.Log import getLogger from Acspy.Clients.SimpleClient import PySimpleClient from sys import argv from time import sleep import threading num_test = int(argv[1]) # Make an instance of the PySimpleClient simpleClient = PySimpleClient() # Get logger logger = getLogger() # Autoreconnect ON, Notify Service restarted def test1(): name = "NamedCh_SUP1" name_con = "NamedCh_CON1" consumer = simpleClient.getComponent(name_con) supplier = simpleClient.getComponent(name) logger.logAlert("Calling supplier.testReconn1(True,True)") supplier.testReconn1(True, True) logger.logAlert("Waiting 20 seconds ...") sleep(20)
#!/usr/bin/env python from Acspy.Clients.SimpleClient import PySimpleClient from Acspy.Common.Err import ACSError from Acspy.Common import TimeHelper from Acspy.Nc.Supplier import Supplier from time import sleep, time import bulkdata c = PySimpleClient() supplier = Supplier(bulkdata.CHANNELNAME_ERR_PROP) #print bulkdata.BAD_SENDER #print bulkdata.BAD_RECEIVER #print bulkdata.OK print "I will send events ..." flow = "00" for x in range(0, 10000): timestamp = TimeHelper.TimeUtil().epoch2py(TimeHelper.getTimeStamp()) h = bulkdata.errorStatusBlock(flow, bulkdata.BAD_RECEIVER, timestamp) # if x % 2 == 0: # h.status = bulkdata.OK supplier.publishEvent(h) sleep(0.1) print(x, h) supplier.disconnect()