Table of Contents

Class Profile

Namespace
Pamoja.Profile
Assembly
Pamoja.Profile.dll

A named, ready-to-run node assembled from pamoja capabilities.

public sealed class Profile : IDisposable
Inheritance
Profile
Implements
Inherited Members

Remarks

A profile is a pre-wired bundle: a control policy, a publish topic, and a power schedule. Instantiate one rather than choosing algorithms and tuning constants by hand. The presentation a dashboard reads travels inside the manifest JSON, so ToJson() carries the whole profile, and is read and built here as a typed Presentation.

Constructors

Profile(string, string, ControlPolicy, PowerSchedule)

Creates a profile of the program's own from its parts, with no description and no presentation.

public Profile(string name, string topic, ControlPolicy control, PowerSchedule power)

Parameters

name string

A stable, human-readable name, such as raised-bed-drip.

topic string

The topic each reading is published to.

control ControlPolicy

The control policy. Only the values belonging to its kind are read, and Cooling and Rising are false unless given.

power PowerSchedule

How often the node samples as the battery drains.

Exceptions

ArgumentException

The control lacks a value its kind needs, or a custom parameter is not a number, a bool, or a string.

PamojaException

A custom kind is empty, built in, or has a parameter named kind.

Properties

Control

Gets the control policy applied to each reading.

public ControlPolicy Control { get; }

Property Value

ControlPolicy

Description

Gets what the profile is for, in the words its manifest carries, or null.

public string? Description { get; }

Property Value

string

Name

Gets the profile's stable, human-readable name.

public string Name { get; }

Property Value

string

Power

Gets the sampling schedule kept as the battery drains.

public PowerSchedule Power { get; }

Property Value

PowerSchedule

PowerPlan

Gets the schedule assembled into a power governor.

public PowerPlan PowerPlan { get; }

Property Value

PowerPlan

Presentation

Gets how the profile presents itself on the dashboard, or null when it declares nothing beyond the built-in set.

public Presentation? Presentation { get; }

Property Value

Presentation

Reads

Gets what the profile reads, the quantity and the unit its numbers are in, or null when the manifest does not say.

public Reads? Reads { get; }

Property Value

Reads?

Topic

Gets the topic each reading is published to.

public string Topic { get; }

Property Value

string

Methods

Controller()

Builds the decision logic this profile describes.

public Controller Controller()

Returns

Controller

The controller, which the caller disposes.

Exceptions

PamojaException

The profile names a custom control kind, which no built-in controller decides.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

FloodSensor()

A flood sensor, which warns when a level rises too fast.

public static Profile FloodSensor()

Returns

Profile

The profile.

FromJson(string)

Loads a profile from its JSON manifest.

public static Profile FromJson(string manifest)

Parameters

manifest string

The manifest.

Returns

Profile

The profile.

Exceptions

PamojaException

The manifest is malformed.

IrrigationNode()

An irrigation node, which opens a valve as soil moisture falls.

public static Profile IrrigationNode()

Returns

Profile

The profile.

ToJson()

Serializes this profile to its JSON manifest.

public string ToJson()

Returns

string

The manifest.

Exceptions

PamojaException

The profile cannot be serialized.

VaccineFridgeMonitor()

A cold-chain fridge monitor, which holds 5 C and flags an excursion.

public static Profile VaccineFridgeMonitor()

Returns

Profile

The profile.

WellLevel()

A well-level monitor, which warns before a tank runs dry.

public static Profile WellLevel()

Returns

Profile

The profile.

WithDescription(string)

Returns a copy of this profile carrying a description of what it is for.

public Profile WithDescription(string description)

Parameters

description string

The description, a sentence or two.

Returns

Profile

The profile, which the caller disposes.

WithPresentation(Presentation)

Returns a copy of this profile carrying a dashboard presentation.

public Profile WithPresentation(Presentation presentation)

Parameters

presentation Presentation

How the profile presents itself.

Returns

Profile

The profile, which the caller disposes.

Exceptions

PamojaException

The presentation does not serialize to one the engine accepts.

WithReads(string, string)

Returns a copy of this profile that says what it reads.

public Profile WithReads(string quantity, string unit)

Parameters

quantity string

The quantity its control decides on, such as temperature.

unit string

The unit its numbers are in, such as celsius.

Returns

Profile

The profile, which the caller disposes.

Exceptions

PamojaException

The quantity or unit is not lowercase words joined by underscores.