MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_view()

uint32_t MayaFlux::Core::SerialInputBackend::add_view ( uint32_t device_id,
SerialSpec spec )

List a second way of reading a device, as a device of its own.

Parameters
device_idThe device to read, never a reading itself.
specFraming and parsing of this reading. Its line setup is not used.
Returns
The id of the reading, or 0 for an unknown device or a reading. Bind nodes to it.

The reading sees the bytes of the device it reads and cuts and parses them on its own, so one port can be read as lines by one node and as raw bytes by another. Opening it opens the device, closing it only stops this reading, and its values carry its own id. Writes to its id go to the device.

Definition at line 467 of file SerialInputBackend.cpp.

468{
469 if (!m_initialized.load()) {
470 return 0;
471 }
472
473 uint32_t id = 0;
474 InputDeviceInfo info {};
475 m_roster.update([&](Roster& roster) {
476 id = 0;
477 const auto parent = roster.entries.find(device_id);
478 if (parent == roster.entries.end() || parent->second.parent != 0) {
479 return false;
480 }
481 id = id_for(roster, "v:" + std::to_string(roster.next_id));
482 Entry entry = parent->second;
483 entry.device.reset();
484 entry.parent = device_id;
485 entry.view_reader = 0;
486 entry.configured = false;
487 entry.spec = spec;
488 entry.info.id = id;
489 entry.info.name = parent->second.info.name + " (reading " + std::to_string(id) + ")";
490 info = entry.info;
491 roster.entries.insert_or_assign(id, std::move(entry));
492 return true;
493 });
494
495 if (id != 0) {
496 notify_device(info, info.is_connected);
497 }
498 return id;
499}
static uint32_t id_for(Roster &roster, const std::string &key)
Memory::SnapshotCell< Roster > m_roster
void notify_device(const InputDeviceInfo &info, bool connected) const

References add_view(), MayaFlux::Core::SerialInputBackend::Entry::configured, MayaFlux::Core::SerialInputBackend::Entry::device, MayaFlux::Core::SerialInputBackend::Roster::entries, MayaFlux::Core::InputDeviceInfo::id, id_for(), MayaFlux::Core::SerialInputBackend::Entry::info, MayaFlux::Core::InputDeviceInfo::is_connected, m_initialized, m_roster, MayaFlux::Core::InputDeviceInfo::name, MayaFlux::Core::SerialInputBackend::Roster::next_id, notify_device(), MayaFlux::Core::SerialInputBackend::Entry::parent, MayaFlux::Core::SerialInputBackend::Entry::spec, and MayaFlux::Core::SerialInputBackend::Entry::view_reader.

Referenced by add_view().

Here is the call graph for this function:
Here is the caller graph for this function: