def __init__(self, directory=None, filename=None, timestamp=None, image_info=None, cached_conversions=None, id=None, path=None, file_required=False): self.id = random_id(id) if directory and filename: self.directory = directory self.filename = filename elif path: self.directory, self.filename = os.path.split(path) else: raise RuntimeError( 'Constructed image without file/directory nor path') if file_required and not os.path.isfile(self.path): raise RuntimeError('File {} not found'.format(self.path)) self.timestamp = timestamp if timestamp else time.time() self.image_info = image_info if not image_info and os.path.isfile(self.path): with fits.open(self.path) as hdulist: shape = hdulist[0].shape self.image_info = { 'width': shape[1], 'height': shape[0], 'size': os.stat(self.path).st_size } self.cached_conversions = {} if cached_conversions: self.cached_conversions.update(cached_conversions)
def __init__(self, name, upload_path, camera, filter_wheel=None, id=None, sequence_jobs=None, status=None): self.name = name self.upload_path = upload_path self.camera = camera self.filter_wheel = filter_wheel self.id = random_id(id) self.sequence_jobs = sequence_jobs if sequence_jobs else [] self.status = status if status else 'idle' self.running_sequence_job = None self.stopped = False
def shoot_image(self, options): # TODO: not great.. from system import controller id = random_id(None) if self.__has_dev_fits(): return self.__dev_fits(options, id) exposure = options['exposure'] filename = os.path.join(self.settings.camera_tempdir, '{}.fits'.format(id)) try: self.camera.set_upload_to('client') if 'roi' in options and options['roi']: self.camera.set_roi({ 'X': options['roi']['x'], 'Y': options['roi']['y'], 'WIDTH': int(options['roi']['width'] / 8) * 8, 'HEIGHT': int(options['roi']['height'] / 2) * 2, }) else: self.camera.clear_roi() current_binning = None if 'binning' in options: current_binning = self.camera.binning() self.camera.set_binning(options['binning']) self.camera.set_upload_path(self.settings.camera_tempdir, prefix=id) self.logger.info('Camera.shoot: id={}, parameters: {}'.format( id, options)) with controller.indi_server.blob_client.listener( self.camera) as blob_listener: self.camera.shoot(exposure) blob_listener.get().save(filename) self.camera.clear_roi() if current_binning: self.camera.set_binning(current_binning.get('value', 1)) except RuntimeError as e: raise FailedMethodError(str(e)) except BLOBError as e: raise FailedMethodError(str(e)) image = self.__new_image_to_list(filename, id) return image.to_map(for_saving=False)
def __init__(self, obj, readonly=False): self.id = random_id(obj.get('id')) self.name = obj['name'] self.category = obj.get('category', 'Misc') self.arguments = obj.get('arguments', []) self.readonly = readonly self.ui_properties = obj.get('ui_properties', None) self.confirmation_message = obj.get('confirmation_message', None) self.request_parameters = self.__build_request_parameters( obj.get('request_parameters', None)) self._check = obj.get('check', None) logger.info('Command parsed: %s', self.name)
def __init__(self, data): self.id = random_id(data.get('id')) self.type = data['type'] data.update({'id': self.id}) self.job = None if self.type == 'shots': self.job = ExposureSequenceJob(data) elif self.type == 'filter': self.job = FilterWheelSequenceJob(data) elif self.type == 'property': self.job = PropertySequenceJob(data) elif self.type == 'command': self.job = CommandSequenceJob(data) elif self.type == 'pause': self.job = PauseSequenceJob(data) else: raise BadRequestError('Invalid sequence job type: {}'.format( self.type)) self.status = data.get('status', 'idle') self.started_ts, self.finished_ts = None, None self.stopped = False
def __init__(self, id=None, name='', drivers=[]): self.name = name self.drivers = drivers self.id = random_id(id)
def import_from_data(data): data['id'] = random_id() for job in data['sequenceJobs']: job['id'] = random_id() return Sequence.from_map(data)