Mohankumar Posted July 23, 2014 Share Posted July 23, 2014 I tried sample driver to retrieve other device variable values and saved it in xml file.These will be done for every one hour to store the latest value for using these latest as well as previous to show report in FlashUI. Facing problem in Initialization part used OnDriverInit() API in which i have called other function to start the execution in my sample driver.Following are my Initialization part in driver:function OnDriverInit() if (PersistData == nil) then PersistData["Devices"] = {} end RegisterPucks()end Here initialized some persist information and a method called RegisterPuck() which it contain remaining part to start further execution on driver file to process the data. Can any one please suggest how could i able to resolve this defect using OnDriverInit() API or need to follow some other API to invoke my starting point in driver file.. Link to comment Share on other sites More sharing options...
RyanE Posted July 23, 2014 Share Posted July 23, 2014 1) If you're saving the data values in an XML file, you do not need PersistData. I don't recommend you store this kind of data (periodic upated data) in the PersistData table, as it will cause the project file to be saved, which can affect performance. 2) If you have an error in your OnDriverInit code, it will not complete. It's possible your RegisterPucks() call is never happening. 3) The code 'PersistData["devices"] = {}' will always fail if PersistData is nil. You can't assign a key/value pair to a Lua table without creating the table first. The code should look like this: if (PersistData == nil) then PersistData = {} PersistData["devices"] = {}end I prefer like this, myself: PersistData = PersistData or {}PersistData["devices"] = {} I also wouldn't typically put that code in the OnDriverInit, I'd put it at the end of the main code block of the driver, since it does not depend on the driver initialization having happened. RyanE Link to comment Share on other sites More sharing options...
Mohankumar Posted July 24, 2014 Author Share Posted July 24, 2014 Thanks for your reply! Its working after resolve the issue in OnDriverInit code and also removed PersistData according to your suggestion. Link to comment Share on other sites More sharing options...
WillEV Posted July 24, 2014 Share Posted July 24, 2014 Thanks for your reply! Its working after resolve the issue in OnDriverInit code and also removed PersistData according to your suggestion. I'd also suggest using OnDriverLateInit to make sure that everything is completed initializing everywhere in the project, not just in your driver. This is only true if you're targeting 2.5 or later (I can't recall when onDriverLateInit was added, so it might be earlier). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.