diff --git a/SRT/Libraries/GAIABoardCommandLibrary/include/GAIABoardCommandLibrary.h b/SRT/Libraries/GAIABoardCommandLibrary/include/GAIABoardCommandLibrary.h new file mode 100644 index 0000000000000000000000000000000000000000..f2a928d4bf6afaceb9be5440d1a5d36dafdc9dfb --- /dev/null +++ b/SRT/Libraries/GAIABoardCommandLibrary/include/GAIABoardCommandLibrary.h @@ -0,0 +1,78 @@ +#ifndef _GAIABOARDCOMMANDLIBRARY_H +#define _GAIABOARDCOMMANDLIBRARY_H + +/** + * GAIABoardCommandLibrary.h + * 2022/02/25 + * Giuseppe Carboni (giuseppe.carboni@inaf.it) + */ + +#include + +#define HEADER "#" +#define TAIL "\n" + +/** + * GAIA Board Command Library + * + * This class features static functions used to build commands to be sent to the GAIA Boards + */ +class GAIABoardCommandLibrary +{ +public: + /** + * Builds the command used to ask some info about the GAIA Board and its firmware + * @return the composed message + */ + static std::string idn(); + + /** + * Builds the command used to turn on the Low Noise Amplifiers + * @param channel the channel the command will be sent to + * @return the composed message + */ + static std::string enable(unsigned int channel); + + /** + * Builds the command used to retrieve the gate tension + * @param channel the channel the command will be sent to + * @return the composed message + */ + static std::string getvg(unsigned int channel); + + /** + * Builds the command used to retrieve the drain tension + * @param channel the channel the command will be sent to + * @return the composed message + */ + static std::string getvd(unsigned int channel); + + /** + * Builds the command used to retrieve the drain current draw + * @param channel the channel the command will be sent to + * @return the composed message + */ + static std::string getid(unsigned int channel); + + /** + * Builds the command used to retrieve the reference tensions + * @param channel the channel the command will be sent to + * @return the composed message + */ + static std::string getref(unsigned int channel); + + /** + * Builds the command used to retrieve the temperature of the analog to digital converter + * @param channel the channel the command will be sent to + * @return the composed message + */ + static std::string getemp(unsigned int channel); + + /** + * Builds the command used to retrieve the name of the GAIA Board + * @return the composed message + */ + static std::string name(); +}; + +#endif diff --git a/SRT/Libraries/GAIABoardCommandLibrary/src/GAIABoardCommandLibrary.cpp b/SRT/Libraries/GAIABoardCommandLibrary/src/GAIABoardCommandLibrary.cpp new file mode 100644 index 0000000000000000000000000000000000000000..583e80abe2d50d314a6fd0a0b6168770acb6da7d --- /dev/null +++ b/SRT/Libraries/GAIABoardCommandLibrary/src/GAIABoardCommandLibrary.cpp @@ -0,0 +1,63 @@ +/** + * GAIABoardCommandLibrary.cpp + * 2022/02/25 + * Giuseppe Carboni (giuseppe.carboni@inaf.it) + */ + +#include "GAIABoardCommandLibrary.h" + +std::string GAIABoardCommandLibrary::idn() +{ + std::stringstream command; + command << HEADER << "IDN?" << TAIL; + return command.str(); +} + +std::string GAIABoardCommandLibrary::enable(unsigned int channel) +{ + std::stringstream command; + command << HEADER << "ENABLE " << channel << TAIL; + return command.str(); +} + +std::string GAIABoardCommandLibrary::getvg(unsigned int channel) +{ + std::stringstream command; + command << HEADER << "GETVG " << channel << TAIL; + return command.str(); +} + +std::string GAIABoardCommandLibrary::getvd(unsigned int channel) +{ + std::stringstream command; + command << HEADER << "GETVD " << channel << TAIL; + return command.str(); +} + +std::string GAIABoardCommandLibrary::getid(unsigned int channel) +{ + std::stringstream command; + command << HEADER << "GETID " << channel << TAIL; + return command.str(); +} + +std::string GAIABoardCommandLibrary::getref(unsigned int channel) +{ + std::stringstream command; + command << HEADER << "GETREF " << channel << TAIL; + return command.str(); +} + +std::string GAIABoardCommandLibrary::getemp(unsigned int channel) +{ + std::stringstream command; + command << HEADER << "GETEMP " << channel << TAIL; + return command.str(); +} + +std::string GAIABoardCommandLibrary::name() +{ + std::stringstream command; + command << HEADER << "NAME?" << TAIL; + return command.str(); +} diff --git a/SRT/Libraries/GAIABoardCommandLibrary/src/Makefile b/SRT/Libraries/GAIABoardCommandLibrary/src/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b9ebdc1a26d8300f3602fdf1c157d39254d81014 --- /dev/null +++ b/SRT/Libraries/GAIABoardCommandLibrary/src/Makefile @@ -0,0 +1,231 @@ + +#******************************************************************************* +# PPPPPPPP +# +# "@(#) $Id$" +# +# Makefile of ........ +# +# who when what +# -------- -------- ---------------------------------------------- +# discos 30/10/20 created +# + +# ALMA - Atacama Large Millimeter Array +# Copyright (c) ESO - European Southern Observatory, 2014 +# (in the framework of the ALMA collaboration). +# All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#******************************************************************************* + +#******************************************************************************* +# This Makefile follows ALMA/ACS Standards (see Makefile(5) for more). +#******************************************************************************* +# REMARKS +# None +#------------------------------------------------------------------------ + +# +# user definable C-compilation flags +#USER_CFLAGS = + +# +# additional include and library search paths +#USER_INC = +#USER_LIB = + +# +# MODULE CODE DESCRIPTION: +# ------------------------ +# As a general rule: public file are "cleaned" and "installed" +# local (_L) are not "installed". + +# +# C programs (public and local) +# ----------------------------- +EXECUTABLES = +EXECUTABLES_L = + +# +# +xxxxx_OBJECTS = +xxxxx_LDFLAGS = +xxxxx_LIBS = + +# +# special compilation flags for single c sources +#yyyyy_CFLAGS = + +# +# Includes (.h) files (public only) +# --------------------------------- +INCLUDES = + +# +# Libraries (public and local) +# ---------------------------- +LIBRARIES = GAIABoardCommandLibrary +LIBRARIES_L = + +# +# +GAIABoardCommandLibrary_OBJECTS = GAIABoardCommandLibrary +GAIABoardCommandLibrary_LIBS = + +# +# Scripts (public and local) +# ---------------------------- +SCRIPTS = +SCRIPTS_L = + +# +# TCL scripts (public and local) +# ------------------------------ +TCL_SCRIPTS = +TCL_SCRIPTS_L = + +# +# Python stuff (public and local) +# ---------------------------- +PY_SCRIPTS = +PY_SCRIPTS_L = + +PY_MODULES = +PY_MODULES_L = + +PY_PACKAGES = +PY_PACKAGES_L = +pppppp_MODULES = + +# +# +tttttt_OBJECTS = +tttttt_TCLSH = +tttttt_LIBS = + +# +# TCL libraries (public and local) +# ------------------------------ +TCL_LIBRARIES = +TCL_LIBRARIES_L = + +# +# +tttlll_OBJECTS = + +# +# Configuration Database Files +# ---------------------------- +CDB_SCHEMAS = + +# +# IDL Files and flags +# +IDL_FILES = +TAO_IDLFLAGS = +USER_IDL = +# +# Jarfiles and their directories +# +JARFILES= +jjj_DIRS= +jjj_EXTRAS= +# For expressing dependencies between jarfiles (parallel builds) +jjj_JLIBS= +# +# java sources in Jarfile on/off +DEBUG= +# +# ACS XmlIdl generation on/off +# +XML_IDL= +# +# Java Component Helper Classes generation on/off +# +COMPONENT_HELPERS= +# +# Java Entity Classes generation on/off +# +XSDBIND= +# +# Schema Config files for the above +# +XSDBIND_INCLUDE= +# man pages to be done +# -------------------- +MANSECTIONS = +MAN1 = +MAN3 = +MAN5 = +MAN7 = +MAN8 = + +# +# local man pages +# --------------- +MANl = + +# +# ASCII file to be converted into Framemaker-MIF +# -------------------- +ASCII_TO_MIF = + +# +# other files to be installed +#---------------------------- +INSTALL_FILES = + +# +# list of all possible C-sources (used to create automatic dependencies) +# ------------------------------ +CSOURCENAMES = \ + $(foreach exe, $(EXECUTABLES) $(EXECUTABLES_L), $($(exe)_OBJECTS)) \ + $(foreach rtos, $(RTAI_MODULES) , $($(rtos)_OBJECTS)) \ + $(foreach lib, $(LIBRARIES) $(LIBRARIES_L), $($(lib)_OBJECTS)) + +# +#>>>>> END OF standard rules + +# +# INCLUDE STANDARDS +# ----------------- + +MAKEDIRTMP := $(shell searchFile include/acsMakefile) +ifneq ($(MAKEDIRTMP),\#error\#) + MAKEDIR := $(MAKEDIRTMP)/include + include $(MAKEDIR)/acsMakefile +endif + +# +# TARGETS +# ------- +all: do_all + @echo " . . . 'all' done" + +clean : clean_all + @echo " . . . clean done" + +clean_dist : clean_all clean_dist_all + @echo " . . . clean_dist done" + +man : do_man + @echo " . . . man page(s) done" + +install : install_all + @echo " . . . installation done" + + +#___oOo___ diff --git a/SRT/Libraries/GAIABoardCommandLibrary/tests/.discos b/SRT/Libraries/GAIABoardCommandLibrary/tests/.discos new file mode 100644 index 0000000000000000000000000000000000000000..1ada672a94fe0bc0155145468f693b3e4180735b --- /dev/null +++ b/SRT/Libraries/GAIABoardCommandLibrary/tests/.discos @@ -0,0 +1,5 @@ +This file is here to differentiate between ACS style test directory and discos-style test. + +This is a discos test directory + +DO NOT REMOVE THIS FILE diff --git a/SRT/Libraries/GAIABoardCommandLibrary/tests/Makefile b/SRT/Libraries/GAIABoardCommandLibrary/tests/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..5e06575c78dfabbb1a7392f30f0739c517f68ef4 --- /dev/null +++ b/SRT/Libraries/GAIABoardCommandLibrary/tests/Makefile @@ -0,0 +1,90 @@ +# CPP UNIT TESTING SETUP +#-------------- +GTEST_HOME=/usr/local/include/gtest +GMOCK_HOME=/usr/local/include/gmock +GTEST_LIBS=gtest gtest_main + +USER_INC=-I$(GTEST_HOME) -I$(GMOCK_HOME) +# END OF CPP UNIT TESTING SETUP +#--------------------- + +# DEFINE YOUR CPP UNIT TEST EXECUTABLES HERE as: +# +# EXECTUABLES_L = unittest +# unittest_OBJECTS = unittest +# unittest_LIBS = $(GTEST_LIBS) + +EXECUTABLES_L = unittest +unittest_OBJECTS = unittest +unittest_LIBS = $(GTEST_LIBS) GAIABoardCommandLibrary +unittest_LDFLAGS = -lstdc++ -lpthread + +# END OF CUSTOMIZATION +# do not edit below this line +#---------------------------- + +CSOURCENAMES = \ + $(foreach exe, $(EXECUTABLES) $(EXECUTABLES_L), $($(exe)_OBJECTS)) \ + $(foreach rtos, $(RTAI_MODULES) , $($(rtos)_OBJECTS)) \ + $(foreach lib, $(LIBRARIES) $(LIBRARIES_L), $($(lib)_OBJECTS)) + +MAKEDIRTMP := $(shell searchFile include/acsMakefile) +ifneq ($(MAKEDIRTMP),\#error\#) + MAKEDIR := $(MAKEDIRTMP)/include + include $(MAKEDIR)/acsMakefile +endif + +# TEST TARGETS +#TODO: unittest(2) discover pyunit + +do_unit: all + @echo "running cpp unit tests" + ../bin/unittest --gtest_output=xml:results/cppunittest.xml + +do_pyunit: + @echo "running python unit tests" + python -m unittest pyunit + +do_functional: + @echo "running python functional tests" + python -m unittest functional + +do_external: + @echo "running python external tests" + python -m unittest external + +clean_test: + rm -f results/*.xml + rm -f functional/*.pyc + rm -f pyunit/*.pyc + rm -f external/*.pyc + +unit: do_unit + @echo " . . . 'unit' done" + +pyunit: do_pyunit + @echo " . . . 'pyunit' done" + +functional: do_functional + @echo " . . . 'functional' done" + +external: do_external + @echo " . . . 'external' done" + +# TARGETS +# ------- +all: do_all + @echo " . . . 'all' done" + +clean : clean_all clean_test + @echo " . . . clean done" + +clean_dist : clean_all clean_dist_all clean_test + @echo " . . . clean_dist done" + +man : do_man + @echo " . . . man page(s) done" + +install : install_all + @echo " . . . installation done" + diff --git a/SRT/Libraries/GAIABoardCommandLibrary/tests/external/__init__.py b/SRT/Libraries/GAIABoardCommandLibrary/tests/external/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/SRT/Libraries/GAIABoardCommandLibrary/tests/functional/__init__.py b/SRT/Libraries/GAIABoardCommandLibrary/tests/functional/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/SRT/Libraries/GAIABoardCommandLibrary/tests/pyunit/__init__.py b/SRT/Libraries/GAIABoardCommandLibrary/tests/pyunit/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/SRT/Libraries/GAIABoardCommandLibrary/tests/unittest.cpp b/SRT/Libraries/GAIABoardCommandLibrary/tests/unittest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5ba815b7193818c43e158c711534faddc1db6799 --- /dev/null +++ b/SRT/Libraries/GAIABoardCommandLibrary/tests/unittest.cpp @@ -0,0 +1,35 @@ +#include "gtest/gtest.h" +#include "GAIABoardCommandLibrary.h" + +TEST(GAIABoardCommandLibraryTest, idn) +{ + EXPECT_EQ(GAIABoardCommandLibrary::idn(), "#IDN?\n"); +} +TEST(GAIABoardCommandLibraryTest, enable) +{ + EXPECT_EQ(GAIABoardCommandLibrary::enable(0), "#ENABLE 0\n"); +} +TEST(GAIABoardCommandLibraryTest, getvg) +{ + EXPECT_EQ(GAIABoardCommandLibrary::getvg(0), "#GETVG 0\n"); +} +TEST(GAIABoardCommandLibraryTest, getvd) +{ + EXPECT_EQ(GAIABoardCommandLibrary::getvd(0), "#GETVD 0\n"); +} +TEST(GAIABoardCommandLibraryTest, getid) +{ + EXPECT_EQ(GAIABoardCommandLibrary::getid(0), "#GETID 0\n"); +} +TEST(GAIABoardCommandLibraryTest, getref) +{ + EXPECT_EQ(GAIABoardCommandLibrary::getref(0), "#GETREF 0\n"); +} +TEST(GAIABoardCommandLibraryTest, getemp) +{ + EXPECT_EQ(GAIABoardCommandLibrary::getemp(0), "#GETEMP 0\n"); +} +TEST(GAIABoardCommandLibraryTest, name) +{ + EXPECT_EQ(GAIABoardCommandLibrary::name(), "#NAME?\n"); +}