source: remote_control/puzzlebox_brainstorms_configuration.py @ 73

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

brainstorms:

  • comprehensive file and class renaming in response to conversions

from PyGame/Twisted? frameworks to Qt

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
84TWISTED_SERVER_MAX_COMPONENTS = 16
85
86
87#####################################################################
88# Client configuration
89#####################################################################
90
91TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS = 5
92TWISTED_CLIENT_NO_REPLY_WAIT = 10 # how many seconds before considering a component dead
93
94
95#####################################################################
96# ThinkGear Connect configuration
97#####################################################################
98
99THINKGEAR_DELIMITER = '\r'
100
101THINKGEAR_CONFIGURATION_PARAMETERS = {"enableRawOutput": False, "format": "Json"}
102
103THINKGEAR_AUTHORIZATION_ENABLED = False
104
105THINKGEAR_AUTHORIZATION_REQUEST = { \
106        "appName": "Puzzlebox Brainstorms", \
107        "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408"
108}
109
110
111#####################################################################
112# Client Interface configuration [Qt]
113#####################################################################
114
115THINKGEAR_POWER_THRESHOLDS = { \
116       
117        'concentration': { \
118                0: 0, \
119                10: 0, \
120                20: 0, \
121                30: 0, \
122                40: 0, \
123                50: 0, \
124                60: 60, \
125                70: 70, \
126                75: 75, \
127                80: 80, \
128                90: 85, \
129                100: 90, \
130                }, \
131       
132        'relaxation': { \
133                0: 0, \
134                10: 0, \
135                20: 0, \
136                30: 0, \
137                40: 0, \
138                50: 0, \
139                60: 0, \
140                70: 0, \
141                80: 10, \
142                90: 15, \
143                100: 20, \
144                }, \
145       
146} # THINKGEAR_POWER_THRESHOLDS
147
148
149#####################################################################
150# Client Interface configuration [Pygame]
151#####################################################################
152
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')
164
165# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
166CLIENT_PYGAME_BUTTON_LAYOUT = { \
167       
168        'left': { \
169                'command': 'turn_left', \
170                'active': False, \
171                'button_image': '1-upper_left-white.png', \
172                'activated_image': '1-upper_left-orange.png', \
173                'image_x': 0, \
174                'image_y': 0, \
175                'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q]
176                }, \
177       
178        'forward': { \
179                'command': 'drive_forward', \
180                'active': False, \
181                'button_image': '2-up-white.png', \
182                'activated_image': '2-up-orange.png', \
183                'image_x': 98, \
184                'image_y': 0, \
185                'match_keys': [pygame.K_UP, pygame.K_w]
186                }, \
187       
188        'right': { \
189                'command': 'turn_right', \
190                'active': False, \
191                'button_image': '3-upper_right-white.png', \
192                'activated_image': '3-upper_right-orange.png', \
193                'image_x': 157, \
194                'image_y': 0, \
195                'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e]
196                }, \
197       
198        'reverse_left': { \
199                'command': 'turn_left_in_reverse', \
200                'active': False, \
201                'button_image': '7-lower_left-white.png', \
202                'activated_image': '7-lower_left-orange.png', \
203                'image_x': 0, \
204                'image_y': 220, \
205                'match_keys': [pygame.K_z]
206                }, \
207       
208        'reverse': { \
209                'command': 'drive_reverse', \
210                'active': False, \
211                'button_image': '8-down-white.png', \
212                'activated_image': '8-down-orange.png', \
213                'image_x': 98, \
214                'image_y': 220, \
215                'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x]
216                }, \
217       
218        'reverse_right': { \
219                'command': 'turn_right_in_reverse', \
220                'active': False, \
221                'button_image': '9-lower_right-white.png', \
222                'activated_image': '9-lower_right-orange.png', \
223                'image_x': 157, \
224                'image_y': 220, \
225                'match_keys': [pygame.K_PAGEDOWN, pygame.K_c]
226                }, \
227       
228} # BUTTON_LAYOUT
229
230
231#####################################################################
232# Flash socket policy handling
233#####################################################################
234
235FLASH_POLICY_FILE_REQUEST = \
236        '<policy-file-request/>%c' % 0 # NULL byte termination
237FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
238<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
239<cross-domain-policy>
240   <site-control permitted-cross-domain-policies="all" />
241   <allow-access-from domain="*" to-ports="%i" />
242</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
243
244
245#####################################################################
246# Configuration File Parser
247#####################################################################
248
249if os.path.exists(BRAINSTORMS_CONFIGURATION_FILE_PATH):
250       
251        file = open(BRAINSTORMS_CONFIGURATION_FILE_PATH, 'r')
252       
253        for line in file.readlines():
254                line = line.strip()
255                if len(line) == 0:
256                        continue
257                if line[0] == '#':
258                        continue
259                if line.find('=') == -1:
260                        continue
261                try:
262                        exec line
263                except:
264                        if DEBUG:
265                                print "Error recognizing Puzzlebox Brainstorms configuration option:",
266                                print line
267
Note: See TracBrowser for help on using the repository browser.