Skip to content
Snippets Groups Projects
Unverified Commit 16df0940 authored by Giuseppe Carboni's avatar Giuseppe Carboni Committed by GitHub
Browse files

Fix #680, implemented the command library for GAIA Boards (#686)

* Fix #680, implemented the command library for GAIA Boards

This command library only contains the bare minimum commands that are necessary to check the status of the hardware and some information of a GAIA Board, along with the command that turns on the Low Noise Amplifiers. The rest of the commands have NOT been implemented in order to prevent possible damage to the hardware controlled by the GAIA Boards

* Moved the GAIABoardCommandLibrary to the SRT section
parent e2941962
No related branches found
No related tags found
No related merge requests found
#ifndef _GAIABOARDCOMMANDLIBRARY_H
#define _GAIABOARDCOMMANDLIBRARY_H
/**
* GAIABoardCommandLibrary.h
* 2022/02/25
* Giuseppe Carboni (giuseppe.carboni@inaf.it)
*/
#include <sstream>
#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
/**
* 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();
}
#*******************************************************************************
# 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 =
#
# <brief description of xxxxx program>
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 =
#
# <brief description of lllll library>
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 =
#
# <brief description of tttttt tcl-script>
tttttt_OBJECTS =
tttttt_TCLSH =
tttttt_LIBS =
#
# TCL libraries (public and local)
# ------------------------------
TCL_LIBRARIES =
TCL_LIBRARIES_L =
#
# <brief description of tttlll library>
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___
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
# 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) <ComponentNameImpl>
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"
#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");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment