def processMessage(self, string): command = immp.parse(string) if command.name() == 'scheduler_status': self.factory.object.status = command.kwargs if command.name() == 'scheduler_pointing_suggestion': self.factory.object.suggestion = command.kwargs
def processMessage(self, string): command = immp.parse(string) if command.name() == 'current_frame': self.is_binary = True self.binary_length = int(command.kwargs.get('length', 0)) self.image_format = command.kwargs.get('format', '') elif command.name() == 'channel_status': self.factory.object.channel_status = command.kwargs
def processMessage(self, string): command = immp.parse(string) if command.name() == 'beholder_status': self.factory.object.status = command.kwargs nchannels = int(command.kwargs.get('nchannels', 0)) nmounts = int(command.kwargs.get('nmounts', 0)) if nchannels != self.factory.object.nchannels: self.factory.object.nchannels = nchannels self.factory.object.current_frames = {} for i in xrange(nchannels): self.factory.object.current_frames[i + 1] = "" self.factory.object.nmounts = nmounts elif command.name() == 'current_frame': self.is_binary = True self.binary_length = int(command.kwargs.get('length', 0)) self.factory.object.current_id = int(command.kwargs.get('id', 0)) elif command.name() == 'get_current_frame_error': self.factory.object.current_frames[int(command.kwargs.get('id', 0))] = ''
def processMessage(self, string): scheduler = self.factory.object command = immp.parse(string) # exit if command.name() == 'exit': reactor.stop() # get_scheduler_status if command.name() == 'get_scheduler_status': if (datetime.datetime.utcnow() - scheduler.fast_update_time).total_seconds() > 3.0: scheduler.update(fast=True) status = 'scheduler_status ' status += ' zsun=%g' % (90.0 - np.rad2deg(scheduler.favor2.sun.alt)) status += ' zmoon=%g' % (90.0 - np.rad2deg(scheduler.favor2.moon.alt)) status += ' latitude=%g longitude=%g' % (np.rad2deg( scheduler.favor2.obs.lat), np.rad2deg( scheduler.favor2.obs.lon)) status += ' ninterests=%d' % len(scheduler.interests) status += ' modes=%s' % ','.join(scheduler.modes) for i, interest in enumerate(scheduler.interests.values()): status += ' interest%d_name=%s interest%d_ra=%g interest%d_dec=%g interest%d_radius=%g interest%d_weight=%g' % ( i, interest['name'], i, interest['ra'], i, interest['dec'], i, interest['radius'], i, interest['weight']) self.message(status) # get_pointing_suggestion if command.name() == 'get_pointing_suggestion': result = 'scheduler_pointing_suggestion' scheduler.update() suggestion = scheduler.getPointingSuggestion() result += ' ' + ' '.join( ['%s=%s' % (k, suggestion[k]) for k in suggestion.keys()]) #print result self.message(result) # add_interest if command.name() == 'add_interest' or command.name( ) == 'set_interest': scheduler.addInterest(command.get('name', 'Unknown'), command.get('ra', 0.0), command.get('dec', 0.0), radius=command.get('radius', command.get('r', 5.0)), weight=command.get('weight', 1.0), reschedule=command.get('reschedule', False), alt=command.get('alt', None), az=command.get('az', None)) self.message(command.name() + '_done') # delete_interest if command.name() == 'delete_interest': scheduler.deleteInterest(command.get('name', 'Unknown')) self.message(command.name() + '_done') # target_complete, target_observed if command.name() == 'target_complete' or command.name( ) == 'target_observed': scheduler.targetComplete(id=command.get('id', 0), uuid=command.get('uuid', None)) self.message(command.name() + '_done') try: reportTargetObserved(id=command.get('id', 0), favor2=scheduler.favor2) except: import traceback traceback.print_exc() pass # reschedule if command.name() == 'reschedule': scheduler.update() suggestion = scheduler.getPointingSuggestion() if suggestion['priority'] > 1.0: message = 'reschedule priority=%g' % suggestion['priority'] if suggestion['type'] == 'Swift' or ( suggestion['type'] == 'Fermi' and suggestion['filter'] == 'Pol'): # External trigger with sufficiently accurate coordinates, # suitable for occasional in-FOV follow-up message += ' ra=%g dec=%g id=%d uuid=%s' % ( suggestion['ra'], suggestion['dec'], suggestion['id'], suggestion['uuid']) # We have high-priority target observable, let's inform everyone! self.factory.message(message) # add_coverage if command.name() == 'add_coverage': scheduler.addCoverage(ra=float(command.get('ra0', 0)), dec=float(command.get('dec0', 0)), sr=0.5 * (float(command.get('size_ra', 0)) + float(command.get('size_dec', 0))), store=False) #scheduler.latest_time = datetime.datetime.utcnow() self.message(command.name() + '_done') if command.name() == 'add_mode': scheduler.modes.add(command.get('mode')) self.message(command.name() + '_done') if command.name() == 'remove_mode' or command.name() == 'delete_mode': if command.get('mode') in scheduler.modes: scheduler.modes.remove(command.get('mode')) self.message(command.name() + '_done')
def processMessage(self, string): command = immp.parse(string) if command.name() == 'beholder_status': self.factory.object.status = command.kwargs self.factory.object.operate()
def processMessage(self, string): command = immp.parse(string) if command.name() == 'mount_status': self.factory.object.status = command.kwargs