Beispiel #1
0
 def set_source_flux(self, args):
     """ inst.set_source_flux(flux_Jy) -> err_code
     This accepts a single float representing the requested source flux density
     in Jansky's and for right now always returns an error code of 0
     meaning that the source flux was set successfully."""
     self._source_flux = FLOAT.unpack(args[:4])[0]
     self.logger.debug('set_source_flux(%.2f)' %self._source_flux)
     return SBYTE.pack(0)
Beispiel #2
0
 def operations_log(self, args):
     """ inst.operations_log(level, logger_name, msg)
     This allows any client to send log messages to the
     given logger at any level. """
     level, logger_msg = unpack('!B%ds' %(len(args)-1), args)
     logger_name, msg = logger_msg.split('\r')
     logger = logging.getLogger(logger_name)
     logger.log(level, msg)
     return SBYTE.pack(0)
Beispiel #3
0
 def set_integration_time(self, args):
     """ inst.set_integration_time(time) -> err_code
     Overloaded method to set the integration time on the BEE2."""
     itime = unpack('!f', args)[0]
     PERIOD = PERIOD_SYNCSEL[self._bee2.regread('syncsel')]
     integ_time = round(itime / PERIOD)
     self._bee2.regwrite('integ_time', integ_time)
     self._integration_time = integ_time
     return SBYTE.pack(0)
Beispiel #4
0
 def get_correlation(self, args):
     """ inst.get_correlation() -> single_udp_packet
     Gets the next correlation from the correlator client, returns -1 if there is no
     correlation ready. Note: it is preferable to use a direcy UDP client instead of
     this function but it is provided to enable secure remote operations."""
     try:
         pkt = self._correlator_client._request('')
         return pack('!B%ds' % len(pkt), 0, pkt)
     except NoCorrelations:
         return SBYTE.pack(-1)
Beispiel #5
0
 def delay_tracker(self, args):
     """ inst.noise_mode(bool)
     If bool=True, selects internally generated noise.
     If bool=False, selects external ADC data (normal)."""
     on = unpack('!B', args[0])[0]
     if self._delay_tracker_thread.isAlive():
         if on:
             self.logger.warning("delay tracker already started!")
             return SBYTE.pack(-1)
         else:
             self.stop_delay_tracker()
             self.logger.info("delay tracker stopped")
     else:
         if not on:
             self.logger.warning("delay tracker has not been started!")
             return SBYTE.pack(-2)
         else:
             self.start_delay_tracker(1)
             self.logger.info("delay tracker started")
     return SBYTE.pack(0)
Beispiel #6
0
 def load_walsh_table(self, args):
     try:
         walsh_table = self._dds.get_walsh_pattern()
     except:
         self.logger.error("problem communicating with the DDS!")
         return SBYTE.pack(-1)
     for step in range(64):
         cur90 = dict.fromkeys(self._ipas.values(), 0)
         cur180 = dict.fromkeys(self._ipas.values(), 0)
         for antenna, steps in walsh_table.items():
             try:
                 ibob, col = self._input_ibob_map[self._mapping[antenna]]
             except KeyError:
                 self.logger.warning("antenna %d not in array" % antenna)
                 walsh_table.pop(antenna)
                 continue
             bit90 = steps[step] & 1 # extract bottom bit
             bit180 = (steps[step] >> 1) & 1 # extract top bit
             cur90[ibob] = cur90[ibob] | (bit90 << col)
             cur180[ibob] = cur180[ibob] | (bit180 << col)
         for ibob in self._ipas.values():
             ibob.bramwrite('walsh/table/90', cur90[ibob], location=step)
             ibob.bramwrite('walsh/table/180', cur180[ibob], location=step)
     return SBYTE.pack(0)
Beispiel #7
0
 def _board(self, args):
     """ inst._board(board, cmd)
     This allows the client to send commands and receive
     responses from the server's underlying iBOBs. Note: this
     should be used cautiously, if you find yourself using this often
     you should just write a server command."""
     queues = {}
     board_re, sep, cmd = args.partition(' ')
     for name, board in self._boards.iteritems():
         if re.match(board_re, name):
             queues[name] = board.tinysh(cmd)
     response = ''
     for name, queue in queues.iteritems():
         response += queue.get(20)
         response += "\r### {0} {1} @({2})\n\r".format(name, cmd, asctime()) 
     return SBYTE.pack(0) + response
Beispiel #8
0
 def noise_mode(self, args):
     """ inst.noise_mode(bool)
     If bool=True, selects internally generated noise.
     If bool=False, selects external ADC data (normal)."""
     insel = unpack('!B', args[0])[0]
     seed = (randint(0, 2**16-1) << 16) + randint(0, 2**16-1)
     for name, ibob in self._ipas.iteritems():
         ibob.regwrite('noise/seed/0', seed)
         ibob.regwrite('noise/seed/1', seed)
         ibob.regwrite('noise/seed/2', seed)
         ibob.regwrite('noise/seed/3', seed)
     for name, ibob in self._ipas.iteritems():
         ibob.regwrite('noise/arm', 0)
     for name, ibob in self._ipas.iteritems():
         ibob.regwrite('noise/arm', 0x1111)
     for name, ibob in self._ipas.iteritems():
         ibob.regwrite('insel', insel*0x55555555)
     return SBYTE.pack(0)
Beispiel #9
0
 def clear_walsh_table(self, args):
     for name, ibob in self._ipas.iteritems():
         for step in range(64):
             ibob.bramwrite('walsh/table/90', 0, location=step)
             ibob.bramwrite('walsh/table/180', 0, location=step)
     return SBYTE.pack(0)