From b21ff09151ca7e87348f1ea38944decc1f46f5db Mon Sep 17 00:00:00 2001 From: Janis Streib <me@janis-streib.de> Date: Fr., 19 Mai 2023 18:12:03 +0200 Subject: [PATCH] FIXUP --- src/G4Export.cpp | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/G4Export.cpp b/src/G4Export.cpp index 9f25037..18adf0b 100644 --- a/src/G4Export.cpp +++ b/src/G4Export.cpp @@ -12,6 +12,8 @@ #include <osc/OscOutboundPacketStream.h> #include <sstream> #include <signal.h> +#include <chrono> +#include <thread> using namespace clipp; using std::cout; using std::string; @@ -20,7 +22,7 @@ int RunCollect=0; std::unique_ptr<UdpTransmitSocket> transmitSocket; bool use_text = false; -int pollPeriod = 8; +int pollPeriod; void* Collect(REND_STRUCT* prs){ @@ -56,6 +58,16 @@ if(!use_text) { p << osc::BeginBundleImmediate; } + p << osc::BeginMessage( (string("/g4/hub/") + std::to_string(prs->hubList[i].GetId()) + string("/digio")).c_str()); + std::ostringstream ss; + if(use_text) { + ss << prs->hubList[i].GetDigIOData(); + auto res = ss.str(); + p << res.c_str(); + } else { + p << osc::int64(prs->hubList[i].GetDigIOData()); + } + p << osc::EndMessage; auto dat = prs->hubList[i].GetPnoData(); for(int j=0;j<G4_SENSORS_PER_HUB;j++) { if(!prs->hubList[i].IsSenActive(j)){ @@ -77,16 +89,16 @@ } transmitSocket->Send( p.Data(), p.Size() ); } - usleep(pollPeriod*1000); - // usleep(8000); + std::this_thread::sleep_for(std::chrono::milliseconds(pollPeriod)); } + g4_close_tracker(); return NULL; } void sighandler(int s){ printf("Caught signal %d\n",s); - RunCollect = 0; + RunCollect=0; } int main(int argc,char* argv[]){ @@ -148,9 +160,6 @@ sigaction(SIGINT, &sigIntHandler, NULL); Collect(&rs); - - delete[] rs.srcList; - delete[] rs.hubList; return 0; } -- Gitblit v1.9.1