nanoFramework.System.Device.Model
1.2.418
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.System.Device.Model --version 1.2.418
NuGet\Install-Package nanoFramework.System.Device.Model -Version 1.2.418
<PackageReference Include="nanoFramework.System.Device.Model" Version="1.2.418" />
paket add nanoFramework.System.Device.Model --version 1.2.418
#r "nuget: nanoFramework.System.Device.Model, 1.2.418"
// Install nanoFramework.System.Device.Model as a Cake Addin #addin nuget:?package=nanoFramework.System.Device.Model&version=1.2.418 // Install nanoFramework.System.Device.Model as a Cake Tool #tool nuget:?package=nanoFramework.System.Device.Model&version=1.2.418
System.Device.Model - attributes for device bindings
This library is experimental, it may change and it may be moved to a different package in the future. Avoid taking direct dependency on it.
This library provides a set of attributes which allow to annotate devices.
They can be used for:
- implementation of Azure Plug & Play
- providing extra metadata about sensors (we can i.e. generate some parts of the README file or add extra checks)
Model is representing language independent description of the device. The attributes represent a C# mapping from C# types into the model.
InterfaceAttribute
Every class producing telemetry or exposing some commands should put a telemetry attribute on it
[Interface("LPS25H - Piezoresistive pressure and thermometer sensor")]
public class Lps25h : IDisposable
- if class derives from class annotated with
[Interface(...)]
attribute:- class will inherit all annotations from the base class(es)
- if class provides extra telemetry/command/properties it should add another InterfaceAttribute on itself
- if class doesn't provide any extra annotations it should not have extra interface
- display name must be provided to the InterfaceAttribute
TelemetryAttribute
Every method or property producing telemetry should have [Telemetry]
attribute on it.
For properties providing name of the Telemetry
is optional as it can be deduced from the property name.
Telemetry can be put on:
- properties
- methods returning value but not taking any arguments
- methods returning bool and taking one
out
argument- multiple
out
arguments are currently out of scope but are considered
- multiple
[Telemetry]
public Temperature Temperature => Temperature.FromDegreesCelsius(42.5f + ReadInt16(Register.Temperature) / 480f);
[Telemetry("Humidity")]
public bool TryReadHumidity(out RelativeHumidity humidity) => TryReadHumidityCore(out humidity);
[Telemetry("Pressure")]
public Pressure ReadPressure() { /*...*/ }
- if telemetry is not producing typed unit (i.e.
Vector3
) it should have additionaldisplayName
provided - optional arguments are treated as if they were not there
- it's not allowed to have more than one
Telemetry
attribute with the same name on the sameInterface
PropertyAttribute
Properties should be put on properties or methods which describe the device or change its functioning. They should only be used on things which don't change value between calls (unless it's been written to or a command has been executed on the device). Specifially reading (telemetry) from the device should not change the state of the property.
Usage is similar to Telemetry with some additions:
- they can be writable
- if same name (i.e.
PowerMode
) is used on i.e.SetPowerMode
andReadPowerMode
they will be merged into a single model property
- if same name (i.e.
- they can be put on methods without return value taking one argument (it must not be be passed by reference)
- it's not allowed for more than one writers or readers with the same name to be present on the same interface
[Property]
public Sampling HumiditySampling { get { /*...*/ } set { /* ... */ } }
[Property("PowerMode")]
public void SetPowerMode(Bme680PowerMode powerMode) { /*...*/ }
[Property("PowerMode")]
public Bme680PowerMode ReadPowerMode() { /*...*/ }
ComponentAttribute
Components represent references to other (instances) of interfaces.
They can only be put on the properties, the return type of the property or its ancestor class should have an Interface
attribute.
[Component]
public SenseHatTemperatureAndHumidity TemperatureAndHumidity { get; private set; }
// ...
public class SenseHatTemperatureAndHumidity : Hts221.Hts221 { /* ... */ }
// ...
[Interface("HTS221 - Capacitive digital sensor for relative humidity and temperature")]
public class Hts221 : IDisposable { /* ... */ }
CommandAttribute
Commands can be something which can be executed on the device and they can be put only on methods.
[Command]
public void PlayTone(double frequency, int duraton) { /* ... */ }
[Command]
protected override void SetDefaultConfiguration() { /* ... */ }
Type serialization
Only simple types can be serialized:
- enums (without Flags attribute)
- values out of enum range are not permitted (i.e. bitwise combination)
- UnitsNet units
- basic C# types
- System.Numerics.Vector2, System.Numerics.Vector3, System.Numerics.Vector4
- System.Drawing.Color
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
NuGet packages (44)
Showing the top 5 NuGet packages that depend on nanoFramework.System.Device.Model:
Package | Downloads |
---|---|
nanoFramework.Iot.Device.Mpu6886
This package includes the .NET IoT Core binding Iot.Device.Mpu6886 for .NET nanoFramework C# projects. |
|
nanoFramework.Iot.Device.Buzzer
This package includes the .NET IoT Core binding Iot.Device.Buzzer for .NET nanoFramework C# projects. |
|
nanoFramework.Iot.Device.Bmm150
This package includes the .NET IoT Core binding Iot.Device.Bmm150 for .NET nanoFramework C# projects. |
|
nanoFramework.Iot.Device.Bmxx80
This package includes the .NET IoT Core binding Iot.Device.Bmxx80 for .NET nanoFramework C# projects. |
|
nanoFramework.Iot.Device.Bmp180
This package includes the .NET IoT Core binding Iot.Device.Bmp180 for .NET nanoFramework C# projects. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on nanoFramework.System.Device.Model:
Repository | Stars |
---|---|
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
|
|
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
|
|
nanoframework/nanoFramework.M5Stack
:package: Board support package for M5Stack, M5StickC and M5StickCPlus for .NET nanoFramework
|
Version | Downloads | Last updated |
---|---|---|
1.2.670 | 2,358 | 10/23/2024 |
1.2.628 | 6,238 | 8/28/2024 |
1.2.586 | 4,559 | 7/12/2024 |
1.2.418 | 17,103 | 11/9/2023 |
1.2.415 | 1,913 | 11/8/2023 |
1.2.414 | 133 | 11/8/2023 |
1.2.325 | 21,336 | 5/24/2023 |
1.2.295 | 7,917 | 5/3/2023 |
1.2.216 | 45,848 | 1/6/2023 |
1.2.158 | 28,991 | 11/13/2022 |
1.2.141 | 15,675 | 10/25/2022 |
1.2.82 | 61,669 | 9/14/2022 |
1.1.113.2032 | 148,429 | 6/23/2022 |
1.1.1 | 167,265 | 4/14/2022 |
1.0.288 | 19,132 | 3/29/2022 |
1.0.288-preview.113 | 216 | 3/25/2022 |
1.0.288-preview.99 | 246 | 3/18/2022 |
1.0.288-preview.97 | 176 | 3/17/2022 |
1.0.288-preview.92 | 259 | 3/14/2022 |
1.0.288-preview.64 | 466 | 2/18/2022 |
1.0.288-preview.20 | 559 | 1/27/2022 |
1.0.259 | 4,878 | 12/9/2021 |
1.0.176 | 3,142 | 9/22/2021 |
1.0.160 | 1,645 | 9/6/2021 |