Example #1
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.setCentralWidget(self.mdiArea);
        self.statusTxt = QtGui.QLabel("")
        self.statusBar().addWidget(self.statusTxt)

        self.connect(self.action_Tubotron, SIGNAL("triggered()"), SLOT("Tubotron()"))
        self.connect(self.action_Temperature, SIGNAL("triggered()"), SLOT("Temperature()"))
        self.connect(self.action_Utilization, SIGNAL("triggered()"), SLOT("Utilization()"))
        self.connect(self.action_Frequency, SIGNAL("triggered()"), SLOT("Frequency()"))
        self.connect(self.action_SaveData, SIGNAL("triggered()"), SLOT("SaveData()"))
        self.connect(self.action_SelectBoard, SIGNAL("triggered()"), SLOT("SelectBoard()"))
        self.connect(self.action_CoreSwitcher, SIGNAL("triggered()"), SLOT("CoreSwitch()"))

        self.TubSock = QtNetwork.QUdpSocket(self) # this is for Tubotron
        self.RptSock = QtNetwork.QUdpSocket(self) # this if for report streaming (temperature, utilization, etc)
        self.RplSock = QtNetwork.QUdpSocket(self) # this for generic reply for specific command request
        self.initRptSock(DEF.RECV_PORT)
        self.initRplSock(DEF.REPLY_PORT)
                
        self.uw = None
        self.tw = None
        self.fw = None
        self.sw = None
        # First, trigger the Board type and get the core map
        self.SelectBoard()
Example #2
0
    def __init__(self, def_image_dir="./", parent=None):
        self.img_dir = def_image_dir
        self.img = None
        self.res = None
        self.continyu = True
        super(edgeGUI, self).__init__(parent)
        self.setupUi(self)

        self.orgViewPort = imgWidget("Original Image")
        #self.orgViewPort.show()
        self.resViewPort = imgWidget("Result SpiNNaker")
        #self.resViewPort.show()
        self.hostViewPort = imgWidget("Result PC-version")
        #self.hostViewPort.show()

        self.trx = trxIndicator()
        #self.trx.show()

        self.connect(self.pbLoad, QtCore.SIGNAL("clicked()"),
                     QtCore.SLOT("pbLoadClicked()"))
        self.connect(self.pbSend, QtCore.SIGNAL("clicked()"),
                     QtCore.SLOT("pbSendClicked()"))
        self.connect(self.pbProcess, QtCore.SIGNAL("clicked()"),
                     QtCore.SLOT("pbProcessClicked()"))
        self.connect(self.pbSave, QtCore.SIGNAL("clicked()"),
                     QtCore.SLOT("pbSaveClicked()"))
        self.connect(self.pbClear, QtCore.SIGNAL("clicked()"),
                     QtCore.SLOT("pbClearClicked()"))
        #self.connect(self.cbSpiNN, QtCore.SIGNAL("currentIndexChanged(int)")), QtCore.SLOT("cbSpiNNChanged(int)")
        self.cbSpiNN.currentIndexChanged.connect(self.cbSpiNNChanged)

        if spiNN == spin3:
            self.cbSpiNN.setCurrentIndex(0)
        else:
            self.cbSpiNN.setCurrentIndex(1)

        # self.sdpUpdate can be connected to other slot
        # self.sdpUpdate.connect(SOME_OTHER_SLOT)

        self.RptSock = QtNetwork.QUdpSocket(self)
        self.sdpSender = QtNetwork.QUdpSocket(self)
        self.initRptSock(DEF_RESULT_PORT)
        # self.initRptSock(DEF_REPLY_PORT)
        self.DbgSock = QtNetwork.QUdpSocket(self)
        self.initDbgSock(DEF_DEBUG_PORT)

        self.tResult = [0, 0, 0]

        self.debugVal = 0
        self.ResultTriggered = False
Example #3
0
    def send_server_invite_option(self, invite_client_ids, channel_id):
        # for each client_id find the socket on which to send the
        # server_invite option
        for invite_client_id in invite_client_ids:
            for _, client_sockets in self.channels.items():
                for (client_id, socket) in client_sockets:
                    if invite_client_id == client_id:
                        #Hier kann es auch sein, dass nur eine Id gebraucht
                        #wird und nicht eine Liste...
                        option_data = Container(channel_id=channel_id,
                                                client_id=invite_client_ids)

                        option = Container(option_id="SERVER_INVITE_OPTION",
                                           option_data=option_data)

                        pdu = Container(id=self.id, option=[option])

                        ip_to_invite = QtNetwork.QHostAddress(
                            socket.peerAddress())
                        udpSocket_for_invites = QtNetwork.QUdpSocket(self)
                        udpSocket_for_invites.bind(
                            ip_to_invite, broadcast_port,
                            QtNetwork.QUdpSocket.ShareAddress)
                        udpSocket_for_invites.writeDatagram(
                            InstantSoupData.peer_pdu.build(pdu), ip_to_invite,
                            broadcast_port)

        log.debug('PDU: SERVER_INVITE_OPTION - id: %i - SENT' %
                  self.pdu_number)
Example #4
0
    def __init__(self, argv):
        QtGui.QApplication.__init__(self, argv)

        settings = utils.Settings()

        # Prepare socket for sending notifications
        self.socketTo = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.socketTo.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
        self.socketTo.connect(('255.255.255.255', settings.notificationPort))

        # Prepare socket for receiving notifications
        self.socketFrom = QtNetwork.QUdpSocket()
        anyAddress = QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any)
        self.socketFrom.bind(anyAddress, settings.notificationPort)
        self.connect(self.socketFrom, SIGNAL("readyRead()"),
                     self.onNotification)

        # Prepare the ping agent
        self.pingAgent = PingAgent(self, settings.dbHost)

        # Run the timer which checks the connection periodically
        self.connectionTimer = QTimer(self)
        self.connect(self.connectionTimer, SIGNAL("timeout()"),
                     self.checkConnection)
        # Check the connection every 16 seconds if the connection is lost
        # or every 5 minutes if the connection is here
        self.connectionTimer.start(16 * 1000)

        # Check it at the very beginning
        QtCore.QTimer.singleShot(1000, self.checkConnection)
Example #5
0
    def __init__(self, parent=None):
        super(proxies, self).__init__(parent)

        self.client = parent

        self.proxies = {}
        self.proxiesDestination = {}
        port = 12000
        errored = False
        for i in range(11) :
            port = port + 1
            self.proxies[i] = QtNetwork.QUdpSocket(self)
            if not self.proxies[i].bind(QtNetwork.QHostAddress.LocalHost, port) :
                self.__logger.warn("Can't bind socket %i" % i)
                errored = True
            else :
                self.__logger.info("binding socket %i on port %i" % (i, self.proxies[i].localPort()))
                self.proxies[i].readyRead.connect(functools.partial(self.processPendingDatagrams, i))
                self.proxiesDestination[i] = None
        if errored:
            QtGui.QMessageBox.warning(self.client, "Cannot use proxy server", "FAF is unable to bind the port <b>12000 to 12011 on TCP</b>.<br>Please check your firewall settings.<br><b>You may experience connections problems until it's fixed.</b>")
            
        self.proxySocket = QtNetwork.QTcpSocket(self)
        self.proxySocket.connected.connect(self.connectedProxy)
        self.proxySocket.readyRead.connect(self.readData)
        self.proxySocket.disconnected.connect(self.disconnectedFromProxy)
        
        self.blockSize = 0
        self.uid = None
        self.canClose = False
        self.testedPortsAmount = {}
        self.testedPorts = []
        self.testedLoopbackAmount = {}
        self.testedLoopback = []
        self.testing = False
    def __init__(self, parent=None):
        super(Sender, self).__init__(parent)

        self.statusLabel = QtGui.QLabel("Ready to broadcast datagrams on port 45454")

        self.startButton = QtGui.QPushButton("&Start")
        quitButton = QtGui.QPushButton("&Quit")

        buttonBox = QtGui.QDialogButtonBox()
        buttonBox.addButton(self.startButton, QtGui.QDialogButtonBox.ActionRole)
        buttonBox.addButton(quitButton, QtGui.QDialogButtonBox.RejectRole)

        self.timer = QtCore.QTimer(self)
        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.messageNo = 1

        self.startButton.clicked.connect(self.startBroadcasting)
        quitButton.clicked.connect(self.close)
        self.timer.timeout.connect(self.broadcastDatagramm)

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.statusLabel)
        mainLayout.addWidget(buttonBox)
        self.setLayout(mainLayout)

        self.setWindowTitle("Broadcast Sender")
Example #7
0
    def sendSDP(self, flags, tag, dp, dc, dax, day, cmd, seq, arg1, arg2, arg3,
                bArray):
        """
        You know, the detail experiment with sendSDP() see mySDPinger.py
        the bArray can be constructed simply by using type casting. Ex:
        elements = [0, 200, 50, 25, 10, 255]
        bArray = bytearray(elements)        # byte must be in range(0, 256)
        Something wrong with bArray -> try to use list instead
        """
        da = (dax << 8) + day
        dpc = (dp << 5) + dc
        sa = 0
        spc = 255
        pad = struct.pack('2B', 0, 0)
        hdr = struct.pack('4B2H', flags, tag, dpc, spc, da, sa)
        scp = struct.pack('2H3I', cmd, seq, arg1, arg2, arg3)
        sdp = pad + hdr + scp
        """
        if bArray is not None:
            sdp = pad + hdr + scp + bArray
        else:
            sdp = pad + hdr + scp
        """
        if bArray is not None:
            for b in bArray:
                sdp += struct.pack('<B', b)
                #sdp += b

        CmdSock = QtNetwork.QUdpSocket()
        CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(DEF_HOST),
                              DEF_SEND_PORT)
        time.sleep(DEF_SDP_TIMEOUT)
        return sdp
Example #8
0
    def create_udp_socket(self):
        self.udp_socket = QtNetwork.QUdpSocket()
        self.udp_socket.bind(broadcast_port,
                             QtNetwork.QUdpSocket.ReuseAddressHint)
        self.udp_socket.joinMulticastGroup(group_address_ip4)

        # connect the socket input with the processing function
        self.udp_socket.readyRead.connect(self._process_pending_datagrams)
Example #9
0
	def __init__(self, parent):
		QtCore.QObject.__init__(self, parent)

		self.socket = QtNetwork.QUdpSocket(self)
		self.socket.bind(1137)
		self.connect(self.socket, QtCore.SIGNAL("readyRead()"), self.process_datagrams)
		self.count = 0
		parent.txtSocket.setPlainText("RiiFS Python Server is now ready for connections on 1137")
 def sendAck(self, blkID):
     # Try with broadcasting method only
     # sendSDP(self,flags, tag, dp, dc, dax, day, cmd, seq, arg1, arg2, arg3, bArray):
     # dp = sdpImgConfigPort
     dpc = (sdpAckPort << 5) + sdpCore
     hdr = struct.pack('4B2H', 0x07, 0, dpc, 255, 0, 0)
     reply = QtNetwork.QUdpSocket()
     self.sendSDP(0x07, 0, sdpAckPort, sdpCore, 0, 0, 0, 0, 0, 0, 0, None)
Example #11
0
    def __init__(self):
        QtGui.QDialog.__init__(self)
        self.ui = Ui_EventMessageDialog()
        self.ui.setupUi(self)
        self.setWindowTitle(pageTitle)

        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.udpSocket.bind(int(udpPort))
        self.udpSocket.readyRead.connect(self.processPendingDatagrams)
Example #12
0
    def __init__(self, listen_port, parent=None):
        super(dp_udp, self).__init__(parent)

        self.ListenPort = listen_port
	print "Listening on UDP port %d" % listen_port

        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.udpSocket.bind(QtNetwork.QHostAddress.Any, self.ListenPort)
        self.udpSocket.readyRead.connect(self.processPendingDatagrams)
    def __init__(self, send_port, targetIP, parent=None):
        super(UDP_sendStatus, self).__init__(parent)

        self.sendPort = num(send_port)
        self.target_IP = QtNetwork.QHostAddress(targetIP)

        try:
            self.ss = QtNetwork.QUdpSocket(self)
        except:
            print "Trouble opening UDP on socket %d" % (self.sendPort)
Example #14
0
 def setupUDP(self):
     self.sdpRecv = QtNetwork.QUdpSocket(self)
     print "[INFO] Trying to open UDP port-{}...".format(
         SDP_SEND_RESULT_PORT),
     ok = self.sdpRecv.bind(SDP_SEND_RESULT_PORT)
     if ok:
         print "done!"
     else:
         print "fail!"
     self.sdpRecv.readyRead.connect(self.readSDP)
Example #15
0
    def __init__(self, msg, parent=None):
        super(Sender, self).__init__(parent)
        self.msg = str(msg)
        self.dataconf = configset.read_config()

        self.setGeometry(0, 0, 0, 0)
        self.timer = QtCore.QTimer(self)
        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.timer.timeout.connect(self.broadcastDatagramm)

        self.broadcastDatagramm()
    def __init__(self):
        QtGui.QDialog.__init__(self)
        self.ui = Ui_GenericTelemetryDialog()
        self.ui.setupUi(self)
        self.setWindowTitle(pageTitle)

        #
        # connect the method to process a UDP packet
        #
        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.udpSocket.bind(int(udpPort))
        self.udpSocket.readyRead.connect(self.processPendingDatagrams)
Example #17
0
 def sendImgInfo(self, cmd, data_type):
     dpc = (SDP_RECV_JPG_INFO_PORT <<
            5) + SDP_RECV_CORE_ID  #destination port and core
     pad = struct.pack('2B', 0, 0)
     hdr = struct.pack('4B2H', 7, 0, dpc, 255, 0, 0)
     scp = struct.pack('2H3I', cmd, data_type, self.szImgFile, 0, 0)
     sdp = pad + hdr + scp
     CmdSock = QtNetwork.QUdpSocket()
     CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(self.spinn),
                           SPINN_PORT)
     CmdSock.flush()
     # then give a break, otherwise spinnaker will collapse
     self.delay()
def sendChunk(ch_port, ba):
    da = 0
    dpc = (ch_port << 5) + 1
    sa = 0
    spc = 255
    pad = struct.pack('<2B', 0, 0)
    hdr = struct.pack('<4B2H', 7, 0, dpc, spc, da, sa)

    sdp = pad + hdr + ba

    CmdSock = QtNetwork.QUdpSocket()
    CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(DEF_HOST), DEF_SEND_PORT)
    CmdSock.flush()
Example #19
0
 def sendImgInfo(self):
     dpc = (SDP_RECV_RAW_INFO_PORT <<
            5) + SDP_RECV_CORE_ID  # destination port and core
     pad = struct.pack('2B', 0, 0)
     hdr = struct.pack('4B2H', 7, 0, dpc, 255, 0, 0)
     scp = struct.pack('2H3I', SDP_CMD_INIT_SIZE, 0, len(self.orgImg),
                       self.wImg, self.hImg)
     sdp = pad + hdr + scp
     CmdSock = QtNetwork.QUdpSocket()
     CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(self.spinn),
                           SPINN_PORT)
     CmdSock.flush()
     # then give a break, otherwise spinnaker might collapse
     self.delay()
Example #20
0
    def __init__(self, parent=None, device_id=None):

        pygame.init()

        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        QtCore.QObject.connect(self.ui.pushButton_stream_webcam,
                               QtCore.SIGNAL("clicked()"),
                               self.cmd_stream_webcam)
        QtCore.QObject.connect(self.ui.horizontalSlider_fps,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.cmd_fps_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_red,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.cmd_red_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_green,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.cmd_green_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_blue,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.cmd_blue_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_gamma,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.cmd_gamma_slider_changed)
        QtCore.QObject.connect(self.ui.verticalSlider_brightness,
                               QtCore.SIGNAL("valueChanged(int)"),
                               self.cmd_brightness_slider_changed)

        # Network init
        self.sock = QtNetwork.QUdpSocket()
        self.sock.bind(QtNetwork.QHostAddress.Any, PORT)
        self.connect(self.sock, QtCore.SIGNAL("readyRead()"),
                     self.on_recv_udp_packet)

        self.image = None
        self.streaming = False
        self.threshold = 128
        self.equalize = False
        self.fps = FRAMES_PER_SECOND
        self.time_between_frames = TIME_BETWEEN_FRAMES

        self.max_red = 100
        self.max_green = 100
        self.max_blue = 100
        self.max_gamma = 100
        self.max_brightness = 100
def sendChunk(ch_port, core, seq, ba):
    da = 0
    dpc = (ch_port << 5) + core
    sa = seq
    spc = 255
    pad = struct.pack('<2B',0,0)
    hdr = struct.pack('<4B2H',7,0,dpc,spc,da,sa)

    if ba is not None:
        sdp = pad + hdr + ba
    else:
        sdp = pad + hdr

    CmdSock = QtNetwork.QUdpSocket()
    CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(DEF_HOST), DEF_SEND_PORT)
    CmdSock.flush()
Example #22
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self._parser = parserlog.parser()
        self.dataconf = configset.read_config()
        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.statusText = "Stop"

        self.sqlA = '''CREATE TABLE IF NOT EXISTS [datatemp](
                       [id] BIGINT(100) NOT NULL PRIMARY KEY,
                       [pid] VARCHAR(255) NOT NULL,
                       [name] VARCHAR(255) NOT NULL,
                       [addinfo] VARCHAR(255) NOT NULL)'''

        #self.conn = sqlite.connect(os.environ['TEMP'] + '\\' + 'dtemp.db')
        self.conn = sqlite.connect('dtemp.db')
        self.curs = self.conn.cursor()
        self.process = QtCore.QProcess()

        #self.createIconGroupBox()
        #self.createMessageGroupBox()

        #self.iconLabel.setMinimumWidth(self.durationLabel.sizeHint().width())

        self.createActions()
        self.createTrayIcon()
        self.setIcon()

        #QtCore.QObject.connect(self.showMessageButton,
        #        QtCore.SIGNAL("clicked()"), self.showMessage)
        #QtCore.QObject.connect(self.showIconCheckBox,
        #        QtCore.SIGNAL("toggled(bool)"), self.trayIcon,
        #        QtCore.SLOT("setVisible(bool)"))
        #QtCore.QObject.connect(self.iconComboBox,
        #        QtCore.SIGNAL("currentIndexChanged(int)"), self.setIcon)
        #QtCore.QObject.connect(self.trayIcon,
        #        QtCore.SIGNAL("messageClicked()"), self.messageClicked)
        #QtCore.QObject.connect(self.trayIcon,
        #        QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
        #        self.iconActivated)

        #mainLayout = QtGui.QVBoxLayout()
        #mainLayout.addWidget(self.iconGroupBox)
        #mainLayout.addWidget(self.messageGroupBox)
        #self.setLayout(mainLayout)

        #self.iconComboBox.setCurrentIndex(1)
        self.trayIcon.show()
Example #23
0
def sendSDP(flags, tag, dp, dc, dax, day, cmd, seq, arg1, arg2, arg3, bArray):
    da = (dax << 8) + day
    dpc = (dp << 5) + dc
    sa = 0
    spc = 255
    pad = struct.pack('<2B', 0, 0)
    hdr = struct.pack('<4B2H', flags, tag, dpc, spc, da, sa)
    scp = struct.pack('<2H3I', cmd, seq, arg1, arg2, arg3)
    if bArray is not None:
        sdp = pad + hdr + scp + bArray
    else:
        sdp = pad + hdr + scp

    CmdSock = QtNetwork.QUdpSocket()
    CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(DEF_HOST), DEF_SEND_PORT)
    CmdSock.flush()
    return sdp
Example #24
0
 def sendChunk(self, chunk):
     # based on sendSDP()
     # will be sent to chip <0,0>, no SCP
     dpc = (SDP_RECV_RAW_DATA_PORT <<
            5) + SDP_RECV_CORE_ID  # destination port and core
     pad = struct.pack('2B', 0, 0)
     hdr = struct.pack('4B2H', 7, 0, dpc, 255, 0, 0)
     if chunk is not None:
         sdp = pad + hdr + chunk
     else:
         # empty sdp means end of image transmission
         sdp = pad + hdr
     CmdSock = QtNetwork.QUdpSocket()
     CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(self.spinn),
                           SPINN_PORT)
     CmdSock.flush()
     # then give a break, otherwise spinnaker will collapse
     self.delay()
Example #25
0
    def sendSDP(self,flags, tag, dp, dc, dax, day, cmd, seq, arg1, arg2, arg3, bArray):
        """
        The detail experiment with sendSDP() see mySDPinger.py
        """
        da = (dax << 8) + day
        dpc = (dp << 5) + dc
        sa = 0
        spc = 255
        pad = struct.pack('2B',0,0)
        hdr = struct.pack('4B2H',flags,tag,dpc,spc,da,sa)
        scp = struct.pack('2H3I',cmd,seq,arg1,arg2,arg3)
        if bArray is not None:
            sdp = pad + hdr + scp + bArray
        else:
            sdp = pad + hdr + scp

        CmdSock = QtNetwork.QUdpSocket()
        CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(DEF.HOST), DEF.SEND_PORT)
        return sdp
Example #26
0
    def sendFreqReq(self, freq, dax, day):
        #def sendFreqReq(self,flags, tag, dp, dc, dax, day, cmd, seq, arg1, arg2, arg3, bArray):
        """
        The detail experiment with sendSDP() see mySDPinger.py
        """
        da = (dax << 8) + day
        dpc = (DEF.SDP_PORT << 5) + DEF.SDP_CORE
        sa = 0
        spc = 255
        pad = struct.pack('2B', 0, 0)
        hdr = struct.pack('4B2H', DEF.NO_REPLY, DEF.SEND_IPTAG, dpc, spc, da,
                          sa)
        scp = struct.pack('2H3I', DEF.HOST_SET_FREQ_VALUE, freq, 0, 0, 0)
        sdp = pad + hdr + scp

        CmdSock = QtNetwork.QUdpSocket()
        CmdSock.writeDatagram(sdp, QtNetwork.QHostAddress(DEF.HOST),
                              DEF.SEND_PORT)
        return sdp
Example #27
0
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self._parser = parserlog.parser()
        self.dataconf = configset.read_config()
        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.statusText = "Stop"

        self.sqlA = '''CREATE TABLE IF NOT EXISTS [datatemp](
                       [id] BIGINT(100) NOT NULL PRIMARY KEY,
                       [pid] VARCHAR(255) NOT NULL,
                       [name] VARCHAR(255) NOT NULL,
                       [addinfo] VARCHAR(255) NOT NULL)'''

        self.conn = sqlite.connect('totalcmd_dtemp.db')
        self.curs = self.conn.cursor()
        self.process = QtCore.QProcess()

        self.createActions()
        self.createTrayIcon()
        self.setIcon()
        self.trayIcon.show()
    def __init__(self, parent=None):
        super(Receiver, self).__init__(parent)

        self.statusLabel = QtGui.QLabel("Listening for broadcasted messages")
        quitButton = QtGui.QPushButton("&Quit")

        self.udpSocket = QtNetwork.QUdpSocket(self)
        self.udpSocket.bind(45454)

        self.udpSocket.readyRead.connect(self.processPendingDatagrams)
        quitButton.clicked.connect(self.close)

        buttonLayout = QtGui.QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(quitButton)
        buttonLayout.addStretch(1)

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.statusLabel)
        mainLayout.addLayout(buttonLayout)
        self.setLayout(mainLayout)

        self.setWindowTitle("Broadcast Receiver")
        self.timer.timeout.connect(self.update_plots)
        self.timer.start(20)
        self.amp = amp
        self.box_phase = phase

    @QtCore.pyqtSlot()
    def update_plots(self):
        self.penAmp.setData(self.carrier, self.amplitude)
        self.penPhase.setData(self.carrier, self.phase)
        self.process_events()  ## force complete redraw for every plot

    def process_events(self):
        self.app.processEvents()


## Start Qt event loop unless running in interactive mode.
if (__name__ == '__main__'):
    import sys

    udp_port = 1234
    udpSocket = QtNetwork.QUdpSocket()
    udpSocket.bind(udp_port, QtNetwork.QUdpSocket.ShareAddress)

    form = UI(app=app)
    form.show()

    e = UDP_listener([], [], sock=udpSocket, form=form)

    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
Example #30
0
 def __init__(self, parent=None):
     super(sdpComm, self).__init__(parent)
     self.RptSock = QtNetwork.QUdpSocket(self)
     self.initSDPReceiver()