Reference
API reference
The public types and members of the Komod SDK, by namespace. The descriptions come from the XML documentation of the code. protected members are the ones you can override or use in a class derived from KomodBase.
Kofa.Abstractions.DataTypes
DepthQuality
How a depth of a DepthMap cell is known (higher is more trustworthy).
public static class DepthQuality
| Member |
Description |
public const byte None |
No depth known here. |
public const byte Modelled |
A modelled bed (e.g. GLOBathy): the shape is right, a single place can be off by a metre. |
public const byte Charted |
An imported chart or survey (GeoTIFF, ASCII grid, XYZ soundings). |
public const byte Measured |
Measured by the boat's own depth sounder. |
KofaJson
JSON conventions of port payloads between the server, the browser and sidecars.
public static class KofaJson
| Member |
Description |
public static JsonSerializerOptions CreatePayloadOptions() |
camelCase, enums as strings, NaN / Infinity allowed. Fields are included because System.Numerics vectors and quaternions (ImuSample, Pose3) store their components in fields. |
KofaMessage<T>
Envelope of every value travelling on a link.
public record struct KofaMessage<T>
| Member |
Description |
public KofaMessage<T>(T Value, long Seq, DateTimeOffset TimestampUtc, string SourceInstanceId) |
Envelope of every value travelling on a link. |
public T Value { get; init; } |
The payload. In-process it is passed by reference, receivers must treat it as read-only. |
public long Seq { get; init; } |
Per output port monotonically increasing sequence number. |
public DateTimeOffset TimestampUtc { get; init; } |
When the value was measured / produced (not when it was forwarded). |
public string SourceInstanceId { get; init; } |
The instance that published the value. |
KofaTypeId
Stable identifier of a port payload type, e.g. kofa.drive.command/1.
public record struct KofaTypeId
| Member |
Description |
public KofaTypeId(string Name, int Version) |
Stable identifier of a port payload type, e.g. kofa.drive.command/1. |
public bool IsCompatibleWith(KofaTypeId other) |
Two ports can be linked when name and major version are equal. |
public static KofaTypeId Parse(string value) |
|
public static bool TryParse(string? value, out KofaTypeId id) |
|
public static KofaTypeId Of(Type type) |
Reads the KofaTypeAttribute of a payload type. |
public static bool TryOf(Type type, out KofaTypeId id) |
|
public string Name { get; init; } |
|
public int Version { get; init; } |
|
SceneClass
Meaning of a SceneGrid cell.
public static class SceneClass
| Member |
Description |
public const byte Unknown |
Not seen (outside the view or hidden). |
public const byte Ground |
Seen, but not drivable: grass, garden, building, fence. |
public const byte Road |
|
public const byte Sidewalk |
|
public const byte Obstacle |
|
public const byte Water |
Open water a boat can sail on (the seen world's water mode); on the water the seen SceneClass.Ground is the shore. |
WindMath
Apparent ↔ true wind. The apparent wind (what a vane on the boat measures) is the true wind minus the boat's velocity over ground; knowing the heading (vane mounting) and the velocity, it can be turned back into the true wind and vice versa. Conventions: see Wind.DirectionRad and Motion.
public static class WindMath
| Member |
Description |
public const double CalmMps |
Below this the direction of a wind vector is meaningless (reported as 0). |
public static Wind ToTrue(Wind apparent, Motion motion, bool useCourseOverGround = true) |
True wind from the apparent wind and the boat's motion. |
public static Wind ToApparent(Wind trueWind, Motion motion, bool useCourseOverGround = true) |
Apparent wind a vane on the boat would measure in this true wind. |
public static Wind FromAirVelocity(double eastMps, double northMps, WindKind kind, double headingRad = 0) |
Wind from an air velocity vector (where the air moves to, m/s east / north). For an apparent wind the direction is made relative to headingRad. |
public static ValueTuple<double, double> ToAirVelocity(Wind trueWind) |
Air velocity (east, north) of a true wind. |
public static double TrueWindAngle(Wind trueWind, double headingRad) |
True wind angle relative to the bow ((-π, π], positive = from starboard). |
public static double NormalizeBearing(double radians) |
[0, 2π) |
public static double NormalizeSigned(double radians) |
(-π, π] |
Kofa.Abstractions.Hardware
HardwareException
Hardware error with a user facing (Hungarian) message.
public class HardwareException : Exception
| Member |
Description |
public HardwareException(string message, Exception? innerException = null) |
Hardware error with a user facing (Hungarian) message. |
HardwareResources
Resource id conventions.
public static class HardwareResources
| Member |
Description |
public static string I2c(int busId, int address) |
i2c-1:0x40 |
public static string Video(string device) |
video:/dev/video0 |
public static string Gpio(int pin) |
gpio:18 (BCM numbering) |
IHardwareAccess
Hardware of the host (I2C, camera, ...) as seen by one Komod instance (IKomodContext.Hardware). Every device goes through the reservation system: a resource (e.g. i2c-1:0x40) belongs to at most one instance. Everything opened here is owned by the instance and closed by the runtime when it stops or faults (after the registered failsafes ran), so a Komod does not need to close its devices itself.
public interface IHardwareAccess
| Member |
Description |
public IHardwareLease Acquire(string resource) |
Reserves a resource without opening a device (e.g. a GPIO pin driven by other means). |
public II2cDevice OpenI2cDevice(int busId, int address) |
Reserves HardwareResources.I2c and opens the device. |
public IVideoCapture OpenVideoCapture(VideoCaptureOptions options) |
Reserves HardwareResources.Video and opens the camera (MJPEG capture). |
public IDisposable RegisterFailsafe(Action failsafe) |
Registers an action putting the outputs into a safe state (e.g. neutral PWM). The runtime calls it when the instance stops or faults, before closing the devices; dispose the result to unregister it. |
public string Backend { get; } |
Backend name: linux, simulated or none. |
public bool IsSimulated { get; } |
True when the devices are simulated (development PC): values are only shown, nothing moves. |
IHardwareLease
A reserved resource; disposing releases it.
public interface IHardwareLease
| Member |
Description |
public string Resource { get; } |
|
IHardwareResourceSettings
Optional interface of a Komod's settings record: the resources an instance with these settings will reserve. The graph validation reports two nodes claiming the same resource before anything starts.
public interface IHardwareResourceSettings
| Member |
Description |
public IEnumerable<string> GetHardwareResources() |
|
II2cDevice
An I2C device (one address on one bus). Calls are not thread safe: serialize them in the Komod.
public interface II2cDevice
| Member |
Description |
public void Write(ReadOnlySpan<byte> buffer) |
|
public void Read(Span<byte> buffer) |
|
public void WriteRead(ReadOnlySpan<byte> writeBuffer, Span<byte> readBuffer) |
|
public int BusId { get; } |
|
public int Address { get; } |
|
IVideoCapture
A running camera capture.
public interface IVideoCapture
| Member |
Description |
public IAsyncEnumerable<VideoFrame> ReadFramesAsync(CancellationToken cancellationToken = null) |
Frames at most at VideoCaptureOptions.FrameRate; a slow reader gets the newest frame (older ones are dropped). Ends with a HardwareException when the camera goes away. |
public VideoCaptureOptions Options { get; } |
|
VideoCaptureOptions
public sealed record VideoCaptureOptions
| Member |
Description |
public VideoCaptureOptions(string Device = "/dev/video0", int Width = 640, int Height = 480, double FrameRate = 15) |
|
public string Device { get; init; } |
V4L2 device path (/dev/video0). |
public int Width { get; init; } |
Requested width; the driver may pick the nearest supported size. |
public int Height { get; init; } |
Requested height. |
public double FrameRate { get; init; } |
Requested frames per second; faster cameras are throttled to it. |
VideoFrame
One JPEG frame as the camera produced it (no decoding / re-encoding).
public record struct VideoFrame
| Member |
Description |
public VideoFrame(ReadOnlyMemory<byte> Jpeg, int Width, int Height, DateTimeOffset TimestampUtc) |
One JPEG frame as the camera produced it (no decoding / re-encoding). |
public ReadOnlyMemory<byte> Jpeg { get; init; } |
A complete JPEG image, owned by the receiver. |
public int Width { get; init; } |
|
public int Height { get; init; } |
|
public DateTimeOffset TimestampUtc { get; init; } |
|
Kofa.Abstractions.Komods
IKomod
Contract between the runtime and a Komod. Implement it through KomodBase; the runtime creates a fresh object for every (re)start of an instance.
public interface IKomod
| Member |
Description |
public void Attach(IKomodContext context, object settings) |
Called once, right after construction and port injection. |
public Task InitializeAsync(CancellationToken cancellationToken) |
|
public Task ExecuteAsync(CancellationToken cancellationToken) |
|
public Task<bool> ApplySettingsAsync(object settings) |
Returns false when the change needs a restart. |
public void OnInputTimeout(IInputPort port) |
|
public Type SettingsType { get; } |
|
IKomodContext
Services the runtime gives to a Komod instance.
public interface IKomodContext
| Member |
Description |
public void ReportStatus(KomodHealth health, string? message = null) |
Shown on the graph node and the dashboard. |
public void ReportStatus(KomodHealth health, LocalizedText message) |
A translatable status (ReportStatus(KomodHealth.Ok, Text("status.ready", "Kész"))): every viewer sees it in their own language. An older host shows the Hungarian text. |
public LocalizedText Text(string key, string fallback, ValueTuple<string, object?>[] args) |
A user facing text from the package's dictionary (i18n/<lang>.json, the key without the package id), shown in the language of whoever reads it; fallback is the Hungarian source text with {name} placeholders. Use it for KomodCommandException messages. |
public string InstanceId { get; } |
|
public string InstanceLabel { get; } |
|
public ILogger Logger { get; } |
|
public TimeProvider TimeProvider { get; } |
|
public string StorageDirectory { get; } |
Private, persistent data folder of this instance (created on first access). |
public IHardwareAccess Hardware { get; } |
Host hardware through the reservation system (simulated on a development PC). |
public string? PackageId { get; } |
Id of the Komod package the instance belongs to: the namespace of its dictionary keys (docs/I18N.md). |
KomodBase
Base class of Komods without settings.
public abstract class KomodBase : KomodBase<NoSettings>, IKomod
| Member |
Description |
protected KomodBase() |
|
KomodBase<TSettings>
Base class of all Komods. TSettings is deserialized from the instance settings JSON.
public abstract class KomodBase<TSettings> : IKomod
| Member |
Description |
protected LocalizedText Text(string key, string fallback, ValueTuple<string, object?>[] args) |
A translatable user facing text of this package (IKomodContext.Text). |
protected virtual Task InitializeAsync(CancellationToken cancellationToken) |
Allocate resources. Throwing here faults the instance. |
protected abstract Task ExecuteAsync(CancellationToken cancellationToken) |
Main loop; cancellationToken signals stop. Returning early is allowed (passive Komod). |
protected virtual Task<bool> OnSettingsChangedAsync(TSettings oldSettings, TSettings newSettings) |
KomodBase.Settings already holds newSettings. Return true when applied live, false to let the runtime restart the instance (default). |
protected virtual void OnInputTimeout(IInputPort port) |
An input's deadline elapsed without a message. Put actuators into a safe state here. |
public virtual ValueTask DisposeAsync() |
|
protected KomodBase<TSettings>() |
|
protected IKomodContext Context { get; } |
|
protected ILogger Logger { get; } |
|
protected TSettings Settings { get; } |
|
KomodCommandException
A command failed with a message meant for the user. With a LocalizedText (e.g. Context.Text("errors.noMap", "Nincs betöltött térkép.")) the caller sees it in its own language; a plain string is shown as it is (Hungarian).
public sealed class KomodCommandException : Exception
| Member |
Description |
public KomodCommandException(string message) |
|
public KomodCommandException(LocalizedText text) |
|
public LocalizedText Text { get; } |
The message as a translatable text (a plain one for the string constructor). |
LocalTunnels
Loopback connections a transport Komod opened to its own host for a peer it admitted itself (the Bluetooth connector: only paired devices, paired inside the window an admin opened). The host may trust such a request more than any other local one (KOFA Lite: an operator session without a password). Process-wide: only code in the host process registers, and a registered port is held by that connection until it is disposed.
public static class LocalTunnels
| Member |
Description |
public static IDisposable Register(EndPoint? localEndPoint, string transport) |
Registers the local end of a connection to the host; dispose the result when the connection closes. |
public static string? TransportOf(IPAddress? remoteAddress, int remotePort) |
The transport of a request's client end (its remote address and port), or null when it is no registered tunnel. |
NoSettings
Settings type of Komods without settings.
public sealed record NoSettings
| Member |
Description |
public NoSettings() |
|
Kofa.Abstractions.Localization
ITextCatalog
Resolves dictionary keys to texts of a language.
public interface ITextCatalog
| Member |
Description |
public LanguageInfo? GetLanguage(string language) |
|
public IReadOnlyList<string> GetFallbackChain(string language) |
The languages searched for a text of language: the language, its primary subtag, its fallback (by default TextCatalog.DefaultFallbackLanguage, recursively) and finally TextCatalog.SourceLanguage. |
public bool TryGetValue(string language, string key, out TextValue value, out string foundLanguage) |
Finds a text along the fallback chain; foundLanguage is the language it was found in. |
public string Get(string language, string key, string? fallback = null, IReadOnlyDictionary<string, object?>? args = null) |
The text of key with the arguments filled in; without a translation fallback (the Hungarian source text), without that the key itself. The count argument selects the plural form. |
public string Format(string language, LocalizedText text) |
A LocalizedText in language (nested arguments too). |
public IReadOnlyList<LanguageInfo> Languages { get; } |
Languages that have texts or a description, sorted by code. |
LanguageCode
Language codes: lower case BCP 47 tags (hu, en, pt-br).
public static class LanguageCode
| Member |
Description |
public static string Normalize(string language) |
|
public static string Primary(string language) |
The primary subtag: en-us → en. |
LanguageInfo
A language of the catalog: i18n/language.json (one language) or i18n/languages.json (an array, e.g. the community languages written by tools/Kofa.I18n pull).
public sealed record LanguageInfo
| Member |
Description |
public const string FileName |
|
public const string ListFileName |
Description of several languages (a JSON array of LanguageInfo.FileName objects). |
public LanguageInfo(string Code, string Name, string NativeName, string? Fallback = null, string? DateFormat = null, string? Plural = null) |
A language of the catalog: i18n/language.json (one language) or i18n/languages.json (an array, e.g. the community languages written by tools/Kofa.I18n pull). |
public static bool IsDescriptionFile(string fileName) |
Whether a file name (with or without the .json extension) is a language description, not a dictionary. |
public static IReadOnlyList<LanguageInfo> ParseDescription(string json, string? source = null) |
Parses a description file: one object (LanguageInfo.FileName) or an array (LanguageInfo.ListFileName). |
public static LanguageInfo Parse(string json, string? source = null) |
|
public string Code { get; init; } |
Language code, e.g. de. |
public string Name { get; init; } |
English name, e.g. German. |
public string NativeName { get; init; } |
Name in the language itself (shown in the language selector), e.g. Deutsch. |
public string? Fallback { get; init; } |
Language used for missing texts; null = TextCatalog.DefaultFallbackLanguage. Hungarian is always the last one. |
public string? DateFormat { get; init; } |
Date pattern (e.g. yyyy.MM.dd.); null = ISO. |
public string? Plural { get; init; } |
Plural rule, a PluralRules.Presets name; null = keep the registered rule (one / other). |
public static LanguageInfo Hungarian { get; } |
|
public static LanguageInfo English { get; } |
|
LocalizedText
A language neutral, user facing text: a dictionary key, the Hungarian source text and its arguments. The server and the Komods create it; the one who shows it (the browser, an HTTP response) picks the language with ITextCatalog.Format. Without a translation LocalizedText.Text is shown. JSON: { "key": "...", "text": "...", "args": { ... } }; a plain JSON string is read as a text without a key.
public sealed record LocalizedText
| Member |
Description |
public LocalizedText(string Key, string Text, IReadOnlyDictionary<string, object?>? Args = null) |
A language neutral, user facing text: a dictionary key, the Hungarian source text and its arguments. The server and the Komods create it; the one who shows it (the browser, an HTTP response) picks the language with ITextCatalog.Format. Without a translation LocalizedText.Text is shown. JSON: { "key": "...", "text": "...", "args": { ... } }; a plain JSON string is read as a text without a key. |
public static LocalizedText Create(string key, string text, ValueTuple<string, object?>[] args) |
|
public static LocalizedText Plain(string text) |
A text that is never translated (e.g. a message of an older Komod). |
public string Key { get; init; } |
Dictionary key; empty = no translation, LocalizedText.Text is always used. |
public string Text { get; init; } |
Hungarian source text with {name} placeholders. |
public IReadOnlyDictionary<string, object?>? Args { get; init; } |
Placeholder values; an argument may itself be a LocalizedText. count selects the plural form. |
LocalizedTextJsonConverter
Trim safe JSON converter of LocalizedText.
public sealed class LocalizedTextJsonConverter : JsonConverter<LocalizedText>
| Member |
Description |
public override LocalizedText? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
public override void Write(Utf8JsonWriter writer, LocalizedText value, JsonSerializerOptions options) |
|
public static LocalizedText? FromElement(JsonElement element) |
Reads a LocalizedText from an object or a string element; null for anything else. |
public LocalizedTextJsonConverter() |
|
PluralRules
CLDR plural categories per language. Hungarian and English are built in (one for exactly 1, otherwise other); a language with other rules names a preset (LanguageInfo.Plural, see PluralRules.Presets) or registers its own rule with PluralRules.Register. Unknown languages use the one / other rule.
public static class PluralRules
| Member |
Description |
public const string Zero |
|
public const string One |
|
public const string Two |
|
public const string Few |
|
public const string Many |
|
public const string Other |
|
public const string OneOtherPreset |
Preset of Hungarian, English and most Germanic and Romance languages: one for exactly 1. |
public static void Register(string language, Func<decimal, string> rule) |
Sets the rule of a language (its primary subtag, e.g. de); the rule returns one of PluralRules.Categories. |
public static void RegisterPreset(string language, string preset) |
Sets the rule of a language to a PluralRules.Presets entry. |
public static string Select(string language, decimal count) |
|
public static bool IsCategory(string name) |
|
public static IReadOnlyList<string> Categories { get; } |
|
public static IReadOnlyDictionary<string, Preset> Presets { get; } |
The presets a language description may name: one-other (hu, en, de, es, it …), none (ja, zh, ko, vi), french (fr, pt: 0 and 1 are singular), east-slavic (ru, uk, be), polish, czech (cs, sk), arabic. Simplified CLDR rules for the counts KOFA formats (integers, plain decimals). |
TextCatalog
Layered texts of every language. TextCatalog.Add sources override earlier ones key by key (the core and the Komod packages, each in its own namespace); TextCatalog.AddSupplement sources (language packs) only fill keys that no TextCatalog.Add source has. Build the catalog, then share it: lookups are thread safe, changes are not; to reload, build a new catalog and swap it.
public sealed class TextCatalog : ITextCatalog
| Member |
Description |
public const string SourceLanguage |
The language of the source texts in the code; the last element of every fallback chain. |
public const string DefaultFallbackLanguage |
Fallback of a language that does not name one. |
public void Add(TextDictionary dictionary) |
|
public void AddSupplement(TextDictionary dictionary) |
|
public void AddLanguage(LanguageInfo language) |
Adds or replaces the description of a language (language.json); its LanguageInfo.Plural preset becomes the plural rule of the language. |
public LanguageInfo? GetLanguage(string language) |
|
public IReadOnlyCollection<string> GetKeys(string language) |
Keys that have a text in exactly language (no fallback), for coverage checks. |
public IReadOnlyList<string> GetFallbackChain(string language) |
|
public bool TryGetValue(string language, string key, out TextValue value, out string foundLanguage) |
|
public string Get(string language, string key, string? fallback = null, IReadOnlyDictionary<string, object?>? args = null) |
|
public string Format(string language, LocalizedText text) |
|
public TextCatalog() |
|
public IReadOnlyList<LanguageInfo> Languages { get; } |
|
TextCatalogLoader
Loads i18n/ folders into a TextCatalog: <lang>.json dictionaries (the file name is the language code) and optional language descriptions (LanguageInfo.FileName, LanguageInfo.ListFileName).
public static class TextCatalogLoader
| Member |
Description |
public const string FolderName |
Folder of the dictionaries in a project and in a Komod package. |
public static int LoadDirectory(TextCatalog catalog, string directory, string? keyPrefix = null, bool supplement = false) |
Loads the dictionaries of a folder; a missing folder loads nothing. |
public static int LoadEmbedded(TextCatalog catalog, Assembly assembly, string? keyPrefix = null, bool supplement = false) |
Loads the dictionaries embedded in an assembly: resources named <anything>.i18n.<lang>.json (an i18n/<lang>.json file included as EmbeddedResource). |
TextDictionary
The texts of one language from one source (an i18n/<lang>.json file): a flat JSON object of "key": "text" or "key": { "one": "...", "other": "..." } entries. A null value marks a known but untranslated key (it is skipped). Comments and trailing commas are allowed.
public sealed class TextDictionary
| Member |
Description |
public static TextDictionary Create(string language, IReadOnlyDictionary<string, TextValue> entries, string? source = null) |
|
public static TextDictionary Parse(string language, string json, string? keyPrefix = null, string? source = null) |
|
public static TextDictionary Load(string language, Stream stream, string? keyPrefix = null, string? source = null) |
|
public string Language { get; } |
|
public IReadOnlyDictionary<string, TextValue> Entries { get; } |
|
public IReadOnlyList<string> MissingKeys { get; } |
Keys with a null value (known, not yet translated). |
public string? Source { get; } |
File or resource name, for error messages. |
TextDictionaryException
A dictionary file could not be read.
public sealed class TextDictionaryException : Exception
| Member |
Description |
public TextDictionaryException(string? source, string message, Exception? inner = null) |
A dictionary file could not be read. |
public string? DictionarySource { get; } |
File or resource name of the dictionary; null = unknown. |
TextFormatter
Fills {name} placeholders. {{ and }} are literal braces; a placeholder without an argument stays as it is, so a missing argument is visible instead of silently empty. Numbers use the invariant format.
public static class TextFormatter
| Member |
Description |
public static string Format(string template, IReadOnlyDictionary<string, object?>? args, Func<LocalizedText, string>? nested = null) |
|
public static IReadOnlyList<string> GetPlaceholders(string template) |
Names of the placeholders of a template, in order of appearance, without duplicates. |
public static decimal? ToCount(object? value) |
The plural count of an argument value (number, numeric string or JSON number); null when it is not a number. |
TextValue
One dictionary entry: a single text or plural forms (PluralRules.Categories, other required).
public sealed class TextValue
| Member |
Description |
public static TextValue Single(string text) |
|
public static TextValue Plural(IReadOnlyDictionary<string, string> forms) |
|
public string Select(string language, decimal? count) |
The template for count (null = other) by the rules of language. |
public bool HasSamePlaceholders(TextValue source) |
Whether a translation uses exactly the placeholders of its source text; a translation must neither drop nor invent arguments (the dictionary check, the package validation and the community editor use this rule). |
public string? Text { get; } |
|
public IReadOnlyDictionary<string, string>? Forms { get; } |
|
public IEnumerable<string> Templates { get; } |
All templates (the single text or every plural form). |
public IReadOnlySet<string> Placeholders { get; } |
The placeholder names of every template (TextFormatter.GetPlaceholders). |
Kofa.Abstractions.Ports
public interface IInputPort : IPort
| Member |
Description |
public DateTimeOffset? LastReceivedUtc { get; } |
When the last message arrived (runtime clock), null if none since start. |
Typed input, injected by the runtime into properties marked with InputAttribute.
public interface IInput<T> : IInputPort
| Member |
Description |
public bool TryRead(out KofaMessage<T> message) |
|
public ValueTask<KofaMessage<T>> ReadAsync(CancellationToken cancellationToken = null) |
|
public IAsyncEnumerable<KofaMessage<T>> ReadAllAsync(CancellationToken cancellationToken = null) |
|
public KofaMessage<T>? Latest { get; } |
The most recent message, even if it was already read. Null before the first message. |
IOutputPort
public interface IOutputPort : IPort
IOutput<T>
Typed output, injected by the runtime into properties marked with OutputAttribute.
public interface IOutput<T> : IOutputPort
| Member |
Description |
public void Publish(T value) |
Publishes with the current time as measurement timestamp. |
public void Publish(T value, DateTimeOffset timestampUtc) |
|
IPort
public interface IPort
| Member |
Description |
public PortDescriptor Descriptor { get; } |
|
PortDescriptor
public sealed record PortDescriptor
| Member |
Description |
public PortDescriptor(string Id, PortDirection Direction, KofaTypeId Type, PortQos Qos, bool Multiple = false, TimeSpan? Deadline = null, string? DisplayName = null, string? Description = null, bool FromUi = false, RelayPriority RelayPriority = auto, bool Bulk = false) |
|
public string Id { get; init; } |
|
public PortDirection Direction { get; init; } |
|
public KofaTypeId Type { get; init; } |
|
public PortQos Qos { get; init; } |
|
public bool Multiple { get; init; } |
|
public TimeSpan? Deadline { get; init; } |
|
public string? DisplayName { get; init; } |
|
public string? Description { get; init; } |
|
public bool FromUi { get; init; } |
|
public RelayPriority RelayPriority { get; init; } |
Outputs: the author's relay priority (Auto = the Komod's value). |
public bool Bulk { get; init; } |
The payload carries raw bytes (camera frames, grids, 3D worlds): never High over the relay. |
PortQos
public record struct PortQos
| Member |
Description |
public PortQos(PortQosKind Kind, int Capacity) |
|
public static PortQos Queue(int capacity) |
|
public PortQosKind Kind { get; init; } |
|
public int Capacity { get; init; } |
|
public static PortQos Latest { get; } |
|
Kofa.Abstractions.Ui
IKomodClientContext
Browser side services for Komod UIs. A Komod UI only displays data and sends commands; it has no runtime ports.
public interface IKomodClientContext
| Member |
Description |
public IAsyncEnumerable<KofaMessage<T>> SubscribeAsync<T>(PortRef port, double maxRateHz = 10, CancellationToken cancellationToken = null) |
Live messages of a port (input or output) of a server instance. The server thins the stream to at most maxRateHz, always sending the newest value, so the browser never slows the control loop. The sequence ends when the instance is removed or cancellationToken is cancelled. |
public Task<JsonElement> GetSettingsAsync(string instanceId, CancellationToken cancellationToken = null) |
Current settings of a running instance (camelCase JSON, defaults filled in). |
public Task SaveSettingsAsync(string instanceId, JsonElement settings, CancellationToken cancellationToken = null) |
Applies new settings to a running instance live (validated by the server; the instance restarts if the Komod cannot apply them in place). They are also written into the active graph, so they survive a server restart. Needs the Operator role. |
public Task InjectAsync<T>(PortRef port, T value, CancellationToken cancellationToken = null) |
Sends a browser value to a UI input of a server instance ([Input(..., FromUi = true)]), e.g. the stick position of a remote controller. Send periodically: the input's deadline protects against a lost browser. Needs the Operator role. |
public Task<JsonElement?> InvokeAsync(string instanceId, string command, object? arguments = null, CancellationToken cancellationToken = null) |
Calls a [KomodCommand] of a running instance; returns its JSON result (null for none). Needs the Operator role. |
public Task UploadFileAsync(string instanceId, string folder, string fileName, Stream content, CancellationToken cancellationToken = null) |
Uploads a file into the instance's storage folder (Context.StorageDirectory, the Files panel), under folder (relative, "" = the root); an existing file of that name is replaced. The server limits the size (Kofa:Runtime:MaxInstanceFileSizeMb). Needs the Operator role. |
public string GetAssetUrl(string komodId, string path) |
URL of a static file of the Komod's package (the UI project's wwwroot/), e.g. a JS module for IJSRuntime.InvokeAsync<IJSObjectReference>("import", url). |
public Task<string?> GetRelayPriorityAsync(PortRef port, CancellationToken cancellationToken = null) |
Effective relay priority of a port: "High", "Low", "None" or "Blocked"; null = unknown. Through a relay a None / Blocked port sends nothing (`IKomodClientContext.SubscribeAsync`` ends at once) and a Low one may update rarely, so a UI can show a placeholder instead of waiting. |
public string Localize(string komodId, string key, string fallback, IReadOnlyDictionary<string, object?>? args = null) |
A text of the package of komodId (i18n/<lang>.json, key without the package id) in IKomodClientContext.Language; fallback is the Hungarian source text. |
public string Localize(LocalizedText text) |
A server or Komod message (e.g. a LocalizedText command result) in IKomodClientContext.Language. |
public bool IsRelaySession { get; } |
The browser reaches the server through a relay (remote session): relay priorities apply. |
public string Language { get; } |
Language of the UI (e.g. hu, en). |
KomodClientContextExtensions
public static class KomodClientContextExtensions
| Member |
Description |
public static Task<TResult> InvokeAsync<TResult>(IKomodClientContext context, string instanceId, string command, object? arguments = null, CancellationToken cancellationToken = null) |
IKomodClientContext.InvokeAsync with the result deserialized to TResult. |
KomodClientException
A KOFA server call made by a Komod UI failed. The message is user facing (Hungarian).
public sealed class KomodClientException : Exception
| Member |
Description |
public KomodClientException(string message) |
A KOFA server call made by a Komod UI failed. The message is user facing (Hungarian). |
KomodComponentBase
Base class of Komod views; the host passes the instance it belongs to.
public abstract class KomodComponentBase : ComponentBase
| Member |
Description |
protected PortRef Port(string portId) |
|
protected string AssetUrl(string path) |
URL of a file in the package's wwwroot/. |
protected Task InjectAsync<T>(string portId, T value, CancellationToken cancellationToken = null) |
Sends a value to a UI input of this instance. |
protected string T(string key, string fallback, ValueTuple<string, object?>[] args) |
A text of this package's dictionary (i18n/<lang>.json; the key without the package id) in the UI's language; fallback is the Hungarian source text with {name} placeholders (count selects the plural form): @T("widget.release", "Feloldás"). |
protected string T(LocalizedText text) |
A server or Komod message (LocalizedText) in the UI's language. |
protected Task<JsonElement?> InvokeCommandAsync(string command, object? arguments = null, CancellationToken cancellationToken = null) |
Calls a command of this instance (not to be confused with ComponentBase.InvokeAsync). |
protected KomodComponentBase() |
|
public string InstanceId { get; set; } |
|
public string? InstanceLabel { get; set; } |
|
public string KomodId { get; set; } |
The Komod this view belongs to (set by the host). |
public JsonElement? Settings { get; set; } |
ViewKind.Settings views only: the settings being edited (the graph editor's draft, defaults filled in). |
public EventCallback<JsonElement> SettingsChanged { get; set; } |
ViewKind.Settings views only: report edited settings (they go into the draft, applied with the graph). |
protected IKomodClientContext Kofa { get; set; } |
|
protected string Language { get; } |
Language of the UI (e.g. hu, en). |
PortRef
A port of a server side instance.
public record struct PortRef
| Member |
Description |
public PortRef(string InstanceId, string PortId) |
A port of a server side instance. |
public string InstanceId { get; init; } |
|
public string PortId { get; init; } |
|
_Imports
public class _Imports
| Member |
Description |
protected void Execute() |
|
public _Imports() |
|