Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Dec 2012 06:39:39 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r244892 - user/adrian/ath_radar_stuff/src/qt-hpktlog
Message-ID:  <201212310639.qBV6ddaG075794@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Mon Dec 31 06:39:38 2012
New Revision: 244892
URL: http://svnweb.freebsd.org/changeset/base/244892

Log:
  Add very basic heatmap support.

Added:
  user/adrian/ath_radar_stuff/src/qt-hpktlog/HeatMap.cpp
  user/adrian/ath_radar_stuff/src/qt-hpktlog/HeatMap.h
Modified:
  user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp
  user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h
  user/adrian/ath_radar_stuff/src/qt-hpktlog/Makefile
  user/adrian/ath_radar_stuff/src/qt-hpktlog/main.cpp
  user/adrian/ath_radar_stuff/src/qt-hpktlog/qt-hpktlog.pro

Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/HeatMap.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/HeatMap.cpp	Mon Dec 31 06:39:38 2012	(r244892)
@@ -0,0 +1,33 @@
+
+#include "HeatMap.h"
+
+HeatMap::HeatMap()
+{
+
+	// Blank the heat map
+	for (int i = 0; i < MAX_RSSI; i++)
+		for (int j = 0; j < MAX_PULSEDUR; j++)
+		heatmap[i][j] = 0;
+}
+
+void
+HeatMap::incr(int x, int y)
+{
+
+	if (heatmap[x % MAX_RSSI][y % MAX_PULSEDUR] < (MAX_HEATCNT - 1))
+		heatmap[x % MAX_RSSI][y % MAX_PULSEDUR]++;
+}
+
+void
+HeatMap::decr(int x, int y)
+{
+
+	if (heatmap[x % MAX_RSSI][y % MAX_PULSEDUR] > 0)
+		heatmap[x % MAX_RSSI][y % MAX_PULSEDUR]--;
+}
+
+uint8_t
+HeatMap::get(int x, int y)
+{
+	return heatmap[x % MAX_RSSI][y % MAX_PULSEDUR];
+}

Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/HeatMap.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/HeatMap.h	Mon Dec 31 06:39:38 2012	(r244892)
@@ -0,0 +1,28 @@
+#ifndef	__HEATMAP_H__
+#define	__HEATMAP_H__
+
+#include <sys/types.h>
+
+/*
+ * This is a hard-coded heatmap for RSSI/duration.
+ * It should be made less hardcoded!
+ */
+
+/* XXX hard-coded */
+#define	MAX_PULSEDUR	255
+#define	MAX_RSSI	255
+
+#define	MAX_HEATCNT	255
+
+class HeatMap {
+	private:
+		uint8_t	heatmap[MAX_PULSEDUR][MAX_RSSI];
+
+	public:
+		HeatMap();
+		void incr(int x, int y);
+		void decr(int x, int y);
+		uint8_t get(int x, int y);
+};
+
+#endif	/* __HEATMAP_H__ */

Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp
==============================================================================
--- user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp	Mon Dec 31 06:39:20 2012	(r244891)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp	Mon Dec 31 06:39:38 2012	(r244892)
@@ -11,17 +11,14 @@
 #include "qwt_plot_histogram.h"
 #include "qwt_symbol.h"
 
+#include "HeatMap.h"
+
 #include "MainApp.h"
 
 MainApp::MainApp(QMainWindow *parent)
 {
 
-	// Blank the heat map
-	for (int i = 0; i < MAX_RSSI; i++) {
-		for (int j = 0; j < MAX_PULSEDUR; j++) {
-			heat_map[i][j] = 0;
-		}
-	}
+	hm = new HeatMap();
 
 	// How many entries to keep in the FIFO
 	num_entries = 128;
@@ -64,6 +61,8 @@ MainApp::~MainApp()
 		delete q_curve;
 	if (q_plot)
 		delete q_plot;
+
+	delete hm;
 }
 
 void
@@ -90,16 +89,14 @@ MainApp::getRadarEntry(struct radar_entr
 	q_rssi.insert(q_rssi.begin(), (float) re.re_rssi);
 
 
-	// Update the heat map for the current pixel, topping out at 65535
-	// entries (ie, don't overflow.)
-	if (heat_map[re.re_rssi % MAX_RSSI][re.re_dur % MAX_PULSEDUR] < MAX_HEATCNT)
-		heat_map[re.re_rssi % MAX_RSSI][re.re_dur % MAX_PULSEDUR]++;
+	// Update the heat map for the current sample
+	hm->incr(re.re_rssi, re.re_dur);
 
 	q_points.insert(q_points.begin(),
 	    QwtPoint3D(
 	    (float) re.re_dur,
 	    (float) re.re_rssi,
-	    (float) heat_map[re.re_rssi % MAX_RSSI][re.re_dur % MAX_PULSEDUR] * 100.0));
+	    (float) hm->get(re.re_rssi, re.re_dur) * 100.0));
 
 	// If we're too big, delete the first entry
 	if (q_points.size() > num_entries) {
@@ -107,8 +104,7 @@ MainApp::getRadarEntry(struct radar_entr
 		uint8_t rssi, dur;
 		rssi = q_rssi[q_rssi.size() - 1];
 		dur = q_dur[q_dur.size() - 1];
-		if (heat_map[rssi % MAX_RSSI][dur % MAX_PULSEDUR] > 0)
-			heat_map[rssi % MAX_RSSI][dur % MAX_PULSEDUR]--;
+		hm->decr(rssi, dur);
 
 		// Remove the tail entry
 		q_dur.pop_back();

Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h
==============================================================================
--- user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h	Mon Dec 31 06:39:20 2012	(r244891)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h	Mon Dec 31 06:39:38 2012	(r244892)
@@ -20,9 +20,7 @@
 
 #include "libradarpkt/pkt.h"
 
-#define		MAX_RSSI		256
-#define		MAX_PULSEDUR		256
-#define		MAX_HEATCNT		254
+#include "HeatMap.h"
 
 class MainApp : public QMainWindow
 {
@@ -36,7 +34,7 @@ class MainApp : public QMainWindow
 		QwtSymbol *q_symbol;
 
 		// How many entries to keep in the histogram
-		size_t num_entries;
+		int num_entries;
 
 		// Our old-style histogram data
 		std::vector<double> q_dur;
@@ -45,9 +43,8 @@ class MainApp : public QMainWindow
 		// and the new-style histogram data
 		QVector<QwtPoint3D> q_points;
 
-		// Now, an array of items, for "heat" data
-		// XXX this really should be another class..
-		uint8_t heat_map[MAX_RSSI][MAX_PULSEDUR];
+		// "Heat" map data
+		HeatMap *hm;
 
 		// TODO	When rendering the screen, we only want to do it
 		//	every say, 3ms.

Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/Makefile
==============================================================================
--- user/adrian/ath_radar_stuff/src/qt-hpktlog/Makefile	Mon Dec 31 06:39:20 2012	(r244891)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/Makefile	Mon Dec 31 06:39:38 2012	(r244892)
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: qt-hpktlog
-# Generated by qmake (2.01a) (Qt 4.7.4) on: Sun Jun 24 00:10:19 2012
+# Generated by qmake (2.01a) (Qt 4.7.4) on: Mon Jun 25 15:31:47 2012
 # Project:  qt-hpktlog.pro
 # Template: app
 # Command: /usr/local/bin/qmake-qt4 -o Makefile qt-hpktlog.pro
@@ -43,11 +43,13 @@ OBJECTS_DIR   = ./
 
 ####### Files
 
-SOURCES       = MainApp.cpp \
+SOURCES       = HeatMap.cpp \
+		MainApp.cpp \
 		PktSource.cpp \
 		main.cpp moc_MainApp.cpp \
 		moc_PktSource.cpp
-OBJECTS       = MainApp.o \
+OBJECTS       = HeatMap.o \
+		MainApp.o \
 		PktSource.o \
 		main.o \
 		moc_MainApp.o \
@@ -154,7 +156,7 @@ qmake:  FORCE
 
 dist: 
 	@$(CHK_DIR_EXISTS) .tmp/qt-hpktlog1.0.0 || $(MKDIR) .tmp/qt-hpktlog1.0.0 
-	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qt-hpktlog1.0.0/ && $(COPY_FILE) --parents MainApp.h PktSource.h .tmp/qt-hpktlog1.0.0/ && $(COPY_FILE) --parents MainApp.cpp PktSource.cpp main.cpp .tmp/qt-hpktlog1.0.0/ && (cd `dirname .tmp/qt-hpktlog1.0.0` && $(TAR) qt-hpktlog1.0.0.tar qt-hpktlog1.0.0 && $(COMPRESS) qt-hpktlog1.0.0.tar) && $(MOVE) `dirname .tmp/qt-hpktlog1.0.0`/qt-hpktlog1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qt-hpktlog1.0.0
+	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qt-hpktlog1.0.0/ && $(COPY_FILE) --parents HeatMap.h MainApp.h PktSource.h .tmp/qt-hpktlog1.0.0/ && $(COPY_FILE) --parents HeatMap.cpp MainApp.cpp PktSource.cpp main.cpp .tmp/qt-hpktlog1.0.0/ && (cd `dirname .tmp/qt-hpktlog1.0.0` && $(TAR) qt-hpktlog1.0.0.tar qt-hpktlog1.0.0 && $(COMPRESS) qt-hpktlog1.0.0.tar) && $(MOVE) `dirname .tmp/qt-hpktlog1.0.0`/qt-hpktlog1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qt-hpktlog1.0.0
 
 
 clean:compiler_clean 
@@ -178,7 +180,8 @@ mocables: compiler_moc_header_make_all c
 compiler_moc_header_make_all: moc_MainApp.cpp moc_PktSource.cpp
 compiler_moc_header_clean:
 	-$(DEL_FILE) moc_MainApp.cpp moc_PktSource.cpp
-moc_MainApp.cpp: MainApp.h
+moc_MainApp.cpp: HeatMap.h \
+		MainApp.h
 	/usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) MainApp.h -o moc_MainApp.cpp
 
 moc_PktSource.cpp: PktSource.h
@@ -203,13 +206,18 @@ compiler_clean: compiler_moc_header_clea
 
 ####### Compile
 
-MainApp.o: MainApp.cpp MainApp.h
+HeatMap.o: HeatMap.cpp HeatMap.h
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o HeatMap.o HeatMap.cpp
+
+MainApp.o: MainApp.cpp HeatMap.h \
+		MainApp.h
 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o MainApp.o MainApp.cpp
 
 PktSource.o: PktSource.cpp PktSource.h
 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o PktSource.o PktSource.cpp
 
 main.o: main.cpp MainApp.h \
+		HeatMap.h \
 		PktSource.h
 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
 

Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/main.cpp
==============================================================================
--- user/adrian/ath_radar_stuff/src/qt-hpktlog/main.cpp	Mon Dec 31 06:39:20 2012	(r244891)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/main.cpp	Mon Dec 31 06:39:38 2012	(r244892)
@@ -12,6 +12,7 @@
 
 #include "libradarpkt/pkt.h"
 #include "libradarpkt/ar5416_radar.h"
+#include "libradarpkt/ar5212_radar.h"
 #include "libradarpkt/ar9280_radar.h"
 
 
@@ -69,7 +70,7 @@ plotSet(QwtPlot *p, PktLogData *pl)
 static void
 usage()
 {
-	printf("usage: <ar5416|ar9280> <ifname>\n");
+	printf("usage: <ar5212|ar5416|ar9280> <ifname>\n");
 	exit(127);
 }
 
@@ -88,6 +89,8 @@ main(int argc, char *argv[])
 
 	if (strcmp(argv[1], "ar5416")== 0)
 		type = CHIP_AR5416;
+	else if (strcmp(argv[1], "ar5212")== 0)
+		type = CHIP_AR5212;
 	else if (strcmp(argv[1], "ar9280")== 0)
 		type = CHIP_AR9280;
 	else

Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/qt-hpktlog.pro
==============================================================================
--- user/adrian/ath_radar_stuff/src/qt-hpktlog/qt-hpktlog.pro	Mon Dec 31 06:39:20 2012	(r244891)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/qt-hpktlog.pro	Mon Dec 31 06:39:38 2012	(r244892)
@@ -12,6 +12,6 @@ QMAKE_CFLAGS=	-g -ggdb -DATH_ENABLE_RADI
 QMAKE_CXXFLAGS=	-g -ggdb -DATH_ENABLE_RADIOTAP_VENDOR_EXT
 
 # Input
-HEADERS += MainApp.h PktSource.h
+HEADERS += HeatMap.h MainApp.h PktSource.h
 # FORMS += PlotWindow.ui MainWindow.ui
-SOURCES += MainApp.cpp PktSource.cpp main.cpp
+SOURCES += HeatMap.cpp MainApp.cpp PktSource.cpp main.cpp



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212310639.qBV6ddaG075794>