-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathControlLight_Test.py
More file actions
57 lines (48 loc) · 1.88 KB
/
ControlLight_Test.py
File metadata and controls
57 lines (48 loc) · 1.88 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
import sys
#For quick testing of latest compilation of library
#main_path = "D:\\Florian\\Firefly\\FireflyControl\\ControlLight\\"
#library_path = main_path + "out\\build\\x64-debug"
#For more permanent installation, copy
# control_light_api.cp310-win_amd64.pyd
# ControlLight.dll
# from the library creation path, e.g. D:\Florian\Firefly\FireflyControl\ControlLight\out\build\x64-debug,
# to the "lib" subdirectory of this script
#you can also do "pip install ." in the root path of ControlLight_DLL_Test_Python_for_pip to install the library Python system wide.
# Then you don't need the following three lines and you don't need to copy the .pyd and .dll files.
main_path = ""
library_path = "lib"
sys.path.append(library_path)
import control_light_api
cla = control_light_api.ControlLightAPI()
print("Created:", cla.is_created())
try:
cla.configure(display_errors = False)
cla.load_from_json_file(main_path+r"ControlHardwareConfig.json")
except Exception as e:
print("Error loading JSON file:", e)
sys.exit(1)
try:
cla.initialize()
cla.switch_debug_mode(True, "DebugSequence")
start_time = 0
for i in range(10):
cla.start_assembling_sequence()
cla.sequencer_start_analog_in_acquisition(
0,
0, # AQuRA MCP3208 analog in board
0, # SPI chip-select
0,
100,
0.1)
for j in range(100):
cla.set_voltage(0, 24, 10.0 * j / 100.0)
cla.wait_ms(0.1)
frequency = 1000.0 * j / 100.0
cla.set_frequency(0, 232, frequency)
cla.execute_sequence()
input = cla.wait_till_end_of_sequence_then_get_input_data(timeout_in_s = 10)
print("Input data length:", input["length"]," duration:", input["end_time_of_cycle"]-start_time)
start_time = input["end_time_of_cycle"]
except Exception as e:
print("Error:", e)
sys.exit(1)