 Hello everyone. So I'm Abhinav. I work for SAP in Bangalore. And today I will be presenting a topic of using embedding business rules in the Cloud Foundry IoT applications. In this topic, basically, I will be talking about how to use the business rules in IoT applications. But the concept of using the business rules remains the same, and can be applied to other applications which are not exactly an IoT application. So for this session, I have taken IoT use case as a lead scenario. But it also talks about how you can use the business rules for achieving this. So what is IoT in nutshell? There are multiple devices which are connected to the internet and sending the data. There may be multiple use cases for it. Like you have your refrigerator, which is intelligent, which is sensing how much quantity of food you have, and if something goes down, it sends a request to the supermarket to send it to you. Similarly, in your car, there are multiple sensors which are sensing all the data one by one, and if something is wrong or exceptionally varying from what is supposed to be the standard, it books service for the vehicle and informs the driver when it has to be taken. Similarly, your health devices. So you have the health bands, which is continuously monitoring your health data, and as and when something is wrong, it informs you so that the corrective measures can be taken and appointment with the doctor can be taken. So in the nutshell, IoT or Internet of Things are multiple things which are connected to the cloud and talking to each other to get the result. By 2020, there will be 30 billion devices in the IoT network, so that means there will be 30 billion devices which are connected to the Internet and talking to each other. The main point over here is all the devices are sending all their data to the cloud for processing. So imagine that means 30 billion devices are sensing the data every second, so your heartbeat, your cars, all the parameters are sensed every second, and then it is sent to the cloud for processing. So this means 30 billion devices every second or even lesser than that, sending the data to the cloud for further processing. Now, coming to the problem with this kind of scenario is there's an overloaded cloud. So that means all the data is always reaching to the cloud whether it is required or not required. So maybe to start with, let's take an example of your car. So if you have a car which has the sensors in you, the tires to identify what's the air pressure, and if the air pressure is below a threshold or above a threshold, then it's a critical situation where you need to take an action. But majority of the time, it will be under the range which is required or which is prescribed by the manufacturer. In that case, that data need not be sent to the cloud because it's just a noise which is just adding more and more work for the cloud. Similarly, the simple data enrichment is also happening at the cloud. So what I mean by data enrichment is, let's assume you had a software program which is written to measure the temperature in degrees and degrees. Now you have the sensors which are measuring it in Fahrenheit or Kelvin or some other unit. Then this data will be sent to the cloud and over the cloud this conversion will happen. Now what is happening with all these things happening over the cloud is, the cloud is becoming more and more overloaded with the noise which actually can be filtered out right away in the edge of the device. The second bigger problem with this is your data processing logic is basically hard-coded in the cloud in a code. So that means if you wrote that my temperature will be in degrees centigrade, then that is hard-coded in the cloud. And if your new sensor sends it in a different value, then you need to put a new IT project to convert it or do it. So the business user, though he knows that my new sensor is having the values in some different unit, but he cannot do anything without an IT project to be implemented to do this simple convergence. So the business user actually is not able to react to the changing requirement. So these are the two major problems with this current setup. The cloud is always overloaded and the data processing is hard-coded in the cloud application code. So the possible solution which we have prototyped is basically pushing down the data processing to the device of the edge. So what I mean by this is you push down your data processing to the edge. So edge becomes smart or edge knows like what is basically an event for it which requires an attention which needs to go to the cloud so that the cloud application can take an action for it. And other data which is noise, it just gets filtered out in the edge itself so that the cloud doesn't even know about it. The second thing is basically empowering the business user to react to the changing business. So let's go back to the same example which I was talking about, that you had a program which understands the temperature in degrees and degrees and now your new sensors sense it in a different unit. Now the business user should be able to program it so that automatically it converts the data before it reaches to the cloud in the degrees and degrees. And the business user should be able to do it on his own without any IT thing. So basically if I sum up what we discussed till now is basically two kind of scenarios. One scenario is basically the thinning use case. That means you filter the unnecessary noise at the device or the edge level itself. And second is the enrichment use case. So by filtering use case, the example which I have captured here is only if the room temperature is above 27 degrees centigrade then publish and even to the cloud. Otherwise, don't do anything because it's of no value to us. The second enrichment is basically the data conversion and supplementing the data. So supplementing the data is like adding some status value to it. Like if something is going to the cloud, you just add some status at the edge level itself. And to empower the business user, user to change it is basically we are suggesting to use a business rules. So business rules basically provides the user with capability where a business user can change it. So one of the examples is a decision table where it is written like if the tire number of the tire is equal to one, so that means it's the first tire, it's like your front tire. And the air pressure of the tire is less than 26 or the air pressure of the tire is more than 32 than reason alarm. Otherwise, don't do anything and just drop it. Similarly, if there's a decision table which just does a data conversion, then you can have input and then how the output should look like. And now the business user can just come, change the decision table and then deploy it so that the rules get changed automatically and you don't require an IT intervention. So I will teach you through a demo where I will be showing you both the use cases which we discussed till now. So before going into it, like I would explain how the entire setup looks like. So we have the cloud where this SAP IoT cloud platform service is running. And that is connected to an IoT gateway edge. So gateway edge basically connects to the cloud and this edge has a device, right? So device is like a physical device, so that's like your car and then it has like multiple sensors in it. So sensors are basically a logical device and like device is a physical device. So devices like you can assume is like a car and then sensors are the logical device, logical nodes in it. Now the sensor senses the data and sends it to the gateway and in the gateway itself the rules are running and they filter out or do the data conversion, whatever is required and then only if it is necessary it gets pushed to the cloud. So that means if there's a noise it just gets filtered out at the IoT gateway edge itself. So because in the IoT use cases the performance is a key. So the rule and the rule engine is running in the gateway edge itself and the modeling of the rules is actually in the cloud. So the business just models the rule and he deploys it and it goes and sits in the gateway edge. So what is happening over here is there's an interceptor. So interceptor is something which gets invoked on whenever a data comes from the device and you can write whatever you want your custom logic in the interceptors. So what I have done for the demo is in the interceptor I have written that you call the rules so that it takes that decision and accordingly the data gets pushed to the cloud or not. So I will be just jumping to the demo and this demo basically uses two services one is SAP Cloud Platform Business Rules and SAP Cloud Platform Internet of Things. So for this demo I am using the gateway as the REST gateway. So basically this laptop acts as a gateway and then the devices are sending the data and then this desktop basically acts as a gateway where the rule engine is running and processing the data. In the real world this will be based on either MQTT or Modbus the protocols. So I have already started my gateway and if you see over here I am sending a call to 151. So 151 is basically like a device and then this is a logical node address this is a sensor. So what I am trying to tell is for device 151 for the sensor 2 this is the value and this measure ID tells the type. So now what you can consider it is like car number 151 tire number 2 has a 33 as the pressure of the air tire and this measure ID basically tells whether what's the unit. So 2 is basically for air pressure similarly like that is well that is predefined. So now I'll be calling this and it shows 200 okay. So this is basically the IoT cockpit where I can monitor the values. So if you see for 151 so for this node I have received the data and I will just check the gauge. So it came like zero because we have filtered the data so I will just put it on the real-time measure so as soon as we keep on sending the data it will start appearing over here. So now if the air pressure is something like 39 recent the data ideally it should show me over here the value should get plotted I think there's some problem with the network speed with the network speed over here or something I'll just try to repush the values. Okay so I am seeing for something wrong what I am sending is basically for 151 and what I was checking is 142 let me just recheck it. Okay it's on the top. So if you see the value 40 came and now I will just put it for real-time measures. So the value 40 came over here now I will just change it to something like 38 so if you see this value should get plotted over here and these are the values which are of interest so basically I have defined a rule where I have tell that the value between 28 and 32 is what is normal and everything is basically an alarming situation which need to be reported. So I will be sending 31 over here and if you see the data that got dropped and I just didn't receive anything for it but if I just redo it and put 35 then actually the value gets populated. So if you see over here the value never reached to the cloud because it was not a critical situation and if you would have sent it to the cloud it would have of no use. Now how I have done it is basically I have this air pressure rule so this is basically a cloud environment where the business user can deploy the rule or model the rule so for tire number 2 I have told that less than 26 and more than 32 is only the critical situation let's change it something to 30 so now the business user is able to change the rule and then he deploys it so now the air pressure is even 31 it should actually reach to the cloud so if you see now 31 is reaching earlier it was getting filtered out so what has happened is I have modeled the rule and then deployed it so at that time it came to my my net edge where this rule is getting processed and I am filtering whatever is not relevant to me so now moving to the second scenario where we have the simple data conversion or the enrichment use case so here again I have a device number 251 which has a logical sensor number 1 and it is sending the data it is sending basically that the temperature and the unit which it has so if you see the 400 which is basically the value my type is 1 it defines that it is the temperature in degree centigrade and Fahrenheit basically actually tells what is the unit of this the problem with this is I expected in my cloud that everything will come in degree centigrade but now it is coming in Fahrenheit and this need to be changed so I have already deployed a rule which takes care of converting it so what I would do is I will send the data for device 251 and for if you see the gauge it automatically got converted to 37.78 which is equivalent in degree centigrade and K if I send it in Celsius 41 so basically now I am telling that 41 in degree centigrade and then it should not get converted so if you see the last value is coming as 41 degree centigrade over here so how we have done is I have deployed another rule over here which is called temperature conversion rule and if you see this rule it has basically the unit of the input and here we have written is equal to Fahrenheit and then do the some conversion is like percentage is basically a wild card so it is like if anything then return the same thing so that is why there was no changes for this centigrade now if a business user finds that there is another sensor which is sensing in different unit then what he can do is he can write another the rule over here so is equal to Kelvin and then it becomes value of the input minus 273.15 which is the formula so what happens is if unit I give it as Kelvin then it this rule should get fired so the idea over here is earlier you had to implement an IT project just to do all these things but now the business users is empowered and he can just write his own rules and do it and even if you see over here it just gives you all the possibility of what need to what all you can do and then you just write your rule and even if you read it it is very English like like unit of the input is equal to Kelvin then do something so it gives your very English like structure to express your rules now I would just go and activate or deploy this so at this time it is actually getting deployed to my gateway edge where it is running and now if I send it in Kelvin the value is 300 then I should get I got the value changed to the converted value so so if you see by using the business rules expressing the logic was much easier how the business rules basically if you were wondering how we got the vocabulary or the content is working is basically you have to define your data objects acts like on this acts like vocabulary on which your rule runs so I have just defined that I have input which takes the unit and the value and then I have output which basically gives the how your output will look like and when you invoke the rule basically what you do is you pass these values from the data object which gives you the rule name which runs through it so jumping back to my PPT so this is how the overall architecture looks like so you have the devices which is connected to the gateway edge where your the rules are running which basically does all the filtering or the basic conversion and if we find that it need to it is required to reach to the cloud then only it reaches and in the required format whatever required like all the conversion all those things happened already in the gateway edge and then in the cloud foundry we have the user interfaces which basically can be used by the application user to develop its thing but now the point is application user only gets the data what is relevant to him he doesn't get all the noises from the device which is not required and secondly even on the IoT services like when it reaches the cloud you can use the rule engine to express your logic so that it can be easily changed by the business user without requiring much of the intervention so that's all for the today's talk this is my contact address is not here today but his contact address is also there he works with me is my colleague that's all thank you and I'm open for questions so rule service is a service in cloud foundry and IoT is another service in the cloud foundry so basically that's a service running in cloud foundry in SAP cloud foundry okay so so basically business rules is a separate service so technically you can use it to use it with other IoT other applications also but the thing is currently when I was doing deploy it was running with within the gateway edge so over here you will be making an STTP call to the rule service it will be giving the result and then you can consume it so that's all my question was I understood that part but is it also possible for me to develop a cloud foundry application that use the SAP Rural Engine provided analytic results as a service to the cloud foundry application yes okay thanks because rule service is a separate service from which can be used independently yes on the edge you don't have the cloud foundry thing running right how did the rules what was the ecosystem there on that side on the edge gateway side so edge gateway what we have done is basically when you deploy it I get the rule corresponding rule at a particular file system in my location and then the rule engine reads from that particular thing so rule is basically more like a macro so you have a rule engine and then the whatever you model the rule basically is like XML or a macro which gets downloaded and then my rule engine which is running in the gate edge reads from that particular location so it's just a custom application which you have written on gateway to actually get the yes so gateway if I go back to the thing so gateway provides this interceptors so interceptor gets invoked whenever some data flows in so what I have written is when the code gets called then invoke the whatever is there I mean I have my own gateway so how do I use that so I need to borrow that code from you rule engine and interceptor and rules so basically the idea over here is the rule service is a separate service so you can just invoke it so how it goes is basically I can show it to you so if you see the rule can rules is a service so you have to actually end point and then you can actually give the payload so this is how you can consume the rule engine now because you are using your own gateway so you have to ensure when you trigger this rules so basically if you need to have something like this interceptor at that moment you need to just trigger it as of now no because what I have done is whenever you click a deploy the corresponding thing comes down to my system so I am not making a call because IOT generally need to be a high performance system but yes theoretically you can make a call or as of now but yes you can actually make a call to cloud but only thing is a performance will be a little bit of problem that defeats the purpose of sending a data to the cloud right essentially if you did the service if there are no more questions then thank you