source: remote_control/puzzlebox_brainstorms_configuration.py @ 55

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

client_thinkgear:

  • default response cleanup
  • comment cleanup

configuration:

  • Special socket handling for Flash applications

server_thinkgear:

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