Skip to content

Commit

Permalink
Merge pull request #63 from sy-c/master
Browse files Browse the repository at this point in the history
updated patternplayer
  • Loading branch information
sy-c authored Oct 3, 2023
2 parents 48c6532 + 643e059 commit 0e7ccef
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 87 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ if(NOT APPLE)
find_package(Python3 3.6 COMPONENTS Interpreter Development)
if(Python3_FOUND)
set(boost_python_component "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
else()
# Backwards compatible. Can be removed once the Python3 recipe is stable
message(WARNING "Python 3 was not found: falling back to Python 2")
find_package(Python2 2.7 COMPONENTS Development REQUIRED)
set(boost_python_component "python27")
endif()
endif()

Expand All @@ -99,7 +94,6 @@ target_sources(ALF PRIVATE
src/AlfServer.cxx
src/DimServices/DimServices.cxx
src/DimServices/ServiceNames.cxx
$<$<BOOL:${Python2_FOUND}>:src/PythonInterface.cxx>
$<$<BOOL:${Python3_FOUND}>:src/PythonInterface.cxx>
)

Expand All @@ -116,8 +110,6 @@ set(LINK_LIBS
AliceO2::ReadoutCard
AliceO2::Common
Boost::boost
$<$<BOOL:${Python2_FOUND}>:Boost::python27>
$<$<BOOL:${Python2_FOUND}>:Python2::Python>
$<$<BOOL:${Python3_FOUND}>:Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}>
$<$<BOOL:${Python3_FOUND}>:Python3::Python>
)
Expand Down
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,29 @@ It extends the `SCA_SEQUENCE` to add the following functionality:
##### PATTERN_PLAYER

* Parameters
* Sync Pattern
* Reset Pattern
* Idle Pattern
* Sync Length
* Sync Delay
* Reset Length
* Reset Trigger Select
* Sync Trigger Select
* Sync At Start
* Trigger Sync
* Trigger Reset
* pat0 Pattern
* pat1 Pattern
* pat2 Pattern
* pat3 Pattern
* pat1 Length
* pat1 Delay
* pat2 Length
* pat3 Length
* pat1 Trigger Select
* pat2 Trigger Select
* pat3 Trigger Select
* pat2 TF[31:20] ORBIT[19:12] BC[11:0]
* execute pat1 at start
* execute pat1 now
* execute pat2 now

see [registers definition](https://gitlab.cern.ch/alice-cru/cru-fw/-/tree/pplayer/TTC#address-table)

* Returns
* empty

* Example:
* DIM input `0x23456789abcdef123456\n0x5678\n0x9abc\n42\n0\n53\n30\n29\n#a comment\nfalse\ntrue\nfalse`
* DIM input `0x123\n123\n1024\n0xFFFFFFFFFFFFFFFFFFFF\n10\n11\n20\n30\n0xFF\n0xEE\n0xDDDe\n0xAAABBCCC\n#comment\nfalse\ntrue\ntrue`
* DIM output ` `

##### LLA_SESSION_START
Expand Down
80 changes: 13 additions & 67 deletions src/AlfServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,19 @@ std::string AlfServer::icGbtI2cWrite(const std::string& parameter, AlfLink link)
std::string AlfServer::patternPlayer(const std::string& parameter, std::shared_ptr<roc::BarInterface> bar2)
{
std::vector<std::string> parameters = Util::split(parameter, argumentSeparator());
if (parameters.size() < 11) { // Test that we have enough parameters
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("Wrong number of parameters for the Pattern Player RPC call: " + std::to_string(parameters.size())));
try {
roc::PatternPlayer::Info info = parseStringToPatternPlayerInfo(parameters);
roc::PatternPlayer pp = roc::PatternPlayer(bar2);
pp.play(info);
}
catch(boost::exception const& e) {
auto info = boost::get_error_info<ErrorInfo::Message>(e);
if (info) {
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message(info->data()));
} else {
throw;
}
}

roc::PatternPlayer::Info info = parseStringToPatternPlayerInfo(parameters);

roc::PatternPlayer pp = roc::PatternPlayer(bar2);
pp.play(info);
return "";
}

Expand Down Expand Up @@ -213,66 +218,7 @@ std::string AlfServer::resetCard(const std::string& /*parameter*/, AlfLink link)

roc::PatternPlayer::Info AlfServer::parseStringToPatternPlayerInfo(const std::vector<std::string> parameters)
{
roc::PatternPlayer::Info ppInfo;

int infoField = 0;
for (const auto& parameter : parameters) {
if (parameter.find('#') == std::string::npos) {
infoField++;
}
}

if (infoField != 11) { // Test that we have enough non-comment parameters
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("Wrong number of non-comment parameters for the Pattern Player RPC call: " + std::to_string(infoField)));
}

infoField = 0;
for (const auto& parameter : parameters) {
if (parameter.find('#') == std::string::npos) {
switch (infoField) {
bool boolValue;
case 0:
ppInfo.syncPattern = uint128_t(parameter);
break;
case 1:
ppInfo.resetPattern = uint128_t(parameter);
break;
case 2:
ppInfo.idlePattern = uint128_t(parameter);
break;
case 3:
ppInfo.syncLength = std::stoi(parameter);
break;
case 4:
ppInfo.syncDelay = std::stoi(parameter);
break;
case 5:
ppInfo.resetLength = std::stoi(parameter);
break;
case 6:
ppInfo.resetTriggerSelect = std::stoi(parameter);
break;
case 7:
ppInfo.syncTriggerSelect = std::stoi(parameter);
break;
case 8:
std::istringstream(parameter) >> std::boolalpha >> boolValue;
ppInfo.syncAtStart = boolValue;
break;
case 9:
std::istringstream(parameter) >> std::boolalpha >> boolValue;
ppInfo.triggerSync = boolValue;
break;
case 10:
std::istringstream(parameter) >> std::boolalpha >> boolValue;
ppInfo.triggerReset = boolValue;
break;
}
infoField++;
}
}

return ppInfo;
return roc::PatternPlayer::getInfoFromString(parameters);
}

std::vector<uint32_t> AlfServer::stringToRegisterPair(const std::string stringPair)
Expand Down

0 comments on commit 0e7ccef

Please sign in to comment.