diff --git a/src/controller.jsonnet b/src/controller.jsonnet new file mode 100644 index 0000000..578138d --- /dev/null +++ b/src/controller.jsonnet @@ -0,0 +1,42 @@ +local entity = import '../lib/entity.libsonnet'; + +entity +{ + '$id': 'https://picc.app/schemata/v0.1-dev/controller', + title: 'Controller', + description: 'Describes a relationship between two entities.', + + properties+: { + module: { + type: 'string', + description: 'Module name of the controller.', + }, + arg: { + description: 'Additional arguments. Can be any JSON type.', + }, + entities: { + type: 'array', + description: 'Entities this controller controls.', + items: + $.properties.id, + }, + measures: { + type: 'array', + description: 'List of variables this controller measures.', + items: 'string', + minItems: 1, + uniqueItems: true, + }, + controls: { + type: 'array', + description: 'List of variables this controller controls.', + items: 'string', + minItems: 1, + uniqueItems: true, + } + }, + required+: [ + 'module', + 'entities', + ], +} diff --git a/src/devices/sensor.jsonnet b/src/devices/sensor.jsonnet index 7b6ecbb..5e4c519 100644 --- a/src/devices/sensor.jsonnet +++ b/src/devices/sensor.jsonnet @@ -1,3 +1,4 @@ +local types = import 'types.libsonnet'; local entity = import 'entity.libsonnet'; entity @@ -7,4 +8,13 @@ entity description: ||| A sensor device entity. |||, + + properties+: { + measures: { + type: 'array', + items: types.id, + description: 'List of variables measured by sensor.', + uniqueItems: true, + } + } } diff --git a/src/docs.jsonnet b/src/docs.jsonnet index f9fa1d5..69fd7ee 100644 --- a/src/docs.jsonnet +++ b/src/docs.jsonnet @@ -1,7 +1,7 @@ local loom = import 'lib/loom.libsonnet'; loom.weave(import 'src/entity.jsonnet') + -loom.weave(import 'src/room.jsonnet') + +loom.weave(import 'src/locations/room.jsonnet') + loom.weave(import 'src/relationship.jsonnet') + loom.weave(import 'src/devices/light.jsonnet') + loom.weave(import 'src/devices/sensor.jsonnet') diff --git a/src/locations/building.jsonnet b/src/locations/building.jsonnet index c313703..71afeba 100644 --- a/src/locations/building.jsonnet +++ b/src/locations/building.jsonnet @@ -9,6 +9,7 @@ entity |||, properties+: { + location: types.location, rooms: { type: 'array', description: 'Rooms contained in this building.', @@ -21,17 +22,5 @@ entity ], }, }, - relationships: { - type: 'array', - description: 'Relationships that bind other entities to this room.', - items: { - oneOf: [ - { - '$ref': 'https://picc.app/schemata/v0.1-dev/relationship', - }, - $.properties.id, - ], - }, - }, }, } diff --git a/src/locations/room.jsonnet b/src/locations/room.jsonnet index cd2fa3e..9f24718 100644 --- a/src/locations/room.jsonnet +++ b/src/locations/room.jsonnet @@ -1,4 +1,5 @@ -local entity = import '../lib/entity.libsonnet'; +local entity = import 'entity.libsonnet'; +local types = import 'types.libsonnet'; entity { @@ -9,6 +10,7 @@ entity |||, properties+: { + location: types.location, relationships: { type: 'array', description: 'Relationships that bind other entities to this room.', diff --git a/src/relationship.jsonnet b/src/relationship.jsonnet index 91635aa..6197efc 100644 --- a/src/relationship.jsonnet +++ b/src/relationship.jsonnet @@ -4,26 +4,16 @@ entity { '$id': 'https://picc.app/schemata/v0.1-dev/relationship', title: 'Relationship', - description: 'Describes a relationship between two entities.', + description: 'Describes a relationship between entities. An arity of 1 is used to describe a property of an entity (a relationship of the entity to itself).', properties+: { - module: { - type: 'string', - description: 'Module name of the relationship.', - }, - entities: { - type: 'array', - description: 'Entities invloved in the relationship.', - items: - $.properties.id, - - }, - arg: { - description: 'Additional arguments. Can be any JSON type.', + arity: { + type: 'number', + description: 'The number of entities involved in the relationship.', + minimum: 1, }, }, required+: [ - 'module', - 'entities', + 'description', ], } diff --git a/src/schemata.jsonnet b/src/schemata.jsonnet index 43c4515..e7e4c64 100644 --- a/src/schemata.jsonnet +++ b/src/schemata.jsonnet @@ -1,11 +1,14 @@ local loom = import 'lib/loom.libsonnet'; loom.tangle(import 'src/entity.jsonnet') + +loom.tangle(import 'src/relationship.jsonnet') + +loom.tangle(import 'src/controller.jsonnet') + + +loom.tangle(import 'src/variables/real.jsonnet') + loom.tangle(import 'src/locations/room.jsonnet') + loom.tangle(import 'src/locations/building.jsonnet') + loom.tangle(import 'src/locations/site.jsonnet') + -loom.tangle(import 'src/relationship.jsonnet') + loom.tangle(import 'src/devices/light.jsonnet') + loom.tangle(import 'src/devices/sensor.jsonnet') diff --git a/src/variables/real.jsonnet b/src/variables/real.jsonnet new file mode 100644 index 0000000..fafe758 --- /dev/null +++ b/src/variables/real.jsonnet @@ -0,0 +1,34 @@ +local entity = import '../lib/entity.libsonnet'; + +entity +{ + '$id': 'https://picc.app/schemata/v0.1-dev/variables/real', + title: 'Real', + description: 'Real-valued variable.', + + properties+: { + moreThan: { + type: 'number', + description: 'Open lower bound on value of variable.', + }, + moreThanEq : { + type: 'number', + description: 'Closed lower bound on value of variable.', + }, + lessThan: { + type: 'number', + description: 'Open upper bound on value of variable.', + }, + lessThanEq: { + type: 'number', + description: 'Closed lower bound on the value of variable.', + }, + distribution: { + type: 'string', + description: 'Assumed distribution of variable.', + enum: ['normal', 'uniform', 'exponential', 'gamma'], + }, + }, + required+: [ + ], +}