LCOV - code coverage report
Current view: top level - nrao/VLA - VLAOnlineInput.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 47 0.0 %
Date: 2024-10-09 13:55:54 Functions: 0 6 0.0 %

          Line data    Source code
       1             : //# VLAOnlineInput.cc: This class reads VLA archive files from a Disk
       2             : //# Copyright (C) 2001
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id: VLAOnlineInput.cc,v 19.1.20.4 2006/02/17 23:46:40 wyoung Exp $
      27             : 
      28             : #include <nrao/VLA/VLAOnlineInput.h>
      29             : #include <casacore/casa/Utilities/Assert.h>
      30             : #include <casacore/casa/Exceptions/Error.h>
      31             : #include <casacore/casa/IO/MemoryIO.h>
      32             : #include <casacore/casa/IO/ByteIO.h>
      33             : #include <nrao/VLA/nreal.h>
      34             : #include <cstdlib>
      35             : 
      36             : 
      37             : // this is an expediant, we should get it from the IERS table
      38             : #define LEAP_SECONDS 33
      39             : 
      40           0 : String VLAOnlineInput::getTodaysFile(int relDay){
      41           0 :   int LeapSeconds = LEAP_SECONDS;
      42             :   time_t curTime, holdTime;          /* time vars */
      43             :   struct tm *tmTime;                 /* time structure */
      44           0 :   ostringstream  aDate;
      45           0 :   curTime = time(&holdTime) + LeapSeconds + relDay*86400;
      46           0 :   tmTime = gmtime(&curTime);
      47           0 :   oldDay = tmTime->tm_yday;
      48             : 
      49             : // Format up the online vla file
      50             : 
      51           0 :   aDate << visDir << "/vla";
      52           0 :   aDate.width(4);
      53           0 :   aDate.fill('0');
      54           0 :   aDate << tmTime->tm_year+1900 << "-";
      55           0 :   aDate.width(2);
      56           0 :   aDate << tmTime->tm_mon+1 << "-" << tmTime->tm_mday << ".dat";
      57           0 :   return(String(aDate.str()));
      58           0 : }
      59             : 
      60             : // simple function see what today is
      61             : 
      62           0 : Int VLAOnlineInput::whatsToday(){
      63           0 :   time_t LeapSeconds = LEAP_SECONDS;
      64             :   time_t curTime, holdTime;          /* time vars */
      65             :   struct tm *tmTime;                 /* time structure */
      66           0 :   curTime = time(&holdTime) + LeapSeconds;
      67           0 :   tmTime = gmtime(&curTime);
      68           0 :   return tmTime->tm_yday;
      69             : }
      70             : 
      71             : // Here's the online version to read data from the VLA online data repository
      72             : 
      73           0 : VLAOnlineInput::VLAOnlineInput(String &onlineFlag, Int afiles)
      74           0 :   :VLAArchiveInput()
      75             : {
      76             :    // Need to check for :-x to set the relative day.
      77           0 :    if(onlineFlag == "online"){
      78           0 :       previousDay = 0;
      79           0 :       char *dataDir = getenv("VISDATADIR");
      80           0 :       if(!dataDir){
      81           0 :           dataDir = strdup("/home/vis-serv-mirror/vladata");
      82             :       }
      83           0 :       visDir = String(dataDir);
      84           0 :       int dum(-99);
      85           0 :       std::cerr << getTodaysFile() << std::endl;
      86             :       //olopen_(&dum, (char *)getTodaysFile().data(), 1);
      87           0 :       olopen_(&dum, const_cast<char*>("online"), 1);
      88           0 :       oladvf_(&dum, &afiles);      // Positions the online filler
      89             :                                    // afile < 0 previous days upto 14
      90             :                                    // afile == 0, start of current day
      91             :                                    // afile > 0, now
      92           0 :       onlineFill = true;
      93             :    } else {
      94           0 :       throw(AipsError("Invalid online specifier " + onlineFlag));
      95             :    }
      96             : 
      97           0 : }
      98             : 
      99           0 : VLAOnlineInput::~VLAOnlineInput() {
     100             :   // The StreamIO destructor closes the port.
     101           0 : }
     102             : 
     103           0 : Bool VLAOnlineInput::read() {
     104           0 :         Bool rstatus(true);
     105           0 :   itsMemIO->clear();
     106           0 :   Long logicalRecordSize(MAX_LOGICAL_RECORD_SIZE);
     107           0 :   Char* recordPtr = (Char *)itsMemIO->setBuffer(logicalRecordSize);
     108           0 :   logicalRecordSize = readVLALogRec(recordPtr);
     109           0 :   itsMemIO->setUsed(logicalRecordSize);
     110           0 :   itsRecord.seek(0);
     111           0 :   if(!logicalRecordSize)
     112           0 :           rstatus = false;
     113           0 :   return rstatus;
     114             : }
     115             : 
     116             : // Local Variables:
     117             : // compile-command: "gmake VLADiskInput; cd test; gmake OPTLIB=1 tVLADiskInput"
     118             : // End:

Generated by: LCOV version 1.16