| | |
| | | #include <osc/OscOutboundPacketStream.h> |
| | | #include <sstream> |
| | | #include <signal.h> |
| | | #include <chrono> |
| | | #include <thread> |
| | | |
| | | using namespace clipp; using std::cout; using std::string; |
| | | |
| | |
| | | int RunCollect=0; |
| | | std::unique_ptr<UdpTransmitSocket> transmitSocket; |
| | | bool use_text = false; |
| | | int pollPeriod = 8; |
| | | int pollPeriod; |
| | | |
| | | |
| | | void* Collect(REND_STRUCT* prs){ |
| | |
| | | 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)){ |
| | |
| | | } |
| | | 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[]){ |
| | |
| | | sigaction(SIGINT, &sigIntHandler, NULL); |
| | | |
| | | Collect(&rs); |
| | | |
| | | delete[] rs.srcList; |
| | | delete[] rs.hubList; |
| | | |
| | | return 0; |
| | | } |