Example #1
0
    def STARSint_hdlr(self, frameid, vals):
        """Called with information provided by the STARS interface."""

        # TODO: integgui shouldn't have to understand this level of
        # the stars protocol
        if Monitor.has_keys(vals, ['done', 'time_done']):
            if Monitor.has_keys(vals, ['errorclass', 'msg']):
                # --> there was an error in the STARS interface
                self.in_stars(frameid, 'E')
            elif (Monitor.has_keys(
                    vals, ['end_result', 'end_status1', 'end_status2'])
                  and (vals['end_result'] == 0) and (vals['end_status1'] == 0)
                  and (vals['end_status2'] == 0)):
                # --> STARS may have the file
                self.in_stars(frameid, 'T')
Example #2
0
    def __init__(self,
                 logger,
                 monitor,
                 debug,
                 dummyval,
                 usethread,
                 ev_quit=None):

        self.logger = logger
        self.debug = debug  # do dubug or not
        self.monitor = monitor  # do monitoring
        self.dummyval = dummyval  # use dummy fits values
        self.usethread = usethread  # use thread

        self.timeout = 0.2  # Q timeout

        self.cmd_end = "END"

        self.aliasVal = guiderfitsheader.getAlias()  # status alias values
        self.keyVal = guiderfitsheader.getKeyVal()

        # fits header template
        self.guiderFitsHeader = guiderfitsheader.guider_fits_header

        # set thread event
        if not ev_quit: self.ev_quit = threading.Event()
        else: self.ev_quit = ev_quit

        # monitor instance
        if self.monitor:
            self.db = Monitor.Minimon('GuiderInt.mon', self.logger)
            self.db.subscribe(self.monitor, ['GuiderInt'], None)

        if not self.dummyval:
            self.svc = ro.remoteObjectProxy('status')
Example #3
0
    def INSint_hdlr(self, frameid, vals):
        """Called with information provided by the instrument interface."""

        if Monitor.has_keys(vals, ['done', 'time_done', 'status', 'filepath']):
            self.transfer_done(frameid, vals['status'])

        elif vals.has_key('time_start'):
            self.transfer_started(frameid)
    def data_arr(self, payload, name, channels):
        try:
            self.logger.debug("received values '%s'" % str(payload))
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError, e:
            self.logger.error("data receive error: %s" % str(e))
            return
Example #5
0
def main(options, args):

    logger = ssdlog.make_logger('test', options)

    ro.init()

    ev_quit = threading.Event()
    queue = Queue.Queue()

    # make a name for our monitor
    myMonName = options.name

    # monitor channels we are interested in
    channels = options.channels.split(',')

    # Create a local monitor
    mymon = Monitor.Monitor(myMonName, logger, numthreads=20)

    # Make our callback functions
    m = Make_cb(logger=logger,
                monitor=mymon,
                queue=queue,
                monpath=options.monpath,
                watch_execs=options.watch_execs,
                history=options.history)

    # Subscribe our callback functions to the local monitor
    mymon.subscribe_cb(m.anon_arr, channels)

    server_started = False
    try:
        # Startup monitor threadpool
        mymon.start(wait=True)
        # start_server is necessary if we are subscribing, but not if only
        # publishing
        mymon.start_server(wait=True, port=options.port)
        server_started = True

        # subscribe our monitor to the central monitor hub
        mymon.subscribe_remote(options.monitor, channels, ())

        while not ev_quit.isSet():
            try:
                (path, tree, time) = queue.get(block=True, timeout=1.0)

                printTree(path, tree, time)

            except Queue.Empty:
                continue

            except KeyboardInterrupt:
                logger.error("Received keyboard interrupt!")
                ev_quit.set()

    finally:
        if server_started:
            mymon.stop_server(wait=True)
        mymon.stop(wait=True)
    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()
def main(options, args):
    logger = ssdlog.make_logger('test', options)

    print "mode<%s>" % (options.mode)

    if not options.mode == 'test':

        ro.init()
        # make a name for our monitor

        #myMonName = ('testmon-%d' % os.getpid())
        myMonName = ('testmon')
        # monitor channels we are interested in
        channels = options.channels.split(',')

        # Create a local monitor
        mymon = Monitor.Monitor(myMonName, logger, numthreads=4)

        # Startup monitor threadpool
        mymon.start(wait=True)
        # start_server is necessary if we are subscribing, but not if only
        # publishing
        mymon.start_server(port=options.port, wait=True)
        #mymon.start_server(wait=True)

        # Make our callback functions
        m = Make_cb(logger=logger, monitor=mymon)

        # Subscribe our callback functions to the local monitor
        mymon.subscribe_cb(m.anon_arr, channels)

        try:
            # subscribe our monitor to the central monitor hub
            #monitor = ro.remoteObjectProxy(options.monitor)
            mymon.subscribe_remote(options.monitor, channels, ())
        except:
            logger.error("subscribe to the central monitor faild")

    else:
        feed_test_data()
        mymon = None

    try:

        gtk.gdk.threads_init()
        task_view = TreeView(logger)
        task_view.start_updating()
        gtk.main()
        stop_service(task_view, mymon=mymon)
        print 'GUI END'

    except KeyboardInterrupt:
        #gtk.main_quit()
        stop_service(task_view, mymon=mymon)
Example #8
0
def main(options, args):

    ro_hosts = options.gen2host.split(',')
    ro.init(ro_hosts)

    svcname = options.svcname
    monname = svcname + '.mon'
    
    # create a real logger if you want logging
    logger = ssdlog.make_logger(svcname, options)

    ev_quit = threading.Event()
    
    # Create a local subscribe object
    myhost = ro.get_myhost(short=True)
    mymon = Monitor.Monitor(monname, logger)

    channels = options.channels.split(',')
    relay = StatusRelay(logger, options.statsvc, options.monitor,
                        mymon, channels)

    # Startup monitor
    mymon.start(wait=True)
    monport = options.monport
    if not monport:
        monport = options.port + 1
    mymon.start_server(wait=True, port=monport)
    threadPool = mymon.get_threadPool()

    svc = ro.remoteObjectServer(svcname=options.svcname,
                                obj=relay, logger=logger,
                                port=options.port,
                                default_auth=None,
                                ev_quit=ev_quit,
                                usethread=False,
                                threadPool=threadPool)
    try:
        relay.update_statusProxy()
        relay.update_monitorFeed()
    
        try:
            print "Press ^C to terminate the server."
            svc.ro_start(wait=True)
            svr_started = True

        except KeyboardInterrupt:
            logger.error("Caught keyboard interrupt!")
            ev_quit.set()
            
    finally:
        logger.info("Shutting down...")
        mymon.unsubscribe_remote('monitor', channels, {})
        mymon.stop_server()
        mymon.stop()
def main(options, args):
    logger = ssdlog.make_logger('test', options)

    if options.mode == 'test':
        print 'test mode'
        feed_test_data()
        mymon = None

    else:

        ro.init()
        # make a name for our monitor

        #myMonName = ('testmon-%d' % os.getpid())
        myMonName = ('testmon')
        # monitor channels we are interested in
        channels = options.channels.split(',')

        # Create a local monitor
        mymon = Monitor.Monitor(myMonName, logger, numthreads=4)

        # Startup monitor threadpool
        mymon.start(wait=True)
        # start_server is necessary if we are subscribing, but not if only
        # publishing
        mymon.start_server(wait=True)

        # Make our callback functions
        m = Make_cb(logger=logger, monitor=mymon)

        # Subscribe our callback functions to the local monitor
        mymon.subscribe_cb(m.anon_arr, channels)

        try:
            # subscribe our monitor to the central monitor hub
            monitor = ro.remoteObjectProxy(options.monitor)
            monitor.subscribe(myMonName, channels, ())
        except:
            logger.error("subscribe to the central monitor faild")

    try:

        app = QtGui.QApplication(sys.argv)
        tv = TreeView()
        tv.start_updating()
        tv.show()
        sys.exit(app.exec_())
        stop_service(tv, mymon=mymon)
        print 'GUI END'

    except KeyboardInterrupt:
        print 'Keyboard'
        #gtk.main_quit()
        stop_service(tv, mymon=mymon)
Example #10
0
    def arr_sessinfo(self, payload, name, channels):
        self.logger.debug("received values '%s'" % str(payload))

        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" % (
                str(payload), str(e)))
            return

        if bnch.path == ('mon.session.%s' % self.sessionName):
            
            info = bnch.value
Example #11
0
    def status_cb(self, payload, name, channels):
        try:
            bnch = Monitor.unpack_payload(payload)
            if bnch.path != 'mon.status':
                return

            with self.lock:
                ## print "status updated: %s" % (time.strftime("%H:%M:%S",
                ##                                             time.localtime()))
                self.statusDict.update(bnch.value)
            self.logger.debug("Status updated: %s" % str(bnch.value))

        except Monitor.MonitorError, e:
            print "monitor error: %s" % (str(e))
Example #12
0
def status_cb(payload, logger, statusProxy):
    global statusFromGen2, lock
    try:
        bnch = Monitor.unpack_payload(payload)
        if bnch.path != 'mon.status':
            return

        with lock:
            logger.debug('status updated: %s' %
                         (time.strftime("%H:%M:%S", time.localtime())))
            statusFromGen2.update(bnch.value)

    except Monitor.MonitorError, e:
        logger.error('monitor error: %s' % (str(e)))
    def setUp(self):
        import rpc
        
        self.ev_quit = threading.Event()

        # Create monitor and other allocations
        self.monitor = Monitor.Minimon(TestTCSCmds.monitorName, logger)

#
#        commandManager = CommandManager.CommandManager(None)
#        commandSender  = CommandManager.CommandSender(commandManager=commandManager,
#                                            timeout=0.1,
#                                            host='localhost',
#                                            prog=0x20000011,
#                                            uid=CommandManager.TCS_UID,
#                                            gid=CommandManager.TCS_GID )
#        #humm...
#        commandManager.commandQueue = commandSender.commandQueue
#        commandReceiver = CommandManager.ReplyReceiver(host="",
#                                            prog=0x20000012,
#                                            vers=1,
#                                            port=0,
#                                            commandManager=commandManager)

        commandManager  = TCSintTestCase.MockCommandManager()
        commandManager.mockResult = True
        commandSender   = TCSintTestCase.MockTCSClient()
        commandReceiver = TCSintTestCase.MockReplyReceiver(rpc.Packer(), 
                                                           rpc.Unpacker('\x00\x00\x00=CEOBS%TSC%00002006020719514370028000005930020000000COMPLETE%%\x00\x00\x00'), 
                                                           commandManager)
        ddSequenceGenerator = TCSint.FakeSequenceGenerator()
        
        self.tCSint   = TCSint.TCSint(self.monitor,
                                      commandManager, 
                                      commandSender, 
                                      commandReceiver, 
                                      ddSequenceGenerator)

        self.tCSint.start()

        self.alloc = Bunch.Bunch(monitor=self.monitor,
                                 TSC=self.tCSint,
                                 status=None)

        # Create and start our task manager
        self.tm = TaskManager.TaskManager(logger=logger, ev_quit=self.ev_quit,
                                          internal_allocs=self.alloc)
        self.tm.setAllocs([TestTCSCmds.monitorName, 
                           TestTCSCmds.intName])
        self.tm.start()
Example #14
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)
Example #15
0
    def anon_arr(self, payload, name, channels):
        self.logger.debug("received values '%s'" % str(payload))

        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" %
                              (str(payload), str(e)))
            return

        try:
            ast_id = bnch.value['ast_id']
            return self.process_ast(ast_id, bnch.value)

        except KeyError:
            return self.process_task(bnch.path, bnch.value)
    def __init__(self, logger, svcname, monitor, debug, port, usethread=False):

        # Superclass constructor
        #self.guider=GuiderSaveFrame(debug=False, monitor=monitor, svcname=svcname)
        ro.remoteObjectServer.__init__(self,
                                       svcname=svcname,
                                       port=port,
                                       logger=logger,
                                       usethread=usethread)

        self.logger = logger
        self.debug = debug
        self.monitor = monitor

        if self.monitor:
            self.db = Monitor.Minimon(monSvcName, self.logger)
            self.db.subscribe(self.monitor, (monChannel), (Monitor.TWO_WAY))
Example #17
0
    def arr_fitsinfo(self, payload, name, channels):
        self.logger.debug("received values '%s'" % str(payload))

        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" % (
                str(payload), str(e)))
            return

        # Find out the source of this information by examining the path
        match = regex_frame.match(bnch.path)
        if match:
            (frameid, subsys) = match.groups()

            try:
                # See if there is method to handle this information
                # in the 'fits' object
                method = getattr(self.fits, '%s_hdlr' % subsys)

            except AttributeError:
                self.logger.debug("No handler for '%s' subsystem" % subsys)
                return

            # check if this is a frame from an instrument that is
            # allocated
            match = regex_frameid.match(frameid)
            if match:
                inscode = match.group(1).upper()
                if not (inscode in self.inscodes):
                    return

            try:
                # Get all the saved items under this path to report to
                # the handler
                vals = self.monitor.getitems_suffixOnly(bnch.path)
                
                method(frameid, vals)
                return

            except Exception, e:
                self.logger.error("Error processing '%s': %s" % (
                    str(bnch.path), str(e)))
            return
    def anon_arr(self, payload, name, channels):
        self.logger.debug("received values '%s'" % str(payload))

        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" %
                              (str(payload), str(e)))
            return

        try:
            ast_id = bnch.value['ast_id']
            # because gtk thread handling sucks
            gobject.idle_add(self.process_ast, ast_id, bnch.value)

        except KeyError:
            gobject.idle_add(self.process_task, bnch.path, bnch.value)
Example #19
0
    def arr_taskinfo(self, payload, name, channels):
        self.logger.debug("received values '%s'" % str(payload))
        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" % (
                str(payload), str(e)))
            return

        if not bnch.has_key('value'):
            # delete (vaccuum) packet
            return
        vals = bnch.value

        if vals.has_key('ast_id'):
            # SkMonitorPage update on some abstract or device dependent command
            self.gui.process_ast(vals['ast_id'], vals)

        elif vals.has_key('subpath'):
            # SkMonitorPage update on some subcommand
            self.gui.process_subcommand(bnch.path,
                                        vals['subpath'], vals)

        # possible SkMonitorPage update on some command status change
        else:
            self.gui.process_task(bnch.path, vals)
        
        if vals.has_key('task_code'):
            res = vals['task_code']
            # Interpret task results:
            #   task_code == 0 --> OK   task_code != 0 --> ERROR
            if res == 0:
##                 self.gui.gui_do(self.gui.feedback_ok,
##                                 tmtrans.queueName, tmtrans, res)
                pass
            else:
                # If there was a problem, let the gui know about it
##                 self.gui.gui_do(self.gui.feedback_error,
##                                 tmtrans.queueName, tmtrans, str(res))
                if res == 3:
                    self.logger.info("Task cancelled (%s)" % bnch.path)
                    self.gui.cancel_dialog(bnch.path)
Example #20
0
    def anon_arr(self, payload, names, channels):
        self.logger.debug("received values '%s'" % (str(payload)))
        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" %
                              (str(payload), str(e)))
            return

        info = bnch.value
        #self.logger.debug("info is: %s" % (str(info.keys())))

        self.playSound(info['buffer'],
                       filename=info['filename'],
                       decode=True,
                       format=info['format'],
                       decompress=info['compressed'],
                       priority=info['priority'])
    def arr_status(self, payload, name, channels):
        """Called when new status information arrives at the periodic
        interval.
        """
        #self.logger.debug("received values '%s'" % str(payload))
        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" % (
                str(payload), str(e)))
            return

        if bnch.path != 'mon.status':
            return
        
        statusInfo = bnch.value

        self.update_statusInfo(statusInfo)
Example #22
0
    def arr_loginfo(self, payload, name, channels):
        self.logger.debug("received values '%s'" % str(payload))
        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" % (
                str(payload), str(e)))
            return

        # Find out the log for this information by examining the path
        match = regex_log.match(bnch.path)
        if match:
            logname = match.group(1)
            # Remove any non-ascii characters that won't go into
            # a standard text buffer
            # this is now handled at the sending end....EJ
            #buf = bnch.value['msgstr']
            #bnch.value['msgstr'] = buf.translate(None, self.deletechars)
            self.gui.update_loginfo(logname, bnch.value)
Example #23
0
    def anon_arr(self, payload, name, channels):

        try:
            bnch = Monitor.unpack_payload(payload)

            if self.monpath and (not bnch.path.startswith(self.monpath)):
                return
        except Monitor.MonitorError:
            return

        try:
            with StatIO.lock:
                #self.logger.debug('bnch val  %s' %bnch.value)
                newvaldict.update((k, bnch.value[k])
                                  for k in newvaldict.keys()
                                  if k in bnch.value)
                #self.logger.debug('update newvaldict ...  %s' %newvaldict)
        except Exception, e:
            self.logger.error('status updating error %s' % e)
            return
Example #24
0
    def arr_obsinfo(self, payload, name, channels):
        self.logger.debug("received values '%s'" % str(payload))

        try:
            bnch = Monitor.unpack_payload(payload)

        except Monitor.MonitorError:
            self.logger.error("malformed packet '%s': %s" % (
                str(payload), str(e)))
            return

        vals = bnch.value
        if vals.has_key('obsinfo'):
            statusDict = bnch.value['obsinfo']
            self.update_integgui(statusDict)

        elif vals.has_key('ready'):
            self.gui.update_statusMsg("TaskManager is ready.")

            self.playSound(common.sound.tm_ready, priority=22)
    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 monitor and other allocations
        self.monitor_name = 'monitor'
        self.monitor = Monitor.Minimon(self.monitor_name, logger)
        
        myhost = SOSSrpc.get_myhost(short=True)

        # Create and start STARS simulator
        self.stars = STARSint.STARSsimulator(logger=logger, ev_quit=self.ev_quit)
        # Tell STARS how to contact us to copy files
        STARSint.add_transferParams('*',
                                    transfermethod='ssh',
                                    raidpath=self.env.ARCH_PATH,
                                    #username=os.getlogin(),
                                    username=os.environ['LOGNAME'],
                                    password='******')
        
        self.stars.start()

        # Create and start the STARS interface
        self.starsint = STARSint.STARSinterface(starshost=myhost,
                                                db=self.monitor, logger=logger,
                                                ev_quit=self.ev_quit)
        self.starsint.start()

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

        # 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', 'STARSint'])
        self.tm.start()
def status_cb(payload, logger, mainWindow, svConfig):
    global statusFromGen2, lock
    try:
        bnch = Monitor.unpack_payload(payload)
        if bnch.path != 'mon.status':
            return

        with lock:
            logger.debug('status updated: %s' %
                         (time.strftime("%H:%M:%S", time.localtime())))
            statusDict = bnch.value
            statusFromGen2.update(statusDict)
            logger.debug(
                "status updated: %d items time:%s" %
                (len(statusDict), time.strftime("%H:%M:%S", time.localtime())))

        if mainWindow:
            updateAlarmWindow(mainWindow, svConfig, statusDict)

    except Monitor.MonitorError, e:
        logger.error('monitor error: %s' % (str(e)))
def status_cb(payload, logger, statusProxy, svConfig, statusValHistory,
              soundsink):
    global statusFromGen2, lock
    try:
        bnch = Monitor.unpack_payload(payload)
        if bnch.path != 'mon.status':
            return

        with lock:
            logger.debug('status updated: %s' %
                         (time.strftime("%H:%M:%S", time.localtime())))
            statusFromGen2.update(bnch.value)

        statusValHistory.update(svConfig, statusFromGen2)
        #        statusValHistory.report()
        statusValHistory.reportAlarms(svConfig, soundsink)
        updateStatusForGUI(statusProxy, statusValHistory, logger)
        updateStatusForSTS(statusProxy, svConfig, statusValHistory, logger)

    except Monitor.MonitorError, e:
        logger.error('monitor error: %s' % (str(e)))
    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()
Example #29
0
    def anon_arr(self, payload, name, channels):
        #recvtime = time.time()         

        try:
            bnch = Monitor.unpack_payload(payload)
            
            if self.monpath and (not bnch.path.startswith(self.monpath)):
                return
            try: 
                # update status values as soon as they are changed  
                self.stat_val.update((k,bnch.value[k]) for k in self.stat_val.keys() if k in bnch.value)

                self.coordinator.stat_dict=self.stat_val

                self.logger.debug('stat val  %s' %self.stat_val)
                
            except Exception, e:
                self.logger.error('status updating error %s' %e)
                return 

        except Monitor.MonitorError:
            return
Example #30
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)