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
RevLine 
[5]1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Puzzlebox - Brainstorms - Configuration
5#
[31]6# Copyright Puzzlebox Productions, LLC (2010)
[5]7#
[31]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
[5]10#
[73]11# Last Update: 2010.06.28
[5]12#
13#####################################################################
14
[43]15import os, sys
[27]16import pygame
[12]17
[5]18#####################################################################
19# General configuration
20#####################################################################
21
22DEBUG = 1
23
[73]24BRAINSTORMS_CONFIGURATION_FILE_PATH = 'puzzlebox_brainstorms_configuration.ini'
[45]25
[73]26BRAINSTORMS_DISCRETE_CONTROL_COMMANDS = True
[42]27
[45]28
[5]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
[73]39DEFAULT_LOGFILE = 'brainstorms'
[5]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
[73]54BRAINSTORMS_SERVER_INTERFACE = '' # listen on all of server's network interfaces
55BRAINSTORMS_SERVER_HOST = '127.0.0.1' # localhost
56BRAINSTORMS_SERVER_PORT = 8194
[5]57
[48]58THINKGEAR_SERVER_HOST = '127.0.0.1'
59THINKGEAR_SERVER_PORT = 13854
[5]60
[48]61
[5]62#####################################################################
63# Remote Control configuration
64#####################################################################
65
[73]66DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS = 'COM1'
67DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX = '/dev/rfcomm0'
68
[43]69if (sys.platform == 'win32'):
[73]70        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_WINDOWS
[43]71else:
[73]72        NXT_BLUETOOTH_DEVICE = DEFAULT_NXT_BLUETOOTH_DEVICE_LINUX
[43]73
[73]74NXT_MOTORS_MOUNTED_BACKWARDS = True
75NXT_MOTOR_PORT_RIGHT = 'a'
76NXT_MOTOR_PORT_LEFT = 'b'
77NXT_DEFAULT_RC_COMMAND = 'test_drive'
[5]78
79
80#####################################################################
[6]81# Server configuration
[5]82#####################################################################
83
[73]84TWISTED_SERVER_MAX_COMPONENTS = 16
[5]85
86
[6]87#####################################################################
88# Client configuration
89#####################################################################
[5]90
[73]91TWISTED_CLIENT_MAX_CONNECTION_ATTEMPTS = 5
92TWISTED_CLIENT_NO_REPLY_WAIT = 10 # how many seconds before considering a component dead
[5]93
[11]94
95#####################################################################
[48]96# ThinkGear Connect configuration
97#####################################################################
98
[73]99THINKGEAR_DELIMITER = '\r'
[62]100
[73]101THINKGEAR_CONFIGURATION_PARAMETERS = {"enableRawOutput": False, "format": "Json"}
102
103THINKGEAR_AUTHORIZATION_ENABLED = False
104
[48]105THINKGEAR_AUTHORIZATION_REQUEST = { \
[73]106        "appName": "Puzzlebox Brainstorms", \
107        "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408"
108}
[48]109
110
111#####################################################################
[67]112# Client Interface configuration [Qt]
[11]113#####################################################################
114
[73]115THINKGEAR_POWER_THRESHOLDS = { \
[67]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       
[73]146} # THINKGEAR_POWER_THRESHOLDS
[67]147
148
149#####################################################################
150# Client Interface configuration [Pygame]
151#####################################################################
152
[73]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
[11]157
[73]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
[11]162
[73]163CLIENT_PYGAME_IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images')
[11]164
[27]165# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
[73]166CLIENT_PYGAME_BUTTON_LAYOUT = { \
[27]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
[45]230
231#####################################################################
[57]232# Flash socket policy handling
233#####################################################################
[55]234
[56]235FLASH_POLICY_FILE_REQUEST = \
236        '<policy-file-request/>%c' % 0 # NULL byte termination
[55]237FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
238<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
239<cross-domain-policy>
[56]240   <site-control permitted-cross-domain-policies="all" />
[55]241   <allow-access-from domain="*" to-ports="%i" />
[56]242</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
[55]243
[57]244
[55]245#####################################################################
[45]246# Configuration File Parser
247#####################################################################
248
[73]249if os.path.exists(BRAINSTORMS_CONFIGURATION_FILE_PATH):
[45]250       
[73]251        file = open(BRAINSTORMS_CONFIGURATION_FILE_PATH, 'r')
252       
[45]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:
[73]264                        if DEBUG:
265                                print "Error recognizing Puzzlebox Brainstorms configuration option:",
[45]266                                print line
267
Note: See TracBrowser for help on using the repository browser.