Skip to content

Commit

Permalink
More changes from MxID to DeviceID
Browse files Browse the repository at this point in the history
  • Loading branch information
Matevz Morato committed Dec 13, 2024
1 parent 5851969 commit 1e7e958
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/utility/RecordReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ bool allMatch(const std::vector<std::string>& v1, const std::vector<std::string>
}
return true;
}
std::string matchTo(const std::vector<std::string>& mxIds, const std::vector<std::string>& filenames, const std::vector<std::string>& nodenames) {
std::string mxId = "";
for(const auto& id : mxIds) {
std::string matchTo(const std::vector<std::string>& deviceIds, const std::vector<std::string>& filenames, const std::vector<std::string>& nodenames) {
std::string deviceId = "";
for(const auto& id : deviceIds) {
std::vector<std::string> matches;
for(const auto& filename : filenames) {
if(filename.size() >= 4 && filename.substr(filename.size() - 4, filename.size()) != "meta" && filename.find(id) != std::string::npos) {
Expand All @@ -227,15 +227,15 @@ std::string matchTo(const std::vector<std::string>& mxIds, const std::vector<std
}
if(matches.size() == nodenames.size()) {
if(allMatch(matches, nodenames)) {
if(mxId.empty()) {
mxId = id;
if(deviceId.empty()) {
deviceId = id;
} else {
throw std::runtime_error("Multiple recordings match the pipeline configuration - unsupported.");
}
}
}
}
return mxId;
return deviceId;
}

} // namespace utility
Expand Down
2 changes: 1 addition & 1 deletion src/utility/RecordReplayImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ bool checkRecordConfig(std::string& recordPath, RecordConfig& config);

bool allMatch(const std::vector<std::string>& v1, const std::vector<std::string>& v2);

std::string matchTo(const std::vector<std::string>& mxIds, const std::vector<std::string>& filenames, const std::vector<std::string>& nodenames);
std::string matchTo(const std::vector<std::string>& deviceIds, const std::vector<std::string>& filenames, const std::vector<std::string>& nodenames);
} // namespace utility
} // namespace dai
8 changes: 4 additions & 4 deletions src/xlink/XLinkConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ DeviceInfo::DeviceInfo(const deviceDesc_t& desc) {
DeviceInfo::DeviceInfo(std::string name, std::string deviceId, XLinkDeviceState_t state, XLinkProtocol_t protocol, XLinkPlatform_t platform, XLinkError_t status)
: name(std::move(name)), deviceId(std::move(deviceId)), state(state), protocol(protocol), platform(platform), status(status) {}

DeviceInfo::DeviceInfo(std::string mxidOrName) {
DeviceInfo::DeviceInfo(std::string deviceIdOrName) {
// Parse parameter and set to ip if any dots found
// mxid doesn't have a dot in the name
if(mxidOrName.find(".") != std::string::npos) {
if(deviceIdOrName.find(".") != std::string::npos) {
// This is reasoned as an IP address or USB path (name). Set rest of info accordingly
name = std::move(mxidOrName);
name = std::move(deviceIdOrName);
deviceId = "";
} else {
// This is reasoned as mxid
name = "";
deviceId = std::move(mxidOrName);
deviceId = std::move(deviceIdOrName);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main(){
if(test) {
auto devices = dai::XLinkConnection::getAllConnectedDevices();
for(const auto& device : devices){
std::cout << "Device name: " << device.name << " id: " << device.mxid << std::endl;
std::cout << "Device name: " << device.name << " id: " << device.deviceId << std::endl;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/multiple_devices_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main() {
auto device = make_shared<dai::Device>(pipeline, dev, dai::UsbSpeed::SUPER);
device->getOutputQueue("rgb", 4, false);

cout << "MXID: " << device->getDeviceId() << endl;
cout << "DeviceID: " << device->getDeviceId() << endl;
// cout << "Connected cameras: ";
// for(const auto& cam : device->getConnectedCameras()) {
// cout << cam << " ";
Expand Down

0 comments on commit 1e7e958

Please sign in to comment.