forked from Intan-Technologies/Intan-RHX
-
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
1 parent
7f38717
commit 31fc274
Showing
15 changed files
with
1,006 additions
and
1,039 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
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,5 @@ | |
# Build | ||
/build | ||
/.venv | ||
/.cache | ||
/CMakeUserPresets.json |
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 @@ | ||
#include "controller_info.h" | ||
|
||
#include <fmt/format.h> | ||
|
||
#include <chrono> | ||
#include <thread> | ||
|
||
bool wait_xdaq(xdaq::Device *dev, int retry) | ||
{ | ||
using Clock = std::chrono::high_resolution_clock; | ||
for (; retry >= 0; --retry) { | ||
const auto start = Clock::now(); | ||
while (true) { | ||
if ((*dev->get_register_sync(0x22) & 0x4) == 0) return true; | ||
if ((Clock::now() - start) > std::chrono::seconds(3)) break; | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
} | ||
if (retry == 0) return false; | ||
dev->trigger(0x48, 3); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
} | ||
return false; | ||
} | ||
|
||
XDAQInfo read_xdaq_info(xdaq::Device *dev) | ||
{ | ||
if (!wait_xdaq(dev, 1)) { | ||
throw std::runtime_error("XDAQ is not ready, please restart the device and try again"); | ||
} | ||
XDAQInfo info; | ||
info.serial = fmt::format("{:08x}", *dev->get_register_sync(0x32)); | ||
const auto hdmi = *dev->get_register_sync(0x31); | ||
switch ((hdmi & 0xFF)) { | ||
case 0: | ||
if (((hdmi & 0xFF00) >> 8) == 1) | ||
info.model = XDAQModel::Core; | ||
else if (((hdmi & 0xFF00) >> 8) == 3) | ||
info.model = XDAQModel::One; | ||
else | ||
info.model = XDAQModel::Unknown; | ||
break; | ||
case 1: info.model = XDAQModel::Core; break; | ||
case 2: info.model = XDAQModel::One; break; | ||
default: info.model = XDAQModel::Unknown; | ||
} | ||
info.expander = (*dev->get_register_sync(0x35)) != 0; | ||
info.max_rhs_channels = ((hdmi >> 16) & 0xFF) * 16; | ||
info.max_rhd_channels = ((hdmi >> 24) & 0xFF) * 32; | ||
if (info.model == XDAQModel::Core) { | ||
info.max_rhd_channels /= 2; | ||
} | ||
return info; | ||
} |
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,22 @@ | ||
#pragma once | ||
#include <xdaq/xdaq/device.h> | ||
|
||
#include <functional> | ||
#include <string> | ||
|
||
enum class XDAQModel { Unknown = 0, Core = 1, One = 3 }; | ||
|
||
struct XDAQInfo { | ||
std::string plugin; | ||
std::string id; | ||
std::string serial; | ||
XDAQModel model = XDAQModel::Unknown; | ||
|
||
int max_rhd_channels = 0; | ||
int max_rhs_channels = 0; | ||
bool expander = false; | ||
std::string device_config; | ||
std::function<xdaq::Device *(std::string)> get_device = nullptr; | ||
}; | ||
|
||
XDAQInfo read_xdaq_info(xdaq::Device *dev); |
Oops, something went wrong.