fossasia / fossasia/pslab-python
External device meta data
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 242
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Devices in `pslab.external`, such as sensors, motors, and displays, should include some kind of meta data so that front ends like pslab-desktop and pslab-cli can use them without large amounts of custom code.
One possible solution is a JSON file for every supported device, with a structure like this:
```json
{
"name": "MLX90614",
"modes":
{
"thermometer":
{
"input":
{
"name": "source",
"type": "selection",
"options": ["object", "ambient"],
},
"output":
{
"name": "temperature",
"type": "float",
"range": [-127, 128],
"unit": "degC",
},
},
},
}
```
This file specifies that the MLX90614 class has:
- A single mode called "thermometer".
- A `set` method which accepts "source" followed by either `"object"` or `"ambient"` as its argument.
- A `get` method which accepts "temperature" and returns a float between -127 degC and 128 degC.
A more complex example:
```json
{
"name": "BMP180",
"modes":
{
"thermometer":
{
"output":
{
"name": "temperature",
"type": "float",
"range": [-127, 128],
"unit": "degC",
},
"default": 1,
},
"pressure meter":
{
"output":
{
"name": "pressure",
"type": "float",
"range": [0, 1e7],
"unit": "Pa",
},
"default": 0,
},
"altitude meter":
{
"input":
{
"name": "baseline",
"type": "float",
"range": [0, 1e7],
"unit": "Pa",
},
"output":
{
"name": "altitude",
"type": "float",
"range": [-1e2, 1e4],
"unit": "m",
},
"default": 0,
},
},
}
```
This file specifies that the BMP180 class has:
- Multiple modes, which can be selected by setting the `BMP180.mode` property, the default being "thermometer".
- No setters in the "thermometer" or "pressure meter" modes.
By reading these files, the front end does not need to know any details about the sensors and requires no custom code. @orangecms what do you think?
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Esamina le classi dei dispositivi in pslab.external e il modo in cui pslab-desktop e pslab-cli interagiscono attualmente con esse. Concorda lo schema dei metadati e la copertura dei dispositivi prima di implementarlo; il lavoro è completato quando i dispositivi supportati espongono metadati sufficienti affinché entrambi i frontend funzionino senza grandi quantità di codice personalizzato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- api, developer-experience
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100