source: remote_control/puzzlebox_brainstorms_configuration.py @ 63

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

client_thinkgear:

  • no longer inherits from puzzlebox_brainstorms_client
  • authorization can be enabled/disabled via configuration file
  • automatically attempts to reset connection parameters to JSON if response is not recognized

configuration:

  • thinkgear authorization enable/disble support

thinkgear_emulator_server_setup.py:

  • initial checkin
File size: 6.2 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
112#####################################################################
113
114DISPLAY_WINDOW_X_COORDINATE = 0
115DISPLAY_WINDOW_Y_COORDINATE = 0
116DISPLAY_WINDOW_X_DIMENSION = 254
117DISPLAY_WINDOW_Y_DIMENSION = 424
118
119#WINDOW_BACKGROUND_COLOR = (255,255,255) # white background
120#WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background
121#WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background
122WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background
123
124IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images')
125
126# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
127BUTTON_LAYOUT = { \
128       
129        'left': { \
130                'command': 'turn_left', \
131                'active': False, \
132                'button_image': '1-upper_left-white.png', \
133                'activated_image': '1-upper_left-orange.png', \
134                'image_x': 0, \
135                'image_y': 0, \
136                'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q]
137                }, \
138       
139        'forward': { \
140                'command': 'drive_forward', \
141                'active': False, \
142                'button_image': '2-up-white.png', \
143                'activated_image': '2-up-orange.png', \
144                'image_x': 98, \
145                'image_y': 0, \
146                'match_keys': [pygame.K_UP, pygame.K_w]
147                }, \
148       
149        'right': { \
150                'command': 'turn_right', \
151                'active': False, \
152                'button_image': '3-upper_right-white.png', \
153                'activated_image': '3-upper_right-orange.png', \
154                'image_x': 157, \
155                'image_y': 0, \
156                'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e]
157                }, \
158       
159        'reverse_left': { \
160                'command': 'turn_left_in_reverse', \
161                'active': False, \
162                'button_image': '7-lower_left-white.png', \
163                'activated_image': '7-lower_left-orange.png', \
164                'image_x': 0, \
165                'image_y': 220, \
166                'match_keys': [pygame.K_z]
167                }, \
168       
169        'reverse': { \
170                'command': 'drive_reverse', \
171                'active': False, \
172                'button_image': '8-down-white.png', \
173                'activated_image': '8-down-orange.png', \
174                'image_x': 98, \
175                'image_y': 220, \
176                'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x]
177                }, \
178       
179        'reverse_right': { \
180                'command': 'turn_right_in_reverse', \
181                'active': False, \
182                'button_image': '9-lower_right-white.png', \
183                'activated_image': '9-lower_right-orange.png', \
184                'image_x': 157, \
185                'image_y': 220, \
186                'match_keys': [pygame.K_PAGEDOWN, pygame.K_c]
187                }, \
188       
189} # BUTTON_LAYOUT
190
191
192#####################################################################
193# Flash socket policy handling
194#####################################################################
195
196FLASH_POLICY_FILE_REQUEST = \
197        '<policy-file-request/>%c' % 0 # NULL byte termination
198FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
199<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
200<cross-domain-policy>
201   <site-control permitted-cross-domain-policies="all" />
202   <allow-access-from domain="*" to-ports="%i" />
203</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
204
205
206#####################################################################
207# Configuration File Parser
208#####################################################################
209
210if os.path.exists(CONFIGURATION_FILE_PATH):
211       
212        file = open(CONFIGURATION_FILE_PATH, 'r')
213       
214        for line in file.readlines():
215                line = line.strip()
216                if len(line) == 0:
217                        continue
218                if line[0] == '#':
219                        continue
220                if line.find('=') == -1:
221                        continue
222                try:
223                        exec line
224                except:
225                        if DEBUG:
226                                print "Error recognizing configuration option:",
227                                print line
228
Note: See TracBrowser for help on using the repository browser.