mirror of
https://gitlab.com/fabinfra/fabaccess/fabaccess-api.git
synced 2025-03-12 14:51:42 +01:00
Add traits
This commit is contained in:
parent
ef3db21789
commit
d7c26ed4c1
12
claim.capnp
12
claim.capnp
@ -52,12 +52,20 @@ interface Claim extends (Notifiable) {
|
|||||||
|
|
||||||
traits @1 () -> Map(OID, AnyPointer);
|
traits @1 () -> Map(OID, AnyPointer);
|
||||||
|
|
||||||
disown @2 () -> Fallible(Void, Error(Void));
|
disown @2 () -> Fallible(Void, Error(DisownError));
|
||||||
# Disown this claim TODO define ConstraintViolation type -> Dependencies!
|
# Disown this claim TODO define ConstraintViolation type -> Dependencies!
|
||||||
|
|
||||||
makeTransferable @3 () -> Fallible(SturdyRef, Error(Void));
|
makeTransferable @3 () -> Fallible(SturdyRef, Error(Void));
|
||||||
makeLendable @4 () -> Fallible(( token :Sturdyref, returnToken :Interest ), Error(Void));
|
makeLendable @4 () -> Fallible(( token :Sturdyref, returnToken :Interest ), Error(Void));
|
||||||
# TODO: should returnToken be an Interest instead?
|
|
||||||
|
getDependencies @5 () -> ( dependencies: List(Claim) );
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DisownError {
|
||||||
|
union {
|
||||||
|
dependency @0 :List(Claim);
|
||||||
|
badState @1 :Void;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Lock extends (Claim) {
|
interface Lock extends (Claim) {
|
||||||
|
82
traits.capnp
82
traits.capnp
@ -3,81 +3,13 @@
|
|||||||
using CSharp = import "programming_language/csharp.capnp";
|
using CSharp = import "programming_language/csharp.capnp";
|
||||||
$CSharp.namespace("FabAccessAPI.Schema");
|
$CSharp.namespace("FabAccessAPI.Schema");
|
||||||
|
|
||||||
using import "utils.capnp".OID;
|
interface TraitSuper {
|
||||||
using import "utils.capnp".Map;
|
getName @0 () -> ( name :Text );
|
||||||
using import "utils.capnp".Fallible;
|
|
||||||
|
|
||||||
using ID = Data;
|
|
||||||
|
|
||||||
struct StateError
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MeasureError
|
struct TraitError(ConstraintError) {
|
||||||
{
|
union {
|
||||||
|
permissionFailed @0 :Void;
|
||||||
|
constraintViolation @1 ( error :ConstraintError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Action
|
|
||||||
{
|
|
||||||
do @0 ( Map(ID, Data) ) -> Fallible( ID, StateError );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
interface Measure
|
|
||||||
{
|
|
||||||
get @0 ( List(ID) ) -> Fallible( Map(ID, Data), MeasureError );
|
|
||||||
set @1 ( Map(ID, Data) ) -> Fallible( Map(ID, Data), MeasureError );
|
|
||||||
}
|
|
||||||
|
|
||||||
struct FSM
|
|
||||||
{
|
|
||||||
oid @0 :OID;
|
|
||||||
name @1 :Text;
|
|
||||||
description @2 :Text;
|
|
||||||
states @3 :List(State);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct State
|
|
||||||
{
|
|
||||||
id @0 :ID;
|
|
||||||
name @1 :Text;
|
|
||||||
description @2 :Text;
|
|
||||||
traits @3 :List(Trait);
|
|
||||||
measurements @4 :List(Measurement);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Trait
|
|
||||||
{
|
|
||||||
id @0 :ID;
|
|
||||||
name @1 :Text;
|
|
||||||
description @2 :Text;
|
|
||||||
currentstate @3 :ID;
|
|
||||||
nextstate @4 :ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Parameter
|
|
||||||
{
|
|
||||||
id @0 :ID;
|
|
||||||
name @1 :Text;
|
|
||||||
description @2 :Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Measurement
|
|
||||||
{
|
|
||||||
id @0 :ID;
|
|
||||||
name @1 :Text;
|
|
||||||
description @2 :Text;
|
|
||||||
state @3 :ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Power
|
|
||||||
const power_s_off : State ( id = 0x"000", name = "off", description = "power is off", );
|
|
||||||
|
|
||||||
const power_m_consumption : Measurement ( id = 0x"000", name = "Power Consumption", description = "TODO", state = 0x"001" );
|
|
||||||
|
|
||||||
const power_t_turnon : Trait ( id = 0x"000", name = "turnon", description = "Turn Power to on", currentstate = 0x"000", nextstate = 0x"001" );
|
|
||||||
const power_t_turnoff : Trait ( id = 0x"001", name = "turnoff", description = "Turn Power to off", currentstate = 0x"001", nextstate = 0x"000" );
|
|
||||||
|
|
||||||
const power_fsm :FSM = ( oid = 0x"TODO", name = "power1", description = "TODO" );
|
|
||||||
|
33
traits/checkable.capnp
Normal file
33
traits/checkable.capnp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
@0x80d4a09e28022edb;
|
||||||
|
|
||||||
|
using import "traits.capnp".TraitSuper;
|
||||||
|
using import "utils.capnp".Fallible;
|
||||||
|
using import "traits_error.capnp".TraitError;
|
||||||
|
|
||||||
|
# OID for this trait: 1.3.6.1.4.1.61783.612.1.3
|
||||||
|
# │ │ │ │
|
||||||
|
# RLKM UG PEN ╯ │ │ │
|
||||||
|
# │ │ │
|
||||||
|
# FabAccess subtree ╯ │ │
|
||||||
|
# │ │
|
||||||
|
# Traits ╯ │
|
||||||
|
# │
|
||||||
|
# Checkable ╯
|
||||||
|
|
||||||
|
interface TraitCheckable extends (TraitSuper) {
|
||||||
|
getState @0 () -> StateCheckable;
|
||||||
|
turnOn @1 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
|
||||||
|
turnOff @2 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
|
||||||
|
giveBack @3 () -> Fallible(TraitCheckable, TraitError(StateCheckable));;
|
||||||
|
accept @4 () -> Fallible(TraitCheckable, TraitError(StateCheckable));
|
||||||
|
reject @5 ( reason :Text, reason_lang :Text ) -> Fallible(TraitCheckable, TraitError(StateCheckable));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StateCheckable {
|
||||||
|
union {
|
||||||
|
off @0 :Void;
|
||||||
|
on @1 :Void;
|
||||||
|
check @2 :Void;
|
||||||
|
rejected @3 :L10NString;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
4.4.4.4
|
|
||||||
|
|
||||||
interface CncTrait {
|
|
||||||
turnOn @0 () -> Fallible;
|
|
||||||
turnOff @1 () -> Fallible;
|
|
||||||
giveBack @2 () -> Fallible;
|
|
||||||
accept @3 () -> Fallible(ConstraintError);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ConstraintError {
|
|
||||||
|
|
||||||
}
|
|
31
traits/door.capnp
Normal file
31
traits/door.capnp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@0xccad643c8c6f6b25;
|
||||||
|
|
||||||
|
using import "traits.capnp".TraitSuper;
|
||||||
|
using import "utils.capnp".Fallible;
|
||||||
|
using import "utils.capnp".Duration;
|
||||||
|
using import "traits_error.capnp".TraitError;
|
||||||
|
|
||||||
|
# OID for this trait: 1.3.6.1.4.1.61783.612.1.2
|
||||||
|
# │ │ │ │
|
||||||
|
# RLKM UG PEN ╯ │ │ │
|
||||||
|
# │ │ │
|
||||||
|
# FabAccess subtree ╯ │ │
|
||||||
|
# │ │
|
||||||
|
# Traits ╯ │
|
||||||
|
# │
|
||||||
|
# Doorable ╯
|
||||||
|
|
||||||
|
interface TraitDoorable extends (TraitSuper) {
|
||||||
|
getState @0 () -> StateDoorable;
|
||||||
|
unlock @1 () -> Fallible(TraitDoorable, TraitError(StateDoorable));
|
||||||
|
unlockTemp @2 ( time :Duration ) -> Fallible(TraitDoorable, TraitError(StateDoorable));
|
||||||
|
lock @3 () -> Fallible(TraitDoorable, TraitError(StateDoorable));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StateDoorable {
|
||||||
|
union {
|
||||||
|
Closed @0 :Void;
|
||||||
|
Open @1 :Void;
|
||||||
|
TempOpen @2 :Void;
|
||||||
|
}
|
||||||
|
}
|
30
traits/locateable.capnp
Normal file
30
traits/locateable.capnp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
@0x9fa2b43397f34e02;
|
||||||
|
|
||||||
|
using import "traits.capnp".TraitSuper;
|
||||||
|
using import "utils.capnp".Fallible;
|
||||||
|
using import "utils.capnp".Duration;
|
||||||
|
using import "traits_error.capnp".TraitError;
|
||||||
|
|
||||||
|
# OID for this trait: 1.3.6.1.4.1.61783.612.1.5
|
||||||
|
# │ │ │ │
|
||||||
|
# RLKM UG PEN ╯ │ │ │
|
||||||
|
# │ │ │
|
||||||
|
# FabAccess subtree ╯ │ │
|
||||||
|
# │ │
|
||||||
|
# Traits ╯ │
|
||||||
|
# │
|
||||||
|
# Locateable ╯
|
||||||
|
|
||||||
|
interface TraitLocateable extends (TraitSuper) {
|
||||||
|
getState @0 () -> ();
|
||||||
|
identify @1 ( time :Duration ) -> Fallible(TraitLocateable, TraitError(Void));
|
||||||
|
setActive @2 () -> Fallible(TraitLocateable, TraitError(Void));
|
||||||
|
setIdle @2 () -> Fallible(TraitLocateable, TraitError(Void));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StateLocateable {
|
||||||
|
union {
|
||||||
|
idle @0 :Void;
|
||||||
|
active @1 :Void;
|
||||||
|
}
|
||||||
|
}
|
41
traits/lockers.capnp
Normal file
41
traits/lockers.capnp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
@0x82abdb5c1dcf399d;
|
||||||
|
|
||||||
|
using import "traits.capnp".TraitSuper;
|
||||||
|
using import "utils.capnp".Fallible;
|
||||||
|
using import "traits_error.capnp".TraitError;
|
||||||
|
|
||||||
|
# OID for this trait: 1.3.6.1.4.1.61783.612.1.4
|
||||||
|
# │ │ │ │
|
||||||
|
# RLKM UG PEN ╯ │ │ │
|
||||||
|
# │ │ │
|
||||||
|
# FabAccess subtree ╯ │ │
|
||||||
|
# │ │
|
||||||
|
# Traits ╯ │
|
||||||
|
# │
|
||||||
|
# Lockers ╯
|
||||||
|
|
||||||
|
interface TraitLocker extends (TraitSuper) {
|
||||||
|
getState @0 () -> StateLocker;
|
||||||
|
engage @1 () -> Fallible(TraitLocker, TraitError(ErrorLocker))
|
||||||
|
unengage @2 () -> Fallible(TraitLocker, TraitError(ErrorLocker));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StateLocker {
|
||||||
|
union {
|
||||||
|
locked @0 :Void;
|
||||||
|
unlocked @1 :Void;
|
||||||
|
open @2 :Void;
|
||||||
|
unenganged @3 :Void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ErrorLocker {
|
||||||
|
union {
|
||||||
|
isLocked @0 :Void;
|
||||||
|
isUnlocked @1 :Void;
|
||||||
|
isOpen @2 :Void;
|
||||||
|
incomplete @3 :AnyPointer;
|
||||||
|
# Object is incomplete in some way.
|
||||||
|
# TODO: Define this interface
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,23 @@
|
|||||||
|
@0xbab3de8275be2271;
|
||||||
|
|
||||||
struct BadState { }
|
using import "traits.capnp".TraitSuper;
|
||||||
|
using import "utils.capnp".Fallible;
|
||||||
|
using import "traits_error.capnp".TraitError;
|
||||||
|
|
||||||
interface TraitPowerable {
|
# OID for this trait: 1.3.6.1.4.1.61783.612.1.1
|
||||||
turnOn @0 () -> Fallible(StatePowerable, Error(BadState));
|
# │ │ │ │
|
||||||
turnOff @1 () -> Fallible(StatePowerable, Error(BadState));
|
# RLKM UG PEN ╯ │ │ │
|
||||||
|
# │ │ │
|
||||||
|
# FabAccess subtree ╯ │ │
|
||||||
|
# │ │
|
||||||
|
# Traits ╯ │
|
||||||
|
# │
|
||||||
|
# Powerable ╯
|
||||||
|
|
||||||
|
interface TraitPowerable extends (TraitSuper) {
|
||||||
|
getState @0 () -> StatePowerable;
|
||||||
|
turnOn @1 () -> Fallible(TraitPowerable, TraitError(StatePowerable));
|
||||||
|
turnOff @2 () -> Fallible(TraitPowerable, TraitError(StatePowerable));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StatePowerable {
|
struct StatePowerable {
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
1.1.1.1
|
|
||||||
|
|
||||||
interface RgbLamp {
|
|
||||||
setRgb @0 ( r :u8, g :u8, b :u8 );
|
|
||||||
setHsv @1 ( h :u8, s :u8, v :u8 );
|
|
||||||
}
|
|
||||||
|
|
||||||
struct RgbLampState {
|
|
||||||
rgb @0 ( r :u8, g :u8, b :u8 );
|
|
||||||
hsv @1 ( h :u8, s :u8, v :u8 );
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
struct Error(ConstraintError) {
|
|
||||||
union {
|
|
||||||
permissionFailed @0 :Void;
|
|
||||||
constraintViolation @1 ( error :ConstraintError);
|
|
||||||
}
|
|
||||||
}
|
|
@ -81,6 +81,12 @@ struct Fallible(Ok, Error) {
|
|||||||
err :group {
|
err :group {
|
||||||
error @1 :Error;
|
error @1 :Error;
|
||||||
description @2 :L10NString;
|
description @2 :L10NString;
|
||||||
|
# May be NULL if `Error` is :Void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Duration {
|
||||||
|
seconds @0 :UInt64;
|
||||||
|
nanoseconds @1 :UInt64;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user