Skip to content

Commit

Permalink
Merge pull request #25 from lsst-ts/tickets/DM-41827
Browse files Browse the repository at this point in the history
DM-41827: sends heartbeat signal
  • Loading branch information
pkubanek authored May 2, 2024
2 parents 65e928e + 82c866e commit 4a1c8a6
Show file tree
Hide file tree
Showing 34 changed files with 1,459 additions and 1,340 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ ts-VMSd
.isort.cfg
.mypy.ini
.ruff.toml
src/version.c
towncrier.toml
1,056 changes: 528 additions & 528 deletions Bitfiles/NiFpga.c

Large diffs are not rendered by default.

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
12 changes: 6 additions & 6 deletions src/LSST/VMS/Accelerometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#define ACCELEROMETER_H_

#include <SAL_MTVMS.h>
#include <VMSApplicationSettings.h>
#include <Telemetry/PSD.h>
#include <VMSApplicationSettings.h>

namespace LSST {
namespace VMS {
Expand All @@ -36,7 +36,7 @@ namespace VMS {
*/
class Accelerometer {
public:
Accelerometer(VMSApplicationSettings* vmsApplicationSettings);
Accelerometer(VMSApplicationSettings *vmsApplicationSettings);
virtual ~Accelerometer(void);

void enableAccelerometers();
Expand All @@ -49,11 +49,11 @@ class Accelerometer {

int _numberOfSensors;
int _dataIndex;
MTVMS_dataC* _sampleData;
Telemetry::PSD* _psds;
VMSApplicationSettings* _vmsApplicationSettings;
MTVMS_dataC *_sampleData;
Telemetry::PSD *_psds;
VMSApplicationSettings *_vmsApplicationSettings;

float _convert(uint32_t** data);
float _convert(uint32_t **data);
};

} /* namespace VMS */
Expand Down
10 changes: 5 additions & 5 deletions src/LSST/VMS/Commands/EnterControl.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* EnterControl command.
*
* Developed for the Vera C. Rubin Observatory Telescope & Site Software Systems.
* This product includes software developed by the Vera C.Rubin Observatory Project
* (https://www.lsst.org). See the COPYRIGHT file at the top-level directory of
* this distribution for details of code ownership.
* Developed for the Vera C. Rubin Observatory Telescope & Site Software
* Systems. This product includes software developed by the Vera C.Rubin
* Observatory 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
Expand All @@ -23,9 +23,9 @@
#ifndef _VMS_Command_EnterControl_
#define _VMS_Command_ENterControl_

#include <cRIO/Command.h>
#include <SAL_MTVMS.h>
#include <VMSPublisher.h>
#include <cRIO/Command.h>

#include <Events/SummaryState.h>

Expand Down
8 changes: 4 additions & 4 deletions src/LSST/VMS/Commands/SAL.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* SAL command.
*
* Developed for the Vera C. Rubin Observatory Telescope & Site Software Systems.
* This product includes software developed by the Vera C.Rubin Observatory Project
* (https://www.lsst.org). See the COPYRIGHT file at the top-level directory of
* this distribution for details of code ownership.
* Developed for the Vera C. Rubin Observatory Telescope & Site Software
* Systems. This product includes software developed by the Vera C.Rubin
* Observatory 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
Expand Down
8 changes: 4 additions & 4 deletions src/LSST/VMS/Commands/SAL.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* SAL commands
*
* Developed for the Vera C. Rubin Observatory Telescope & Site Software Systems.
* This product includes software developed by the Vera C.Rubin Observatory Project
* (https://www.lsst.org). See the COPYRIGHT file at the top-level directory of
* this distribution for details of code ownership.
* Developed for the Vera C. Rubin Observatory Telescope & Site Software
* Systems. This product includes software developed by the Vera C.Rubin
* Observatory 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
Expand Down
2 changes: 1 addition & 1 deletion src/LSST/VMS/Commands/Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

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

using namespace LSST::VMS::Commands;

Expand Down
12 changes: 6 additions & 6 deletions src/LSST/VMS/Events/FPGAState.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* AcquistionPeriod event handling class.
*
* Developed for the Vera C. Rubin Observatory Telescope & Site Software Systems.
* This product includes software developed by the Vera C.Rubin Observatory Project
* (https://www.lsst.org). See the COPYRIGHT file at the top-level directory of
* this distribution for details of code ownership.
* Developed for the Vera C. Rubin Observatory Telescope & Site Software
* Systems. This product includes software developed by the Vera C.Rubin
* Observatory 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
Expand All @@ -20,10 +20,10 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <FPGA.h>
#include <Events/FPGAState.h>
#include <FPGA.h>

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

using namespace LSST::VMS;
using namespace LSST::VMS::Events;
Expand Down
10 changes: 5 additions & 5 deletions src/LSST/VMS/Events/FPGAState.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* AcquisitionPeriod event handling class.
*
* Developed for the Vera C. Rubin Observatory Telescope & Site Software Systems.
* This product includes software developed by the Vera C.Rubin Observatory Project
* (https://www.lsst.org). See the COPYRIGHT file at the top-level directory of
* this distribution for details of code ownership.
* Developed for the Vera C. Rubin Observatory Telescope & Site Software
* Systems. This product includes software developed by the Vera C.Rubin
* Observatory 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
Expand All @@ -28,8 +28,8 @@

#include <VMSPublisher.h>

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

namespace LSST {
namespace VMS {
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;
}
}
Loading

0 comments on commit 4a1c8a6

Please sign in to comment.