mlink/ipc-types-private.h
mlink/ipc-types-private.h
Namespaces
| Name |
|---|
| Syntalos |
Classes
| Name | |
|---|---|
| struct | Syntalos::InputPortChange Information about an input port change. |
| struct | Syntalos::OutputPortChange Information about an output port change. |
| struct | Syntalos::UpdateInputPortMetadataRequest request to update the metadata of an input port |
| struct | Syntalos::DoneResponse |
| struct | Syntalos::ErrorEvent |
| struct | Syntalos::StateChangeEvent |
| struct | Syntalos::StatusMessageEvent |
| struct | Syntalos::SetNicenessRequest |
| struct | Syntalos::SetMaxRealtimePriority |
| struct | Syntalos::SetCPUAffinityRequest |
| struct | Syntalos::DeletePortRequest |
| struct | Syntalos::ConnectInputRequest |
| struct | Syntalos::LoadScriptRequest |
| struct | Syntalos::SetPortsPresetRequest |
| struct | Syntalos::PrepareStartRequest |
| struct | Syntalos::StartRequest |
| struct | Syntalos::StopRequest |
| struct | Syntalos::ShutdownRequest |
| struct | Syntalos::SettingsChangeEvent |
| struct | Syntalos::ShowSettingsRequest |
| struct | Syntalos::ShowDisplayRequest |
Source code
/*
* Copyright (C) 2020-2026 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QObject>
#include <QIODevice>
#include <QVariantHash>
#include <QDataStream>
#include <iox2/bb/static_string.hpp>
#include <iox2/bb/static_vector.hpp>
#include <iox2/iceoryx2.hpp>
#include "syntalos-datactl"
namespace Syntalos
{
// number of elements to hold in the IPC queues
static constexpr uint64_t SY_IOX_QUEUE_CAPACITY = 12U;
// number of elements to hold in the publisher history
static constexpr uint64_t SY_IOX_HISTORY_SIZE = 2U;
// initial size of the shared memory block for IPC communication
static constexpr uint64_t SY_IOX_INITIAL_SLICE_LEN = 4096;
// maximum length for IPC service name components
static constexpr size_t SY_IOX_ID_MAX_LEN = IOX2_SERVICE_NAME_LENGTH;
enum class PortAction : uint8_t {
UNKNOWN,
ADD,
REMOVE,
CHANGE
};
struct InputPortChange {
PortAction action;
QString id;
QString title;
int dataTypeId;
QVariantHash metadata;
uint throttleItemsPerSec;
InputPortChange() = default;
explicit InputPortChange(PortAction pa)
: action(pa),
dataTypeId(-1),
throttleItemsPerSec(0)
{
}
QByteArray toBytes() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << action << id << title << dataTypeId << metadata << throttleItemsPerSec;
return bytes;
}
static InputPortChange fromMemory(const void *memory, size_t size)
{
InputPortChange info;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> info.action >> info.id >> info.title >> info.dataTypeId >> info.metadata >> info.throttleItemsPerSec;
return info;
}
friend QDataStream &operator<<(QDataStream &out, const InputPortChange &info)
{
out << info.action << info.id << info.title << info.dataTypeId << info.metadata << info.throttleItemsPerSec;
return out;
}
friend QDataStream &operator>>(QDataStream &in, InputPortChange &info)
{
in >> info.action >> info.id >> info.title >> info.dataTypeId >> info.metadata >> info.throttleItemsPerSec;
return in;
}
};
static const std::string IN_PORT_CHANGE_CHANNEL_ID = "InPortChange";
struct OutputPortChange {
PortAction action;
QString id;
QString title;
int dataTypeId;
QVariantHash metadata;
OutputPortChange() = default;
explicit OutputPortChange(PortAction pa)
: action(pa),
dataTypeId(-1)
{
}
QByteArray toBytes()
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << action << id << title << dataTypeId << metadata;
return bytes;
}
static OutputPortChange fromMemory(const void *memory, size_t size)
{
OutputPortChange info;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> info.action >> info.id >> info.title >> info.dataTypeId >> info.metadata;
return info;
}
friend QDataStream &operator<<(QDataStream &out, const OutputPortChange &info)
{
out << info.action << info.id << info.title << info.dataTypeId << info.metadata;
return out;
}
friend QDataStream &operator>>(QDataStream &in, OutputPortChange &info)
{
in >> info.action >> info.id >> info.title >> info.dataTypeId >> info.metadata;
return in;
}
};
static const std::string OUT_PORT_CHANGE_CHANNEL_ID = "OutPortChange";
struct UpdateInputPortMetadataRequest {
QString id;
QVariantHash metadata;
UpdateInputPortMetadataRequest() = default;
QByteArray toBytes() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << id << metadata;
return bytes;
}
static UpdateInputPortMetadataRequest fromMemory(const void *memory, size_t size)
{
UpdateInputPortMetadataRequest req;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> req.id >> req.metadata;
return req;
}
};
static const std::string IN_PORT_UPDATE_METADATA_ID = "UpdateInputPortMetadata";
struct DoneResponse {
bool success;
};
static const std::string WORKER_CTL_EVENT_ID = "worker-event";
static const std::string MASTER_CTL_EVENT_ID = "master-event";
struct ErrorEvent {
iox2::bb::StaticString<128> title;
iox2::bb::StaticString<2048> message;
};
static const std::string ERROR_CHANNEL_ID = "Error";
struct StateChangeEvent {
ModuleState state;
};
static const std::string STATE_CHANNEL_ID = "State";
struct StatusMessageEvent {
iox2::bb::StaticString<512> text;
};
static const std::string STATUS_MESSAGE_CHANNEL_ID = "StatusMessage";
struct SetNicenessRequest {
int nice;
};
static const std::string SET_NICENESS_CALL_ID = "SetNiceness";
struct SetMaxRealtimePriority {
int priority;
};
static const std::string SET_MAX_RT_PRIORITY_CALL_ID = "SetMaxRealtimePriority";
struct SetCPUAffinityRequest {
iox2::bb::StaticVector<uint32_t, 256> cores; // array of CPU core indices to set affinity to
};
static const std::string SET_CPU_AFFINITY_CALL_ID = "SetCPUAffinity";
struct DeletePortRequest {
int portId;
};
static const std::string DELETE_PORT_CALL_ID = "DeletePort";
struct ConnectInputRequest {
iox2::bb::StaticString<SY_IOX_ID_MAX_LEN> portId;
iox2::bb::StaticString<SY_IOX_ID_MAX_LEN> instanceId;
iox2::bb::StaticString<SY_IOX_ID_MAX_LEN> channelId;
};
static const std::string CONNECT_INPUT_CALL_ID = "ConnectInputPort";
struct LoadScriptRequest {
QString workingDir;
QString venvDir;
QString script;
QByteArray toBytes() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << workingDir << script;
return bytes;
}
static LoadScriptRequest fromMemory(const void *memory, size_t size)
{
LoadScriptRequest req;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> req.workingDir >> req.script;
return req;
}
};
static const std::string LOAD_SCRIPT_CALL_ID = "LoadScript";
struct SetPortsPresetRequest {
QList<InputPortChange> inPorts;
QList<OutputPortChange> outPorts;
QByteArray toBytes() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << inPorts << outPorts;
return bytes;
}
static SetPortsPresetRequest fromMemory(const void *memory, size_t size)
{
SetPortsPresetRequest req;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> req.inPorts >> req.outPorts;
return req;
}
};
static const std::string SET_PORTS_PRESET_CALL_ID = "SetPortsPresetRequest";
struct PrepareStartRequest {
QByteArray settings;
QByteArray toBytes() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << settings;
return bytes;
}
static PrepareStartRequest fromMemory(const void *memory, size_t size)
{
PrepareStartRequest req;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> req.settings;
return req;
}
};
static const std::string PREPARE_START_CALL_ID = "PrepareStart";
struct StartRequest {
int64_t startTimestampUsec;
};
static const std::string START_CALL_ID = "Start";
struct StopRequest {
};
static const std::string STOP_CALL_ID = "Stop";
struct ShutdownRequest {
};
static const std::string SHUTDOWN_CALL_ID = "Shutdown";
struct SettingsChangeEvent {
QByteArray settings;
SettingsChangeEvent() = default;
explicit SettingsChangeEvent(QByteArray settings)
: settings(std::move(settings))
{
}
QByteArray toBytes() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << settings;
return bytes;
}
static SettingsChangeEvent fromMemory(const void *memory, size_t size)
{
SettingsChangeEvent ev;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> ev.settings;
return ev;
}
};
static const std::string SETTINGS_CHANGE_CHANNEL_ID = "SettingsChange";
struct ShowSettingsRequest {
QByteArray settings;
QByteArray toBytes() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << settings;
return bytes;
}
static ShowSettingsRequest fromMemory(const void *memory, size_t size)
{
ShowSettingsRequest req;
QByteArray block(reinterpret_cast<const char *>(memory), size);
QDataStream stream(block);
stream >> req.settings;
return req;
}
};
static const std::string SHOW_SETTINGS_CALL_ID = "ShowSettings";
struct ShowDisplayRequest {
};
static const std::string SHOW_DISPLAY_CALL_ID = "ShowDisplay";
} // namespace Syntalos
Updated on 2026-03-16 at 19:16:01 +0000