source: remote_control/puzzlebox_brainstorms_configuration.py @ 74

Last change on this file since 74 was 74, checked in by sc, 11 years ago

brainstorms:

  • continued file and class renaming in response to conversions

from PyGame/Twisted? frameworks to Qt

network_client:

  • initial checkin of Qt based Brainstorms client

network_client_thinkgear:

File size: 7.1 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Puzzlebox - Brainstorms - Configuration
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# Last Update: 2010.06.28
12#
13#####################################################################
14
15import os, sys
16import pygame
17
18#####################################################################
19# General configuration
20#####################################################################
21
22DEBUG = 1
23
24BRAINSTORMS_CONFIGURATION_FILE_PATH = 'puzzlebox_brainstorms_configuration.ini'
25
26BRAINSTORMS_DISCRETE_CONTROL_COMMANDS = True
27
28
29#####################################################################
30# Logging
31#####################################################################
32
33LOG_LEVEL_DEBUG = 2
34LOG_LEVEL_INFO = 1
35LOG_LEVEL_ERROR = 0
36LOG_LEVEL_DISABLE = -1
37
38DEFAULT_LOG_LEVEL = LOG_LEVEL_DEBUG
39DEFAULT_LOGFILE = 'brainstorms'
40
41LOGFILE_DIR = '/var/log/puzzlebox'
42LOGFILE_SUFFIX = '.log'
43LOGFILE_SUFFIX_DEBUG = '_debug.log'
44LOGFILE_SUFFIX_INFO = '_info.log'
45LOGFILE_SUFFIX_ERROR = '_error.log'
46
47SPLIT_LOGFILES = False
48
49
50#####################################################################
51# Network addresses
52#####################################################################
53
54BRAINSTORMS_SERVER_INTERFACE = '' # listen on all of server's network interfaces
55BRAINSTORMS_SERVER_HOST = '127.0.0.1' # localhost
56BRAINSTORMS_SERVER_PORT = 8194
57
58THINKGEAR_SERVER_HOST = '127.0.0.1'
59THINKGEAR_SERVER_PORT = 13854
60
61
62#####################################################################
63# Remote Control configuration
64#####################################################################
65
66DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS = 'COM1'
67DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX = '/dev/rfcomm0'
68
69if (sys.platform == 'win32'):
70        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS
71else:
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'
78
79
80#####################################################################
81# Server configuration
82#####################################################################
83
84BRAINSTORMS_DELIMITER = '\r'
85
86TWISTED_SERVER_MAX_COMPONENTS = 16
87
88
89#####################################################################
90# Client configuration
91#####################################################################
92
93TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS = 5
94TWISTED_CLIENT_NO_REPLY_WAIT = 10 # how many seconds before considering a component dead
95
96
97#####################################################################
98# ThinkGear Connect configuration
99#####################################################################
100
101THINKGEAR_DELIMITER = '\r'
102
103THINKGEAR_CONFIGURATION_PARAMETERS = {"enableRawOutput": False, "format": "Json"}
104
105THINKGEAR_AUTHORIZATION_ENABLED = False
106
107THINKGEAR_AUTHORIZATION_REQUEST = { \
108        "appName": "Puzzlebox Brainstorms", \
109        "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408"
110}
111
112
113#####################################################################
114# Client Interface configuration [Qt]
115#####################################################################
116
117THINKGEAR_POWER_THRESHOLDS = { \
118       
119        'concentration': { \
120                0: 0, \
121                10: 0, \
122                20: 0, \
123                30: 0, \
124                40: 0, \
125                50: 0, \
126                60: 60, \
127                70: 70, \
128                75: 75, \
129                80: 80, \
130                90: 85, \
131                100: 90, \
132                }, \
133       
134        'relaxation': { \
135                0: 0, \
136                10: 0, \
137                20: 0, \
138                30: 0, \
139                40: 0, \
140                50: 0, \
141                60: 0, \
142                70: 0, \
143                80: 10, \
144                90: 15, \
145                100: 20, \
146                }, \
147       
148} # THINKGEAR_POWER_THRESHOLDS
149
150
151#####################################################################
152# Client Interface configuration [Pygame]
153#####################################################################
154
155CLIENT_PYGAME_DISPLAY_WINDOW_X_COORDINATE = 0
156CLIENT_PYGAME_DISPLAY_WINDOW_Y_COORDINATE = 0
157CLIENT_PYGAME_DISPLAY_WINDOW_X_DIMENSION = 254
158CLIENT_PYGAME_DISPLAY_WINDOW_Y_DIMENSION = 424
159
160#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (255,255,255) # white background
161#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background
162#CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background
163CLIENT_PYGAME_WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background
164
165CLIENT_PYGAME_IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images')
166
167# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
168CLIENT_PYGAME_BUTTON_LAYOUT = { \
169       
170        'left': { \
171                'command': 'turn_left', \
172                'active': False, \
173                'button_image': '1-upper_left-white.png', \
174                'activated_image': '1-upper_left-orange.png', \
175                'image_x': 0, \
176                'image_y': 0, \
177                'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q]
178                }, \
179       
180        'forward': { \
181                'command': 'drive_forward', \
182                'active': False, \
183                'button_image': '2-up-white.png', \
184                'activated_image': '2-up-orange.png', \
185                'image_x': 98, \
186                'image_y': 0, \
187                'match_keys': [pygame.K_UP, pygame.K_w]
188                }, \
189       
190        'right': { \
191                'command': 'turn_right', \
192                'active': False, \
193                'button_image': '3-upper_right-white.png', \
194                'activated_image': '3-upper_right-orange.png', \
195                'image_x': 157, \
196                'image_y': 0, \
197                'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e]
198                }, \
199       
200        'reverse_left': { \
201                'command': 'turn_left_in_reverse', \
202                'active': False, \
203                'button_image': '7-lower_left-white.png', \
204                'activated_image': '7-lower_left-orange.png', \
205                'image_x': 0, \
206                'image_y': 220, \
207                'match_keys': [pygame.K_z]
208                }, \
209       
210        'reverse': { \
211                'command': 'drive_reverse', \
212                'active': False, \
213                'button_image': '8-down-white.png', \
214                'activated_image': '8-down-orange.png', \
215                'image_x': 98, \
216                'image_y': 220, \
217                'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x]
218                }, \
219       
220        'reverse_right': { \
221                'command': 'turn_right_in_reverse', \
222                'active': False, \
223                'button_image': '9-lower_right-white.png', \
224                'activated_image': '9-lower_right-orange.png', \
225                'image_x': 157, \
226                'image_y': 220, \
227                'match_keys': [pygame.K_PAGEDOWN, pygame.K_c]
228                }, \
229       
230} # BUTTON_LAYOUT
231
232
233#####################################################################
234# Flash socket policy handling
235#####################################################################
236
237FLASH_POLICY_FILE_REQUEST = \
238        '<policy-file-request/>%c' % 0 # NULL byte termination
239FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
240<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
241<cross-domain-policy>
242   <site-control permitted-cross-domain-policies="all" />
243   <allow-access-from domain="*" to-ports="%i" />
244</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
245
246
247#####################################################################
248# Configuration File Parser
249#####################################################################
250
251if os.path.exists(BRAINSTORMS_CONFIGURATION_FILE_PATH):
252       
253        file = open(BRAINSTORMS_CONFIGURATION_FILE_PATH, 'r')
254       
255        for line in file.readlines():
256                line = line.strip()
257                if len(line) == 0:
258                        continue
259                if line[0] == '#':
260                        continue
261                if line.find('=') == -1:
262                        continue
263                try:
264                        exec line
265                except:
266                        if DEBUG:
267                                print "Error recognizing Puzzlebox Brainstorms configuration option:",
268                                print line
269
Note: See TracBrowser for help on using the repository browser.