Commit 2260f8f0 authored by Andrea Orlat's avatar Andrea Orlat
Browse files

added summary.fits that reports scan information and marks the end of the scan

parent 33cdc439
Loading
Loading
Loading
Loading
+94 −0
Original line number Diff line number Diff line
@@ -47,6 +47,100 @@ public:
			return "GC";
		}
	}
	static bool map(const char *str,TReferenceFrame& frame) {
		if (strcasecmp(str,"TOPOCEN")==0) {
			frame=Antenna::ANT_TOPOCEN;
			return true;
		}
		else if (strcasecmp(str,"BARY")==0) {
			frame=Antenna::ANT_BARY;
			return true;
		}
		else if (strcasecmp(str,"LSRK")==0) {
			frame=Antenna::ANT_LSRK;
			return true;
		}
		else if (strcasecmp(str,"LSRD")==0) {
			frame=Antenna::ANT_LSRD;
			return true;
		}
		else if (strcasecmp(str,"GALCEN")==0) {
			frame=Antenna::ANT_GALCEN;
			return true;
		}
		else if (strcasecmp(str,"LGRP")==0) {
			frame=Antenna::ANT_LGROUP;
			return true;
		}
		else if (strcasecmp(str,"UNDEF")==0) {
			frame=Antenna::ANT_UNDEF_FRAME;
			return true;
		}
		else {
			return false;
		}
	};

	static const char *map(const TReferenceFrame& frame) {
		if (frame==Antenna::ANT_TOPOCEN) {
			return "TOPOCEN";
		}
		else if (frame==Antenna::ANT_BARY) {
			return "BARY";
		}
		else if (frame==Antenna::ANT_LSRK) {
			return "LSRK";
		}
		else if (frame==Antenna::ANT_LSRD) {
			return "LSRD";
		}
		else if (frame==Antenna::ANT_GALCEN) {
			return "GALCEN";
		}
		else if (frame==Antenna::ANT_LGROUP) {
			return "LGRP";
		}
		else { //if (frame==Antenna::ANT_UNDEF_FRAME) {
			return "UNDEF";
		}
	};

	static bool map(const char *str,TVradDefinition& frame) {
		if (strcasecmp(str,"RD")==0) {
			frame=Antenna::ANT_RADIO;
			return true;
		}
		else if (strcasecmp(str,"OP")==0) {
			frame=Antenna::ANT_OPTICAL;
			return true;
		}
		else if (strcasecmp(str,"Z")==0) {
			frame=Antenna::ANT_REDSHIFT;
			return true;
		}
		else if (strcasecmp(str,"UNDEF")==0) {
			frame=Antenna::ANT_UNDEF_DEF;
			return true;
		}
		else {
			return false;
		}
	};

	static const char *map(const TVradDefinition& frame) {
		if (frame==Antenna::ANT_RADIO) {
			return "RD";
		}
		else if (frame==Antenna::ANT_OPTICAL) {
			return "OP";
		}
		else if (frame==Antenna::ANT_REDSHIFT) {
			return "Z";
		}
		else { // if (frame==Antenna::ANT_UNDEF_DEF) {
			return "UNDEF";
		}
	};
};

};
+2 −0
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@ public:
	 * @param services pointer to the container services object
	 */		
	static void unloadMeteoComponent(Weather::GenericWeatherStation_var& ref,maci::ContainerServices *& services) throw (ComponentErrors::CouldntReleaseComponentExImpl,ComponentErrors::UnexpectedExImpl);

	static void map(const ACS::doubleSeq& seq,std::list<double>& va);
};


+10 −1
Original line number Diff line number Diff line
@@ -223,6 +223,12 @@ public:
	 */	
	IRA::CString getFileName() const;

	/**
	 * Get the full name of the current summary file
	 * @return the full path and the file name of the current file
	 */
	IRA::CString getSummaryFileName() const;

	/**
	 * Get the name of the project
	 */
@@ -406,6 +412,8 @@ public:
	 */
	bool isSubScanHeaderReady() const { return m_subScanHeader; }

	bool isWriteSummary() const { return m_writeSummary; }

	/**
	 * It puts the component into the stop stage
	 */
@@ -494,6 +502,7 @@ private:
	 */
	bool m_scanHeader;
	bool m_subScanHeader;
	bool m_writeSummary;
	/**
	 *  indicates if the component is saving...
	 */
+11 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <fstream>
#else
#include "FitsWriter.h"
#include "SummaryWriter.h"
#endif
#include "Configuration.h"
#include "MetaData.h"
@@ -85,11 +86,13 @@ private:
	ofstream m_file;
#else
	CFitsWriter *m_file;
	CSummaryWriter *m_summary;
#endif
	CConfiguration *m_config;
	CMetaData m_info;
	maci::ContainerServices * m_service;
	bool m_fileOpened;
	bool m_summaryOpened;
	ACS::TimeInterval m_timeSlice;
	double *m_ptsys;
	bool antennaBossError;
@@ -98,6 +101,8 @@ private:
	Receivers::ReceiversBoss_var m_receiversBoss;
	bool minorServoBossError;
	MinorServo::MinorServoBoss_var m_minorServoBoss;
	bool m_schedulerError;
	Management::Scheduler_var m_scheduler;
	ACS::Time m_lastMinorServoEnquireTime;
	bool checkTime(const ACS::Time& jobStartTime);
	bool checkTimeSlot(const ACS::Time& slotStart);
@@ -105,15 +110,19 @@ private:
	/**
	 * It gets and updates the receiver code, and all the required data from the receviers subsystem 
	 */
	void collectReceiversData();
	void collectReceiversData(FitsWriter_private::CFile* summaryFile);
	/**
	 * It gets and updates the all the required data from the antenna subsystem 
	 */
	void collectAntennaData();
	void collectAntennaData(FitsWriter_private::CFile* summaryFile);
	/**
	 * It gets and update all the required data from the minor servo subsytem
	 */
	void collectMinorServoData();
	/**
	 * It gets and update all the required data from the management subsystem
	 */
	void collectSchedulerData(FitsWriter_private::CFile* summaryFile);

};

+255 −0
Original line number Diff line number Diff line
/* ************************************************************************************************************* */
/* IRA Istituto di Radioastronomia                                                                               */
/*                                                                                                               */
/* This code is under GNU General Public Licence (GPL).                                                          */
/*                                                                                                               */
/* Who                                    when            What                                                       */
/* Andrea Orlati (a.orlati@ira.inaf.it)   29/04/2015      created                         */


#ifndef FILE_H_
#define FILE_H_

#include <IRA>
#include <list>
#include <boost/preprocessor/iteration/local.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/comparison/equal.hpp>


#define _FILE_DOUBLE_TYPE CDoubleTypeEntry
#define _FILE_STRING_TYPE CStringTypeEntry
#define _FILE_LONG_TYPE CLongTypeEntry

#define _FILE_SINGLE_ENTRY 1
#define _FILE_MULTI_ENTRY 2

#define _FILE_EXPAND(n) SCHEMA_ENTRY##n
#define _FILE_CREATEFILE(n) _FILE_LOCAL_FILE->createEntry<BOOST_PP_TUPLE_ELEM(4, 0, _FILE_EXPAND(n)), \
														  !BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(4,1,_FILE_EXPAND(n)),1) > \
														( BOOST_PP_TUPLE_ELEM(4, 2, _FILE_EXPAND(n)), \
													      BOOST_PP_TUPLE_ELEM(4, 3, _FILE_EXPAND(n)) );

// note, the blank between the macro and the parenthesis is mandatory
#define BOOST_PP_LOCAL_LIMITS (1, SCHEMA_ENTRY_NUMBER)
#define BOOST_PP_LOCAL_MACRO(n) _FILE_CREATEFILE(n)

#define _FILE_COMPARE(H,K) BOOST_PP_EQUAL(H,K)

namespace FitsWriter_private {

typedef enum {
	_FILE_STRING_TYPE_S,
	_FILE_DOUBLE_TYPE_S,
	_FILE_LONG_TYPE_S
} TFileTypeEnumeration;

class CDoubleTypeEntry {
public:
	static double defaultValue;
	typedef double TEntryType;
	typedef double TEntryReference;
	static TFileTypeEnumeration typeSpec;
};

class CStringTypeEntry {
public:
	static IRA::CString defaultValue;
	typedef IRA::CString TEntryType;
	typedef const char * TEntryReference;
	static TFileTypeEnumeration typeSpec;
};

class CLongTypeEntry {
public:
	static long defaultValue;
	typedef long TEntryType;
	typedef long TEntryReference;
	static TFileTypeEnumeration typeSpec;
};

class CEntry {
public:
	virtual ~CEntry() {};
	virtual const char *getKeyword() const { return (const char *)keyword; };
	virtual const char *getDescription() const { return (const char*)description; }
	virtual TFileTypeEnumeration getType() const { return typeSpec; }
	virtual bool isSimple() const { return !multi; }
protected:
	CEntry(): keyword(""), description("") { };
	//CEntry(const IRA::CString& key,const IRA::CString& desc): keyword(key), description(desc) { };
	CEntry(const IRA::CString& key,const IRA::CString& desc,const TFileTypeEnumeration& t,const bool& m): keyword(key), description(desc),
			typeSpec(t), multi(m) { };
	IRA::CString keyword;
	IRA::CString description;
	TFileTypeEnumeration typeSpec;
	bool multi;
};

template <class T,bool MULTI> class CHeaderEntry : public virtual CEntry {
public:
	typedef typename T::TEntryType _type;
	typedef typename T::TEntryReference _ref;
	CHeaderEntry() { };
	CHeaderEntry(const IRA::CString& key,const IRA::CString& desc): CEntry(key,desc,T::typeSpec,MULTI), value(T::defaultValue)
	{
	};
	CHeaderEntry(const IRA::CString& key,const IRA::CString& desc,const T& val): CEntry(key,desc,T::typeSpec,MULTI), value(val)
	{
	};
	virtual ~CHeaderEntry() {
	};
	CHeaderEntry& operator=(const _type& val) {
		value=val;
		return *this;
	};
	_ref getValue() const { return value; }
private:
	_type value;
};

template <class T> class CHeaderEntry<T,true>: public virtual CEntry {
public:
	typedef typename T::TEntryType _type;
	typedef typename T::TEntryReference _ref;
	typedef typename std::list<_type> TSequence;
	typedef typename TSequence::iterator TScroll;
	typedef typename std::list<_ref> TRefSequence;
	typedef typename TRefSequence::iterator TRefScroll;
	CHeaderEntry(const IRA::CString& key,const IRA::CString& desc) : CEntry(key,desc,T::typeSpec,true) {
		vocabulary.empty();
		vocabulary.push_back(T::defaultValue);
	}
	CHeaderEntry(const IRA::CString& key,const IRA::CString& desc,const TSequence& val) : CEntry(key,desc,T::typeSpec,true) {
		vocabulary=val;
	}
	~CHeaderEntry() {
		vocabulary.empty();
	}
	CHeaderEntry& operator=(const TSequence& val) {
		TScroll it;
		vocabulary=val;
		ret.empty();
		for (it=vocabulary.begin();it!=vocabulary.end();it++) {  // this is done to cope with the (const char *) conversion in the CString case
			ret.push_back((_ref)*it);
		}
		return *this;
	};
	const TRefSequence& getValue() const {
		return ret;
	}
private:
	TSequence vocabulary;
	TRefSequence ret;
};

class CFile {
public:
	CFile();

	~CFile();

	void reset();

	template <class T,bool MULTI> void createEntry(const IRA::CString& keyword,const IRA::CString& desc) {
		CHeaderEntry<T,MULTI> *p=new CHeaderEntry<T,MULTI>(keyword,desc);
		m_file[keyword]=(CEntry *)p;
	};

	void setKeyword(const IRA::CString& key,const _FILE_STRING_TYPE::TEntryType& val) {
		TScroll it=m_file.find(key);
		if (it!=m_file.end()) {
			if (it->second->getType()==_FILE_STRING_TYPE::typeSpec) {
				CHeaderEntry<_FILE_STRING_TYPE,false> *p=dynamic_cast<CHeaderEntry<_FILE_STRING_TYPE,false> *>(it->second);
				if (p!=NULL) {
					(*p)=val;
				}
			}
		}
	}

	void setKeyword(const IRA::CString& key,const std::list<_FILE_STRING_TYPE::TEntryType>& val) {
		TScroll it=m_file.find(key);
		if (it!=m_file.end()) {
			if (it->second->getType()==_FILE_STRING_TYPE::typeSpec) {
				CHeaderEntry<_FILE_STRING_TYPE,true> *p=dynamic_cast<CHeaderEntry<_FILE_STRING_TYPE,true> *>(it->second);
				if (p!=NULL) {
					(*p)=val;
				}
			}
		}
	}

	void setKeyword(const IRA::CString& key,const _FILE_DOUBLE_TYPE::TEntryType& val) {
		TScroll it=m_file.find(key);
		if (it!=m_file.end()) {
			if (it->second->getType()==_FILE_DOUBLE_TYPE::typeSpec) {
				CHeaderEntry<_FILE_DOUBLE_TYPE,false> *p=dynamic_cast<CHeaderEntry<_FILE_DOUBLE_TYPE,false> *>(it->second);
				if (p!=NULL) {
					(*p)=val;
				}
			}
		}
	}

	void setKeyword(const IRA::CString& key,const std::list<_FILE_DOUBLE_TYPE::TEntryType>& val) {
		TScroll it=m_file.find(key);
		if (it!=m_file.end()) {
			if (it->second->getType()==_FILE_DOUBLE_TYPE::typeSpec) {
				CHeaderEntry<_FILE_DOUBLE_TYPE,true> *p=dynamic_cast<CHeaderEntry<_FILE_DOUBLE_TYPE,true> *>(it->second);
				if (p!=NULL) {
					(*p)=val;
				}
			}
		}
	}

	void setKeyword(const IRA::CString& key,const _FILE_LONG_TYPE::TEntryType& val) {
		TScroll it=m_file.find(key);
		if (it!=m_file.end()) {
			if (it->second->getType()==_FILE_LONG_TYPE::typeSpec) {
				CHeaderEntry<_FILE_LONG_TYPE,false> *p=dynamic_cast<CHeaderEntry<_FILE_LONG_TYPE,false> *>(it->second);
				if (p!=NULL) {
					(*p)=val;
				}
			}
		}
	}

	void setKeyword(const IRA::CString& key,const std::list<_FILE_LONG_TYPE::TEntryType>& val) {
		TScroll it=m_file.find(key);
		if (it!=m_file.end()) {
			if (it->second->getType()==_FILE_LONG_TYPE::typeSpec) {
				CHeaderEntry<_FILE_LONG_TYPE,true> *p=dynamic_cast<CHeaderEntry<_FILE_LONG_TYPE,true> *>(it->second);
				if (p!=NULL) {
					(*p)=val;
				}
			}
		}
	}

	CEntry *getNextEntry() {
		CEntry *temp;
		if (m_iter!=m_file.end()) {
			temp=m_iter->second;
			m_iter++;
		}
		else {
			temp=NULL;
		}
		return temp;
	}

	void begin() { m_iter=m_file.begin(); }

private:
	typedef std::map<IRA::CString,CEntry *> TFile;
	typedef TFile::iterator TScroll;
	TFile m_file;
	TScroll m_iter;
};

};


#endif /* FILE_H_ */
Loading