Changeset 73


Ignore:
Timestamp:
06/29/10 11:31:19 (11 years ago)
Author:
sc
Message:

brainstorms:

  • comprehensive file and class renaming in response to conversions

from PyGame/Twisted? frameworks to Qt

Location:
remote_control
Files:
3 edited
1 copied
7 moved

Legend:

Unmodified
Added
Removed
  • remote_control/puzzlebox_brainstorms_client_interface.py

    r71 r73  
    3131import puzzlebox_brainstorms_configuration as configuration 
    3232import puzzlebox_brainstorms_client as client 
    33 import puzzlebox_brainstorms_client_interface_component as component 
    34 import puzzlebox_brainstorms_client_interface_button as interface_button 
    3533#import puzzlebox_logger 
    3634 
     
    4139DEBUG = 1 
    4240 
    43 SERVER_HOST = configuration.SERVER_HOST 
    44 SERVER_PORT = configuration.SERVER_PORT 
     41BRAINSTORMS_SERVER_HOST = configuration.BRAINSTORMS_SERVER_HOST 
     42BRAINSTORMS_SERVER_PORT = configuration.BRAINSTORMS_SERVER_PORT 
    4543 
    4644THINKGEAR_SERVER_HOST = configuration.THINKGEAR_SERVER_HOST 
    47 THINKGEAR_SERVER_PORT = configuration.THINKGEAR_SERVER_PORT  
    48  
    49 THINKGEAR_DELIMITER = '\r' 
    50  
    51 THINKGEAR_PARAMETERS = {"enableRawOutput": False, "format": "Json"} 
     45THINKGEAR_SERVER_PORT = configuration.THINKGEAR_SERVER_PORT 
     46 
     47THINKGEAR_DELIMITER = configuration.THINKGEAR_DELIMITER 
     48 
     49THINKGEAR_CONFIGURATION_PARAMETERS = configuration.THINKGEAR_CONFIGURATION_PARAMETERS 
     50 
     51THINKGEAR_POWER_THRESHOLDS = configuration.THINKGEAR_POWER_THRESHOLDS 
     52 
     53NXT_BLUETOOTH_DEVICE = configuration.NXT_BLUETOOTH_DEVICE 
    5254 
    5355##################################################################### 
     
    5557##################################################################### 
    5658 
    57 class puzzlebox_brainstorms_client_interface_qt(QtGui.QWidget, Ui_Form, \ 
    58                                                      client.puzzlebox_brainstorms_client): 
     59class puzzlebox_brainstorms_client_interface( \ 
     60              QtGui.QWidget, Ui_Form, \ 
     61              client.puzzlebox_brainstorms_client): 
    5962         
    6063        def __init__(self, log, DEBUG=DEBUG, parent = None): 
     
    7982                 
    8083                # Display communication port for LEGO Mindstorms NXT device 
    81                 self.lineEditBluetoothPort.setText(configuration.BLUETOOTH_DEVICE) 
     84                self.lineEditBluetoothPort.setText(NXT_BLUETOOTH_DEVICE) 
    8285                 
    8386                # Bluetooth connection control not available 
     
    8689                # Set concentration threshold value 
    8790                concentration_threshold = \ 
    88                         self.getMinimumThreshold(configuration.POWER_THRESHOLDS['concentration']) 
     91                        self.getMinimumThreshold(THINKGEAR_POWER_THRESHOLDS['concentration']) 
    8992                self.spinBoxConcentrationThreshold.setValue(concentration_threshold) 
    9093                self.spinBoxConcentrationThreshold.update() 
     
    9598                # Set relaxation threshold value 
    9699                relaxation_threshold = \ 
    97                         self.getMinimumThreshold(configuration.POWER_THRESHOLDS['relaxation']) 
     100                        self.getMinimumThreshold(THINKGEAR_POWER_THRESHOLDS['relaxation']) 
    98101                self.spinBoxRelaxationThreshold.setValue(relaxation_threshold) 
    99102                self.spinBoxRelaxationThreshold.update() 
     
    161164                 
    162165                 
    163                 self.connect(self.pushButtonBluetoothConnect, \ 
    164                                   QtCore.SIGNAL("clicked()"), \ 
    165                                   self.test) 
     166                #self.connect(self.pushButtonBluetoothConnect, \ 
     167                                  #QtCore.SIGNAL("clicked()"), \ 
     168                                  #self.test) 
    166169         
    167170         
     
    183186                self.thinkgearClientTcpSocket.readyRead.connect(self.printReply) 
    184187                self.thinkgearClientTcpSocket.error.connect(self.displayError) 
    185  
    186                 self.sendCommand(THINKGEAR_PARAMETERS, self.thinkgearClientTcpSocket, THINKGEAR_SERVER_HOST, THINKGEAR_SERVER_PORT) 
     188                 
     189                self.sendCommand(THINKGEAR_CONFIGURATION_PARAMETERS, \ 
     190                                 self.thinkgearClientTcpSocket, \ 
     191                                 THINKGEAR_SERVER_HOST, \ 
     192                                 THINKGEAR_SERVER_PORT) 
    187193         
    188194         
     
    190196         
    191197        def printReply(self, reply=None): 
    192  
     198                 
    193199                socket = self.thinkgearClientTcpSocket 
    194  
     200                 
    195201                socket_buffer = socket.readAll() 
    196  
     202                 
    197203                for packet in socket_buffer.split(THINKGEAR_DELIMITER): 
    198  
     204                         
    199205                        if packet != '': 
    200206                                 
    201207                                data = json.loads(packet.data()) 
    202  
     208                                 
    203209                                if self.DEBUG: 
    204210                                        print "<-- [%s] Received:" % socket.name, 
    205211                                        print data 
    206  
     212                                 
    207213                                self.processPacketThinkGear(data) 
    208214         
    209215         
    210216        ################################################################## 
    211  
     217         
    212218        def processPacketThinkGear(self, packet): 
    213  
     219                 
    214220                if ('eSense' in packet.keys()): 
    215  
     221                                 
    216222                        if ('attention' in packet['eSense'].keys()): 
    217223                                self.progressBarConcentration.setValue(packet['eSense']['attention']) 
    218  
     224                         
    219225                        if ('meditation' in packet['eSense'].keys()): 
    220226                                self.progressBarRelaxation.setValue(packet['eSense']['meditation'])                      
    221  
    222                  
     227         
     228         
    223229        ################################################################## 
    224230         
     
    230236                elif socketError == QtNetwork.QAbstractSocket.HostNotFoundError: 
    231237                        QtGui.QMessageBox.information(self, "Puzzlebox Brainstorms Client", 
    232                                           "The server host was not found. Please check the host name and " 
    233                                           "port settings.") 
     238                                        "The server host was not found. Please check the host name and " 
     239                                        "port settings.") 
    234240                 
    235241                elif socketError == QtNetwork.QAbstractSocket.ConnectionRefusedError: 
    236242                        QtGui.QMessageBox.information(self, "Puzzlebox Brainstorms Client", 
    237                                           "The server connection was refused by the peer. Make sure the " 
    238                                           "server is running, and check that the host name " 
    239                                           "and port settings are correct.") 
     243                                        "The server connection was refused by the peer. Make sure the " 
     244                                        "server is running, and check that the host name " 
     245                                        "and port settings are correct.") 
    240246                 
    241247                else: 
    242248                        QtGui.QMessageBox.information(self, "Puzzlebox Brainstorms Client", 
    243                                           "The following error occurred: %s." % self.brainstormsClientTcpSocket.errorString()) 
     249                                        "The following error occurred: %s." % \ 
     250                                           self.brainstormsClientTcpSocket.errorString()) 
    244251         
    245252         
     
    270277        ################################################################## 
    271278         
    272         def sendCommand(self, command, socket, host=SERVER_HOST, port=SERVER_PORT): 
     279        def sendCommand(self, \ 
     280                             command, \ 
     281                             socket, \ 
     282                             host=BRAINSTORMS_SERVER_HOST, \ 
     283                             port=BRAINSTORMS_SERVER_PORT): 
    273284                 
    274285                if self.DEBUG: 
     
    276287                        print command 
    277288                 
    278                 #self.blockSize = 0 
    279 ##              self.brainstormsClientTcpSocket.abort() 
    280 ##              self.brainstormsClientTcpSocket.connectToHost(SERVER_HOST, SERVER_PORT) 
    281 ##               
    282 ##              data = json.dumps(command) 
    283 ##              self.brainstormsClientTcpSocket.write(data) 
    284  
    285289                socket.abort() 
    286290                socket.connectToHost(host, port) 
     
    294298        def test(self): 
    295299                 
    296                 print "nice." 
    297                  
    298                 self.progressBarConcentration.setValue(50) 
     300                print "Test Successful" 
    299301 
    300302 
     
    313315        app = QtGui.QApplication(sys.argv) 
    314316         
    315         window = puzzlebox_brainstorms_client_interface_qt(log, DEBUG) 
     317        window = puzzlebox_brainstorms_client_interface(log, DEBUG) 
    316318        window.show() 
    317319         
    318320        app.exec_() 
    319321 
    320  
    321  
  • remote_control/puzzlebox_brainstorms_client_interface_pygame.py

    r71 r73  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Puzzlebox - Brainstorms - Client Interface 
     4# Puzzlebox - Brainstorms - Client Interface - Pygame 
    55# 
    66# Copyright Puzzlebox Productions, LLC (2010) 
     
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.06.10 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    2323 
    2424import puzzlebox_brainstorms_configuration as configuration 
    25 import puzzlebox_brainstorms_client as client 
    26 import puzzlebox_brainstorms_client_interface_component as component 
    27 import puzzlebox_brainstorms_client_interface_button as interface_button 
     25import puzzlebox_brainstorms_client_twisted as client 
     26import puzzlebox_brainstorms_client_interface_pygame_component as component 
     27import puzzlebox_brainstorms_client_interface_pygame_button as interface_button 
    2828#import puzzlebox_logger 
    2929 
     
    3636FLIP = 1 
    3737 
    38 DISCRETE_CONTROL_COMMANDS = configuration.DISCRETE_CONTROL_COMMANDS 
    39  
    40 SERVER_HOST = configuration.SERVER_HOST 
    41 SERVER_PORT = configuration.SERVER_PORT 
    42  
    43 DISPLAY_WINDOW_X_COORDINATE = configuration.DISPLAY_WINDOW_X_COORDINATE 
    44 DISPLAY_WINDOW_Y_COORDINATE = configuration.DISPLAY_WINDOW_Y_COORDINATE 
    45 DISPLAY_WINDOW_X_DIMENSION = configuration.DISPLAY_WINDOW_X_DIMENSION 
    46 DISPLAY_WINDOW_Y_DIMENSION = configuration.DISPLAY_WINDOW_Y_DIMENSION 
    47  
    48 WINDOW_BACKGROUND_COLOR = configuration.WINDOW_BACKGROUND_COLOR 
    49  
    50 IMAGE_DIRECTORY = configuration.IMAGE_DIRECTORY 
    51  
    52 BUTTON_LAYOUT = configuration.BUTTON_LAYOUT 
     38DISCRETE_CONTROL_COMMANDS = configuration.BRAINSTORMS_DISCRETE_CONTROL_COMMANDS 
     39 
     40SERVER_HOST = configuration.BRAINSTORMS_SERVER_HOST 
     41SERVER_PORT = configuration.BRAINSTORMS_SERVER_PORT 
     42 
     43MAX_CONNECTION_ATTEMPTS = configuration.TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS 
     44 
     45DISPLAY_WINDOW_X_COORDINATE = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE 
     46DISPLAY_WINDOW_Y_COORDINATE = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE 
     47DISPLAY_WINDOW_X_DIMENSION = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION 
     48DISPLAY_WINDOW_Y_DIMENSION = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION 
     49 
     50WINDOW_BACKGROUND_COLOR = configuration.CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR 
     51 
     52IMAGE_DIRECTORY = configuration.CLIENT_PYGAME_IMAGE_DIRECTORY 
     53 
     54BUTTON_LAYOUT = configuration.CLIENT_PYGAME_BUTTON_LAYOUT 
    5355 
    5456##################################################################### 
     
    5658##################################################################### 
    5759 
    58 class puzzlebox_brainstorms_client_interface( \ 
    59          component.puzzlebox_brainstorms_client_interface_component, \ 
    60          client.puzzlebox_brainstorms_client): 
     60class puzzlebox_brainstorms_client_interface_pygame( \ 
     61         component.puzzlebox_brainstorms_client_interface_pygame_component, \ 
     62         client.puzzlebox_brainstorms_client_twisted): 
    6163         
    6264        def __init__(self, log, \ 
     
    7779                self.window_background_color = window_background_color 
    7880                 
    79                 self.server_host = configuration.SERVER_HOST 
    80                 self.server_port = configuration.SERVER_PORT 
    81                 self.max_connection_attempts = configuration.MAX_CONNECTION_ATTEMPTS 
     81                self.server_host = SERVER_HOST 
     82                self.server_port = SERVER_PORT 
     83                self.max_connection_attempts = MAX_CONNECTION_ATTEMPTS 
    8284                 
    8385                if (os.name == "nt") or (os.name == "dos"): 
     
    208210                         
    209211                        new_button = \ 
    210                            interface_button.puzzlebox_brainstorms_client_interface_button( \ 
     212                           interface_button.puzzlebox_brainstorms_client_interface_pygame_button( \ 
    211213                                   self.pygame, \ 
    212214                                   self.screen, \ 
  • remote_control/puzzlebox_brainstorms_client_interface_pygame_button.py

    r71 r73  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Puzzlebox - Brainstorms - Client Interface - Button 
     4# Puzzlebox - Brainstorms - Client Interface - Pygame - Button 
    55# 
    66# Copyright Puzzlebox Productions, LLC (2010) 
     
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.02.04 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
    1414 
    15 import puzzlebox_brainstorms_client_interface_component as component 
     15import puzzlebox_brainstorms_client_interface_pygame_component as component 
    1616 
    1717##################################################################### 
     
    1919##################################################################### 
    2020 
    21 class puzzlebox_brainstorms_client_interface_button( \ 
    22    component.puzzlebox_brainstorms_client_interface_component): 
     21class puzzlebox_brainstorms_client_interface_pygame_button( \ 
     22   component.puzzlebox_brainstorms_client_interface_pygame_component): 
    2323         
    2424        def __init__(self, pygame, screen, \ 
  • remote_control/puzzlebox_brainstorms_client_interface_pygame_component.py

    r71 r73  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Puzzlebox - Brainstorms - Client Interface - Component 
     4# Puzzlebox - Brainstorms - Client Interface - Pygame - Component 
    55# 
    66# Copyright Puzzlebox Productions, LLC (2010) 
     
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.02.01 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    1717##################################################################### 
    1818 
    19 class puzzlebox_brainstorms_client_interface_component: 
     19class puzzlebox_brainstorms_client_interface_pygame_component: 
    2020         
    2121        def __init__(self, DEBUG = 0): 
  • remote_control/puzzlebox_brainstorms_client_interface_pygame_local.py

    r71 r73  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Puzzlebox - Brainstorms - Client Interface - Local 
     4# Puzzlebox - Brainstorms - Client Interface - Pygame - Local 
    55# 
    66# Copyright Puzzlebox Productions, LLC (2010) 
     
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.06.10 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    2323 
    2424import puzzlebox_brainstorms_configuration as configuration 
    25 import puzzlebox_brainstorms_client_interface as client_interface 
    26 import puzzlebox_brainstorms_server as server 
     25import puzzlebox_brainstorms_client_interface_pygame as client_interface 
     26import puzzlebox_brainstorms_server_twisted as server 
    2727#import puzzlebox_logger 
    2828 
     
    3333DEBUG = 1 
    3434 
    35 SERVER_INTERFACE = configuration.SERVER_INTERFACE 
    36 SERVER_HOST = configuration.SERVER_HOST 
    37 SERVER_PORT = configuration.SERVER_PORT 
     35SERVER_INTERFACE = configuration.BRAINSTORMS_SERVER_INTERFACE 
     36SERVER_HOST = configuration.BRAINSTORMS_SERVER_HOST 
     37SERVER_PORT = configuration.BRAINSTORMS_SERVER_PORT 
    3838 
    39 DISPLAY_WINDOW_X_COORDINATE = configuration.DISPLAY_WINDOW_X_COORDINATE 
    40 DISPLAY_WINDOW_Y_COORDINATE = configuration.DISPLAY_WINDOW_Y_COORDINATE 
    41 DISPLAY_WINDOW_X_DIMENSION = configuration.DISPLAY_WINDOW_X_DIMENSION 
    42 DISPLAY_WINDOW_Y_DIMENSION = configuration.DISPLAY_WINDOW_Y_DIMENSION 
     39DISPLAY_WINDOW_X_COORDINATE = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE 
     40DISPLAY_WINDOW_Y_COORDINATE = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE 
     41DISPLAY_WINDOW_X_DIMENSION = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION 
     42DISPLAY_WINDOW_Y_DIMENSION = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION 
    4343 
    44 WINDOW_BACKGROUND_COLOR = configuration.WINDOW_BACKGROUND_COLOR 
     44WINDOW_BACKGROUND_COLOR = configuration.CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR 
    4545 
    4646##################################################################### 
     
    9494         
    9595                 
    96         embedded_server = server.puzzlebox_brainstorms_server(log, DEBUG=DEBUG) 
     96        embedded_server = server.puzzlebox_brainstorms_server_twisted(log, DEBUG=DEBUG) 
    9797         
    9898        if DEBUG: 
     
    103103         
    104104 
    105         interface = client_interface.puzzlebox_brainstorms_client_interface( \ 
     105        interface = client_interface.puzzlebox_brainstorms_client_interface_pygame( \ 
    106106                                             log, \ 
    107107                                             display_window_x_coordinate, \ 
  • remote_control/puzzlebox_brainstorms_client_interface_pygame_network.py

    r71 r73  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Puzzlebox - Brainstorms - Client Interface - Network 
     4# Puzzlebox - Brainstorms - Client Interface - Pygame - Network 
    55# 
    66# Copyright Puzzlebox Productions, LLC (2010) 
     
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.06.10 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    2323 
    2424import puzzlebox_brainstorms_configuration as configuration 
    25 import puzzlebox_brainstorms_client_interface as client_interface 
     25import puzzlebox_brainstorms_client_interface_pygame as client_interface 
    2626#import puzzlebox_logger 
    2727 
     
    3232DEBUG = 1 
    3333 
    34 SERVER_HOST = configuration.SERVER_HOST 
    35 SERVER_PORT = configuration.SERVER_PORT 
     34SERVER_HOST = configuration.BRAINSTORMS_SERVER_HOST 
     35SERVER_PORT = configuration.BRAINSTORMS_SERVER_PORT 
    3636 
    37 DISPLAY_WINDOW_X_COORDINATE = configuration.DISPLAY_WINDOW_X_COORDINATE 
    38 DISPLAY_WINDOW_Y_COORDINATE = configuration.DISPLAY_WINDOW_Y_COORDINATE 
    39 DISPLAY_WINDOW_X_DIMENSION = configuration.DISPLAY_WINDOW_X_DIMENSION 
    40 DISPLAY_WINDOW_Y_DIMENSION = configuration.DISPLAY_WINDOW_Y_DIMENSION 
     37DISPLAY_WINDOW_X_COORDINATE = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE 
     38DISPLAY_WINDOW_Y_COORDINATE = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE 
     39DISPLAY_WINDOW_X_DIMENSION = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION 
     40DISPLAY_WINDOW_Y_DIMENSION = configuration.CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION 
    4141 
    42 WINDOW_BACKGROUND_COLOR = configuration.WINDOW_BACKGROUND_COLOR 
     42WINDOW_BACKGROUND_COLOR = configuration.CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR 
    4343 
    4444##################################################################### 
     
    8989         
    9090         
    91         interface = client_interface.puzzlebox_brainstorms_client_interface( \ 
     91        interface = client_interface.puzzlebox_brainstorms_client_interface_pygame( \ 
    9292                                             log, \ 
    9393                                             display_window_x_coordinate, \ 
  • remote_control/puzzlebox_brainstorms_client_twisted.py

    r71 r73  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Puzzlebox - Brainstorms - Client 
     4# Puzzlebox - Brainstorms - Client - Twisted 
    55# 
    66# Copyright Puzzlebox Productions, LLC (2010) 
     
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.06.16 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    2828DEBUG = 1 
    2929 
    30 SERVER_HOST = configuration.SERVER_HOST 
    31 SERVER_PORT = configuration.SERVER_PORT 
    32  
    33 MAX_CONNECTION_ATTEMPTS = configuration.MAX_CONNECTION_ATTEMPTS 
    34 NO_REPLY_WAIT = configuration.NO_REPLY_WAIT 
     30SERVER_HOST = configuration.BRAINSTORMS_SERVER_HOST 
     31SERVER_PORT = configuration.BRAINSTORMS_SERVER_PORT 
     32 
     33MAX_CONNECTION_ATTEMPTS = configuration.TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS 
     34NO_REPLY_WAIT = configuration.TWISTED_CLIENT_NO_REPLY_WAIT 
    3535 
    3636##################################################################### 
     
    3838##################################################################### 
    3939 
    40 class puzzlebox_brainstorms_client: 
     40class puzzlebox_brainstorms_client_twisted: 
    4141         
    4242        def __init__(self, log, \ 
     
    5757                         max_connection_attempts=MAX_CONNECTION_ATTEMPTS): 
    5858                 
    59                 factory = puzzlebox_brainstorms_client_send_command_factory(self.log, \ 
     59                factory = puzzlebox_brainstorms_client_twisted_factory(self.log, \ 
    6060                                                       command, \ 
    6161                                                       self.server_host, \ 
     
    7373##################################################################### 
    7474 
    75 class puzzlebox_brainstorms_client_send_command_protocol(protocol.Protocol): 
     75class puzzlebox_brainstorms_client_twisted_protocol(protocol.Protocol): 
    7676         
    7777        def __init__(self): 
     
    144144##################################################################### 
    145145 
    146 class puzzlebox_brainstorms_client_send_command_factory(protocol.ClientFactory): 
     146class puzzlebox_brainstorms_client_twisted_factory(protocol.ClientFactory): 
    147147         
    148148        def __init__(self, log, \ 
     
    163163                 
    164164                self.protocol = \ 
    165                    puzzlebox_brainstorms_client_send_command_protocol 
     165                   puzzlebox_brainstorms_client_twisted_protocol 
    166166                 
    167167                self.replyDefer = defer.Deferred() 
     
    209209##################################################################### 
    210210 
    211 class puzzlebox_brainstorms_client_command_line(puzzlebox_brainstorms_client): 
     211class puzzlebox_brainstorms_client_twisted_command_line(puzzlebox_brainstorms_client_twisted): 
    212212         
    213213        def __init__(self, log, \ 
     
    276276        #log.info("Command parameters: %s" % command_parameters) 
    277277         
    278         client = puzzlebox_brainstorms_client_command_line(log, \ 
     278        client = puzzlebox_brainstorms_client_twisted_command_line(log, \ 
    279279                                                           command_parameters, \ 
    280280                                                           server_host=SERVER_HOST, \ 
  • remote_control/puzzlebox_brainstorms_configuration.ini

    r67 r73  
    33##################################################################### 
    44 
    5 BLUETOOTH_DEVICE = 'COM1' 
     5NXT_BLUETOOTH_DEVICE = 'COM1' 
    66 
    7 #DISCRETE_CONTROL_COMMANDS = True 
     7#BRAINSTORMS_DISCRETE_CONTROL_COMMANDS = True 
    88 
    99##################################################################### 
     
    1111##################################################################### 
    1212 
    13 SERVER_INTERFACE = '' # listen on all of server's network interfaces 
    14 #SERVER_HOST = '172.16.1.1' 
    15 SERVER_HOST = '127.0.0.1' # localhost 
    16 SERVER_PORT = 8194 
     13BRAINSTORMS_SERVER_INTERFACE = '' # listen on all of server's network interfaces 
     14BRAINSTORMS_SERVER_HOST = '127.0.0.1' # localhost 
     15#BRAINSTORMS_SERVER_HOST = '172.16.1.1' 
     16BRAINSTORMS_SERVER_PORT = 8194 
    1717 
    1818THINKGEAR_SERVER_HOST = '127.0.0.1' 
     
    2424##################################################################### 
    2525 
    26 MOTORS_MOUNTED_BACKWARDS = True 
    27 MOTOR_PORT_RIGHT = 'a' 
    28 MOTOR_PORT_LEFT = 'b' 
     26NXT_MOTORS_MOUNTED_BACKWARDS = True 
     27NXT_MOTOR_PORT_RIGHT = 'a' 
     28NXT_MOTOR_PORT_LEFT = 'b' 
    2929 
    3030 
     
    3333##################################################################### 
    3434 
    35 ENABLE_THINKGEAR_AUTHORIZATION = False 
     35THINKGEAR_AUTHORIZATION_ENABLED = False 
    3636 
    3737THINKGEAR_AUTHORIZATION_REQUEST = { "appName": "Puzzlebox Brainstorms", "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408" } 
     
    3939 
    4040##################################################################### 
    41 # Client Interface configuration [Qt] 
     41# Client Interface configuration 
    4242##################################################################### 
    4343 
    44 POWER_THRESHOLDS = {} 
     44THINKGEAR_POWER_THRESHOLDS = {} 
    4545 
    46 POWER_THRESHOLDS['concentration'] = { 0: 0, 10: 0, 20: 0, 30: 0, 40: 0, 50: 0, 60: 60, 70: 70, 75: 75, 80: 80, 90: 85, 100: 90 } 
     46THINKGEAR_POWER_THRESHOLDS['concentration'] = { 0: 0, 10: 0, 20: 0, 30: 0, 40: 0, 50: 0, 60: 60, 70: 70, 75: 75, 80: 80, 90: 85, 100: 90 } 
    4747 
    48 POWER_THRESHOLDS['relaxation'] = { 0: 0, 10: 0, 20: 0, 30: 0, 40: 0, 50: 0, 60: 0, 70: 0, 80: 10, 90: 15, 100: 20 } 
     48THINKGEAR_POWER_THRESHOLDS['relaxation'] = { 0: 0, 10: 0, 20: 0, 30: 0, 40: 0, 50: 0, 60: 0, 70: 0, 80: 10, 90: 15, 100: 20 } 
    4949 
    50  
    51 ##################################################################### 
    52 # Logging 
    53 ##################################################################### 
    54  
    55 #LOGFILE_DIR = '/var/log/puzzlebox' 
    56  
  • remote_control/puzzlebox_brainstorms_configuration.py

    r67 r73  
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.06.22 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    2222DEBUG = 1 
    2323 
    24 CONFIGURATION_FILE_PATH = 'puzzlebox_brainstorms_configuration.ini' 
    25  
    26 DISCRETE_CONTROL_COMMANDS = True 
    27  
    28 DEFAULT_WINDOWS_BLUETOOTH_DEVICE = 'COM1' 
    29 DEFAULT_LINUX_BLUETOOTH_DEVICE = '/dev/rfcomm0' 
     24BRAINSTORMS_CONFIGURATION_FILE_PATH = 'puzzlebox_brainstorms_configuration.ini' 
     25 
     26BRAINSTORMS_DISCRETE_CONTROL_COMMANDS = True 
     27 
    3028 
    3129##################################################################### 
     
    3937 
    4038DEFAULT_LOG_LEVEL = LOG_LEVEL_DEBUG 
    41 DEFAULT_LOGFILE = 'puzzlebox' 
     39DEFAULT_LOGFILE = 'brainstorms' 
    4240 
    4341LOGFILE_DIR = '/var/log/puzzlebox' 
     
    4947SPLIT_LOGFILES = False 
    5048 
    51 #BRAINSTORMS_LOGFILE = 'brainstorms' 
    52  
    5349 
    5450##################################################################### 
     
    5652##################################################################### 
    5753 
    58 SERVER_INTERFACE = '' # listen on all of server's network interfaces 
    59 #SERVER_HOST = '172.16.1.1' 
    60 SERVER_HOST = '127.0.0.1' # localhost 
    61 SERVER_PORT = 8194 
     54BRAINSTORMS_SERVER_INTERFACE = '' # listen on all of server's network interfaces 
     55BRAINSTORMS_SERVER_HOST = '127.0.0.1' # localhost 
     56BRAINSTORMS_SERVER_PORT = 8194 
    6257 
    6358THINKGEAR_SERVER_HOST = '127.0.0.1' 
     
    6964##################################################################### 
    7065 
     66DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS = 'COM1' 
     67DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX = '/dev/rfcomm0' 
     68 
    7169if (sys.platform == 'win32'): 
    72         BLUETOOTH_DEVICE = DEFAULT_WINDOWS_BLUETOOTH_DEVICE 
     70        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS 
    7371else: 
    74         BLUETOOTH_DEVICE = DEFAULT_LINUX_BLUETOOTH_DEVICE 
    75  
    76 MOTORS_MOUNTED_BACKWARDS = True 
    77 MOTOR_PORT_RIGHT = 'a' 
    78 MOTOR_PORT_LEFT = 'b' 
    79 DEFAULT_RC_COMMAND = 'test_drive' 
     72        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX 
     73 
     74NXT_MOTORS_MOUNTED_BACKWARDS = True 
     75NXT_MOTOR_PORT_RIGHT = 'a' 
     76NXT_MOTOR_PORT_LEFT = 'b' 
     77NXT_DEFAULT_RC_COMMAND = 'test_drive' 
    8078 
    8179 
     
    8482##################################################################### 
    8583 
    86 MAX_COMPONENTS = 16 
     84TWISTED_SERVER_MAX_COMPONENTS = 16 
    8785 
    8886 
     
    9189##################################################################### 
    9290 
    93 MAX_CONNECTION_ATTEMPTS = 5 
    94 HEALTH_CHECK_CONNECTION_ATTEMPTS = 5 
    95 NO_REPLY_WAIT = 10 # how many seconds before considering a component dead 
     91TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS = 5 
     92TWISTED_CLIENT_NO_REPLY_WAIT = 10 # how many seconds before considering a component dead 
    9693 
    9794 
     
    10097##################################################################### 
    10198 
    102 ENABLE_THINKGEAR_AUTHORIZATION = False 
     99THINKGEAR_DELIMITER = '\r' 
     100 
     101THINKGEAR_CONFIGURATION_PARAMETERS = {"enableRawOutput": False, "format": "Json"} 
     102 
     103THINKGEAR_AUTHORIZATION_ENABLED = False 
    103104 
    104105THINKGEAR_AUTHORIZATION_REQUEST = { \ 
    105         "appName": "Puzzlebox Brainstorms", \ 
    106         "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408" 
    107         } 
     106        "appName": "Puzzlebox Brainstorms", \ 
     107        "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408" 
     108} 
    108109 
    109110 
     
    112113##################################################################### 
    113114 
    114 POWER_THRESHOLDS = { \ 
     115THINKGEAR_POWER_THRESHOLDS = { \ 
    115116         
    116117        'concentration': { \ 
     
    143144                }, \ 
    144145         
    145 } # POWER_THRESHOLDS 
     146} # THINKGEAR_POWER_THRESHOLDS 
    146147 
    147148 
     
    150151##################################################################### 
    151152 
    152 DISPLAY_WINDOW_X_COORDINATE = 0 
    153 DISPLAY_WINDOW_Y_COORDINATE = 0 
    154 DISPLAY_WINDOW_X_DIMENSION = 254 
    155 DISPLAY_WINDOW_Y_DIMENSION = 424 
    156  
    157 #WINDOW_BACKGROUND_COLOR = (255,255,255) # white background 
    158 #WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background 
    159 #WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background 
    160 WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background 
    161  
    162 IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images') 
     153CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE = 0 
     154CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE = 0 
     155CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION = 254 
     156CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION = 424 
     157 
     158#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (255,255,255) # white background 
     159#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background 
     160#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background 
     161CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background 
     162 
     163CLIENT_PYGAME_IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images') 
    163164 
    164165# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key 
    165 BUTTON_LAYOUT = { \ 
     166CLIENT_PYGAME_BUTTON_LAYOUT = { \ 
    166167         
    167168        'left': { \ 
     
    246247##################################################################### 
    247248 
    248 if os.path.exists(CONFIGURATION_FILE_PATH): 
    249          
    250         file = open(CONFIGURATION_FILE_PATH, 'r') 
     249if os.path.exists(BRAINSTORMS_CONFIGURATION_FILE_PATH): 
     250         
     251        file = open(BRAINSTORMS_CONFIGURATION_FILE_PATH, 'r') 
    251252         
    252253        for line in file.readlines(): 
     
    261262                        exec line 
    262263                except: 
    263                         if DEBUG: 
    264                                 print "Error recognizing configuration option:", 
     264                        if DEBUG: 
     265                                print "Error recognizing Puzzlebox Brainstorms configuration option:", 
    265266                                print line 
    266267 
  • remote_control/puzzlebox_brainstorms_remote_control.py

    r42 r73  
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.05.03 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    2727DEBUG = 2 
    2828 
    29 DISCRETE_CONTROL_COMMANDS = configuration.DISCRETE_CONTROL_COMMANDS 
    30  
    31 BLUETOOTH_DEVICE = configuration.BLUETOOTH_DEVICE 
    32 MOTORS_MOUNTED_BACKWARDS = configuration.MOTORS_MOUNTED_BACKWARDS 
    33 MOTOR_PORT_RIGHT = configuration.MOTOR_PORT_RIGHT 
    34 MOTOR_PORT_LEFT = configuration.MOTOR_PORT_LEFT 
    35 DEFAULT_RC_COMMAND = configuration.DEFAULT_RC_COMMAND 
     29DISCRETE_CONTROL_COMMANDS = configuration.BRAINSTORMS_DISCRETE_CONTROL_COMMANDS 
     30 
     31BLUETOOTH_DEVICE = configuration.NXT_BLUETOOTH_DEVICE 
     32MOTORS_MOUNTED_BACKWARDS = configuration.NXT_MOTORS_MOUNTED_BACKWARDS 
     33MOTOR_PORT_RIGHT = configuration.NXT_MOTOR_PORT_RIGHT 
     34MOTOR_PORT_LEFT = configuration.NXT_MOTOR_PORT_LEFT 
     35DEFAULT_RC_COMMAND = configuration.NXT_DEFAULT_RC_COMMAND 
    3636 
    3737##################################################################### 
     
    3939##################################################################### 
    4040 
    41 class puzzlebox_brainstorms_rc: 
     41class puzzlebox_brainstorms_remote_control: 
    4242         
    4343        def __init__(self, \ 
     
    335335         
    336336         
    337         rc = puzzlebox_brainstorms_rc(device=device, command=command, DEBUG=DEBUG) 
     337        rc = puzzlebox_brainstorms_remote_control(device=device, command=command, DEBUG=DEBUG) 
    338338         
    339339        if rc.connection == None: 
  • remote_control/puzzlebox_brainstorms_server_twisted.py

    r71 r73  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Puzzlebox - Brainstorms - Server 
     4# Puzzlebox - Brainstorms - Server - Twisted 
    55# 
    66# Copyright Puzzlebox Productions, LLC (2010) 
     
    99# For more information please refer to http://www.gnu.org/copyleft/gpl.html 
    1010# 
    11 # Last Update: 2010.06.16 
     11# Last Update: 2010.06.28 
    1212# 
    1313##################################################################### 
     
    2929DEBUG = 1 
    3030 
    31 DISCRETE_CONTROL_COMMANDS = configuration.DISCRETE_CONTROL_COMMANDS 
     31DISCRETE_CONTROL_COMMANDS = configuration.BRAINSTORMS_DISCRETE_CONTROL_COMMANDS 
    3232 
    33 SERVER_INTERFACE = configuration.SERVER_INTERFACE 
    34 SERVER_PORT = configuration.SERVER_PORT 
     33SERVER_INTERFACE = configuration.BRAINSTORMS_SERVER_INTERFACE 
     34SERVER_PORT = configuration.BRAINSTORMS_SERVER_PORT 
     35 
     36BLUETOOTH_DEVICE = configuration.NXT_BLUETOOTH_DEVICE 
    3537 
    3638##################################################################### 
     
    3840##################################################################### 
    3941 
    40 class puzzlebox_brainstorms_server(protocol.ServerFactory): 
     42class puzzlebox_brainstorms_server_twisted(protocol.ServerFactory): 
    4143         
    4244        def __init__(self, log, DEBUG=DEBUG): 
     
    4547                self.DEBUG = DEBUG 
    4648                 
    47                 self.protocol = puzzlebox_brainstorms_server_protocol 
     49                self.protocol = puzzlebox_brainstorms_server_twisted_protocol 
    4850         
    4951         
     
    8082                #os.system(command_line) 
    8183                 
    82                 rc = remote_control.puzzlebox_brainstorms_rc( \ 
    83                         device=configuration.BLUETOOTH_DEVICE, \ 
     84                rc = remote_control.puzzlebox_brainstorms_remote_control( \ 
     85                        device=BLUETOOTH_DEVICE, \ 
    8486                        command=command, \ 
    8587                        DEBUG=DEBUG) 
     
    116118##################################################################### 
    117119 
    118 class puzzlebox_brainstorms_server_protocol(protocol.Protocol): 
     120class puzzlebox_brainstorms_server_twisted_protocol(protocol.Protocol): 
    119121         
    120122        def __init__(self): 
     
    186188         
    187189         
    188         server = puzzlebox_brainstorms_server(log, DEBUG=DEBUG) 
     190        server = puzzlebox_brainstorms_server_twisted(log, DEBUG=DEBUG) 
    189191         
    190192        if DEBUG: 
Note: See TracChangeset for help on using the changeset viewer.