In IoT Development
1- How to use programs in Niagara framework IoT | create a water level control component. - read the full article about IoT Development, IoT Development and Internet of Things technologies from Iot Easily on Qualified.One

Youtube Blogger

hello everybody this is Maher and this is my first video about Niagara framework developer tutorial I hope you like it and if you have any questions or suggestions about my next videos welcome to leave your comments to let me begin by why do we need a program module actually for some functions that are needed in a project but not available in the Niagara itself its not available in Niagara module components you can use program editor provided by Niagara to write and generate your own controller your own control component today Im going to explain how to use the program to implement a water level control component as we can see here I bring this example I have a tank and there are two sensors that represent high and low levels these two sensors will be as the inputs for my component also I have valve and pumps switch which are the outputs for my component so the logic table for my component will be like this when the water exceeds the high-level sensor both sensors are on at this point the valve is off and the pump is on when the water is between two sensors the high level one is off while the low level one is on at this point the valve is still off and the pump is still one which is exactly the same as the first status and when the water level is lower than the low-level sensor the valve turns on but the pump is off now I will move to the practical part of the implementation okay it will begin by bringing the program palette here program and after that, i will create the code for this program by drag and drop this program for example I will call my component as water control and I will go inside this component as you can see here at the right top corner there is a program editor okay now Im going to the slots tab here I will define my inputs my outputs all these slots for this component okay for here I will set the high-level and this will be the type of this class or this attribute or can say this slot it will be a boolean status point its here status okay and then I have a low level and also its a status boolean as well another one its uh the output its a valve and also status volume but at this time I will do this execute and change the plug and pump status boolean execute okay and also I will add another slot will represent the status of the component itself I mean the enabled its enabled or not so I would call it to enable and then its a status boolean as well okay and now Im going to write the code in this editor as we said in this part you have to have a piece of java language so if you have just the basic of language java language you can do this part its so easy so simple speeding up i put the code now its ready here all the execute as you can see the the program module give you a three mode three function automatic automatically generated on start on execute on stop so now for this video i will focus on the unsecured on execute method so as you can see and niagara also auto generated the the source code for this program and by default all the slots uh provided uh a get and set functions so you can see here get high level whatever all of them you i have the get and set functions so thats me i can use it in my program and also you can see here in imports which is mean all of this library i can directly use it in my program uh for now for this case i dont need to use uh like any special uh module or out of third party library so i can just directly use my my my inputs and thats it as you can see here get enable that means i will get enabled for my my in for my input this input and i will check the the status and because this input as we defined its a p value uh b value class so that its also should called by get value to get the value inside so here i put all my logic as we as we explained in the previous table and now its everything is ready i just still need to save and compile so in the in the toolbar here you can see save and compile this button click it and you can note here and its compiled successfully and i dont have any errors so now everything is ready i will save and i will go back to the the module now this is just a program now i need to package this program inside one one module and then i need to to generate uh the final module which it will be used okay now i will drag and drop this program module here and okay before i now package my my program inside the module i still need to paint the slots that mean i need to show what i need to show okay i need to high level low level valve pump and enable is not much important to see and uh in the component like this so now its ready so i will open down the program module now i will drag and drop the my program inside the module so okay sorry thats me here still need to uh okay after I drop the program inside the program module and also I need to note that that the name of the program should be started by capital letter after Ive filled the module name description vendor all these you can do build after the build actually we have to reopen the workbench and restart the station now Im going to close the workbench and open it again after I restarted the workbench and the station and now I can go to pallet I can see my module created and I can use it so you can see in my module I have my program now this program uh now its a component so I can use it as a component on my logic or on my and you can see drag-drop my component you can see here its ready and now in this time I can delete all this program and uh program module because its just to building uh or and generating the module purpose now its done so this module can be used and at the end of this video I hope my video can help you and if you have any topic that you want me to talk about in future videos please leave your comments I will read them all thats all for today see you in the next video
Iot Easily: 1- How to use programs in Niagara framework IoT | create a water level control component. - IoT Development