Commit 909e8256 authored by Joern jkuensem's avatar Joern jkuensem

SBB-102: Processing review comments

parent cc452a9e
......@@ -132,13 +132,13 @@ void TbbSettings::getTbbSettings()
try { itsIfName = globalParameterSet()->getString("TBBDriver.IF_NAME"); }
catch (APSException&) { LOG_INFO_STR(formatString("TBBDriver.IF_NAME not found")); configOK = false; }
try { itsSendTriggersToHost = globalParameterSet()->getInt32("TBBDriver.SEND_TRIGGERS_TO_HOST"); }
try { itsSendTriggersToHost = globalParameterSet()->getInt32("TBBDriver.SEND_TRIGGERS_TO_HOST"); }
catch (APSException&) { LOG_INFO_STR(formatString("TBBDriver.SEND_TRIGGERS_TO_HOST not found")); }
try { itsSendTriggersHost = globalParameterSet()->getInt32("TBBDriver.SEND_TRIGGERS_HOST"); }
try { itsSendTriggersHost = globalParameterSet()->getString("TBBDriver.SEND_TRIGGERS_HOST"); }
catch (APSException&) { LOG_INFO_STR(formatString("TBBDriver.SEND_TRIGGERS_HOST not found")); }
try { itsSendTriggersPort = globalParameterSet()->getInt32("TBBDriver.SEND_TRIGGERS_PORT"); }
try { itsSendTriggersPort = globalParameterSet()->getString("TBBDriver.SEND_TRIGGERS_PORT"); }
catch (APSException&) { LOG_INFO_STR(formatString("TBBDriver.SEND_TRIGGERS_PORT not found")); }
char dstmac[64];
......
......@@ -282,7 +282,7 @@ private:
// --- Datamembers ---
int32 itsDriverVersion;
uint32 itsDefaultImageNr;
uint32 itsDefaultImageNr;
int32 itsMaxBoards; // constants
int32 itsMaxChannels;
int32 itsMpsOnBoard;
......@@ -397,9 +397,9 @@ inline string TbbSettings::getDstMacCep(int32 channelnr) {
if (itsChannelInfo[channelnr].dstMacCep.empty()) { return(itsBoardInfo[getChBoardNr(channelnr)].dstMacCep); }
else { return(itsChannelInfo[channelnr].dstMacCep); }
}
inline int32 TbbSettings::saveTriggersToFile() { return(itsSaveTriggersToFile); }
inline int32 TbbSettings::saveTriggersToFile() { return(itsSaveTriggersToFile); }
inline void TbbSettings::resetTriggersLeft() {
inline void TbbSettings::resetTriggersLeft() {
int missed = 0;
for (int bnr = 0; bnr < itsMaxBoards; bnr++) {
if (itsBoardInfo[bnr].triggersLeft < 0) {
......@@ -413,14 +413,14 @@ inline void TbbSettings::resetTriggersLeft() {
LOG_INFO_STR(formatString("missed %d triggers last 100mSec", (missed)));
}
}
inline bool TbbSettings::isTriggersLeft(int32 boardnr) {
inline bool TbbSettings::isTriggersLeft(int32 boardnr) {
itsBoardInfo[boardnr].triggersLeft--;
if (itsBoardInfo[boardnr].triggersLeft < 0) return(false);
return(true);
}
inline bool TbbSettings::isNewTrigger() { return(itsNewTriggerInfo); }
inline void TbbSettings::setTriggerInfo(int32 boardnr, uint8 *info) {
inline bool TbbSettings::isNewTrigger() { return(itsNewTriggerInfo); }
inline void TbbSettings::setTriggerInfo(int32 boardnr, uint8 *info) {
memcpy(itsTriggerInfo, info, 40);
itsTriggerInfo->boardnr = boardnr;
......@@ -443,7 +443,7 @@ inline void TbbSettings::setTriggerInfo(int32 boardnr, uint8 *info) {
LOG_INFO_STR("rcu = " << itsTriggerInfo->rcu);
LOG_INFO_STR("time = " << itsTriggerInfo->time);
LOG_INFO_STR("sample nr = " << itsTriggerInfo->sample_nr);
LOG_INFO_STR("nsec = " << itsTriggerInfo->ns_timestamp.nsec());
LOG_INFO_STR("nsec = " << itsTriggerInfo->ns_timestamp.nsec());
LOG_INFO_STR("sum = " << itsTriggerInfo->trigger_sum);
LOG_INFO_STR("samples = " << itsTriggerInfo->trigger_samples);
LOG_INFO_STR("peak value = " << itsTriggerInfo->peak_value);
......@@ -453,12 +453,12 @@ inline void TbbSettings::setTriggerInfo(int32 boardnr, uint8 *info) {
#endif
}
inline TriggerInfo *TbbSettings::getTriggerInfo() {
inline TriggerInfo *TbbSettings::getTriggerInfo() {
itsNewTriggerInfo = false;
return(itsTriggerInfo);
}
inline bool TbbSettings::isRecording() { return(static_cast<bool>(itsRecording)); }
inline bool TbbSettings::isRecording() { return(static_cast<bool>(itsRecording)); }
inline void TbbSettings::setChStatus(int32 channelnr, uint32 status){ itsChannelInfo[channelnr].Status = status; }
inline void TbbSettings::setChState(int32 channelnr, char state){
......@@ -496,33 +496,33 @@ inline void TbbSettings::setFlashState(int32 boardnr,uint32 state) { itsBoardInf
inline bool TbbSettings::getFreeToReset(int32 boardnr) { return (itsBoardInfo[boardnr].freeToReset); }
inline void TbbSettings::setFreeToReset(int32 boardnr, bool reset) { itsBoardInfo[boardnr].freeToReset = reset; }
inline bool TbbSettings::isBoardReady(int32 boardnr) { return(itsBoardInfo[boardnr].boardState == boardReady); }
inline bool TbbSettings::isBoardUsed(int32 boardnr) { return(itsBoardInfo[boardnr].used); }
inline void TbbSettings::setBoardUsed(int32 boardnr) { itsBoardInfo[boardnr].used = true; }
inline void TbbSettings::resetBoardUsed() {
inline bool TbbSettings::isBoardUsed(int32 boardnr) { return(itsBoardInfo[boardnr].used); }
inline void TbbSettings::setBoardUsed(int32 boardnr) { itsBoardInfo[boardnr].used = true; }
inline void TbbSettings::resetBoardUsed() {
for (int boardnr = 0; boardnr < itsMaxBoards; boardnr++) {
itsBoardInfo[boardnr].used = false;
}
}
inline void TbbSettings::setSetupNeeded(bool state) { itsSetupNeeded = state; }
inline bool TbbSettings::isSetupNeeded() { return(itsSetupNeeded); }
inline void TbbSettings::setClockFreq(int32 clock) {
inline void TbbSettings::setSetupNeeded(bool state) { itsSetupNeeded = state; }
inline bool TbbSettings::isSetupNeeded() { return(itsSetupNeeded); }
inline void TbbSettings::setClockFreq(int32 clock) {
itsClockChanged = true;
itsClockFreq = clock; // sample clock freq in Mhz
itsSampleTime = 1000./clock; // sample time = 1/clock in nsec
}
inline int32 TbbSettings::getClockFreq() { return(itsClockFreq); }
inline bool TbbSettings::isClockFreqChanged() {
inline int32 TbbSettings::getClockFreq() { return(itsClockFreq); }
inline bool TbbSettings::isClockFreqChanged() {
if (itsClockChanged) {
itsClockChanged = false;
return(true);
}
return(false);
}
inline double TbbSettings::getSampleTime() { return(itsSampleTime); }
inline double TbbSettings::getSampleTime() { return(itsSampleTime); }
inline int32 TbbSettings::sendTriggersToHost() { return(itsSendTriggersToHost); }
inline string TbbSettings::sendTriggersHost() { return(itsSendTriggersHost); }
inline string TbbSettings::sendTriggersPort() { return(itsSendTriggersPort); }
inline int32 TbbSettings::sendTriggersToHost() { return(itsSendTriggersToHost); }
inline string TbbSettings::sendTriggersHost() { return(itsSendTriggersHost); }
inline string TbbSettings::sendTriggersPort() { return(itsSendTriggersPort); }
} // namespace TBB
} // namespace LOFAR
......
......@@ -94,55 +94,55 @@ void MsgHandler::sendSavedTrigger()
tbb_event.power_after = triggerInfo->power_after;
tbb_event.missed = triggerInfo->missed & 0x00FFFFFF;
// send UDP alert
if (TS->sendTriggersToHost()) {
sendTriggerToAlertListeners(tbb_event);
}
// send UDP alert
if (TS->sendTriggersToHost()) {
sendTriggerToAlertListeners(tbb_event);
}
sendTriggerMessage(tbb_event);
// save trigger messages to a file
if (TS->saveTriggersToFile()) {
//LOG_DEBUG_STR(formatString("write saved trigger from board %d to file", boardnr));
//LOG_DEBUG_STR(formatString("write saved trigger from board %d to file", boardnr));
writeTriggerToFile(&tbb_event);
}
}
void MsgHandler::sendTriggerToAlertListeners(
const TBBTriggerEvent& tbb_event)
const TBBTriggerEvent& tbb_event)
{
std::ostringstream message;
message << tbb_event.rcu
<< ", "
<< tbb_event.nstimestamp
<< ", "
<< tbb_event.trigger_sum
<< ", "
<< tbb_event.trigger_samples
<< ", "
<< tbb_event.peak_value
<< ", "
<< tbb_event.power_before
<< ", "
<< tbb_event.power_after
<< ", "
<< tbb_event.missed
<< "\n";
std::ostringstream message;
message << tbb_event.rcu
<< ", "
<< tbb_event.nstimestamp
<< ", "
<< tbb_event.trigger_sum
<< ", "
<< tbb_event.trigger_samples
<< ", "
<< tbb_event.peak_value
<< ", "
<< tbb_event.power_before
<< ", "
<< tbb_event.power_after
<< ", "
<< tbb_event.missed
<< "\n";
const std::string messageString(message.str());
tbbAlertUdpClient->write(messageString.c_str(), messageString.size());
const std::string messageString(message.str());
tbbAlertUdpClient->write(messageString.c_str(), messageString.size());
}
void MsgHandler::startTbbAlertUdpClient()
{
tbbAlertUdpClient.reset(
new LOFAR::Socket("TBB_Alert_UDP_Client", TS->sendTriggersHost(), TS->sendTriggersPort(), LOFAR::Socket::UDP));
tbbAlertUdpClient.reset(
new LOFAR::Socket("TBB_Alert_UDP_Client", TS->sendTriggersHost(), TS->sendTriggersPort(), LOFAR::Socket::UDP));
}
void MsgHandler::stopTbbAlertUdpClient()
{
tbbAlertUdpClient.release();
tbbAlertUdpClient.release();
}
//-----------------------------------------------------------------------------
......@@ -171,8 +171,8 @@ void MsgHandler::closeTriggerFile()
void MsgHandler::writeTriggerToFile(TBBTriggerEvent *trigger_event)
{
if (itsFile != 0) {
// if file to big, open a new one and ad file number
// the highest number is the oldest file
// if file to big, open a new one and ad file number
// the highest number is the oldest file
if ((ftell(itsFile) - itsStartFilePos) > 1000000000) {
fclose(itsFile);
char fileName1[256];
......@@ -182,23 +182,23 @@ void MsgHandler::writeTriggerToFile(TBBTriggerEvent *trigger_event)
// find first free file number
while(true) {
snprintf(fileName1, sizeof(fileName1), "/localhome/data/%s_TRIGGER_%d.dat", itsTimeString, fileNr);
f = fopen(fileName1,"r");
if (f) {
fclose(f);
++fileNr;
}
else {
break;
}
snprintf(fileName1, sizeof(fileName1), "/localhome/data/%s_TRIGGER_%d.dat", itsTimeString, fileNr);
f = fopen(fileName1,"r");
if (f) {
fclose(f);
++fileNr;
}
else {
break;
}
}
// shift all files one number, so number 0 is free
while (fileNr > 0) {
snprintf(fileName1, sizeof(fileName1), "/localhome/data/%s_TRIGGER_%d.dat", itsTimeString, fileNr-1);
snprintf(fileName2, sizeof(fileName2), "/localhome/data/%s_TRIGGER_%d.dat", itsTimeString, fileNr);
rename(fileName1, fileName2);
--fileNr;
snprintf(fileName1, sizeof(fileName1), "/localhome/data/%s_TRIGGER_%d.dat", itsTimeString, fileNr-1);
snprintf(fileName2, sizeof(fileName2), "/localhome/data/%s_TRIGGER_%d.dat", itsTimeString, fileNr);
rename(fileName1, fileName2);
--fileNr;
}
rename(itsFileName, fileName1);
......
......@@ -95,23 +95,23 @@ private:
*/
void startTbbAlertUdpClient();
/**
* Shut down the TBB Alert UDP service.
*/
/**
* Shut down the TBB Alert UDP service.
*/
void stopTbbAlertUdpClient();
/**
* Send the same information that is store in the trigger log file to
* clients listening on the UDP port for TBB alerts.
* @param trigger_event The trigger event information.
*/
void sendTriggerToAlertListeners(const TBBTriggerEvent& trigger_event);
* Send the same information that is store in the trigger log file to
* clients listening on the UDP port for TBB alerts.
* @param trigger_event The trigger event information.
*/
void sendTriggerToAlertListeners(const TBBTriggerEvent& trigger_event);
/**
* The UDP socket which will connect to in order to get notified of
* TBB alerts.
*/
std::unique_ptr< LOFAR::Socket > tbbAlertUdpClient;
/**
* The UDP socket which will connect to in order to get notified of
* TBB alerts.
*/
std::unique_ptr< LOFAR::Socket > tbbAlertUdpClient;
};
} // end TBB namespace
} // end LOFAR namespace
......
......@@ -2,6 +2,6 @@ lofar_add_bin_scripts(tbbalertvoeventpublisher)
# supervisord config files
install(FILES
tbbaltervoeventpublisher.ini
tbbalertvoeventpublisher.ini
DESTINATION etc/supervisord.d)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment