Skip to content

Commit f36dbc7

Browse files
committed
Play/Pause works now. Giant vector structures removed
1 parent dcf2ac4 commit f36dbc7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

functions.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const double elev_angles[32] = {-15, 1, -13, 3, -11, 5, -9, 7, -7, 9, -5,
5151
using namespace std;
5252

5353
int global_ctr = 0; //to print out the packet number
54-
const int cycle_num = 100;
54+
const int cycle_num = 50;
5555
const int delay_us = 50000;
5656
int user_data;
5757

@@ -80,7 +80,7 @@ void compressFiles(int signum){
8080

8181
void deleteFiles(int signum){
8282
exit_thread = true;
83-
cout << "deleting pcap and video files" << endl;
83+
cout << "\ndeleting pcap and video files" << endl;
8484
if( system("rm Sample_1.pcap Sample_2.pcap out.avi") < 0){
8585
cout << "error in deleting files" << endl;
8686
}
@@ -96,6 +96,12 @@ void canData(){
9696
cout << "return from can_main function: " << can_return << endl;
9797
}
9898

99+
100+
/* -------------------------------------------------------------
101+
-------------Functions for user UI---------------------------
102+
-------------------------------------------------------------*/
103+
104+
99105
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
100106
void* viewer_void)
101107
{
@@ -112,6 +118,7 @@ void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
112118
}
113119
}
114120

121+
115122
void mouseEventOccurred (const pcl::visualization::MouseEvent &event,
116123
void* viewer_void)
117124
{
@@ -458,6 +465,7 @@ namespace offline
458465
{
459466
void packetHandler_I(u_char *userData, const struct pcap_pkthdr* pkthdr, const u_char* packet)
460467
{
468+
while(*pause_sim_kb == 1){}
461469
//assign the packaged ethernet data to the struct
462470
pcl::visualization::CloudViewer *viewer = (pcl::visualization::CloudViewer *) userData;
463471
struct data_packet processed_packet;
@@ -482,6 +490,7 @@ namespace offline
482490

483491
void packetHandler_II(u_char *userData, const struct pcap_pkthdr* pkthdr, const u_char* packet)
484492
{
493+
while(*pause_sim_kb == 1){}
485494
//assign the packaged ethernet data to the struct
486495
pcl::visualization::CloudViewer *viewer = (pcl::visualization::CloudViewer *) userData;
487496
struct data_packet processed_packet;

main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ int main(int argc, char *argv[])
137137
if(argv[1] == s[2])
138138
{
139139
cout << "Offline Mode Entered" << endl;
140+
cout << "extracting data from tar file ..." << endl;
140141
if(system("tar -xzvf data.tar.gz") < 0){
141142
cout << "error in extracting the data from tar file" << endl;
142143
return 0;
@@ -155,6 +156,8 @@ int main(int argc, char *argv[])
155156
cout << "pcap_open_offline() failed: " << errbuf << endl;
156157
return 1;
157158
}
159+
viewer.registerMouseCallback (mouseEventOccurred, (void*) &viewer);
160+
viewer.registerKeyboardCallback (keyboardEventOccurred, (void*) &viewer);
158161
viewer.runOnVisualizationThreadOnce (viewerOneOff);
159162
viewer.runOnVisualizationThread (viewerPsycho);
160163
//loop through the pcap file and extract the packets

0 commit comments

Comments
 (0)