source: remote_control/puzzlebox_brainstorms_configuration.py @ 67

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

configuration:

  • power thresholds added for concentration and relaxation

client_interface_qt:

  • basic client networking added
  • signal connections added to widgets
  • configuration settings added for widgets

qt4_form:

  • LEGO Mindstorms NXT label added to Bluetooth section

client:

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