From 76f5e59486848e8cac4fd24c5f3349ac529a307c Mon Sep 17 00:00:00 2001
From: wierenga <sdos@astron.nl>
Date: Wed, 14 Jun 2006 07:51:24 +0000
Subject: [PATCH] BugID: 733 Work towards working and synchronous CEP output.

---
 MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc  |  6 ++--
 MAC/APL/PIC/RSPDriver/src/RCUWrite.cc       |  2 ++
 MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in | 36 +++++++++++++++++----
 MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc      | 11 ++++++-
 MAC/APL/PIC/RSPDriver/src/rspctl.cc         | 13 ++++++--
 5 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc b/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc
index 370b4643077..34699024f92 100644
--- a/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc
+++ b/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc
@@ -39,7 +39,7 @@ using namespace RSP;
 using namespace EPA_Protocol;
 
 RCUResultRead::RCUResultRead(GCFPortInterface& board_port, int board_id)
-  : SyncAction(board_port, board_id, StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) // *N_POL for X and Y
+  : SyncAction(board_port, board_id, StationSettings::instance()->nrRcusPerBoard())
 {
   memset(&m_hdr, 0, sizeof(MEPHeader));
 }
@@ -51,7 +51,7 @@ RCUResultRead::~RCUResultRead()
 
 void RCUResultRead::sendrequest()
 {
-  uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) + getCurrentIndex();
+  uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrRcusPerBoard()) + getCurrentIndex();
 
   // skip update if the RCU settings have not been applied yet
   if (RTC::RegisterState::READ != Cache::getInstance().getState().rcuprotocol().get(global_rcu)) {
@@ -89,7 +89,7 @@ GCFEvent::TResult RCUResultRead::handleack(GCFEvent& event, GCFPortInterface& /*
   
   EPARcuResultEvent ack(event);
 
-  uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) + getCurrentIndex();
+  uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrRcusPerBoard()) + getCurrentIndex();
 
   if (!ack.hdr.isValidAck(m_hdr))
   {
diff --git a/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc b/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc
index fab2b40895d..5194a741ac3 100644
--- a/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc
+++ b/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc
@@ -70,7 +70,9 @@ void RCUWrite::sendrequest()
   rcusettings.hdr.set(MEPHeader::RCU_SETTINGS_HDR, 1 << getCurrentIndex()); // also sets payload_length
   rcusettings.ap = EPA_Protocol::RCUHandler();
   rcusettings.ap.input_delay_x = x.getDelay();
+  rcusettings.ap.enable_x      = y.getEnable();
   rcusettings.ap.input_delay_y = y.getDelay();
+  rcusettings.ap.enable_y      = y.getEnable();
 
   m_hdr = rcusettings.hdr;
   getBoardPort().send(rcusettings);
diff --git a/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in b/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in
index 8d4cd212fe7..c2154819ce0 100644
--- a/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in
+++ b/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in
@@ -70,25 +70,47 @@ RSPDriver.MAC_ADDR_23=00:00:00:00:00:17
 # Data output payload size.
 # Should eventually be computed dynamically
 # based on settings.
-# now 1744 was 736
-RSPDriver.OUTPUT_PAYLOAD_SIZE=1744
+#
+# Data output payload size.
+# Should eventually be computed dynamically
+# based on settings.
+# c_frame_size  = g_hdr_sz + nof_blocks * (c_block_size + c_epa_hdr_size)
+#               = 16 + 1*(2*2*54 + 8) = 240 words (16 bit)
+# OUTPUT_PAYLOAD_SIZE = (240 - 16)*2 = 448 octets
+#
+RSPDriver.OUTPUT_PAYLOAD_SIZE=448
 
 #
 # Destination IP and MAC address for data packets
 # leaving the RSP board with the given index
 #
+
 #
-# Output to lofar11
+# Output to CEP inputnode 1
 #
 RSPDriver.SRC_IP_ADDR_0=10.1.0.1
 RSPDriver.DST_IP_ADDR_0=192.168.2.111
-RSPDriver.DST_MAC_ADDR_0=00:04:23:B5:C4:6A
+RSPDriver.DST_MAC_ADDR_0=00:E0:81:31:DE:8A
+
 #
-# Output to lofar12
+# Output to CEP inputnode 3
 #
 RSPDriver.SRC_IP_ADDR_1=10.1.0.2
 RSPDriver.DST_IP_ADDR_1=192.168.2.112
-RSPDriver.DST_MAC_ADDR_1=00:04:23:B5:C5:CA
+RSPDriver.DST_MAC_ADDR_1=00:E0:81:31:DF:D4
+
+#
+# Output to lofar11
+#
+# RSPDriver.SRC_IP_ADDR_0=10.1.0.1
+# RSPDriver.DST_IP_ADDR_0=192.168.2.111
+# RSPDriver.DST_MAC_ADDR_0=00:04:23:B5:C4:6A
+#
+# Output to lofar12
+#
+# RSPDriver.SRC_IP_ADDR_1=10.1.0.2
+# RSPDriver.DST_IP_ADDR_1=192.168.2.112
+# RSPDriver.DST_MAC_ADDR_1=00:04:23:B5:C5:CA
 
 RSPDriver.SRC_IP_ADDR_2=10.1.0.3
 RSPDriver.DST_IP_ADDR_2=10.2.0.3
@@ -210,12 +232,14 @@ RSPDriver.WRITE_BF=1
 RSPDriver.WRITE_SS=1
 RSPDriver.WRITE_RCU=1
 RSPDriver.WRITE_RCU_PROTOCOL=1
+RSPDriver.WRITE_HBA_PROTOCOL=0
 RSPDriver.WRITE_TDS_PROTOCOL=1
 RSPDriver.READ_SST=1
 RSPDriver.READ_BST=1
 RSPDriver.WRITE_WG=1
 RSPDriver.WRITE_WG_WAVE=0
 RSPDriver.READ_RCU_RESULT=1
+RSPDriver.READ_HBA_RESULT=0
 RSPDriver.READ_TDS_RESULT=1
 RSPDriver.READ_VERSION=1
 RSPDriver.READ_XST=1
diff --git a/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc b/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc
index 127e1f767b0..e5697b390fb 100644
--- a/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc
+++ b/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc
@@ -73,7 +73,16 @@ void SetRCUCmd::apply(CacheBuffer& cache, bool setModFlag)
 	cache.getCache().getState().bs().write(cache_rcu / MEPHeader::N_POL);
 
         cache.getCache().getState().rcusettings().write(cache_rcu);
-        cache.getCache().getState().rcuprotocol().write(cache_rcu);
+
+#if 0
+	// HACK HACK, prevent rcuprotocol write when enabling RCU input
+	// assumption is that rcuprotocol has been written previously
+	if (!m_event->settings()(0).getEnable()) {
+#endif
+	  cache.getCache().getState().rcuprotocol().write(cache_rcu);
+#if 0
+	}
+#endif
       }
     }
   }
diff --git a/MAC/APL/PIC/RSPDriver/src/rspctl.cc b/MAC/APL/PIC/RSPDriver/src/rspctl.cc
index c971c5a193c..b487a6ac371 100644
--- a/MAC/APL/PIC/RSPDriver/src/rspctl.cc
+++ b/MAC/APL/PIC/RSPDriver/src/rspctl.cc
@@ -1771,7 +1771,8 @@ static void usage()
   cout << "         --rcureset       |" << endl;
   cout << "         --rcuattenuation |" << endl;
   cout << "         --rcuspecinv     |" << endl;
-  cout << "         --rcudelay" << endl;
+  cout << "         --rcudelay       |" << endl;
+  cout << "         --rcuenable      |" << endl;
   cout << "       ]+ [--select=<set>] # control RCU by combining any of these commands with selection" << endl;
   cout << endl;
   cout << "       --rcumode=[0..7] # set the RCU in a specific mode" << endl;
@@ -1788,6 +1789,7 @@ static void usage()
   cout << "       --rcuattenuation=[0..31]  # set the RCU attenuation" << endl;
   cout << "       --rcuspecinv              # enable spectral inversion" << endl;
   cout << "       --rcudelay=[0..127]       # set the delay for rcu's" << endl;
+  cout << "       --rcudelay                # enable input from RCU's" << endl;
   cout << endl;
   cout << "rspctl --wg                  [--select=<set>]  # get waveform generator settings" << endl;
   cout << "rspctl --wg=freq [--phase=..][--select=<set>]  # set waveform generator settings" << endl;
@@ -1845,6 +1847,7 @@ Command* RSPCtl::parse_options(int argc, char** argv)
 	  { "rcuattenuation", required_argument, 0, 'n' },
 	  { "rcuspecinv",     no_argument,       0, 'u' },
 	  { "rcudelay",       required_argument, 0, 'y' },
+          { "rcuenable",      no_argument,       0, 'E' },
 	  { "wg",             optional_argument, 0, 'g' },
 	  { "wgmode",         required_argument, 0, 'G' },
 	  { "phase",          required_argument, 0, 'P' },
@@ -2010,7 +2013,8 @@ Command* RSPCtl::parse_options(int argc, char** argv)
 	case 'e': // --rcureset
 	case 'n': // --rcuattenuation
 	case 'u': // --rcuspecinv
-	case 'y': // --recudelay
+	case 'y': // --rcudelay
+        case 'E': // --rcuenable
 	  {
 	    // instantiate once, then reuse to add control bits
 	    if (!rcumodecommand) {
@@ -2075,7 +2079,12 @@ Command* RSPCtl::parse_options(int argc, char** argv)
 	      }
 	      rcumodecommand->control().setDelay((uint8)controlopt);
 	      break;
+
+            case 'E': // --rcuenable
+              rcumodecommand->control().setEnable(true);
+              break;
 	    }
+
 	  }
 	  break;
 
-- 
GitLab