Research Topics in Machine Hypermedia System Design
Transcript of Research Topics in Machine Hypermedia System Design
ResearchGoals
• Investigatedesignpatternsforinteroperablehypertextdrivenmachineinterfaces
• InvestigateRESTfuldesignpatternsforsensingandactuation
• Whatistheroleofmodelingandontologyinsemanticinteroperability?
ResearchTopics
• ReferenceSystemArchitecture• ContentFormatDesign• RESTfulAsynchronousCommunication• RESTfulActuation• RESTProtocolAbstraction• ModelBasedHypertextAnnotation
ReferenceArchitecture
BaseSchema
ResourceModel
ClientApplication
ThingObjectModel
(DeferredInterface)
DomainSchema
Resources
HypermediaControls
Discovery
DomainModel
HypermediaClient
ResourceApplication
(PhysicalI/O)
NetworksServer
PublicResource
Tools
Client
ContentFormatDesign
• Whatshouldacontent-formatdescribe?• RepresentationFormats• CommonInteractionModel– Resourcemodele.g.CoREInterfaces– Datamodele.g.SenML– Howlinkswork,e.g.CoRELink-Format– Howformswork– Howrelationtypesareused– Somebaserelationtypes
ContentFormatDesign
Protocols
RepresentationFormats
Common InteractionModel
ApplicationMeta-Model
ApplicationDomainModel
HTTP,CoAP,RD,WebLinking
SenML,Link-Format,HTML
Resources,Links,Forms,Collections
LinkRelations,FormRelations
ResourceTypes,Ontology
hsmlcontenttype
describedByrelationtype
ResourceModel
Link ItemLink ItemLinkLink
Link (self)
(sub)
Link
Collection
Link ItemLinkLinkLink
Form
Link ItemSubResourceCollection
Collection
LinkLink
Collection
Link
RepresentationFormatExample{
"bn": "/light/onOff/currentState/","e": [
{"vb": false,"n": ""
}],"l": [
{"href": "","rel": ["self","item"],"rt": ["property", "currentstate"],"ct": ["application/senml+json"]
}]
}
ItemsmayberepresentedinSenML
LinksmayberepresentedinCoRElink-format
Forms
{"anchor": "/light3/brightness/","rel": "invokeAction", "type": "change","method": "post","href": "actuations","accept": "application/hsml+json",
}
To"invokeAction"oftype"change"onthe"/light3/brightness/"resource,performa"post"totheresourceat"/light3/brightness/actuations"usingthe"application/hsml+json"contentformat
LinkandFormRelations
• LinkRelations– "item"(anembeddediteminacollection)– "sub"(asubresourceiteminacollection)– "form"(aformiteminacollection)– "grp"(agroupinteractionlink)
• FormRelations– "addItem"(addanitemtoacollection)
RESTfulAsynchronousCommunication
• RESTinteractionisastatemachinebetweenclientandserver– requestandresponse
• AsynchronousCommunicationusingRESTisoneormorestatetransitionresponsesthattakeplaceafterarequestismade
• Twoclassesofinteraction:– Betweenresourcesandapplications– FromResourcetoResource
ResourcetoApplication
• CoAPObserveisaRESTfulasynchronouscommunicationmethod
• Clientapplicationmakesstatechangesbasedonserverresponses
• Serveristhenameandstateoriginoftheresource
ServerClient
OBSERVE
Responses
ResourcetoApplication
• PUTorPOSTcanbeusedfortheclienttoupdatethestateoftheserver
• Clientapplicationchangesstateonserverasynchronously• Serveristhenameandstateoriginoftheresource
ServerClient
PUT/POST
Responses
ResourcetoResource
• Aclientinstancemaybe"bound"toaresourceandperformstatetransferbetweenitandanotherresource
• Observebindingupdatesthestateofthelocallyboundresourcebasedonresponsesfromthe"boundTo"resource
• ServerBisthenameandstateoriginoftheresource
ServerBOBSBind
Observe
ResponsesServerA
ResourcetoResource
• Pushbindingobservesthestateofthelocallyboundresourceandupdatesthe"boundTo"resource
• Localbindingmayincorporateafilterandmaybeforms-capable
• ServerBisthenameandstateoriginoftheresource
ServerBPushBind
PUT/POST
ResponsesServerA(obs)
NotificationResource• Collectionresourcetocapturenotificationsfromabinding• BindingusesPOSTtocreateanewresourceinthecollectionforeach
notification• ClientApplicationcanobservethecollectionfornewnotificationsbeing
createdandreceiverepresentations• ServerAisthenameandstateorigin
POSTBindServerA
(obs)Notifications Client
OBSERVE
Responses
Promise+• Patternforapplicationscriptstohandlerecurringeventslikenotificationsfromresourceobservations
• ExtendsthePromisepatternwithanupdatehandlerforrecurringevents
res.observe().then(onResolve, onReject, onUpdate)(…do other stuff)
onUpdate(value){processStateUpdate(value)
HTTPObserve• UsingatechniquebasedonHTML5ServerSentEvents(SSE)
• Header"Transfer-Encoding:chunked"enablesopenTCPconnectiontobeusedforasynchronousmessages
• MessagescouldbeformattedasHTTPResponseandheaderlines,withcontent-typeandcontent-lengthcontrols
• Headeroptionse.g.Observe:0couldbeusedtocreateaCoAP-compatibleobserveforHTTP
RESTfulActuation
• WhatisRESTfulactuation?• Changeofstateonaresourcethathassomeeffectinthephysicalworld
• Manydifferentinterpretationsofthis:– Updateofaresourcedirectlychangesphysicalstate– Updateofaresourcecommunicatesintendedstate– Creationofaresourcethatdescribestheintendedstatetransition
– Updateofasetpointresourceofacontroller
UpdateStateResource
• Thereisalwayssomeuncertainty,e.g.thephysicalprocessmayfailorbedelayed
• Willthestatereturnedonasubsequentreadreflecttheintendedstateortheactualstate?
• IntendedstateistechnicallyRESTfulbutnotuseful
• ActualstateisusefulbutnotRESTful• Delayingtheresponseuntilintendedstateisobservedmightwork…
UpdateIntendedStateResource
• ThiswillbebothRESTfulandUseful• AllowsaRESTresponsetobegeneratedfortheintendedstateandapplicationcanthenmonitorobservedstate
• Thiscouldwork,butwhataboutwherewewanttoparameterizeexecutionwithtransitiontimes,etc?Howdoweknowiftheactionisgoingtosucceedorfail?
CreateaStateTransitionResource
• ThisisRESTfulanduseful,usingtheresourcecreatepatternwithaform,andreturningaresourcelocationthatcanbemonitoredforstatechanges
• Allowsasynchronousnotificationandpromisetobeusedtotrackprogress,success,failureofrunningactions,alsotomodifyorcancel
• Multipleactionsmaybequeued
Controllers
• Thermostatisanexampleofacontroller• Temperaturesettingisaset-pointthatisinputtoacontrolleralgorithmthatdecideswhethertooperateanactuatorbasedontherelationshipoftheset-pointtothemeasuredtemperature,andperhapsothervariables
• Thermostathasmeasurementtemperatureandset-pointtemperatureinputs,andanactuatorstateoutput.
RESTProtocolAbstraction
ApplicationLogic
CommonCRUDRequests
MQTT
CommonCRUDResponses
ResourceModel
Resources
ResourceModel
ThingObjectModel
HTTP CoAP
CommonServer
CommonClient
PluggableProtocols
ResourceLogic
WS
DictionaryMappingofCommonRESTTransactionLayer
{"uriPath": ["/","a", "b"], "uriQuery": {"rt": "test", "obs": "true"}"contentFormat": "application/link-format+json","options": {}"method": "GET","payload": null,"response": {
"status": "Success","contentFormat": "application/link-format+json","payload": "[{"href":"","rel":"self","rt":"test"}]"}
}
CommonCRUD
(IP)
Send/Rcv
(PHY)
Send/Rcv
URI Topic,URI
(IP)
Send/Rcv
(PHY)
(IP)
Pub/Sub
(PHY)
(IP)
Trx
(PHY)
URIURI
REST REST REST
CoAP HTTP MQTT WS CCML
URI
RESTREST
• MapabstractiontoHTTPandCoAPrequestandresponses• EncapsulatetheabstractioninWSandMQTTpayloads
ConsistentResourceIdentifiers:Cross-ProtocolHyperlinking
http://example.com:8000/b31/env/light/onoff
coap://example.com:5683/b31/env/light/onoff
ws://example.com:80/b31/env/light/onoff
mqtt://example.com:1883/b31/env/light/onoff
Mapped toURI
Mapped toURI
PartTopic--- PartPayload
EncapsulatedinPayload
ModelBasedHypertextAnnotation
PropertyEvent Action
(Capability)
Subscription
Notification
Actuation
Thing
Index
Capability
Notification
Capability
Index
has
pointsTo
DomainSchemaandModel• ReusabletermswithmayHaveandusedBydefinitions– “brightness”isusedby“light”butnot“motionsensor”– “brightness”mayhave“change”actionbutnot“open”
class: brightness,type: capability,description: “brightness control”usedBy: [ light ],mayHave: [
currentBrightness, targetBrightness,stepBrightness, moveBrightness, change, step, move, stop, propertyValueChange ],
params: {_targetValue: _targetBrightness,_stepSize: _stepBrightness,_moveRate: _moveBrightness},}
DomainModelExample
"@context": "http://thingschema.org","resource": [{
"type": "light","name": "light","capabilities": [
{"type": "brightness","name": "brightness"
},{"type": "onoff","name": "onoff"
}
DemonstratorandReferenceImplementation
• MachineHypermediaToolkitisanopensourcereferenceimplementation
https://github.com/connectIOT/MachineHypermediaToolkit
• DemonstratorresourceonGithubfortutorialintroduction
https://github.com/connectIOT/HypermediaDemo
Resources…• Theseslideshttp://www.slideshare.net/MichaelKoster/research-topics-in-machine-hypermedia• BlogArticlehttp://iot-datamodels.blogspot.com/2015/10/hypermedia-design-for-machine-interfaces.html• DemoResourcehttps://github.com/connectIOT/HypermediaDemo• ReferenceImplementation(workinprogress)https://github.com/connectIOT/MachineHypermediaToolkit• CoREInterfaceshttps://datatracker.ietf.org/doc/draft-ietf-core-interfaces/• Link-Formathttps://tools.ietf.org/html/rfc6690 ,https://tools.ietf.org/html/draft-ietf-core-links-json-04• SenML-01https://datatracker.ietf.org/doc/draft-jennings-core-senml/01/