Repository navigation
Expand file tree
/
Copy pathshared.py
More file actions
84 lines (69 loc) · 4.43 KB
/
Copy pathshared.py
File metadata and controls
84 lines (69 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from multiprocessing import Value, sharedctypes, RawArray
import numpy as np
import ctypes
import time
from stimulus_module import StimulusModule
import pickle
class Shared():
def __init__(self):
self.window_properties_x = Value('i', 0)
self.window_properties_y = Value('i', 0)
self.window_properties_width = Value('i', 800)
self.window_properties_height = Value('i', 800)
self.window_properties_background = Value('d', 0)
self.window_properties_radius = Value('d', 1.4)
self.control_window_position_x = Value('i', 100)
self.control_window_position_y = Value('i', 100)
self.window_properties_update_requested = Value('b', 0)
self.stimulus_properties_number_of_dots = Value('i', 1000)
self.stimulus_properties_size_of_dots = Value('d', 0.1)
self.stimulus_properties_speed_of_dots = Value('d', 0.3)
self.stimulus_properties_direction_of_dots = Value('d', 0.0)
self.stimulus_properties_coherence_of_dots = Value('d', 50)
self.stimulus_properties_lifetime_of_dots = Value('d', 0.2)
self.stimulus_properties_brightness_of_dots = Value('d', 1.0)
self.stimulus_properties_update_requested = Value('b', 0)
self.running = Value('b', 1)
def load_values(self):
try:
values = pickle.load(open("values.pickle", "rb"))
self.window_properties_x.value = values["window_properties_x"]
self.window_properties_y.value = values["window_properties_y"]
self.window_properties_width.value = values["window_properties_width"]
self.window_properties_height.value = values["window_properties_height"]
self.window_properties_radius.value = values["window_properties_radius"]
self.window_properties_background.value = values["window_properties_background"]
self.control_window_position_x.value = values["control_window_position_x"]
self.control_window_position_y.value = values["control_window_position_y"]
self.stimulus_properties_number_of_dots.value = values["stimulus_properties_number_of_dots"]
self.stimulus_properties_size_of_dots.value = values["stimulus_properties_size_of_dots"]
self.stimulus_properties_speed_of_dots.value = values["stimulus_properties_speed_of_dots"]
self.stimulus_properties_direction_of_dots.value = values["stimulus_properties_direction_of_dots"]
self.stimulus_properties_coherence_of_dots.value = values["stimulus_properties_coherence_of_dots"]
self.stimulus_properties_lifetime_of_dots.value = values["stimulus_properties_lifetime_of_dots"]
self.stimulus_properties_brightness_of_dots.value = values["stimulus_properties_brightness_of_dots"]
except Exception as e:
print(e)
def save_values(self):
try:
values = dict({})
values["window_properties_x"] = self.window_properties_x.value
values["window_properties_y"] = self.window_properties_y.value
values["window_properties_width"] = self.window_properties_width.value
values["window_properties_height"] = self.window_properties_height.value
values["window_properties_radius"] = self.window_properties_radius.value
values["window_properties_background"] = self.window_properties_background.value
values["control_window_position_x"] = self.control_window_position_x.value
values["control_window_position_y"] = self.control_window_position_y.value
values["stimulus_properties_number_of_dots"] = self.stimulus_properties_number_of_dots.value
values["stimulus_properties_size_of_dots"] = self.stimulus_properties_size_of_dots.value
values["stimulus_properties_speed_of_dots"] = self.stimulus_properties_speed_of_dots.value
values["stimulus_properties_coherence_of_dots"] = self.stimulus_properties_coherence_of_dots.value
values["stimulus_properties_direction_of_dots"] = self.stimulus_properties_direction_of_dots.value
values["stimulus_properties_lifetime_of_dots"] = self.stimulus_properties_lifetime_of_dots.value
values["stimulus_properties_brightness_of_dots"] = self.stimulus_properties_brightness_of_dots.value
pickle.dump(values, open("values.pickle", "wb"))
except Exception as e:
print(e)
def start_threads(self):
StimulusModule(self).start()