source: remote_control/puzzlebox_brainstorms_configuration.py @ 45

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

client_interface:

  • converted to a standalone object

client_local:

  • intitial checkin
  • launches both server and client interface

client_network:

  • initial checkin
  • launches network-connected version of client interface

configuration.ini

  • initial checkin
  • overrides default settings found in configuration.py

configuration.py

  • function added to import settings from configuration.ini file

setup.py:

  • fully working py2exe script
File size: 5.3 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.10
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
63
64#####################################################################
65# Remote Control configuration
66#####################################################################
67
68if (sys.platform == 'win32'):
69        BLUETOOTH_DEVICE = DEFAULT_WINDOWS_BLUETOOTH_DEVICE
70else:
71        BLUETOOTH_DEVICE = DEFAULT_LINUX_BLUETOOTH_DEVICE
72
73MOTORS_MOUNTED_BACKWARDS = True
74MOTOR_PORT_RIGHT = 'a'
75MOTOR_PORT_LEFT = 'b'
76DEFAULT_RC_COMMAND = 'test_drive'
77
78
79#####################################################################
80# Server configuration
81#####################################################################
82
83MAX_COMPONENTS = 16
84
85
86#####################################################################
87# Client configuration
88#####################################################################
89
90MAX_CONNECTION_ATTEMPTS = 5
91HEALTH_CHECK_CONNECTION_ATTEMPTS = 5
92NO_REPLY_WAIT = 10 # how many seconds before considering a component dead
93
94
95#####################################################################
96# Client Interface configuration
97#####################################################################
98
99DISPLAY_WINDOW_X_COORDINATE = 0
100DISPLAY_WINDOW_Y_COORDINATE = 0
101DISPLAY_WINDOW_X_DIMENSION = 254
102DISPLAY_WINDOW_Y_DIMENSION = 424
103
104#WINDOW_BACKGROUND_COLOR = (255,255,255) # white background
105#WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background
106#WINDOW_BACKGROUND_COLOR = (64,64,64)    # dark grek background
107WINDOW_BACKGROUND_COLOR = (0,0,0)       # black background
108
109IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images')
110
111# Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key
112BUTTON_LAYOUT = { \
113       
114        'left': { \
115                'command': 'turn_left', \
116                'active': False, \
117                'button_image': '1-upper_left-white.png', \
118                'activated_image': '1-upper_left-orange.png', \
119                'image_x': 0, \
120                'image_y': 0, \
121                'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q]
122                }, \
123       
124        'forward': { \
125                'command': 'drive_forward', \
126                'active': False, \
127                'button_image': '2-up-white.png', \
128                'activated_image': '2-up-orange.png', \
129                'image_x': 98, \
130                'image_y': 0, \
131                'match_keys': [pygame.K_UP, pygame.K_w]
132                }, \
133       
134        'right': { \
135                'command': 'turn_right', \
136                'active': False, \
137                'button_image': '3-upper_right-white.png', \
138                'activated_image': '3-upper_right-orange.png', \
139                'image_x': 157, \
140                'image_y': 0, \
141                'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e]
142                }, \
143       
144        'reverse_left': { \
145                'command': 'turn_left_in_reverse', \
146                'active': False, \
147                'button_image': '7-lower_left-white.png', \
148                'activated_image': '7-lower_left-orange.png', \
149                'image_x': 0, \
150                'image_y': 220, \
151                'match_keys': [pygame.K_z]
152                }, \
153       
154        'reverse': { \
155                'command': 'drive_reverse', \
156                'active': False, \
157                'button_image': '8-down-white.png', \
158                'activated_image': '8-down-orange.png', \
159                'image_x': 98, \
160                'image_y': 220, \
161                'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x]
162                }, \
163       
164        'reverse_right': { \
165                'command': 'turn_right_in_reverse', \
166                'active': False, \
167                'button_image': '9-lower_right-white.png', \
168                'activated_image': '9-lower_right-orange.png', \
169                'image_x': 157, \
170                'image_y': 220, \
171                'match_keys': [pygame.K_PAGEDOWN, pygame.K_c]
172                }, \
173       
174} # BUTTON_LAYOUT
175
176
177#####################################################################
178# Configuration File Parser
179#####################################################################
180
181if os.path.exists(CONFIGURATION_FILE_PATH):
182       
183        file = open(CONFIGURATION_FILE_PATH, 'r')
184       
185        for line in file.readlines():
186                line = line.strip()
187                if len(line) == 0:
188                        continue
189                if line[0] == '#':
190                        continue
191                if line.find('=') == -1:
192                        continue
193                try:
194                        exec line
195                except:
196                        if DEBUG:
197                                print "Error recognizing configuration option:",
198                                print line
199
Note: See TracBrowser for help on using the repository browser.