예제 #1
0
    def __init__(self, context, subaddr=None, pubaddr=None):
        threading.Thread.__init__(self)
        #private data
        self._queue = queue.Queue()
        self._subsocket = context.socket(zmq.SUB)
        self._pubsocket = context.socket(zmq.PUB)
        self._subaddr = subaddr
        self._pubaddr = pubaddr
        if type(self._subaddr) is str:
            self._subaddr = [self._subaddr]
        if type(self._pubaddr) is str:
            self._pubaddr = [self._pubaddr]
        self._sub_connected = False
        self._pubsub = pubsub()
        if self._pubaddr is not None:
            for addr in self._pubaddr:
                self._pubsocket.bind(addr.encode('ascii'))

        self._poller = zmq.Poller()
        self._poller.register(self._subsocket, zmq.POLLIN)

        #public data
        self.shutdown = threading.Event()
        self.finished = threading.Event()
        #init
        self.setDaemon(True)
        self.start()
예제 #2
0
    def __init__(self, context, subaddr=None, pubaddr=None):
        threading.Thread.__init__(self)
        #private data
        self._queue = Queue.Queue()
        self._subsocket = context.socket(zmq.SUB)
        self._pubsocket = context.socket(zmq.PUB)
        self._subaddr = subaddr
        self._pubaddr = pubaddr
        if type(self._subaddr) is str:
            self._subaddr = [self._subaddr]
        if type(self._pubaddr) is str:
            self._pubaddr = [self._pubaddr]
        self._sub_connected = False
        self._pubsub = pubsub()
        if self._pubaddr is not None:
            for addr in self._pubaddr:
                self._pubsocket.bind(addr)

        self._poller = zmq.Poller()
        self._poller.register(self._subsocket, zmq.POLLIN)
        
        #public data
        self.shutdown = threading.Event()
        self.finished = threading.Event()
        #init
        self.setDaemon(True)
        self.start()
예제 #3
0
    def __init__(self,
                 parent,
                 ps=None,
                 direction_key='__direction_key__',
                 callback=None,
                 direction=None,
                 text=None,
                 text_visible=None):
        #init
        if ps is None: ps = pubsub.pubsub()
        if direction is not None: ps[direction_key] = direction
        pubsub.pubsub.__init__(self)
        wx.Panel.__init__(self, parent)
        #proxy keys
        self.proxy(BEAM_AZM_KEY, ps, direction_key)
        #build gui and add plotter
        vbox = wx.BoxSizer(wx.VERTICAL)
        self.plotter = compass_plotter(self)
        self.plotter.SetSize(wx.Size(*PLOTTER_SIZE))
        self.plotter.SetSizeHints(*PLOTTER_SIZE)
        vbox.Add(self.plotter, 1, wx.EXPAND)  # | wx.SHAPED #keep aspect ratio
        #build the control box
        #beam_box = forms.static_box_sizer(
        #parent=self,
        #label='Beam Control',
        #bold=True,
        #)
        #vbox.Add(beam_box, 0, wx.EXPAND)
        #beam_box.Add(_beam_control(self, label='Beam', azm_key=BEAM_AZM_KEY, enb_key=BEAM_ENB_KEY), 0, wx.EXPAND)
        #beam_box.Add(_beam_control(self, label='Null', azm_key=NULL_AZM_KEY, enb_key=NULL_ENB_KEY), 0, wx.EXPAND)
        #self[BEAM_ENB_KEY] = True
        #self[NULL_ENB_KEY] = True
        #self[PATTERN_KEY] = 'ant0'
        #forms.drop_down(
        #label='Pattern',
        #ps=self,
        #key=PATTERN_KEY,
        #choices=PATTERN_KEYS,
        #labels=PATTERN_NAMES,
        #sizer=beam_box,
        #parent=self,
        #proportion=0,
        #)
        self.SetSizerAndFit(vbox)
        #subscribe keys to the update methods
        self.subscribe(BEAM_AZM_KEY, self.update)

        #self.update_enables() #initial updates
        self.set_direction(direction)
        self.plotter.set_text(text)
        self.plotter.set_text_visible(text_visible, True)

        #do last as to not force initial update
        if callback: self.subscribe(TAPS_KEY, callback)
예제 #4
0
    def __init__(self, parent, ps=None, direction_key='__direction_key__', callback=None, direction=None, text=None, text_visible=None):
        #init
        if ps is None: ps = pubsub.pubsub()
        if direction is not None: ps[direction_key] = direction
        pubsub.pubsub.__init__(self)
        wx.Panel.__init__(self, parent)
        #proxy keys
        self.proxy(BEAM_AZM_KEY, ps, direction_key)
        #build gui and add plotter
        vbox = wx.BoxSizer(wx.VERTICAL)
        self.plotter = compass_plotter(self)
        self.plotter.SetSize(wx.Size(*PLOTTER_SIZE))
        self.plotter.SetSizeHints(*PLOTTER_SIZE)
        vbox.Add(self.plotter, 1, wx.EXPAND) # | wx.SHAPED #keep aspect ratio
        #build the control box
        #beam_box = forms.static_box_sizer(
            #parent=self,
            #label='Beam Control',
            #bold=True,
        #)
        #vbox.Add(beam_box, 0, wx.EXPAND)
        #beam_box.Add(_beam_control(self, label='Beam', azm_key=BEAM_AZM_KEY, enb_key=BEAM_ENB_KEY), 0, wx.EXPAND)
        #beam_box.Add(_beam_control(self, label='Null', azm_key=NULL_AZM_KEY, enb_key=NULL_ENB_KEY), 0, wx.EXPAND)
        #self[BEAM_ENB_KEY] = True
        #self[NULL_ENB_KEY] = True
        #self[PATTERN_KEY] = 'ant0'
        #forms.drop_down(
            #label='Pattern',
            #ps=self,
            #key=PATTERN_KEY,
            #choices=PATTERN_KEYS,
            #labels=PATTERN_NAMES,
            #sizer=beam_box,
            #parent=self,
            #proportion=0,
        #)
        self.SetSizerAndFit(vbox)
        #subscribe keys to the update methods
        self.subscribe(BEAM_AZM_KEY, self.update)
        
        #self.update_enables() #initial updates
        self.set_direction(direction)
        self.plotter.set_text(text)
        self.plotter.set_text_visible(text_visible, True)

        #do last as to not force initial update
        if callback: self.subscribe(TAPS_KEY, callback)