Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ThingModel] Example of Eclipse Vorto model #1000

Closed
kolotu opened this issue Nov 11, 2020 · 6 comments
Closed

[ThingModel] Example of Eclipse Vorto model #1000

kolotu opened this issue Nov 11, 2020 · 6 comments
Labels
Propose closing Problem will be closed shortly if there is no veto. Thing Model Topic related to Thing Models

Comments

@kolotu
Copy link
Member

kolotu commented Nov 11, 2020

Here is an example of an Eclipse Vorto model that is being used in a real-life application. The device / digital twin that is modelled represents a washer. The model consists of an InformationModel that describes the specific type of the Washer (Bosch WAT286H8SG).

vortolang 1.0

namespace com.bshg
version 2.0.0
displayname "WasherWAT286H8SG"
description "Information model for BSH Washer WAT286H8SG"
category smarthome
using com.bshg.programs.Washer ; 2.0.0
using com.bshg.common.RemoteControlActivationState ; 2.0.0
using com.bshg.common.RemoteStartAllowanceState ; 2.0.0
using com.bshg.common.LocalControlState ; 2.0.0
using com.bshg.common.OperationState ; 2.0.0
using com.bshg.common.DoorState ; 2.0.0
using com.bshg.common.PowerState ; 2.0.0

infomodel WasherWAT286H8SG {

	functionblocks {
		washer as Washer
		remoteControlActivationState as RemoteControlActivationState
		remoteStartAllowanceState as RemoteStartAllowanceState
		localControlState as LocalControlState
		operationState as OperationState
		doorState as DoorState
		powerState as PowerState
	}
}

This InformationModel contains the FunctionBlocks that describe the capabilities of this specific washer. One of those FunctionBlocks is a generic Washer FunctionBlock that describes capabilities of washers in general.

vortolang 1.0

namespace com.bshg.programs
version 2.0.0
displayname "Washer"
description "Function block model for Washer functionality of Home Appliances"
category smarthome
using com.bshg.types.programs.washer.options.Program ; 2.0.0
using com.bshg.types.programs.washer.options.Temperature ; 2.0.0
using com.bshg.types.programs.washer.options.SpinSpeed ; 2.0.0
using com.bshg.types.common.EventPresentState ; 2.0.0

functionblock Washer {
	status {
		mandatory program as Program
		mandatory temperature as Temperature
		mandatory spinSpeed as SpinSpeed
		optional delayedStart as int <MIN 0 , MAX 86340>
		"If this option is set, the program will be activated but not started until the defined time span elapses."

		optional delayedStartUnit as string
	}

	events {
		SelectedProgramChanges {
			mandatory timestamp as long
			mandatory value as Program
			mandatory level as string
			mandatory handling as string
		}

		ActiveProgramChanged {
			mandatory timestamp as long
			mandatory value as Program
			mandatory level as string
			mandatory handling as string
		}

		TemperatureChanged {
			mandatory timestamp as long
			mandatory value as Temperature
			mandatory level as string
			mandatory handling as string
		}

		SpinSpeedChanged {
			mandatory timestamp as long
			mandatory value as SpinSpeed
			mandatory level as string
			mandatory handling as string
		}

		RemainingProgramTimeChanged {
			mandatory timestamp as long
			mandatory value as int <MIN 0 , MAX 86340>
			mandatory level as string
			mandatory handling as string
			mandatory unit as string
		}

		ProgramProgress {
			mandatory timestamp as long
			mandatory value as int <MIN 0 , MAX 100>
			mandatory level as string
			mandatory handling as string
			mandatory unit as string
		}

		ProgramFinished {
			mandatory timestamp as long
			mandatory value as EventPresentState
			mandatory level as string
			mandatory handling as string
		}

	}

	operations {
		startWashing(program as Program,
			temperature as Temperature,
			spinSpeed as SpinSpeed)
	}

}

In general, InformationModels describe specific types of devices / digital twins, while FunctionBlocks are reusable descriptions of capabilities. FunctionBlocks can be used by multiple InformationModels and FunctionBlocks can be extended by other FunctionBlocks to create greater specificity. A FunctionBlock can only extend one other FunctionBlock (no multi-inheritance). When a new FunctionBlock is created that extends an existing FunctionBlock it is not allowed to override any existing property, so naming conflicts cannot occur.

The inheritance feature of Vortolang is very rarely used - and if so mostly for trivial use-cases, that's why the Vorto specification does not cover every edge-case that can occur when using inheritance.

@sebastiankb sebastiankb added the Thing Model Topic related to Thing Models label Nov 11, 2020
@kolotu
Copy link
Member Author

kolotu commented Nov 11, 2020

@kolotu map this model to ThingDescription

@kolotu
Copy link
Member Author

kolotu commented Nov 18, 2020

This is the output of the tentative Vortolang -> WoT TM converter. Not all features are implemented yet, this is just to outline, how it will work. I used the Functionblock of the generic Washer for this example: https://vorto.eclipse.org/#/details/com.bshg.programs:Washer:2.0.0

{
  "@context": ["https://www.w3.org/2019/wot/td/v1"],
  "@type" : "ThingModel",
  "title": "com.bshg.programs.Washer:2.0.0",
  "description" : "Function block model for Washer functionality of Home Appliances",
  "properties": {
    "program": {
      "type": "com.bshg.types.programs.washer.options.Program:2.0.0",
      "readOnly": true
    },
    "temperature": {
      "type": "com.bshg.types.programs.washer.options.Temperature:2.0.0",
      "readOnly": true
    },
    "spinSpeed": {
      "type": "com.bshg.types.programs.washer.options.SpinSpeed:2.0.0",
      "readOnly": true
    },
    "delayedStart": {
      "type": "int",
      "readOnly": true
    },
    "delayedStartUnit": {
      "type": "string",
      "readOnly": true
    }
  },
  "events": {
    "SelectedProgramChanges": {
      "data": {"type": "string"}
    },
    "ActiveProgramChanged": {
      "data": {"type": "string"}
    },
    "TemperatureChanged": {
      "data": {"type": "string"}
    },
    "SpinSpeedChanged": {
      "data": {"type": "string"}
    },
    "RemainingProgramTimeChanged": {
      "data": {"type": "string"}
    },
    "ProgramProgress": {
      "data": {"type": "string"}
    },
    "ProgramFinished": {
      "data": {"type": "string"}
    }
  },
  "actions": {
    "startWashing": {
    }
  }
}

@sebastiankb
Copy link
Contributor

type should rely on JSON Schema types like string, integer, object, etc. Thus I would suggest to introduce a context that allows to point to specific data types that relates to Vorto types. In addition, I would use the id term to provide the identifier of the model.

{
  "@context": ["https://www.w3.org/2019/wot/td/v1",
  {"vorto":"https://bshg.com/vorto#"}
   ],
  "@type" : "ThingModel",
  "title": "Washer 2.0",
  "id" : "com.bshg.programs.Washer:2.0.0",
  "description" : "Function block model for Washer functionality of Home Appliances",
  "properties": {
    "program": {
     "type" : "string",
      "vorto:type" : "com.bshg.types.programs.washer.options.Program:2.0.0",
      "readOnly": true
    },
    "temperature": {
      "type": "string",
      "vor:type" : "com.bshg.types.programs.washer.options.Temperature:2.0.0",
      "readOnly": true
    },
    "spinSpeed": {
      "type": "string",
      "vorto:type": "com.bshg.types.programs.washer.options.SpinSpeed:2.0.0",
      "readOnly": true
    },
    "delayedStart": {
      "type": "int",
      "readOnly": true
    },
    "delayedStartUnit": {
      "type": "string",
      "readOnly": true
    }
  },
  "events": {
    "SelectedProgramChanges": {
      "data": {"type": "string"}
    },
    "ActiveProgramChanged": {
      "data": {"type": "string"}
    },
    "TemperatureChanged": {
      "data": {"type": "string"}
    },
    "SpinSpeedChanged": {
      "data": {"type": "string"}
    },
    "RemainingProgramTimeChanged": {
      "data": {"type": "string"}
    },
    "ProgramProgress": {
      "data": {"type": "string"}
    },
    "ProgramFinished": {
      "data": {"type": "string"}
    }
  },
  "actions": {
    "startWashing": {
    }
  }
}

@egekorkan
Copy link
Contributor

However, from what I have understood, the types are not necessarily just string but are more complex, thus they need to be modelled in JSON Schema in order to represent them for other TD Consumers.

@sebastiankb
Copy link
Contributor

sebastiankb commented Nov 19, 2020

In that case the properties are string values with a sections as enum as shown here

https://vorto.eclipse.org/#/details/com.bshg.types.programs.washer.options:Program:2.0.0

Providing JSON Schema would be alternative.

@egekorkan
Copy link
Contributor

This was just an input right? Not really an issue. I would propose closing it

@egekorkan egekorkan added the Propose closing Problem will be closed shortly if there is no veto. label Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Propose closing Problem will be closed shortly if there is no veto. Thing Model Topic related to Thing Models
Projects
None yet
Development

No branches or pull requests

3 participants