Skip to content
Snippets Groups Projects
Select Git revision
  • 4d59d179accf1b151281d30d9c7ad6ac06dd0943
  • master default protected
  • L2SS-1914-fix_job_dispatch
  • TMSS-3170
  • TMSS-3167
  • TMSS-3161
  • TMSS-3158-Front-End-Only-Allow-Changing-Again
  • TMSS-3133
  • TMSS-3319-Fix-Templates
  • test-fix-deploy
  • TMSS-3134
  • TMSS-2872
  • defer-state
  • add-custom-monitoring-points
  • TMSS-3101-Front-End-Only
  • TMSS-984-choices
  • SDC-1400-Front-End-Only
  • TMSS-3079-PII
  • TMSS-2936
  • check-for-max-244-subbands
  • TMSS-2927---Front-End-Only-PXII
  • Before-Remove-TMSS
  • LOFAR-Release-4_4_318 protected
  • LOFAR-Release-4_4_317 protected
  • LOFAR-Release-4_4_316 protected
  • LOFAR-Release-4_4_315 protected
  • LOFAR-Release-4_4_314 protected
  • LOFAR-Release-4_4_313 protected
  • LOFAR-Release-4_4_312 protected
  • LOFAR-Release-4_4_311 protected
  • LOFAR-Release-4_4_310 protected
  • LOFAR-Release-4_4_309 protected
  • LOFAR-Release-4_4_308 protected
  • LOFAR-Release-4_4_307 protected
  • LOFAR-Release-4_4_306 protected
  • LOFAR-Release-4_4_304 protected
  • LOFAR-Release-4_4_303 protected
  • LOFAR-Release-4_4_302 protected
  • LOFAR-Release-4_4_301 protected
  • LOFAR-Release-4_4_300 protected
  • LOFAR-Release-4_4_299 protected
41 results

tGenerator.cc

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    tGenerator.cc 3.10 KiB
    //# tGenerator.cc
    //# Copyright (C) 2012-2013  ASTRON (Netherlands Institute for Radio Astronomy)
    //# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands
    //#
    //# This file is part of the LOFAR software suite.
    //# The LOFAR software suite is free software: you can redistribute it and/or
    //# modify it under the terms of the GNU General Public License as published
    //# by the Free Software Foundation, either version 3 of the License, or
    //# (at your option) any later version.
    //#
    //# The LOFAR software suite is distributed in the hope that it will be useful,
    //# but WITHOUT ANY WARRANTY; without even the implied warranty of
    //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    //# GNU General Public License for more details.
    //#
    //# You should have received a copy of the GNU General Public License along
    //# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
    //#
    //# $Id$
    
    #include <lofar_config.h>
    
    #include <unistd.h>
    #include <string>
    #include <vector>
    #include <omp.h>
    
    #include <Common/LofarLogger.h>
    #include <CoInterface/Stream.h>
    
    #include <InputProc/OMPThread.h>
    #include <InputProc/Station/PacketFactory.h>
    #include <InputProc/Station/Generator.h>
    #include <InputProc/Station/PacketReader.h>
    
    using namespace LOFAR;
    using namespace Cobalt;
    using namespace std;
    
    // The number of packets to transmit (note: there are 16 time samples/packet)
    #define NUMPACKETS (200000000 / 1024 / 16)
    
    int main( int, char **argv )
    {
      INIT_LOGGER( argv[0] );
    
      // Don't run forever if communication fails for some reason
      alarm(10);
    
      omp_set_nested(true);
      omp_set_num_threads(16);
    
      OMPThread::init();
    
      const string desc = "tcp:localhost:54321";
    
      vector< SmartPtr<Stream> > inputStreams(1);
      vector< SmartPtr<Stream> > outputStreams(1);
    
      #pragma omp parallel sections
      {
        #pragma omp section
        inputStreams[0] = createStream(desc, true);
    
        #pragma omp section
        outputStreams[0] = createStream(desc, false);
      }
    
      struct StationID stationID("RS106", "LBA", 200, 16);
      struct BufferSettings settings(stationID, false);
    
      const TimeStamp from(time(0), 0, stationID.clockMHz * 1000000);
      const TimeStamp to = from + NUMPACKETS * 16; /* 16 timeslots/packet */
      PacketFactory factory(settings);
      Generator g(settings, outputStreams, factory, from, to);
    
      bool error = false;
    
      #pragma omp parallel sections
      {
        #pragma omp section
        {
          // Generate packets
    
          try {
            g.process();
          } catch(Exception &ex) {
            LOG_ERROR_STR("Caught exception: " << ex);
            error = true;
          }
        }
    
        #pragma omp section
        {
          // Read and verify the generated packets
    
          try {
            PacketReader reader("", *inputStreams[0]);
    
            for(size_t nr = 0; nr < NUMPACKETS; ++nr) {
              struct RSP packet;
    
              if (!reader.readPacket(packet, settings)) {
                reader.logStatistics();
    
                ASSERT(false);
              }
            }
    
            // We received NUMPACKETS packets, kill the generator
            g.stop();
          } catch(Exception &ex) {
            LOG_ERROR_STR("Caught exception: " << ex);
            error = true;
          }
        }
      }
    
      return error ? 1 : 0;
    }