def setupChimera (self): try: self.sysconfig = SystemConfig.fromFile(SYSTEM_CONFIG_DEFAULT_FILENAME) except IOError, e: logging.exception(e) logging.error("There was a problem reading your configuration file. (%s)" % e) return False
def startup(self): if self.options.daemon: # detach log.info("FIXME: Daemon...") # system config self.config = SystemConfig.fromFile(self.options.config_file, self.options.use_global) # manager if not self.options.dry: log.info("Starting system.") log.info("Chimera version: %s" % find_dev_version() or _chimera_version_) log.info("Chimera prefix: %s" % ChimeraPath.root()) try: self.manager = Manager(**self.config.chimera) except ChimeraException, e: log.error( "Chimera is already running on this machine. Use chimera-admin to manage it." ) sys.exit(1) log.info("Chimera: running on " + self.manager.getHostname() + ":" + str(self.manager.getPort())) if self.options.use_global: log.info("Chimera: reading configuration from %s" % SYSTEM_CONFIG_DEFAULT_GLOBAL) log.info("Chimera: reading configuration from %s" % os.path.realpath(self.options.config_file))
def __start__(self): self.sysconfig = SystemConfig.fromFile(self['chimera_config']) self.localManager = Manager(self.sysconfig.chimera["host"], 9090) self.offsets = dict( zip(self["focus_filters"].split(), [int(x) for x in self["focus_difference"].split()])) @callback(self.localManager) def filterChange(newFilter, oldFilter): self.log.debug("Moved from %s to %s" % (oldFilter, newFilter)) diff = self.offsets[newFilter] - self.offsets[oldFilter] if diff < 0: diff = int(ceil(abs(diff))) self.log.debug("Moving focuser %i steps IN due filter change" % diff) self.focuser.moveIn(diff) elif diff > 0: diff = int(ceil(abs(diff))) self.log.debug( "Moving focuser %i steps OUT due filter change" % diff) self.focuser.moveOut(diff) self.filterwheel = self.getManager().getProxy(self["filterwheel"]) self.filterwheel.filterChange += filterChange self.focuser = self.getManager().getProxy(self["focuser"])
def _startSystem (self, options): try: self.sysconfig = SystemConfig.fromFile(options.config) self.localManager = Manager(self.sysconfig.chimera["host"], getattr(options, 'port', 9000)) self._remoteManager = ManagerLocator.locate(self.sysconfig.chimera["host"], self.sysconfig.chimera["port"]) except ManagerNotFoundException: # FIXME: better way to start Chimera site = SiteController(wait=False) site.startup() self._keepRemoteManager = False self._remoteManager = ManagerLocator.locate(self.sysconfig.chimera["host"], self.sysconfig.chimera["port"])
def startup(self): if self.options.daemon: # detach log.info("FIXME: Daemon...") # system config try: self.config = SystemConfig.fromFile(self.options.config_file) except (InvalidLocationException, IOError), e: log.exception(e) log.error("There was a problem reading your configuration file. (%s)" % e) sys.exit(1)
def startup(self): if self.options.daemon: # detach log.info("FIXME: Daemon...") # system config try: self.config = SystemConfig.fromFile(self.options.config_file) except (InvalidLocationException, IOError), e: log.exception(e) log.error( "There was a problem reading your configuration file. (%s)" % e) sys.exit(1)
def setJD(self,options): ''' Configure time domain by specifing a julian day. It will use information on exposure time to build time bins that will be filled when selecting targets. ''' sysconfig = SystemConfig.fromFile(options.config) manager = Manager() site = manager.getProxy(sysconfig.sites[0]) jd = options.JD if not jd: jd = np.floor(site.JD())+0.5 lat = np.array([float(tt) / 60.**i for i,tt in enumerate(str(site['latitude']).split(':'))]) lat[1:] *= lat[0]/np.abs(lat[0]) sitelat = np.sum(lat) long = np.array([float(tt) / 60.**i for i,tt in enumerate(str(site['longitude']).split(':'))]) long[1:] *= long[0]/np.abs(long[0]) sitelong = abs(np.sum(long)/360*24.) print site['latitude'],'->',sitelat print site['longitude'],'->',sitelong nightstart = _skysub.jd_sun_alt(self.sunMaxAlt, jd, sitelat, sitelong) nightend = _skysub.jd_sun_alt(self.sunMaxAlt, jd+0.5, sitelat, sitelong) print('Nigh Start @JD= %.3f # Night End @JD = %.3f'%(nightstart,nightend)) # Creating a 1 minute time bin tbin = self.tbin self.obsTimeBins = np.arange(nightstart,nightend+tbin,tbin) self.obsTimeMask = np.zeros(len(self.obsTimeBins)) self.obsTimeMask[-1] = 1.0 # Marking filled bins session = Session() scheduled = session.query(Program) for target in scheduled: tindex = np.abs(self.obsTimeBins - 2400000.5 - target.slewAt).argmin() self.obsTimeMask[tindex] = 1.0 self.isJD = True
def _startSystem(self, options): try: self.sysconfig = SystemConfig.fromFile(options.config) self.localManager = Manager(self.sysconfig.chimera["host"], getattr(options, 'port', 9000)) self._remoteManager = ManagerLocator.locate( self.sysconfig.chimera["host"], self.sysconfig.chimera["port"]) except ManagerNotFoundException: # FIXME: better way to start Chimera site = SiteController(wait=False) site.startup() self._keepRemoteManager = False self._remoteManager = ManagerLocator.locate( self.sysconfig.chimera["host"], self.sysconfig.chimera["port"])
def startup(self): if self.options.daemon: # detach log.info("FIXME: Daemon...") # system config try: self.config = SystemConfig.fromFile(self.options.config_file) except (InvalidLocationException, IOError) as e: log.exception(e) log.error( "There was a problem reading your configuration file. (%s)" % e) sys.exit(1) # manager if not self.options.dry: log.info("Starting system.") log.info("Chimera: %s" % _chimera_version_) log.info("Chimera prefix: %s" % ChimeraPath().root()) log.info("Python: %s" % platform.python_version()) log.info("System: %s" % ' '.join(platform.uname())) try: self.manager = Manager(**self.config.chimera) except ChimeraException as e: log.error( "Chimera is already running on this machine. Use chimera-admin to manage it." ) sys.exit(1) log.info("Chimera: running on " + self.manager.getHostname() + ":" + str(self.manager.getPort())) log.info("Chimera: reading configuration from %s" % os.path.realpath(self.options.config_file)) # add site object if not self.options.dry: for site in self.config.sites: self.manager.addClass(Site, site.name, site.config, True) # search paths log.info( "Setting objects include path from command line parameters...") for _dir in self.options.inst_dir: self.paths["instruments"].append(_dir) for _dir in self.options.ctrl_dir: self.paths["controllers"].append(_dir) # init from config log.info("Trying to start instruments...") for inst in self.config.instruments + self.options.instruments: if self.options.dry: print(inst) else: self._add(inst, path=self.paths["instruments"], start=True) log.info("Trying to start controllers...") for ctrl in self.config.controllers + self.options.controllers: if self.options.dry: print(ctrl) else: self._add(ctrl, path=self.paths["controllers"], start=True) log.info("System up and running.") # ok, let's wait manager work if self.wait and not self.options.dry: self.manager.wait()