From 04ba08a35e332d145d3cc7dbbf1a5e60bdb773d9 Mon Sep 17 00:00:00 2001
From: Ruud Overeem <overeem@astron.nl>
Date: Thu, 17 Sep 2009 14:25:45 +0000
Subject: [PATCH] Bug 1284: Taking subscription to the clock for the wg
 command.

---
 MAC/APL/PIC/RSP_Driver/src/rspctl.cc | 11 +++++++----
 MAC/APL/PIC/RSP_Driver/src/rspctl.h  |  9 ++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/MAC/APL/PIC/RSP_Driver/src/rspctl.cc b/MAC/APL/PIC/RSP_Driver/src/rspctl.cc
index 10e0a176efd..aacf7d14729 100644
--- a/MAC/APL/PIC/RSP_Driver/src/rspctl.cc
+++ b/MAC/APL/PIC/RSP_Driver/src/rspctl.cc
@@ -1448,7 +1448,7 @@ WGCommand::WGCommand(GCFPortInterface& port) :
 	Command(port),
 	m_mode(0),
 	m_phase(0),
-	m_frequency(0),
+	itsFrequency(0),
 	m_amplitude((uint32)round(AMPLITUDE_SCALE))
 {
 	LOG_DEBUG_STR("amplitude=" << m_amplitude);
@@ -1474,13 +1474,14 @@ void WGCommand::send()
 
 		//wgset.settings()(0).freq = (uint32)((m_frequency * ((uint32)-1) / gSampleFrequency) + 0.5);
 		//wgset.settings()(0).freq = (uint32)round(m_frequency * ((uint64)1 << 32) / gSampleFrequency);
+		//wgset.settings()(0).freq        = m_frequency;
 
-		wgset.settings()(0).freq        = m_frequency;
+		wgset.settings()(0).freq        = (uint32)round(itsFrequency * ((uint64)1 << 32) / gSampleFrequency);
 		wgset.settings()(0).phase       = m_phase;
 		wgset.settings()(0).ampl        = m_amplitude;
 		wgset.settings()(0).nof_samples = MEPHeader::N_WAVE_SAMPLES;
 
-		if (m_frequency < 1e-6) {
+		if (wgset.settings()(0).freq < 1e-6) {
 			wgset.settings()(0).mode = WGSettings::MODE_OFF;
 		}
 		else  {	/* frequency ok */
@@ -3023,7 +3024,9 @@ Command* RSPCtl::parse_options(int argc, char** argv)
 					delete command;
 					return 0;
 				}
-				wgcommand->setFrequency(frequency, gSampleFrequency);
+//				wgcommand->setFrequency(frequency, gSampleFrequency);
+				wgcommand->setFrequency(frequency);
+				itsNeedClock = true;
 			}
 		}
 		break;
diff --git a/MAC/APL/PIC/RSP_Driver/src/rspctl.h b/MAC/APL/PIC/RSP_Driver/src/rspctl.h
index 3adedab3609..615baf93057 100644
--- a/MAC/APL/PIC/RSP_Driver/src/rspctl.h
+++ b/MAC/APL/PIC/RSP_Driver/src/rspctl.h
@@ -303,8 +303,10 @@ public:
 	virtual GCFEvent::TResult ack(GCFEvent& e);
 
 	// set frequency in range 0 <= frequency < sample_frequency / 2.0
-	void setFrequency(double frequency, double samplefreq) {
-		m_frequency = (uint32)round(frequency * ((uint64)1 << 32) / samplefreq);
+//	void setFrequency(double frequency, double samplefreq) {
+//		m_frequency = (uint32)round(frequency * ((uint64)1 << 32) / samplefreq);
+	void setFrequency(double frequency) {
+		itsFrequency = frequency;
 	}
 
 	void setWaveMode(int mode) {
@@ -335,7 +337,8 @@ public:
 private:
 	uint8  		m_mode;
 	uint8  		m_phase;
-	uint32 		m_frequency;
+//	uint32 		m_frequency;
+	double 		itsFrequency;
 	uint32 		m_amplitude;
 };
 
-- 
GitLab