source: trunk/synapse/puzzlebox_synapse_configuration.py @ 161

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

puzzlebox_synapse_configuration.py:

  • THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE set to 16384

puzzlebox_synapse_interface.py:

  • automatic searching for COM ports under Windows added
  • enumerate_serial_ports added
  • full_port_name added
  • maximum EEG power values reset to default per-packet when not in emulation mode

puzzlebox_synapse_protocol_thinkgear.py:

  • fix for reading from COM ports under Windows
File size: 5.1 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Puzzlebox - Synapse - 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.08.12
12#
13#####################################################################
14
15import os, sys
16
17#####################################################################
18# General configuration
19#####################################################################
20
21DEBUG = 1
22
23CONFIGURATION_FILE_PATH = 'puzzlebox_synapse_configuration.ini'
24
25if (sys.platform != 'win32'):
26        if not os.path.exists(CONFIGURATION_FILE_PATH):
27                CONFIGURATION_FILE_PATH = \
28                        os.path.join('/etc/puzzlebox_synapse', CONFIGURATION_FILE_PATH)
29
30
31#####################################################################
32# Network addresses
33#####################################################################
34
35THINKGEAR_SERVER_INTERFACE = '' # listen on all of server's network interfaces
36#THINKGEAR_SERVER_HOST = '127.0.0.1'
37THINKGEAR_SERVER_HOST = '*'
38THINKGEAR_SERVER_PORT = 13854
39
40
41#####################################################################
42# ThinkGear Device configuration
43#####################################################################
44
45DEFAULT_THINKGEAR_DEVICE_SERIAL_PORT_WINDOWS = 'COM2'
46DEFAULT_THINKGEAR_DEVICE_SERIAL_PORT_LINUX = '/dev/rfcomm0'
47
48if (sys.platform == 'win32'):
49        THINKGEAR_DEVICE_SERIAL_PORT = DEFAULT_THINKGEAR_DEVICE_SERIAL_PORT_WINDOWS
50else:
51        THINKGEAR_DEVICE_SERIAL_PORT = DEFAULT_THINKGEAR_DEVICE_SERIAL_PORT_LINUX
52
53# Use Bluetooth MAC address for Linux
54THINKGEAR_DEVICE_BLUETOOTH_ADDRESS = ''
55# THINKGEAR_DEVICE_BLUETOOTH_ADDRESS = '00:13:EF:xx:xx:xx' # Linux example
56
57
58#####################################################################
59# Server configuration
60#####################################################################
61
62CLIENT_NO_REPLY_WAIT = 5 # how many seconds before considering a component dead
63
64
65#####################################################################
66# ThinkGear Connect configuration
67#####################################################################
68
69THINKGEAR_DELIMITER = '\r'
70
71THINKGEAR_CONFIGURATION_PARAMETERS = {"enableRawOutput": False, "format": "Json"}
72
73ENABLE_THINKGEAR_AUTHORIZATION = False
74
75THINKGEAR_AUTHORIZATION_REQUEST = { \
76        "appName": "Puzzlebox Brainstorms", \
77        "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408"
78        }
79
80THINKGEAR_EEG_POWER_BAND_ORDER = ['delta', \
81                                  'theta', \
82                                  'lowAlpha', \
83                                  'highAlpha', \
84                                  'lowBeta', \
85                                  'highBeta', \
86                                  'lowGamma', \
87                                  'highGamma']
88
89THINKGEAR_EMULATION_MAX_ESENSE_VALUE = 100
90THINKGEAR_EMULATION_MAX_EEG_POWER_VALUE = 16384
91
92THINKGEAR_ATTENTION_MULTIPLIER = 1.0
93THINKGEAR_MEDITATION_MULTIPLIER = 1.0
94
95THINKGEAR_EEG_POWER_MULTIPLIERS = { \
96        'delta': 1.0, \
97        'theta': 1.0, \
98        'lowAlpha': 1.0, \
99        'highAlpha': 1.0, \
100        'lowBeta': 1.0, \
101        'highBeta': 1.0, \
102        'lowGamma': 1.0, \
103        'highGamma': 1.0, \
104}
105
106
107#####################################################################
108# ThinkGear Connect Server Emulator configuration
109#####################################################################
110
111THINKGEAR_ENABLE_SIMULATE_HEADSET_DATA = True
112
113THINKGEAR_BLINK_FREQUENCY_TIMER = 6 # blink every 6 seconds
114                                    # (6 seconds is listed by Wikipedia
115                                    # as being the average number of times
116                                    # an adult blinks in a laboratory setting)
117
118THINKGEAR_DEFAULT_SAMPLE_WAVELENGTH = 30 # number of seconds from 0 to max
119                                         # and back to 0 for any given
120                                         # detection value below
121
122
123#####################################################################
124# Flash socket policy handling
125#####################################################################
126
127FLASH_POLICY_FILE_REQUEST = \
128        '<policy-file-request/>%c' % 0 # NULL byte termination
129FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?>
130<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
131<cross-domain-policy>
132   <site-control permitted-cross-domain-policies="all" />
133   <allow-access-from domain="*" to-ports="%i" />
134</cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0)
135
136
137#####################################################################
138# Configuration File Parser
139#####################################################################
140
141if os.path.exists(CONFIGURATION_FILE_PATH):
142       
143        file = open(CONFIGURATION_FILE_PATH, 'r')
144       
145        for line in file.readlines():
146                line = line.strip()
147                if len(line) == 0:
148                        continue
149                if line[0] == '#':
150                        continue
151                if line.find('=') == -1:
152                        continue
153                if (line == "THINKGEAR_DEVICE_SERIAL_PORT = ''"):
154                        # use operating system default if device not set manually
155                        continue
156                try:
157                        exec line
158                except:
159                        if DEBUG:
160                                print "Error recognizing configuration option:",
161                                print line
162
Note: See TracBrowser for help on using the repository browser.