source: trunk/brainstorms/brainstorms-local.py @ 219

Last change on this file since 219 was 219, checked in by sc, 12 years ago

trunk/synapse/interface/puzzlebox_synapse_interface_design.ui:

  • cleaner alignment of border lines

trunk/brainstorms/interface/puzzlebox_brainstorms_interface_design.ui:

  • RC Helicopter tab added
  • NXT device selection dropdown added
  • LEGO NXT Configuration section added to Control Panel
  • Message Sending buttons added

trunk/brainstorms/Puzzlebox/Brainstorms/Configuration.py:

  • AUTOCONNECT_TO_NXT_DEVICE added

trunk/brainstorms/brainstorms-local.py:

  • AUTOCONNECT_TO_NXT_DEVICE added

trunk/brainstorms/puzzlebox_brainstorms_configuration.ini:

  • AUTOCONNECT_TO_NXT_DEVICE added
  • Property svn:executable set to *
File size: 5.7 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Puzzlebox - Brainstorms - Interface - Local
5#
6# Copyright Puzzlebox Productions, LLC (2010)
7#
8# This code is released under the GNU Pulic License (GPL) version 2
9# For more information please refer to http://www.gnu.org/copyleft/gpl.html
10
11__changelog__ = """\
12Last Update: 2010.11.25
13
14"""
15
16import os, sys
17import signal
18
19try:
20        import PySide as PyQt4
21        from PySide import QtCore, QtGui, QtNetwork
22except:
23        print "Using PyQt4 module"
24        from PyQt4 import QtCore, QtGui, QtNetwork
25else:
26        print "Using PySide module"
27
28#from PyQt4 import QtCore, QtGui, QtNetwork
29#from PySide import QtCore, QtGui, QtNetwork
30
31import Puzzlebox.Brainstorms.Configuration as configuration
32import Puzzlebox.Brainstorms.Interface as client_interface
33import Puzzlebox.Brainstorms.Client as brainstorms_client
34import Puzzlebox.Brainstorms.Server as server
35import Puzzlebox.Brainstorms.Remote_Control as remote_control
36#import puzzlebox_logger
37
38#####################################################################
39# Globals
40#####################################################################
41
42DEBUG = 1
43
44SERVER_INTERFACE = configuration.BRAINSTORMS_SERVER_INTERFACE
45SERVER_HOST = configuration.BRAINSTORMS_SERVER_HOST
46SERVER_PORT = configuration.BRAINSTORMS_SERVER_PORT
47
48CLIENT_NO_REPLY_WAIT = configuration.CLIENT_NO_REPLY_WAIT * 1000
49
50DELIMITER = configuration.BRAINSTORMS_DELIMITER
51
52BLUETOOTH_DEVICE = configuration.NXT_BLUETOOTH_DEVICE
53
54VARIABLE_CONTROL_DURATION = configuration.BRAINSTORMS_VARIABLE_CONTROL_DURATION
55
56#####################################################################
57# Classes
58#####################################################################
59
60#class puzzlebox_brainstorms_client_interface_local( \
61              #server.puzzlebox_brainstorms_network_server, \
62              #client_interface.puzzlebox_brainstorms_client_interface):
63       
64        #def __init__(self, log, \
65                          #server_interface=SERVER_INTERFACE, \
66                          #server_port=SERVER_PORT, \
67                          #DEBUG=DEBUG, \
68                          #parent=None):
69               
70                #self.log = log
71                #self.DEBUG = DEBUG
72               
73                #self.server_interface = server_interface
74                #self.server_port = server_port
75               
76                #QtGui.QWidget.__init__(self, parent)
77                #self.setupUi(self)
78               
79                #self.configureNetwork()
80               
81                #self.configureSettings()
82                #self.configureNetworkBrainstorms()
83                #self.connectWidgets()
84               
85                #self.drive_state = 'stop_motors'
86                #self.current_speed = 0
87               
88                #self.rc = remote_control.puzzlebox_brainstorms_remote_control( \
89                            #device=BLUETOOTH_DEVICE, \
90                            #DEBUG=DEBUG)
91
92
93######################################################################
94######################################################################
95
96#class puzzlebox_brainstorms_network_server_threaded( \
97              #QtCore.QThread, \
98              #server.puzzlebox_brainstorms_network_server):
99       
100        #def __init__(self, log, \
101                          #server_interface=SERVER_INTERFACE, \
102                          #server_port=SERVER_PORT, \
103                          #embedded_mode=True, \
104                          #DEBUG=DEBUG, \
105                          #parent=None):
106               
107                ##super(puzzlebox_brainstorms_network_server_threaded, self).__init__(parent)
108                #QtCore.QThread.__init__(self,parent)
109               
110                #self.log = log
111                #self.DEBUG = DEBUG
112               
113                #self.server_interface = server_interface
114                #self.server_port = server_port
115               
116                #self.embedded_mode=embedded_mode
117               
118                #self.configureNetwork()
119               
120                #self.rc = remote_control.puzzlebox_brainstorms_remote_control( \
121                            #device=BLUETOOTH_DEVICE, \
122                            #DEBUG=DEBUG)
123       
124       
125        ###################################################################
126       
127        #def run(self):
128               
129                #if self.DEBUG:
130                        #print "<---- [%s]: Main thread running" % self.socket.name
131               
132                #self.exec_()
133               
134                ##while True:
135                        ##print "server: alive"
136                        ##QtCore.QThread.sleep(1)
137
138
139#####################################################################
140# Functions
141#####################################################################
142
143#####################################################################
144# Main
145#####################################################################
146
147if __name__ == '__main__':
148       
149        # Perform correct KeyboardInterrupt handling
150        signal.signal(signal.SIGINT, signal.SIG_DFL)
151       
152        #log = puzzlebox_logger.puzzlebox_logger(logfile='client_interface')
153        log = None
154       
155        # Collect default settings and command line parameters
156        server_interface = SERVER_INTERFACE
157        server_host = SERVER_HOST
158        server_port = SERVER_PORT
159       
160        for each in sys.argv:
161               
162                if each.startswith("--interface="):
163                        server_interface = each[ len("--interface="): ]
164                if each.startswith("--host="):
165                        server_host = each[ len("--host="): ]
166                if each.startswith("--port="):
167                        server_port = each[ len("--port="): ]
168       
169        app = QtGui.QApplication(sys.argv)
170       
171        server = server.puzzlebox_brainstorms_network_server(log, \
172                    server_interface, \
173                    server_port, \
174                    embedded_mode=True, \
175                    DEBUG=DEBUG)
176       
177        #server = puzzlebox_brainstorms_network_server_threaded(log, \
178                    #server_interface, \
179                    #server_port, \
180                    #embedded_mode=True, \
181                    #DEBUG=DEBUG)
182        #server.start()
183       
184        # For debugging purposes it may be useful to launch an integrated
185        # ThinkGear Connect server emulator
186        #
187        #sys.path.append(os.path.join(os.getcwd(), "../thinkgear_emulator"))
188        #import puzzlebox_thinkgear_server as thinkgear_server
189        #
190        #thinkgear_server = \
191        #   thinkgear_server.puzzlebox_brainstorms_network_server_thinkgear(log, DEBUG=DEBUG)
192       
193       
194        window = client_interface.puzzlebox_brainstorms_client_interface(log, \
195                                                                         server=server, \
196                                                                         DEBUG=DEBUG)
197       
198        if configuration.AUTOCONNECT_TO_NXT_DEVICE is True:
199                window.connectToBrainstormsServer()
200       
201        window.show()
202       
203        sys.exit(app.exec_())
204
Note: See TracBrowser for help on using the repository browser.