-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
157 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ ts-VMSd | |
.isort.cfg | ||
.mypy.ini | ||
.ruff.toml | ||
src/version.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters