Skip to content

Commit

Permalink
Fixed Makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Nov 24, 2023
1 parent 65e928e commit b715b32
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ts-VMSd
.isort.cfg
.mypy.ini
.ruff.toml
src/version.c
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ node {
make
cd $WORKSPACE/ts_vms
make simulator
make SIMULATOR=1
LSST_DDS_PARTITION_PREFIX=test make junit || true
"""
}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ src/%.cpp.o: src/%.cpp
$(MAKE) -C src $(patsubst src/%,%,$@)

tests: tests/Makefile tests/*.cpp
@${MAKE} -C tests
@${MAKE} -C SIMULATOR=1 tests

run_tests: tests
@${MAKE} -C tests run

junit: tests
@${MAKE} -C tests junit
@${MAKE} -C SIMULATOR=1 tests junit

doc:
${co}doxygen Doxyfile
Expand Down
69 changes: 31 additions & 38 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,47 @@ c_opts := -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE

ifdef DEBUG
c_opts += -g
silence := --silence-errors
else
c_opts += -O3
endif

CRIOCPP := ../ts_cRIOcpp/

BOOST_CPPFLAGS := -I/usr/include/boost169
SAL_CPPFLAGS := $(shell pkg-config yaml-cpp --cflags $(silence)) \
$(shell pkg-config fmt --cflags $(silence)) \
$(shell pkg-config spdlog --cflags $(silence)) \
$(shell pkg-config fftw3 --cflags $(silence)) \
-I${OSPL_HOME}/include -I${OSPL_HOME}/include/sys \
-I${OSPL_HOME}/include/dcps/C++/SACPP \
-I${SAL_WORK_DIR}/MTVMS/cpp/src \
-I${SAL_WORK_DIR}/include \
-I${SAL_HOME}/include \
-I${LSST_SDK_INSTALL}/include

LIBS := $(shell pkg-config yaml-cpp --libs $(silence)) \
$(shell pkg-config fmt --libs $(silence)) \
$(shell pkg-config fftw3 --libs $(silence)) \
-ldl -ldcpssacpp -ldcpsgapi -lddsuser -lddskernel \
-lpthread -lddsserialization -lddsconfparser -lddsconf \
-lddsdatabase -lddsutil -lddsos \
${SAL_WORK_DIR}/lib/libSAL_MTVMS.a \
-lreadline

C := gcc -Wall ${c_opts}
CPP := g++ --std=c++17 -Wall -fPIE ${c_opts}

# Simulator is dynamicaly linked, distribution uses static linking
PKG_CPPFLAGS := \
$(shell pkg-config yaml-cpp --cflags $(silence)) \
$(shell pkg-config spdlog --cflags $(silence)) \
$(shell pkg-config fmt --cflags $(silence)) \
$(shell pkg-config fftw3 --cflags $(silence))

SAL_CPPFLAGS += $(PKG_CPPFLAGS) \
-I${OSPL_HOME}/include -I${OSPL_HOME}/include/sys -I${OSPL_HOME}/include/dcps/C++/SACPP \
-I${SAL_WORK_DIR}/MTM1M3/cpp/src -I${SAL_WORK_DIR}/MTMount/cpp/src -I${SAL_WORK_DIR}/include \
-I${SAL_HOME}/include -I${LSST_SDK_INSTALL}/include

PKG_LIBS := \
$(shell pkg-config yaml-cpp --libs $(silence)) \
$(shell pkg-config fftw3 --libs $(silence)) \

CPP := g++ -std=c++17 -Wall -fPIE ${c_opts}

ifdef SIMULATOR
C := gcc -Wall ${c_opts}
CPP += -pedantic -DSIMULATOR
LIBS += $(shell pkg-config spdlog --libs $(silence))
PKG_LIBS += $(shell pkg-config spdlog --libs $(silence))
else
C += -fmessage-length=0
CPP += -fmessage-length=0 -ldl
LIBS += $(shell pkg-config spdlog --libs $(silence) | sed -E 's/-l([a-z0-9]*)/-l:lib\1.a/g')
C := gcc -Wall -fmessage-length=0 ${c_opts}
CPP += -fmessage-length=0
# static linkage for cRIO binary
PKG_LIBS += $(shell pkg-config spdlog --libs $(silence) | sed -E 's/-l([a-z0-9]*)/-l:lib\1.a/g')
endif

LIBS_FLAGS += -L"${OSPL_HOME}/lib" -L"${LSST_SDK_INSTALL}/lib"
LIBS += $(PKG_LIBS) -ldl -ldcpssacpp -ldcpsgapi -lddsuser -lddskernel \
-lpthread -lddsserialization -lddsconfparser -lddsconf \
-lddsdatabase -lddsutil -lddsos \
${SAL_WORK_DIR}/lib/libSAL_MTVMS.a

GIT := $(shell command -v git 2> /dev/null)
LIBS_FLAGS += -L${OSPL_HOME}/lib -L${LSST_SDK_INSTALL}/lib

ifndef GIT
VERSION := "v0.0.0-None"
GIT_HASH := "xxxx-NONE"
else
VERSION := $(shell git describe --tags --dirty)
GIT_HASH := $(shell git rev-parse HEAD)
endif
VERSION := $(shell git describe --tags --dirty 2>/dev/null || echo "unknown:non-git")
GIT_HASH := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown-non-git")
9 changes: 5 additions & 4 deletions doc/version-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
Version History
===============

v1.1.1
======
v1.2.0
------

* sends Heartbeat signals
* updated build system

v1.1.0
======
------

* improved data readout - in-CSC PSD calculations

v1.0.0
=======
------

* First release of the Vibration Monitoring System CSC
5 changes: 4 additions & 1 deletion src/LSST/VMS/Commands/Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <Commands/Update.h>
#include <Events/Heartbeat.h>
#include <FPGA.h>
#include <VMSPublisher.h>
#include <Commands/Update.h>

using namespace LSST::VMS;
using namespace LSST::VMS::Commands;

void Update::execute() {
VMSPublisher::instance().putMiscellaneous(FPGA::instance().chassisTemperature(),
FPGA::instance().chassisTicks());
Events::Heartbeat::instance().tryToggle();
}
2 changes: 1 addition & 1 deletion src/LSST/VMS/Events/FPGAState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <FPGA.h>
#include <Events/FPGAState.h>

#include <spdlog/fmt/fmt.h>
#include <spdlog/spdlog.h>

using namespace LSST::VMS;
using namespace LSST::VMS::Events;
Expand Down
53 changes: 53 additions & 0 deletions src/LSST/VMS/Events/Heartbeat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* This file is part of the LSST M1M3 thermal system package.
*
* Developed for the Vera C. Rubin Telescope and Site System.
* This product includes software developed by the LSST Project
* (https://www.lsst.org).
* See the COPYRIGHT file at the top-level directory of this distribution
* for details of code ownership.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <spdlog/spdlog.h>

#include <VMSPublisher.h>

#include <Events/Heartbeat.h>

using namespace LSST::VMS::Events;

const float HEARTBEAT_PERIOD = 1.0; //* Heartbeat period in seconds

Heartbeat::Heartbeat(token) { _lastToggleTimestamp = 0; }

void Heartbeat::tryToggle() {
SPDLOG_TRACE("Trying to toggle heartbeat");
double timestamp = VMSPublisher::instance().getTimestamp();
if (timestamp >= (_lastToggleTimestamp + HEARTBEAT_PERIOD)) {
SPDLOG_DEBUG("Toggling heartbeat");
auto lag = timestamp - _lastToggleTimestamp;
if (_lastToggleTimestamp != 0 && lag > HEARTBEAT_PERIOD * 1.1) {
SPDLOG_WARN("Toggling heartbeat after {:0.03f} seconds!", lag);
}

heartbeat = !heartbeat;

// sends software heartbeat
VMSPublisher::instance().logHeartbeat(this);

_lastToggleTimestamp = timestamp;
}
}
58 changes: 58 additions & 0 deletions src/LSST/VMS/Events/Heartbeat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of the LSST M1M3 thermal system package.
*
* Developed for the Vera C. Rubin Telescope and Site System.
* This product includes software developed by the LSST Project
* (https://www.lsst.org).
* See the COPYRIGHT file at the top-level directory of this distribution
* for details of code ownership.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef LSST_HEARTBEAT_H
#define LSST_HEARTBEAT_H

#include <chrono>

#include <SAL_MTVMS.h>

#include <cRIO/Singleton.h>

namespace LSST {
namespace VMS {
namespace Events {

/**
* Wrapper object for MTM1M3_logevent_heartbeatStatusC.
*/
class Heartbeat : public MTVMS_logevent_heartbeatC, public cRIO::Singleton<Heartbeat> {
public:
/**
* Construct new InterlockStatus
*/
Heartbeat(token);

/**
* Sets heartbeat, publish data if the last heartbeat was send more than 500ms in past.
*/
void tryToggle();

private:
double _lastToggleTimestamp;
};

}}}

#endif // LSST_INTERLOCKSTATUS_H
1 change: 1 addition & 0 deletions src/LSST/VMS/VMSPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class VMSPublisher : public cRIO::Singleton<VMSPublisher> {

void setLogLevel(int newLevel);

void logHeartbeat(MTVMS_logevent_heartbeatC *data) { _vmsSAL->logEvent_heartbeat(data, 0); }
void logSoftwareVersions();
void logSimulationMode();

Expand Down

0 comments on commit b715b32

Please sign in to comment.