Changeset 81 for remote_control
- Timestamp:
- 07/01/10 11:55:18 (12 years ago)
- Location:
- remote_control
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
remote_control/puzzlebox_brainstorms_client_interface.py
r78 r81 150 150 ################################################################## 151 151 152 def configureNetworkThinkGear(self): 152 def connectToThinkGearHost(self): 153 154 if self.DEBUG: 155 print "Connecting to ThinkGear Host" 153 156 154 157 self.thinkgearClient = \ 155 158 thinkgear_client.puzzlebox_brainstorms_network_client_thinkgear(self.log, parent=self) 156 159 160 self.disconnect(self.pushButtonThinkGearConnect, \ 161 QtCore.SIGNAL("clicked()"), \ 162 self.connectToThinkGearHost) 163 157 164 self.connect(self.pushButtonThinkGearConnect, \ 158 165 QtCore.SIGNAL("clicked()"), \ … … 160 167 161 168 self.pushButtonThinkGearConnect.setText('Disconnect') 162 163 #self.pushButtonThinkGearConnect.setEnabled(False)164 169 165 170 … … 168 173 def diconnectFromThinkGearHost(self): 169 174 175 if self.DEBUG: 176 print "Disconnecting from ThinkGear Host" 177 170 178 self.thinkgearClient.disconnectFromHost() 171 179 180 self.disconnect(self.pushButtonThinkGearConnect, \ 181 QtCore.SIGNAL("clicked()"), \ 182 self.diconnectFromThinkGearHost) 183 172 184 self.connect(self.pushButtonThinkGearConnect, \ 173 185 QtCore.SIGNAL("clicked()"), \ 174 self.con figureNetworkThinkGear)186 self.connectToThinkGearHost) 175 187 176 188 self.pushButtonThinkGearConnect.setText('Connect') … … 214 226 self.connect(self.pushButtonThinkGearConnect, \ 215 227 QtCore.SIGNAL("clicked()"), \ 216 self.con figureNetworkThinkGear)228 self.connectToThinkGearHost) 217 229 218 230 -
remote_control/puzzlebox_brainstorms_network_client_thinkgear.py
r79 r81 9 9 # For more information please refer to http://www.gnu.org/copyleft/gpl.html 10 10 # 11 # Last Update: 2010.0 6.2811 # Last Update: 2010.07.01 12 12 # 13 13 ##################################################################### … … 16 16 import signal 17 17 18 from PyQt4 import QtCore, Qt Gui, QtNetwork18 from PyQt4 import QtCore, QtNetwork 19 19 20 20 import simplejson as json … … 276 276 #log.info("Command parameters: %s" % command_parameters) 277 277 278 app = QtCore.QCoreApplication(sys.argv) 279 278 280 client = puzzlebox_brainstorms_network_client_thinkgear_command_line(log, \ 279 281 command_parameters, \ … … 282 284 DEBUG=DEBUG) 283 285 284 while True: 285 while client.socket.waitForReadyRead(CLIENT_NO_REPLY_WAIT): 286 pass 287 286 #while True: 287 #while client.socket.waitForReadyRead(CLIENT_NO_REPLY_WAIT): 288 #pass 289 290 sys.exit(app.exec_()) 291 -
remote_control/puzzlebox_brainstorms_network_server_thinkgear.py
r80 r81 9 9 # For more information please refer to http://www.gnu.org/copyleft/gpl.html 10 10 # 11 # Last Update: 2010.0 6.3011 # Last Update: 2010.07.01 12 12 # 13 13 ##################################################################### … … 49 49 # an adult blinks in a laboratory setting) 50 50 51 DEFAULT_SAMPLE_WAVELENGTH = 10 # number of seconds from 0 to max to 0 for51 DEFAULT_SAMPLE_WAVELENGTH = 20 # number of seconds from 0 to max to 0 for 52 52 # any given detection value below 53 53 … … 126 126 self.blink_frequency_timer = BLINK_FREQUENCY_TIMER 127 127 128 #self.client_connected = False129 128 self.connection_timestamp = time.time() 130 129 self.blink_timestamp = time.time() … … 135 134 self.configureNetwork() 136 135 137 self.timer = QtCore.QTimer() 138 QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.timerEvent) 139 self.timer.start(MESSAGE_FREQUENCY_TIMER) 140 141 #self.timer = QtCore.QTimer.singleShot(MESSAGE_FREQUENCY_TIMER, self.timerEvent) 136 self.updateTimer = QtCore.QTimer() 137 QtCore.QObject.connect(self.updateTimer, QtCore.SIGNAL("timeout()"), self.timerEvent) 138 self.updateTimer.start(MESSAGE_FREQUENCY_TIMER) 142 139 143 140 … … 185 182 ################################################################## 186 183 187 #def getNextConnectionIndex(self):188 189 #index = len(self.connections.keys())190 191 #while index in self.connection.keys():192 #index += 1193 194 195 #return(index)196 197 198 ##################################################################199 200 184 def deleteDisconnected(self): 201 185 … … 204 188 for connection in self.connections: 205 189 206 if self.DEBUG:207 print "Connection state:",208 print connection.state()190 #if self.DEBUG: 191 #print "Connection state:", 192 #print connection.state() 209 193 210 194 if ((connection.state() != QtNetwork.QAbstractSocket.ConnectingState) and \ … … 212 196 213 197 if self.DEBUG: 214 print " x-- [%s] Deleting disconnected socket:" % self.socket.name,198 print "- - [%s] Deleting disconnected socket" % self.socket.name 215 199 216 200 connection.deleteLater() … … 227 211 228 212 clientConnection = self.socket.nextPendingConnection() 229 #index = self.getNextConnectionIndex()230 #clientConnection.index = index231 #clientConnection.disconnected.connect(clientConnection.deleteLater)232 213 clientConnection.disconnected.connect(self.deleteDisconnected) 233 #self.connections[index] = clientConnection 214 215 self.connections.append(clientConnection) 216 234 217 235 218 # Wait until client sends authorization request or configuration packet … … 284 267 285 268 self.sendResponse(clientConnection, response) 286 287 288 self.connections.append(clientConnection)289 269 290 270 … … 479 459 packet = DEFAULT_BLINK_MESSAGE 480 460 self.packet_queue.append(packet) 481 482 483 #####################################################################484 #####################################################################485 486 #class networkServerThinkGearThread(QtCore.QThread):487 488 #error = QtCore.pyqtSignal(QtNetwork.QTcpSocket.SocketError)489 490 #def __init__(self, socketDescriptor, parent):491 ##super(networkServerThinkGearThread, self).__init__(parent)492 493 #self.socketDescriptor = socketDescriptor494 495 496 ###################################################################497 498 #def run(self):499 500 #tcpSocket = QtNetwork.QTcpSocket()501 502 #if not tcpSocket.setSocketDescriptor(self.socketDescriptor):503 #self.error.emit(tcpSocket.error())504 505 #return506 507 ##block = QtCore.QByteArray()508 ##outstr = QtCore.QDataStream(block, QtCore.QIODevice.WriteOnly)509 ##outstr.setVersion(QtCore.QDataStream.Qt_4_0)510 ##outstr.writeUInt16(0)511 ##outstr.writeString(self.text)512 ##outstr.device().seek(0)513 ##outstr.writeUInt16(block.count() - 2)514 515 ##tcpSocket.write(block)516 ##tcpSocket.disconnectFromHost()517 ##tcpSocket.waitForDisconnected()518 461 519 462
Note: See TracChangeset
for help on using the changeset viewer.