Jump to content
C4 Forums | Control4

DriverWorks - Is It Possible To Execute Lua Script Code Of Driver Automatically Instead Manually Doing In Composer?


Recommended Posts

Hi,


 


In my sample driver used its name itself in proxy tag.Therefore i created device specific Execute Command().


Following are Execute Command in driver file:


function ExecuteCommand(strCommand, tParams)

            if (tParams == nil) then                

             if(strCommand == "GET_ENERGYREADINGS") then

                  GET_ENERGYREADINGS()      

             else

                  print ("From ExecuteCommand Function - Unutilized command: " .. strCommand)

             end

            end

end


function GET_ENERGYREADINGS()

             OnDriverInit()

             C4:SendDataToUI("<data>".. filedata .."</data>")

             --C4:SetVariable("READING", 523190)

end


 

In GET_ENERGYREADINGS() method given two things to execute:

1)OnDriverInit() this method is starting point to proceed further collection of other device variable and save it in xml file.

2)The saved data in file are read and send that to Flash UI using  ( C4:SendDataToUI("<data>".. filedata .."</data>" ) once the command  i received from Front end.  

 

Above is my scenario in driver in which once loading sampledriver.c4i file in composer and then from Front end i used to pass

command to receive values for display and calculation purpose.For the first time it is not executing automatically since i copied entire <script> section to composer lua part and executed.After that when ever i send command from Front end means the values are thrown by driver to Front end.

 

Please any one suggest instead of executing script code manually ,shall i execute automatically once i load driver file in Composer.If it is possible means please suggest whether i should use any custom button to send events for Front end or by using any other API.

 

Please any one suggest the better way to resolve the defects which i am facing.

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.