This blog is part of a series which is related to setting up Smart Data Streaming, IoT Services & Predictive Services.
In the previous blog post, I described the initial steps required to setup Smart Data Streaming (SDS) on HANA Cloud Platform. In this blog, I will focus on creating a SDS project.The objective of this blog series is to show how one could use SDS to capture and filter sensor messages from an IoT device and later apply predictive analytics to gain some insights.
Create a SDS Project in HANA Studio:
I have created a target HANA table (named DEVICE_DATA) where I am going to store all the incoming sensor messages (after analyzing them).
To create a SDS project, launch the HANA Studio (which has got all the SDS plug-ins) installed as prerequisite. There will be two perspectives available when working with SDS.
Click on the perspective “SAP HANA Streaming Run-Test” and add a new server connection.
- Host name: <dbname>wsp<HCP account name><HCP landscape>
- Port: 443
- Protocol: Web Services
- SSL: True
Connect to the server with SDSUSER
You can change the default Server URL to the one you have created by navigating to Preferences > SAP HANA Streaming Data and set the “Default Server URL” to one you specified earlier.
Switch to the HANA Streaming Development perspective and create a new Streaming project. Under Data Services tab, select your server and click on “Load Services”
Add HANA Services by selecting the option from the context menu.
Provide the connection details of the user which will be used in all the projects to communicate with SDS service. We had earlier seen how to create HANAUSER1. Once the connection is saved, and if you try to click on Discover option, it will list all the schemas and tables available in the HANA database.
From the File menu,create a new SDS project. It will come with an input stream called “NEWSTREAM” in the canvas. Click on the “Add Coliumns” icon as shown below to add more columns.
I have added few integer columns and one date time column to capture the event time
Rename the stream to something more meaningful
From the Palette, look for the Filter under “Streams and Windows” and drag it to the canvas.
Rename the filter to “Apply_Filter” and then select “Connector” from the palette. Connect Device_Stream input stream to the output stream “Apply_Filter”
Click on the Filter “1” and edit it with a condition. DEVICE_STREAM.TEMP > 20 AND DEVICE_STREAM.LIGHT > 40
This means we are only interested in sensor records which have Temperature > 20 and Light sensitivity > 40. We will only be persisting these records for further analysis.
Click on the HANA Output Adapter and drag it to the canvas. Click on “Edit Properties”.
In the adapter properties, select the data service, schema and table required.Since the input stream has the same structure of my target table, I dont need to use Advanced tab to perform column mappings.
Rename the HANA Output adapter and use the connector tool to connect the filter stream to “To_HANA” output adapter. This is how the final layout should look like in the canvas.
Click on the generated .ccl file in the project. If you know the syntax, you can use this file to create your entire project. Since this is my first project, I am sticking to the visual Layout screen.
In the next blog post, I am going to show how to invoke the input stream via REST calls, we need to enable a Web Service property by navigating to the .ccr
Compile the streaming project using the context menu option of the project
This should show you a success message (in the console) that the project has been compiled. In the next part, I will show you how to test this project.