Class Joiner
Joiner: expects inputs from multiple sources. When the configured "timer" source arrives, concatenates all latest values and publishes one MathNet.Numerics.LinearAlgebra.Vector<T>.
JSON configuration
Use these block entries inside a pipeline configuration. Input names must match other blocks in that pipeline; device addresses and file paths must match your setup.
Block entry for a larger pipeline. The timer token is required and must name an input. Each SignalA arrival publishes the latest concatenated values in Inputs order. This does not synchronize acquisition between sources.
{
"Joiner": {
"Type": "joiner",
"Inputs": ["SignalA", "SignalB"],
"Params": ["timer:SignalA"]
}
}
How Type, Inputs and Params work · Block catalogue and parameter reference
Implements
Inherited Members
Namespace: MOSAIC.Models
Assembly: MOSAIC.dll
Syntax
public sealed class Joiner : BaseBlock, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Constructors
Joiner(string, double, string)
Declaration
public Joiner(string name = "Joiner", double desiredRate = 0, string timerSource = "")
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| double | desiredRate | |
| string | timerSource |
Fields
_latest
Declaration
private readonly Dictionary<string, object?> _latest
Field Value
| Type | Description |
|---|---|
| Dictionary<string, object> |
_latestLock
Guards _latest. Every declared input is published by its OWN block, and
every block owns its own OutputDispatcher with its own pump thread — so a Joiner
with seven inputs has seven threads writing this dictionary concurrently. Unsynchronised
concurrent adds can corrupt a Dictionary<TKey, TValue>'s bucket chain, which
shows up as a hang inside a resize rather than an exception, and the window for it is
startup — exactly when the keys are being created.
Declaration
private readonly object _latestLock
Field Value
| Type | Description |
|---|---|
| object |
Remarks
It also makes ConcatenateLatest() a consistent snapshot. That method walks the sources twice, once to sum lengths and once to fill, and a writer landing between the two passes can make the second disagree with the first — for an undeclared source appearing mid-publish, by enough to run off the end of the destination array.
_notAwaited
Blocks that have published, but will never fill a slot in _latest under their own name — so waiting for them to do so would mean waiting forever.
Declaration
private readonly HashSet<string> _notAwaited
Field Value
| Type | Description |
|---|---|
| HashSet<string> |
Remarks
Two ways in. A block whose payload is neither a Vector nor a Matrix: a Clock publishes a bare timestamp, and four shipped configs list one among a Joiner's inputs. And a block using the legacy tuple format, which files its value under a tag of its own choosing rather than its block name.
Both are excluded from the wait in AllInputsSeen(out string?) — without which a single such input holds the gate shut for the life of the process and the Joiner publishes nothing at all, silently. This changes only what the block waits for, never what it emits: OrderedLatest() is driven entirely by what is present in _latest.
_timerSource
Declaration
private string _timerSource
Field Value
| Type | Description |
|---|---|
| string |
Properties
IsWaitingForInputs
Whether output is being withheld until every declared input has delivered once.
Declaration
public bool IsWaitingForInputs { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MaxInputs
Gets the maximum number of input connections allowed for this block.
Declaration
public override int MaxInputs { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Remarks
Override in derived classes to specify input requirements. Default is 1 (most blocks accept exactly one input). Use MaxValue for blocks that accept unlimited inputs (e.g., Joiner).
MinInputs
Gets the minimum number of input connections required for this block.
Declaration
public override int MinInputs { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Remarks
Override in derived classes to specify input requirements. Default is 1 (most blocks require exactly one input). Source blocks (devices, generators) should return 0.
PendingInputs
Declared inputs still to deliver their first joinable value. Empty once every source that can contribute one has spoken, which is also when this block starts publishing.
Declaration
public IReadOnlyList<string> PendingInputs { get; private set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Remarks
Inputs that cannot contribute — see _notAwaited — never appear here, so a Joiner listing a Clock among its inputs is not held up by it.
TimerSourceName
Declaration
public string TimerSourceName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
AllInputsSeen(out string?)
Whether every declared input has delivered at least once, refreshing PendingInputs as the answer changes.
Declaration
private bool AllInputsSeen(out string? log)
Parameters
| Type | Name | Description |
|---|---|---|
| string | log | A line to write once the caller has released _latestLock, or null when the answer has not changed since the last tick. |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
A Joiner with no declared inputs (built in code rather than from JSON) has nothing to align against and keeps the old arrival-order behaviour.
ConcatenateLatest()
Declaration
private Vector<double> ConcatenateLatest()
Returns
| Type | Description |
|---|---|
| Vector<double> |
ConfigureInput(IServiceProvider, JsonModel)
JSON config: Params supports "timerBlockName:Name" or "timer:Name".
Declaration
public static Joiner ConfigureInput(IServiceProvider sp, JsonModel m)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | sp | |
| JsonModel | m |
Returns
| Type | Description |
|---|---|
| Joiner |
GetJsonParams()
What ConfigureInput reads back: the timer source, in the timer: form it accepts.
Declaration
protected override IReadOnlyList<object>? GetJsonParams()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<object> |
Overrides
OnReceive(object, object)
Accepts both legacy (string, object) tuples and standard BaseBlock outputs.
Declaration
protected override void OnReceive(object sender, object data)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | |
| object | data |
Overrides
OrderedLatest()
The sources to concatenate, in a stable order.
Declaration
private IEnumerable<object?> OrderedLatest()
Returns
| Type | Description |
|---|---|
| IEnumerable<object> |
Remarks
Declared input order when the block was configured from JSON, falling back to arrival order only for sources the configuration does not mention. Iterating the dictionary directly would concatenate in first-arrival order, so the segment a given sensor lands on would depend on which packet happened to appear first and could differ between runs — invisible with one input, silently swapping channels with two.
Report(string?)
Writes a state-change line, if AllInputsSeen(out string?) produced one.
Declaration
private static void Report(string? line)
Parameters
| Type | Name | Description |
|---|---|---|
| string | line |
SetTimerSource(string)
Declaration
public void SetTimerSource(string sourceName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceName |