Presentation is loading. Please wait.

Presentation is loading. Please wait.

Smart Block: A Visual Programming Environment for SmartThings

Similar presentations


Presentation on theme: "Smart Block: A Visual Programming Environment for SmartThings"β€” Presentation transcript:

1 Smart Block: A Visual Programming Environment for SmartThings
Nayeon Bak, Byeong-Mo Chang Dept. of Computer Science Sookmyung Women's University Seoul, Republic of Korea {b_newyork, Kwanghoon Choi Dept. of Electronics and Computer Engineering Chonnam National University Gwangju, Republic of Korea

2 01 Introduction 02 Visual block language Smart Block 03 Visual programming environment for Smart Block 04 Implementation 05 Conclusion and Future works 06 QnA

3 Introduction

4 Fig. Structure of SmartThings
SmartThings is one of the most widely-used open developer platforms for IoT with a high number of applications among currently available platforms [1](π‘†π‘šπ‘Žπ‘Ÿπ‘‘π‘‡β„Žπ‘–π‘›π‘”π‘  π·π‘’π‘£π‘’π‘™π‘œπ‘π‘’π‘Ÿ π·π‘œπ‘π‘’π‘šπ‘’π‘›π‘‘π‘Žπ‘‘π‘–π‘œπ‘› π»π‘œπ‘šπ‘’π‘π‘Žπ‘”π‘’, ) It also supports a wide range of smart devices which work through a central hub SmartApp is an application that provides automatic service by using smart devices SmartThings App is a mobile application managing SmartApps and smart devices Smart devices include lights, cameras, locks, thermostats, and various sensors. Fig. Structure of SmartThings

5 SmartApp SmartApp is a small Groovy-based program that allows users to automate their homes using smart devices A user installs SmartApp on their SmartThings mobile application, and configures it with smart devices SmartApp is executed in the SmartThings cloud It is executed in response to various schedules or events from smart devices SmartThings IDE(Integrated Developer Environment) Developers can build and install new SmartApps in the SmartThings IDE SmartThings IDE provides a set of tools to manage their SmartThings account, builds and installs SmartApps 말둜 preferenceμ—μ„œλŠ” 이 μ•±μ—μ„œ μ‚¬μš©ν•  devic듀을 μ •μ˜ν•˜λŠ” 것이고 predefined and callbackμ—μ„œλŠ” μ–΄λ–€ device의 μ΄λ²€νŠΈκ°€ μΌμ–΄λ‚¬μ„λ•Œ μ–΄λŠ ν•Έλ“€λŸ¬κ°€ μ²˜λ¦¬ν• μ§€ μ •μ˜ν•˜κ³  eventhandler에선 μ΄λ²€νŠΈκ°€ λ°œμƒν• λ•Œ μ–΄λ–€ 일을 ν•˜λŠ”μ§€ μž‘μ„±ν•˜λŠ” 뢀뢄이닀.

6 SmartApp Example When the lock gets unlocked, if a user is present at home, then turn the light on and play music Definition Preferences Predefined Callbacks Event Handlers 말둜 preferenceμ—μ„œλŠ” 이 μ•±μ—μ„œ μ‚¬μš©ν•  devic듀을 μ •μ˜ν•˜λŠ” 것이고 predefined and callbackμ—μ„œλŠ” μ–΄λ–€ device의 μ΄λ²€νŠΈκ°€ μΌμ–΄λ‚¬μ„λ•Œ μ–΄λŠ ν•Έλ“€λŸ¬κ°€ μ²˜λ¦¬ν• μ§€ μ •μ˜ν•˜κ³  eventhandler에선 μ΄λ²€νŠΈκ°€ λ°œμƒν• λ•Œ μ–΄λ–€ 일을 ν•˜λŠ”μ§€ μž‘μ„±ν•˜λŠ” 뢀뢄이닀.

7 Motivation Users can have difficulty in writing SmartApp in Groovy
A visual block language can help users make programs easily by assembling building blocks graphically rather than by specifying them textually We propose a visual block language called Smart Block for IoT, especially for SmartThings Users can develop SmartApp easily in Smart Block, even though they are not expert programmers

8 Smart Block We deigned and implemented a visual block language Smart Block Also we develop a visual programming environment and compiler for Smart Block. Users can build SmartApps by dragging and dropping blocks in this environment easily Implementation A visual programming environment for Smart Block is implemented with Blockly is a client-side JavaScript library which can be used for creating visual block languages and programing environment [2](π΅π‘™π‘œπ‘π‘˜π‘™π‘¦: 𝐴 π‘™π‘–π‘π‘Ÿπ‘Žπ‘Ÿπ‘¦ π‘“π‘œπ‘Ÿ 𝑏𝑒𝑖𝑙𝑑𝑖𝑛𝑔 π‘£π‘–π‘ π‘’π‘Žπ‘™ π‘π‘Ÿπ‘œπ‘”π‘Ÿπ‘Žπ‘šπ‘šπ‘–π‘›π‘” π‘’π‘‘π‘–π‘‘π‘œπ‘Ÿπ‘ , )

9 Visual block language Smart Block

10 SmartApp with Smart Block
when the lock gets unlocked from locked, if a user is present, then turn the light on and play music 핡심 아이디어 λ§ν•˜λŠ” κ³³ Smart Block

11 Key Idea SmartApp Event when the lock gets unlocked from locked,
Condition Action when the lock gets unlocked from locked, if a user is present, then turn the light on and play music Smart Block based on IoTA calculus Event Condition Action

12 IoTA calculus Smart Block is designed based on IoTA calculus
IoTA calculus is a core calculus for Internet of Things Automation that generalizes Event-Condition- Action (ECA) rules for home automation [3](π‘π‘’π‘€π‘π‘œπ‘šπ‘, 𝑒𝑑 π‘Žπ‘™., ) SmartApp can be represented by ECA rules with Smart Block ECA rule can specify which action is triggered by event, if the given condition is satisfied Example Event Condition Action when the lock gets unlocked from locked, if a user is present, then turn the light on and play music.

13 Demo We show how to build a sample SmartApp with Smart Block

14 ECA block, EA block ECA block ECA block represents one rule
It should be connected with Event block, Condition block and Action block EA block EA block is an ECA block whose condition is always true

15 Event block Stands for the event from a device Example
1. This Event block means an event of unlocked from locked on the lock1 device 2. This Event block means timer at 8:00 AM

16 Condition block Checks whether the value of a boolean algebra over a state on devices is true or not If the result is true, the action will be performed Example 1. This Condition block checks whether the value of presenceSensor named presence1 is present 2. This Condition block checks whether the temperature rises above 22 degrees

17 Action block Stands for the action
Action blocks can be linked together in a line as below, which will be performed in sequence Example 1. This Action blocks means turning on a light1 device and playing music on music player1 2. This Action block mean to send a push message which is β€œThe unexpected guest!”

18 All building Blocks in Smart Block
ECA blocks ECA block EA block Event blocks 44 Event Device blocks Event Location block 3 Event Schedule blocks Grouping Event block Condition blocks 44 Condition Device blocks 7 Boolean algebra blocks 2 Grouping Condition blocks Action blocks 28 Action Device blocks 3 Action SMS blocks 8 Action Timer blocks Grouping Action block

19 Visual programming environment for Smart Block

20 Visual programming environment for Smart Block
Users can create SmartApps in this environment by dragging blocks from the toolbox and dropping blocks in the workspace Users can choose smart devices at the smart device table Smart devices are classified as the alphabetical order Users can collect smart devices which are used often in β€˜THINGS’ category Also, SmartApp is compiled in this environment Smart device table Workspace Toolbox smart device와 work space

21 Demo We show how to build the SmartApp consisting of two ECA rules with Smart Block when the locked door gets unlocked if the user is present at home then turn on the light and play music Frist ECA Rule when the locked door gets unlocked if the user is not present at home then ring alarm and send the push message Second ECA Rule Is get?

22 Demo smart device와 work space

23 Compiling Process Overview of Compiling process
SmartApp Code is generated from the completed blocks We take a two-pass approach AST Constructor : Constructing AST from the completed blocks Code Generator : Generating SmartApp Code from the AST

24 Generated SmartApp Code

25 Implementation

26 Implementing Process of Smart Block
Compiler is implemented based on Generator stub produced by Blockly Developer Tools AST Constructor Code Generator Visual programming environment is designed and implemented with custom blocks and on top of HTML, JavaScript, and CSS and by using Blockly Developer Tools Definition code Toolbox workspace Custom blocks for Smart Block are designed and implemented by using Blockly Developer Tools Definition code Visual programming environment is built on top of HTML, JavaScript, and CSS Definition code for Custom block Toolbox XML code Workspace JavaScript code Compiler is implemented based on the default Code Generator from the open source of Blockly AST constructor New code generator

27 Blockly Developer Tools
Blockly Developer Tools gives the definition codes for the custom blocks and the toolbox that contains them, as well as the workspace

28 Custom Block The definition code of ECA block are produced by building an internal organization of ECA block in Blockly Developer Tools Fig. ECA block Fig. definition code of ECA block Fig. internal organization of ECA block

29 Visual Programming Environment
Visual programming environment is built on top of HTML, JavaScript, and CSS Also, it is implemented with custom blocks, toolbox and workspace Blockly Developer Tools provides the XML code for toolbox and the JavaScript for workspace

30 Complier : AST Constructor
We develop AST constructor by extending the default Code Generator AST constructor generates the AST of each ECA block by parsing The AST of ECA block is made up of nodes for Event, Condition and Action ASTs μ•„λ‹ˆλΌ λ…Έλ“œμ•„λ‹˜?

31 AST of ECA blocks Workspace is the root node of the AST for ECA blocks for SmartApp AST of ECA block is a child node of workspace node The AST constructor returns the AST of the ECA blocks

32 Complier : Code Generator
We develop a new Code Generator New Code Generator generates the actual SmartApp code by traversing the AST of the ECA blocks μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ?

33 Conclusion and Future works

34 Conclusion and Future works
We designed a visual block language Smart Block We developed a visual programming environment and the compiler for Smart Block So, Users can build SmartApps by dragging and dropping blocks in this environment We are going to extend Smart Block by implementing new features library for data structure security We will extend Smart Block to support not only SmartThings but also other IoT platforms

35

36

37 All building Blocks in Smart Block
Event Block Condition Block Action Block μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ?

38 Detail of AST Rule Event Condition Action name of device value
Action list μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ? Event name of device value capability of device attribute detail of event from to Condition the right value the left value operator result Action name of device value capability of device command method args

39 Smart Block Turn your lights on when motion is detected μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ?

40 Smart Block turn heater on when the temperature drops below 8 degrees and turn fan on when the temperature rises above 22 degrees. μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ?

41 Expressiveness of Smart Block
Referenced by Iota: A Calculus for Internet of Things Automation We surveyed home automation applications coded in general-purpose languages from app stores, user forms, and Github, and found that most are expressible in an ECA rule system We found that programs from existing ECA languages were easily translated to IoTA, and larger programs from general purpose languages translated to much smaller IoTA programs μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ?

42 SmartThings SmartThings has the largest number of apps among currently available smart home platforms It supports a broad range of devices including motion sensors, fire alarms, and door locks And with SmartThings, we could focus on study about the software for IoT μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ?

43 Library for data structure
SmartApps can store small amounts of data using a map-like API, and retrieve this data in later executions We will implement the custom block for data which will affect the next execution μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ?

44 Security By following the guidelines of SmartThings, Smart Block will generate SmartApp code Such as Subscriptions should be clear Do not hard-code SMS messages Code should be readable Don’t repeat yourself Methods should serve a single purpose Do not submit unused code Do not use offensive, profane, or libelous language …. μ—λ‹ˆλ©”μ΄μ…˜ λ„£μ„κΉŒ? Fig. Code Review Guidelines and Best Practices


Download ppt "Smart Block: A Visual Programming Environment for SmartThings"

Similar presentations


Ads by Google