Commit 8ef8208b authored by LorenzoMonti's avatar LorenzoMonti
Browse files

Merge branch 'centos_7_compatibility' of https://github.com/discos/discos into srt-bandW-receiver

parents 8e3daace 707cdd93
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#define ABS(X,Y) (X>=Y)?X-Y:Y-X

#define LIGHTSPEED_MS 299792458.0
#define ACSTIME2UNIXEPOCHOFFSET 122192928000000000

/** 
 * Creates an exception
+18 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
/* Andrea Orlati(aorlati@ira.inaf.it)  12/08/2015	  Function to check if a file exists or not */
/* Andrea Orlati(aorlati@ira.inaf.it)  19/11/2015	  Function timeToStrExtended was added */
/* Andrea Orlati(aorlati@ira.inaf.it)  12/01/2016	  reviewed the function skyFrequency in order to address also lower side band during down conversion */
/* Giuseppe Carboni (giuseppe.carboni@inaf.it) 07/12/2021 added the getUNIXEpoch, ACSTime2UNIXEpoch and UNIXEpoch2ACSTime functions */

#include <time.h>
#include <sys/time.h>
@@ -136,6 +137,23 @@ public:
	 * @return the ACS::Time variable containing the current time
	*/
	static ACS::Time getACSTime();
	/**
	 * Call this function to get the current UNIX epoch
	 * @return a double containing the current UNIX epoch
	*/
	static double getUNIXEpoch();
	/**
	 * Call this function in order to get the UNIX Epoch of the given ACS::Time
	 * @param acs_time the given ACS::Time
	 * @return a double containing the UNIX epoch of the given ACS::Time
	*/
	static double ACSTime2UNIXEpoch(ACS::Time acs_time);
	/**
	 * Call this function in order to get the ACS::Time of the given UNIX Epoch
	 * @param unix_epoch the given UNIX Epoch (double)
	 * @return a ACS::Time object of the given UNIX Epoch
	*/
	static ACS::Time UNIXEpoch2ACSTime(double unix_epoch);
	/** 
	 * This function performs the copy of an epoch
	 * @param dst destination epoch
+18 −3
Original line number Diff line number Diff line
@@ -56,6 +56,21 @@ ACS::Time CIRATools::getACSTime()
	return now.value().value;
}

double CIRATools::getUNIXEpoch()
{
	return CIRATools::ACSTime2UNIXEpoch(CIRATools::getACSTime());
}

double CIRATools::ACSTime2UNIXEpoch(ACS::Time acs_time)
{
	return double(acs_time - ACSTIME2UNIXEPOCHOFFSET) / 10000000;
}

ACS::Time CIRATools::UNIXEpoch2ACSTime(double unix_epoch)
{
	return ACS::Time(long(unix_epoch * 10000000) + ACSTIME2UNIXEPOCHOFFSET);
}

void CIRATools::timeCopy(TIMEVALUE& dst,const TIMEVALUE& src)
{
	// EpochHelper.value() should have to have the 'const' qualifiers....that would result in a warning
+72 −0
Original line number Diff line number Diff line
#ifndef _SRTMINORSERVOCOMMANDLIBRARY_H
#define _SRTMINORSERVOCOMMANDLIBRARY_H

/**
 * SRTMinorServoCommandLibrary.h
 * 2021/12/07
 * Giuseppe Carboni (giuseppe.carboni@inaf.it)
 */

#include <sstream>
#include <vector>
#include <acstimeEpochHelper.h>
#include <IRA>

/**
 * SRT Minor Servo Command Library
 *
 * This class features static functions used to build commands to be sent to the PON minor servo control unit of the Sardinia Radio Telescope
 */
class SRTMinorServoCommandLibrary
{
public:
    /**
     * Builds the command used to ask the status of the MSCU or, eventually, a single servo
     * @param servo_id the ID number of the eventual single servo to retrieve the status
     * @return the composed message
     */
    static std::string status(int servo_id = -1);

    /**
     * Builds the command used to configure the telescope for an observation
     * @param configuration the desired observing configuration
     * @return the composed message
     */
    static std::string setup(std::string configuration);

    /*
     * Builds the command used to stow a single servo system to a given stow position
     * @param servo_id the ID number of the single servo to be stowed
     * @param stow_position the position to which the servo have to stow to
     * @return the composed message
     */
    static std::string stow(unsigned int servo_id, unsigned int stow_position = 0);

    /*
     * Builds the command used to stop a single servo system
     * @param servo_id the ID number of the single servo to be stopped
     * @return the composed message
     */
    static std::string stop(unsigned int servo_id);

    /*
     * Builds the command used to move a single servo to a given set of coordinates
     * @param servo_id the ID number of the single servo to be moved
     * @param coordinates a vector containing the N coordinates to be sent to the servo
     * @return the composed message
     */
    static std::string preset(unsigned int servo_id, std::vector<double> coordinates);

    /*
     * Builds the command used to provide a single tracking set of coordinates to a single servo
     * @param servo_id the ID number of the single servo to send the command to
     * @param trajectory_id the ID number of the trajectory the given set of coordinates belongs to
     * @param point_id the ID number of the given set of coordinates inside the trajectory
     * @param coordinates a vector containing the N coordinates the servo have to move to at the given time
     * @param start_time only mandatory for the first point in the trajectory, a double representing the UNIX epoch of the starting instant of the trajectory
     * @return the composed message
     */
    static std::string programTrack(unsigned int servo_id, unsigned int trajectory_id, unsigned int point_id, std::vector<double> coordinates, double start_time = -1);
};

#endif
+5 −3
Original line number Diff line number Diff line
@@ -50,15 +50,17 @@ xxxxx_LIBS =
#
# Includes (.h) files (public only)
# ---------------------------------
INCLUDES        = hexlib.h
INCLUDES        = hexlib.h SRTMinorServoCommandLibrary.h

#
# Libraries (public and local)
# ----------------------------
LIBRARIES       = SRTMinorServoLibrary
LIBRARIES       = SRTMinorServoLibrary SRTMinorServoCommandLibrary
LIBRARIES_L     =
SRTMinorServoLibrary_OBJECTS = hexlib
SRTMinorServoLibrary_LIBS =
SRTMinorServoCommandLibrary_OBJECTS = SRTMinorServoCommandLibrary
SRTMinorServoCommandLibrary_LIBS = IRALibrary

#
# <brief description of lllll library>
Loading