コード例 #1
0
    def __init__(self, options, logger):
        """Constructor for the INSintTester object.
        """

        # Invoke our base class constructor.
        INSintGUI.__init__(self)

        self.logger = logger
        self.insconfig = INSconfig()

        # Set up default connection parameters from command line
        self.obcpnum = options.obcpnum
        self.monunitnum = options.monunitnum
        if not options.obcphost:
            self.obcphost = SOSSrpc.get_myhost(short=True)
        else:
            self.obcphost = options.obcphost
        self.raidpath = options.fitsdir
        self.transfermethod = options.transfermethod
        self.username = options.username
        self.password = options.password

        self.ev_quit = threading.Event()
        self.ev_mainquit = threading.Event()
        self.soss = None

        # Did user specify a Gen2 status source?
        if options.statussvc:
            ro_status = ro.remoteObjectProxy(options.statussvc)
            statusObj = INSint.FetchStatusWrapper_Gen2(ro_status)

        # Did user specify a SOSS status source?
        elif options.statushost:
            from SOSS.status import cachedStatusObj

            statusDict = cachedStatusObj(options.statushost)
            statusObj = INSint.FetchStatusWrapper_SOSS(statusDict)

        # Did user specify a SOSS status file?
        elif options.statusfile:
            try:
                in_f = open(options.statusfile, 'r')
                statusDict = eval(in_f.read())
                in_f.close()

            except Exception, e:
                self.showStatus("Error reading status file '%s': %s" % \
                                (options.statusfile, str(e)))
                statusDict = {}

            statusObj = INSint.FetchStatusWrapper_SOSS(statusDict)
コード例 #2
0
    def setUp(self):
        self.env = environment.MockEnvironment()
        self.env.removeTestDirs()  # just in case
        self.env.makeDirs()
        mysqlarchiver._deleteMySQLArchiveDb()  # just in case
        (self.env.con,self.env.cur) = mysqlarchiver.initMySQLArchiveDb()
        self.framedb = archiver.SimFrameDBint(self.env)
        #import test_archiver
        #self.framedb = test_archiver.SimTestFrameDBint(self.env)
        self.iaq = 'SUKA'
        self.archmon = archiver.ArchiveMonitor(self.framedb,self.env)
        self.archivemgr = archiver.ArchiveMgr(self.framedb,self.archmon, self.env)
        self.framesrcSUKA = self.archivemgr.createFrameSourceA("SUK")
        self.basic = ['SIMPLE','BITPIX','NAXIS','EXTEND','PROP-ID',
                      'FRAMEID','RANDOM','OBCPMODE']
        self.basic.sort()
        self.archivemgr.registerKeywords(self.iaq,self.basic)
        import random
        #randokm.seed(0)  # force a random but repeatable sequence
        self.random = str(random.randrange(1000,1010))
        self.mode = "mode_"+str(random.randrange(0,10))

        self.obcpnum = 9
        self.ev_quit = threading.Event()
        # Timeout value for this task
        self.timeout = 20.0

        # Create monitor and other allocations
        self.monitor_name = 'monitor'
        self.monitor = Monitor.Minimon(self.monitor_name, logger=logger)
        
        myhost = SOSSrpc.get_myhost(short=True)
        statusDict = {}
        
        # Create and start the instrument interface
        self.insint = INSint.ocsInsInt(self.obcpnum, myhost, self.env.ARCH_PROP,
                                       statusDict, db=self.monitor,
                                       logger=logger, ev_quit=self.ev_quit)
        self.insint.start()

        # This is our set of allocations
        self.alloc = Bunch.Bunch(monitor=self.monitor,
                                 INSint9=self.insint,
                                 archmgr=self.archivemgr,
                                 status=None)

        # Create and start SIMCAM
        ocsint = DAQtk.ocsInt(self.obcpnum, logger=logger, ev_quit=self.ev_quit)
        simcam = SIMCAM.SIMCAM(logger, self.env, ev_quit=self.ev_quit)
        self.simcam = SIMCAM.OCSInterface(logger, ev_quit=self.ev_quit,
                                          ocsint=ocsint, instrument=simcam)
        self.simcam.start()

        # Create and start our task manager
        self.tm = TaskManager.TaskManager(logger=logger, internal_allocs=self.alloc)
        self.tm.setAllocs(['monitor', 'INSint9', 'archmgr'])
        self.tm.start()
コード例 #3
0
 def __init__(self):
     self.insconfig = INSconfig()
     self.obcpnum = 18
     self.obcphost = 'fmos02'
     self.ev_quit = threading.Event()
     self.ev_mainquit = threading.Event()
     self.soss = None
     self.logger = logging.getLogger('INSintTesterCLI')
     statusDict = {}
     self.statusObj = INSint.FetchStatusWrapper_SOSS(statusDict)
     self.cmdtag = 0
コード例 #4
0
 def send_cmd(self, cmdstr, wait=False, timeout=None):
     if not self.soss:
         raise INSint.INSintError("Servers not started!")
     # Bump the command tag
     self.cmdtag += 1
     tag = 'mon.INSint%d.%d' % (self.obcpnum, self.cmdtag)
     print("send: '%s'" % cmdstr)
     try:
         self.soss.send_cmd(tag, cmdstr)
         if wait:
             self.minimon.get_wait(tag, 'done', timeout=timeout)
     except Exception, e:
         print("ERROR: %s" % str(e))
コード例 #5
0
    def setUp(self):
        self.env = environment.MockEnvironment()
        self.env.removeTestDirs()  # just in case
        self.env.makeDirs()

        self.obcpnum = 9
        self.ev_quit = threading.Event()

        # Create mini monitor for INSint
        self.minimon = Monitor.Minimon('monitor', logger)

        myhost = SOSSrpc.get_myhost(short=True)

        raidpath = self.env.INST_PATH
        statusObj = INSint.FetchStatusWrapper_SOSS({})

        # Create and start the instrument interface
        self.insint = INSint.ocsInsInt(self.obcpnum,
                                       myhost,
                                       raidpath,
                                       statusObj,
                                       db=self.minimon,
                                       logger=logger,
                                       ev_quit=self.ev_quit)
        self.insint.start(wait=True)

        # Create and start SIMCAM
        ocsint = DAQtk.ocsInt(self.obcpnum,
                              logger=logger,
                              ev_quit=self.ev_quit)
        self.simcam = SIMCAM.Instrument(logger,
                                        ev_quit=self.ev_quit,
                                        ocsint=ocsint,
                                        allowNoPara=False,
                                        env=self.env)
        self.simcam.loadPersonality('SIMCAM')
        self.simcam.loadParaBuf(('SIMCAM', 'FITS_FILE'), fits_file_para)
        # Wait until SIMCAM is up and running
        self.simcam.start(wait=True)
コード例 #6
0
    def setup(self, widget):
        """Display and run the Setup dialog for configuring obcp info.
        """
        if self.mode == 'started':
            self.showStatus("PLEASE STOP SERVERS FIRST")
            return gtk.TRUE

        sw = self.widgets['setup_obcp']
        sw.window.show()
        resp = sw.run()
        sw.window.hide()

        if resp == gtk.RESPONSE_OK:
            # If not CANCEL, then refresh our core parameters from the dialog
            self.obcpnum = self.widgets['obcpnum'].get_value_as_int()
            self.username = self.widgets['username'].get_text()
            self.password = self.widgets['password'].get_text()
            self.obcphost = self.widgets['obcphost'].get_text()
            self.raidpath = self.widgets['raidarea'].get_text()
            self.transfermethod = get_combobox_text(
                self.widgets['transfermethod'])

            # If user specified a monitor, then create a mini-monitor and
            # sync ourselves to it
            channel_cmd = 'INSint%d' % self.obcpnum
            channel_file = 'frames'

            # Create a new instrument interface object, but don't start it
            self.soss = INSint.ocsInsInt(self.obcpnum,
                                         self.obcphost,
                                         self.raidpath,
                                         self.statusObj,
                                         ev_quit=self.ev_quit,
                                         interfaces=('cmd', 'thru', 'sreq',
                                                     'sdst', 'file'),
                                         monunitnum=self.monunitnum,
                                         transfermethod=self.transfermethod,
                                         username=self.username,
                                         db=None)

            # If user requested to link to an external monitor, do so.
            self.db = self.soss.get_monitor()
            if self.monitor:
                self.db.subscribe(self.monitor, [channel_cmd, channel_file],
                                  None)

            self.mode = 'stopped'
            self.showStatus("Servers configured.")

        return gtk.TRUE
コード例 #7
0
 def setup(self):
     self.minimon = Monitor.Minimon('mymon',
                                    self.logger,
                                    ev_quit=self.ev_quit)
     self.minimon.start(wait=True)
     tp = self.minimon.get_threadPool()
     self.soss = INSint.ocsInsInt(self.obcpnum,
                                  self.obcphost,
                                  '/tmp',
                                  self.statusObj,
                                  ev_quit=self.ev_quit,
                                  interfaces=('cmd', ),
                                  db=self.minimon,
                                  logger=self.logger,
                                  threadPool=tp)
     self.soss.start(wait=True)
コード例 #8
0
    def setUp(self):
        self.env = environment.MockEnvironment()
        self.env.removeTestDirs()  # just in case
        self.env.makeDirs()
        self.obcpnum = 9
        self.fmtstr = 'EXEC SIMCAM FITS_FILE MOTOR=%(motor)s FRAME_NO=%(frame_no)s DELAY=%(delay)f'
        self.ev_quit = threading.Event()

        # Create monitor and other allocations
        self.monitor_name = 'monitor'
        self.monitor = Monitor.Minimon(self.monitor_name, logger)
        
        myhost = SOSSrpc.get_myhost(short=True)
        statusDict = {}
        
        # Create and start the instrument interface
        self.insint = INSint.ocsInsInt(self.obcpnum, myhost, self.env.ARCH_PROP,
                                       statusDict, db=self.monitor,
                                       logger=logger, ev_quit=self.ev_quit)
        self.insint.start()

        # This is our set of allocations
        self.alloc = Bunch.Bunch(monitor=self.monitor,
                                 INSint9=self.insint,
                                 status=None)

        # Create and start SIMCAM
        ocsint = DAQtk.ocsInt(self.obcpnum, logger=logger, ev_quit=self.ev_quit)
        self.simcam = SIMCAM.Instrument(logger, ev_quit=self.ev_quit,
                                        ocsint=ocsint, allowNoPara=True,
                                        env=self.env)
        self.simcam.loadPersonality('SIMCAM')
        #self.simcam.loadParaBuf(fits_file_para)
        self.simcam.start()

        # Create and start our task manager
        self.tm = TaskManager.TaskManager(logger=logger, ev_quit=self.ev_quit,
                                          internal_allocs=self.alloc)
        self.tm.setAllocs(['monitor', 'INSint9'])
        self.tm.start()
コード例 #9
0
        elif options.statusfile:
            try:
                in_f = open(options.statusfile, 'r')
                statusDict = eval(in_f.read())
                in_f.close()

            except Exception, e:
                self.showStatus("Error reading status file '%s': %s" % \
                                (options.statusfile, str(e)))
                statusDict = {}

            statusObj = INSint.FetchStatusWrapper_SOSS(statusDict)

        else:
            statusDict = {}
            statusObj = INSint.FetchStatusWrapper_SOSS(statusDict)

        self.statusObj = statusObj
        self.mode = None
        self.cmdtag = 0
        self.cmdqueue = Queue.Queue()
        self.monitor = options.monitor

        # Set defaults for setup dialog
        sw = self.widgets['transfermethod']
        sw.set_active(1)
        #current default for this widget is 9, but it would be nice to set it here
        #self.widgets['obcpnum'].set_value_as_int(self.obcpnum)
        self.widgets['username'].set_text(self.username)
        self.widgets['password'].set_text(self.password)
        self.widgets['obcphost'].set_text(self.obcphost)