Skip to content

Commit

Permalink
Use QSettings for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tstenner committed Jun 4, 2018
1 parent a26b328 commit 8039f4f
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 311 deletions.
30 changes: 13 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.5)

project(LabRecorder
LANGUAGES CXX
LANGUAGES CXX
VERSION 1.12.0)

# load LSLAppBoilerplate if not done already
# set up LSL if not done already
if(NOT TARGET LSL::lsl)
# when building out of tree LSL_ROOT needs to be specified on the cmd line
file(TO_CMAKE_PATH "${LSL_INSTALL_ROOT}" LSL_INSTALL_ROOT)
Expand All @@ -19,7 +19,6 @@ if(NOT TARGET LSL::lsl)
endif()

# GENERAL CONFIG #
# Meta information about the project
set(META_PROJECT_DESCRIPTION "Record LabStreamingLayer streams to XDF data file.")

# THIRD PARTY LIBRARIES #
Expand All @@ -41,39 +40,36 @@ add_executable(${target}
recording.h
recording.cpp
)
target_compile_features(${target} PRIVATE cxx_auto_type)
target_compile_features(${target} PRIVATE cxx_auto_type cxx_lambda_init_captures)

find_package(Threads REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem iostreams)
set(zlib_libs "")
find_package(Boost REQUIRED OPTIONAL_COMPONENTS iostreams)
if(WIN32)
find_package(Boost OPTIONAL_COMPONENTS zlib QUIET)
if(TARGET Boost::zlib)
set(zlib_libs "Boost::zlib")
message(STATUS "LabRecorder: Using Boost.zlib for xdfz support")

set(ZLIB_LIBRARIES Boost::zlib)
endif()
else()
find_package(ZLIB QUIET)
if(ZLIB_FOUND)
message(STATUS "LabRecorder: Using zlib for xdfz support")
set(zlib_libs ${ZLIB_LIBRARIES})
endif()
endif()

target_link_libraries(${target}
PRIVATE
Qt5::Widgets
Qt5::Network
Boost::filesystem
Boost::iostreams
Boost::boost
Threads::Threads
${zlib_libs}
LSL::lsl
)

# Enable xdfz support if Boost.zlib (Windows) or plain zlib (Unix) was found
if(${zlib_libs})
if(ZLIB_LIBRARIES)
message(STATUS "Found zlib, enabling support for xdfz files")
target_link_libraries(${target}
PRIVATE
${ZLIB_LIBRARIES}
Boost::iostreams
)
target_compile_definitions(${target} PRIVATE XDFZ_SUPPORT=1)
endif()

Expand Down
128 changes: 32 additions & 96 deletions default_config.cfg
Original file line number Diff line number Diff line change
@@ -1,96 +1,32 @@
# === Storage Location ===
# the default file name can be something like C:\\Recordings\\untitled.xdf, but can also contain a
# placeholder for a running number (incremented per experiment session) called %n, and a
# placeholder for a "block" label %b (if the config script provides a list of block names that
# consitute a session
# The syntax is as in: StorageLocation = "C:\\Recordings\\subject%n\\block_%b.xdf"

StorageLocation=C:\Recordings\CurrentStudy\exp%n\untitled.xdf

#OnlineSync=["ActiChamp-0 (User-PC)" post_ALL]

# === Required Streams ===
# This is optionally a list of streams that are required for the recording;
# a warning is issued if one of the streams is not present when the record button is pressed
# The syntax is as in: RequiredStreams = ["BioSemi (MyHostname)","PhaseSpace (MyHostname)","Eyelink (AnotherHostname)"]
# where the format is identical to what the LabRecorder displays in the "Record from streams" list.

RequiredStreams=[]
OnlineSync=[]
#OnlineSync=[ActiChamp-0 (DM-Laptop) post_ALL, LiveAmpSN-054211-0237 (User-PC) post_ALL ]

# === Block Names ===
# This is optionally a list of blocks that make up a recording session. The blocks are displayed in
# a list box where the experiment can select a block before pressing record. If used, the blocks
# may serve as a reminder of where they are in the experiment, but more practically, can be
# used to determine the file name of the recording. Power users can define scriptable actions
# associated with selecting a block or pressing Start/Stop for a given block (e.g., for remote
# control).
# The syntax is as in: SessionBlocks = [Training,PreBaseline,MainSection,PostBaseline]

SessionBlocks=[]

# From here on, none of the following is currently implemented.
# It stays in case LabRecorder goes back to its previous python implementation, or
# it a Lua interpreter ever gets rolled into the current C++ implementation.

# === Extra checks to apply to some of the streams ===
# Note that this is an optional advanced feature that is aimed at power users.
# For a subset of streams, a list of [condition,errormessage,condition,errormessage, ...] can be
# given to inform the experimenter of possible problems with the recording setup (e.g., a device
# was mis-configured); the syntax of the condition strings is XPath 1.0 (applied to the meta-data
# of the stream) and the overall format for the ExtraCondtions variable is that of a Python
# dictionary.
# See sample_config.cfg for an example of the syntax

ExtraChecks={}



# === Optional script actions ===
# Functions can be defined here that get called when the given action in the Experimenter GUI
# is triggered. For example, thi can be used to remote-control an experiment program on the
# Subject's PC. If the function throws an exception, an warning message is presented to the
# user to alert him of a possible problem. The user can choose to continue recording anyway.
# The script actions are implemented as Python functions; they may refer to the previously
# declared config variables. These functions will only be triggered when EnableScriptedActions
# is set to True.

# set this to true to enable the below remote-control scripts
EnableScriptedActions = False
# you also need to set the correct hostname/IP address that hosts your experiment program
#SNAPHost = ("localhost",7897)

#def on_init(self):
# print "Intitializing..."

#def on_selectblock(self,blockname):
# print "Loading block ", blockname, " in SNAP."
# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.settimeout(3)
# sock.connect(self.SNAPHost)
# sock.sendall("config " + blockname + "\n")
# sock.close()

#def on_startrecord(self,blockname,sessionnumber):
# print "Starting block in SNAP."
# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.settimeout(3)
# sock.connect(self.SNAPHost)
# sock.sendall("setup permutation = " + str(sessionnumber) + "\n")
# sock.sendall("start\n")
# sock.close()

#def on_stoprecord(self,blockname,sessionnumber):
# print "Stopping block in SNAP."
# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.settimeout(3)
# sock.connect(self.SNAPHost)
# sock.sendall("stop\n")
# sock.close()

#def on_pauserecord(self,blockname,sessionnumber):
# pass

#def on_quit(self):
# pass
; === Storage Location ===
; the default file name can be something like C:\\Recordings\\untitled.xdf, but can also contain a
; placeholder for a running number (incremented per experiment session) called %n, and a
; placeholder for a "block" label %b (if the config script provides a list of block names that
; consitute a session
; The syntax is as in: StorageLocation = "C:\\Recordings\\subject%n\\block_%b.xdf"

StorageLocation=C:/Recordings/CurrentStudy/exp%n/untitled.xdf

;OnlineSync=["ActiChamp-0 (User-PC)" post_ALL]

; === Required Streams ===
; This is optionally a list of streams that are required for the recording;
; a warning is issued if one of the streams is not present when the record button is pressed
; The syntax is as in: RequiredStreams = "BioSemi (MyHostname)","PhaseSpace (MyHostname)","Eyelink (AnotherHostname)"
; where the format is identical to what the LabRecorder displays in the "Record from streams" list.

RequiredStreams=
SessionBlocks="T1", "T2", "T3"


; === Block Names ===
; This is optionally a list of blocks that make up a recording session. The blocks are displayed in
; a list box where the experiment can select a block before pressing record. If used, the blocks
; may serve as a reminder of where they are in the experiment, but more practically, can be
; used to determine the file name of the recording. Power users can define scriptable actions
; associated with selecting a block or pressing Start/Stop for a given block (e.g., for remote
; control).
; The syntax is as in: SessionBlocks = "Training","PreBaseline","MainSection","PostBaseline"

OnlineSync="SendDataC (Testpc) post_ALL", "Test (Testpc) post_clocksync"
; OnlineSync="ActiChamp-0 (DM-Laptop) post_ALL", "LiveAmpSN-054211-0237 (User-PC) post_ALL"
23 changes: 23 additions & 0 deletions fptest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>

int main() {
const double sampling_rate = 500,
sample_interval = 1.0 / sampling_rate,
first_timestamp = 60*60*24*365*48; // e.g. a unix timestamp
double last_timestamp = first_timestamp;
int full = 0, deduced = 0;
const int iterations = 100000;
double timestamps[iterations];
for(int i=0;i<iterations; ++i)
timestamps[i] = first_timestamp + i/sampling_rate;
for(int i=0; i<iterations; ++i) {
if(last_timestamp + sample_interval == timestamps[i])
deduced++;
else full++;
last_timestamp = timestamps[i];
}
std::cout << "Deduced: " << deduced << "\nFully written: " << full << std::endl;
return 0;
}


Loading

0 comments on commit 8039f4f

Please sign in to comment.