Skip to content

Commit

Permalink
fixed online sync bug in labrecorder/deleted matlabimporter
Browse files Browse the repository at this point in the history
  • Loading branch information
David Medine committed Mar 30, 2017
1 parent 80434b4 commit 5de7196
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 40 deletions.
5 changes: 3 additions & 2 deletions default_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ StorageLocation=C:\Recordings\CurrentStudy\exp%n\untitled.xdf
RequiredStreams=[]



# === 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
Expand All @@ -29,7 +28,9 @@ RequiredStreams=[]

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.
Expand Down
82 changes: 44 additions & 38 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,41 +137,45 @@ void MainWindow::load_config(const std::string &filename) {
// required streams
// ----------------------------
std::string str_requiredStreams = pt.get<std::string>("RequiredStreams","");
std::string rs_substr = str_requiredStreams.substr(1, str_requiredStreams.size()-2);
boost::algorithm::split(requiredStreams,rs_substr,boost::algorithm::is_any_of(","),boost::algorithm::token_compress_on);
for (int k=0;k<requiredStreams.size();k++){
boost::algorithm::trim_if(requiredStreams[k],boost::algorithm::is_any_of(" '\""));
std::cout << requiredStreams[k] << std::endl;
if(str_requiredStreams.compare("")) {
std::string rs_substr = str_requiredStreams.substr(1, str_requiredStreams.size()-2);
boost::algorithm::split(requiredStreams,rs_substr,boost::algorithm::is_any_of(","),boost::algorithm::token_compress_on);
for (int k=0;k<requiredStreams.size();k++){
boost::algorithm::trim_if(requiredStreams[k],boost::algorithm::is_any_of(" '\""));
std::cout << requiredStreams[k] << std::endl;
}
}

// ----------------------------
// online sync streams
// ----------------------------
std::string str_onlineSyncStreams = pt.get<std::string>("OnlineSync","");
std::string oss_substr = str_onlineSyncStreams.substr(1, str_onlineSyncStreams.size()-2);
boost::algorithm::split(onlineSyncStreams,oss_substr,boost::algorithm::is_any_of(","),boost::algorithm::token_compress_on);
for (int k=0;k<onlineSyncStreams.size();k++) {
boost::algorithm::trim_if(onlineSyncStreams[k],boost::algorithm::is_any_of(" '\""));
std::vector<std::string>words;
boost::algorithm::split(words,onlineSyncStreams[k],boost::algorithm::is_any_of(" "),boost::algorithm::token_compress_on);

//boost::algorithm::trim_if(trio[2],boost::algorithm::is_any_of(" "));
//int val = boost::lexical_cast<int>(trio[2]);
std::string key = std::string(words[0] + " " + words[1]);
if(str_onlineSyncStreams.compare("")) {
std::string oss_substr = str_onlineSyncStreams.substr(1, str_onlineSyncStreams.size()-2);
boost::algorithm::split(onlineSyncStreams,oss_substr,boost::algorithm::is_any_of(","),boost::algorithm::token_compress_on);
for (int k=0;k<onlineSyncStreams.size();k++) {
boost::algorithm::trim_if(onlineSyncStreams[k],boost::algorithm::is_any_of(" '\""));
std::vector<std::string>words;
boost::algorithm::split(words,onlineSyncStreams[k],boost::algorithm::is_any_of(" "),boost::algorithm::token_compress_on);

//boost::algorithm::trim_if(trio[2],boost::algorithm::is_any_of(" "));
//int val = boost::lexical_cast<int>(trio[2]);
std::string key = std::string(words[0] + " " + words[1]);

int val = 0;
for(int l=2;l<words.size();l++){
if(words[l].compare("post_clocksync")==0){val|=lsl::post_clocksync;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_dejitter")==0){val|=lsl::post_dejitter;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_monotonize")==0){val|=lsl::post_monotonize;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_threadsafe")==0){val|=lsl::post_threadsafe;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_ALL")==0){val=lsl::post_ALL;}//std::cout<<words[l]<< " "<<val<<std::endl;}

int val = 0;
for(int l=2;l<words.size();l++){
if(words[l].compare("post_clocksync")==0){val|=lsl::post_clocksync;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_dejitter")==0){val|=lsl::post_dejitter;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_monotonize")==0){val|=lsl::post_monotonize;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_threadsafe")==0){val|=lsl::post_threadsafe;}//std::cout<<words[l]<< " "<<val<<std::endl;}
if(words[l].compare("post_ALL")==0){val=lsl::post_ALL;}//std::cout<<words[l]<< " "<<val<<std::endl;}

}
syncOptionsByStreamName.insert(std::make_pair(key, val));
std::cout << "key = " << key << std::endl;

std::cout << "val = " << val << std::endl;
}
syncOptionsByStreamName.insert(std::make_pair(key, val));
std::cout << "key = " << key << std::endl;

std::cout << "val = " << val << std::endl;


}

Expand All @@ -181,16 +185,18 @@ void MainWindow::load_config(const std::string &filename) {
std::vector<std::string>sessionBlocks;
QListWidgetItem *item;
std::string str_sessionBlocks = pt.get<std::string>("SessionBlocks","");
std::string sb_substr = str_sessionBlocks.substr(1, str_sessionBlocks.size()-2);
boost::algorithm::split(sessionBlocks,sb_substr,boost::algorithm::is_any_of(","),boost::algorithm::token_compress_on);

for (int k=0;k<sessionBlocks.size();k++) {
boost::algorithm::trim_if(sessionBlocks[k],boost::algorithm::is_any_of(" '\""));
item=new QListWidgetItem(QString::fromStdString(sessionBlocks[k]), ui->blockList);
ui->blockList->addItem(item);
if(k==0) {
item->setSelected(true);
blockSelected(item);
if(str_sessionBlocks.compare("")) {
std::string sb_substr = str_sessionBlocks.substr(1, str_sessionBlocks.size()-2);
boost::algorithm::split(sessionBlocks,sb_substr,boost::algorithm::is_any_of(","),boost::algorithm::token_compress_on);

for (int k=0;k<sessionBlocks.size();k++) {
boost::algorithm::trim_if(sessionBlocks[k],boost::algorithm::is_any_of(" '\""));
item=new QListWidgetItem(QString::fromStdString(sessionBlocks[k]), ui->blockList);
ui->blockList->addItem(item);
if(k==0) {
item->setSelected(true);
blockSelected(item);
}
}
}

Expand Down

0 comments on commit 5de7196

Please sign in to comment.