Skip to content

Commit

Permalink
[alf] Assign Infologger error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
kostorr committed Jul 25, 2022
1 parent 26eea1b commit e0acf26
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 19 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,42 @@ It extends the `SCA_SEQUENCE` to add the following functionality:
* DIM input ` `
* DIM output ` `

## Logging
Logging is achieved through the use of the [InfoLogger](https://github.com/AliceO2Group/InfoLogger) library.

Error codes in the range 5000-5999 are assigned to ALF. These are further partitioned according to components:

### General
| 5000 - 5099 | Full Range |
| ----------- | ---------- |

### DIM
| 5100 - 5199 | Full Range |
| ----------- | ---------- |

### SWT
| 4200 - 4299 | Full Range |
| ----------- | ---------- |

### SCA
| 4300 - 4399 | Full Range |
| ----------- | ---------- |

### IC
| 4400 - 4499 | Full Range |
| ----------- | ---------- |

### LLA
| 4400 - 4499 | Full Range |
| ----------- | ---------- |

### Unassigned
| Range |
| ----- |
| 4500 - 4999 |



## Slow Control library
ALF can also be used as a C++ library to access the Slow Control interface of the CRU. The three available interfaces (IC, SCA & SWT) can be accessed through single operations, or sequences of operations.

Expand Down
26 changes: 13 additions & 13 deletions apps/Alf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ class Alf : public AliceO2::Common::Program
kDebugLogging = isVerbose();

Logger::setFacility("ALF");
Logger::get() << "ALF server starting..." << LogInfoOps << endm;
Logger::get() << "ALF server starting..." << LogInfoOps_(5000) << endm;

if (mOptions.dimDnsNode != "") {
Logger::get() << "Setting DIM_DNS_NODE from argument." << LogDebugDevel << endm;
Logger::get() << "DIM_DNS_NODE=" << mOptions.dimDnsNode << LogDebugDevel << endm;
Logger::get() << "Setting DIM_DNS_NODE from argument." << LogDebugDevel_(5001) << endm;
Logger::get() << "DIM_DNS_NODE=" << mOptions.dimDnsNode << LogDebugDevel_(5001) << endm;
} else if (const char* dimDnsNode = std::getenv("DIM_DNS_NODE")) {
Logger::get() << "Picked up DIM_DMS_NODE from the environment." << LogDebugDevel << endm;
Logger::get() << "DIM_DNS_NODE=" << dimDnsNode << LogDebugDevel << endm;
Logger::get() << "Picked up DIM_DMS_NODE from the environment." << LogDebugDevel_(5002) << endm;
Logger::get() << "DIM_DNS_NODE=" << dimDnsNode << LogDebugDevel_(5002) << endm;
mOptions.dimDnsNode = dimDnsNode;
} else {
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("DIM_DNS_NODE env variable not set, and no relevant argument provided.")); // InfoLogger and errors?
Expand All @@ -89,14 +89,14 @@ class Alf : public AliceO2::Common::Program
try {
swtWordSize = SwtWord::sizeFromString(mOptions.swtWordSize);
} catch (const ParseException& e) {
Logger::get() << e.what() << LogWarningOps << endm;
Logger::get() << "SWT word size defaulting to low" << LogWarningOps << endm;
Logger::get() << e.what() << LogWarningOps_(5003) << endm;
Logger::get() << "SWT word size defaulting to low" << LogWarningOps_(5003) << endm;
}

std::string alfId = ip::host_name();
boost::to_upper(alfId);

Logger::get() << "Starting the DIM Server" << LogInfoDevel << endm;
Logger::get() << "Starting the DIM Server" << LogInfoDevel_(5004) << endm;
DimServer::setDnsNode(mOptions.dimDnsNode.c_str(), 2505);
DimServer::start(("ALF_" + alfId).c_str());

Expand All @@ -113,32 +113,32 @@ class Alf : public AliceO2::Common::Program
try {
roc::FirmwareChecker().checkFirmwareCompatibility(card.pciAddress);
} catch (const roc::Exception& e) {
Logger::get() << e.what() << LogWarningOps << endm;
Logger::get() << e.what() << LogWarningOps_(5005) << endm;
continue;
}
}

if (card.cardType == roc::CardType::Cru) {

Logger::get() << "CRU " << card.serialId << " registered" << LogInfoDevel << endm;
Logger::get() << "CRU " << card.serialId << " registered" << LogInfoDevel_(5006) << endm;
bar = roc::ChannelFactory().getBar(card.serialId, 2);
for (int linkId = 0; linkId < kCruNumLinks; linkId++) {
links.push_back({ alfId, card.serialId, linkId, card.serialId.getEndpoint() * 12 + linkId, bar, roc::CardType::Cru });
}

} else if (card.cardType == roc::CardType::Crorc) {
Logger::get() << "CRORC " << card.serialId << " registered" << LogInfoDevel << endm;
Logger::get() << "CRORC " << card.serialId << " registered" << LogInfoDevel_(5007) << endm;
for (int linkId = 0; linkId < kCrorcNumLinks; linkId++) {
bar = roc::ChannelFactory().getBar(card.serialId, linkId);
links.push_back({ alfId, card.serialId, linkId, -1, bar, roc::CardType::Crorc });
}
} else {
Logger::get() << card.serialId << " is not a CRU or a CRORC. Skipping..." << LogWarningDevel << endm;
Logger::get() << card.serialId << " is not a CRU or a CRORC. Skipping..." << LogWarningDevel_(5008) << endm;
}

if (isVerbose()) {
for (auto const& link : links) {
Logger::get() << link.alfId << " " << link.serialId << " " << link.linkId << LogDebugDevel << endm;
Logger::get() << link.alfId << " " << link.serialId << " " << link.linkId << LogDebugDevel_(5009) << endm;
}
}
alfServer.makeRpcServers(links, mOptions.sequentialRpcs);
Expand Down
2 changes: 1 addition & 1 deletion src/DimServices/DimServices.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void StringRpcServer::rpcHandler()
setDataString(makeSuccessString(returnValue), *this);
} catch (const std::exception& e) {
if (kDebugLogging) {
Logger::get() << mServiceName << ": " << e.what() << LogErrorDevel << endm;
Logger::get() << mServiceName << ": " << e.what() << LogErrorDevel_(5100) << endm;
}
setDataString(makeFailureString(e.what()), *this);
}
Expand Down
4 changes: 3 additions & 1 deletion src/DimServices/DimServices.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ bool isSuccess(const std::string& str);
bool isFailure(const std::string& str);
std::string stripPrefix(const std::string& str);

// SERVER
class StringRpcServer : public DimRpcParallel
{
public:
Expand All @@ -86,6 +87,7 @@ class StringRpcServer : public DimRpcParallel
std::string mServiceName;
};

// CLIENT
class DimRpcInfoWrapper
{
public:
Expand All @@ -103,7 +105,7 @@ class DimRpcInfoWrapper
{
auto str = std::string(mRpcInfo->getString());
if (isFailure(str) && kDebugLogging) {
Logger::get() << "ALF server failure: " << str << LogErrorDevel << endm;
Logger::get() << "ALF server failure: " << str << LogErrorDevel_(5101) << endm;
}
return str;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ std::string Ic::writeSequence(std::vector<std::pair<Operation, Data>> ops, bool
std::string errMessage = boost::get<std::string>(data);
resultBuffer << errMessage;
if (kDebugLogging) {
Logger::get() << errMessage << LogErrorDevel << endm;
Logger::get() << errMessage << LogErrorDevel_(5400) << endm;
}
BOOST_THROW_EXCEPTION(IcException() << ErrorInfo::Message(resultBuffer.str()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sca.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ std::string Sca::writeSequence(const std::vector<std::pair<Operation, Data>>& op
} else if (operation == Operation::Error) {
resultBuffer << data; // "[error_msg]"
if (kDebugLogging) {
Logger::get() << data << LogErrorDevel << endm;
Logger::get() << data << LogErrorDevel_(5300) << endm;
}
BOOST_THROW_EXCEPTION(ScaException() << ErrorInfo::Message(resultBuffer.str()));
break;
Expand Down
2 changes: 1 addition & 1 deletion src/ScaMftPsu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ std::string ScaMftPsu::writeSequence(const std::vector<std::pair<Operation, Data
} else if (operation == Operation::Error) {
resultBuffer << data; // "[error_msg]"
if (kDebugLogging) {
Logger::get() << data << LogErrorDevel << endm;
Logger::get() << data << LogErrorDevel_(5301) << endm;
}
BOOST_THROW_EXCEPTION(ScaMftPsuException() << ErrorInfo::Message(resultBuffer.str()));
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Swt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ std::string Swt::writeSequence(std::vector<std::pair<Operation, Data>> sequence,
} else if (operation == Operation::Error) {
resultBuffer << data;
if (kDebugLogging) {
Logger::get() << data << LogErrorDevel << endm;
Logger::get() << data << LogErrorDevel_(5200) << endm;
}
BOOST_THROW_EXCEPTION(SwtException() << ErrorInfo::Message(resultBuffer.str()));
break;
Expand Down

0 comments on commit e0acf26

Please sign in to comment.