Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: "Enabeling" a plugin Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 245
Posted: January 16 2014 at 18:51 | IP Logged Quote gg102

In trying to clean up some code, and change polling a file for changes. So, I decided to try the "filemon" plugin. I got it working nicely, and was very happy with it until I discovered that "ANY" change to a file triggers the plugin. The problem is that when I delete the file, I get the trigger.

So, I decided I would disable the plugin, then delete the file, then re-enable the plugin. So I used ph_pictrl( "FILEMON", "disable", 0). Nice, it worked. Then after I delete the file, I use ph_pictrl( "FILEMON", "enable", 0) and I found out that while the plugin is "enabled" (in help/about/plugins) it doesn't work anymore. To get it to work, I must re-initialize PH.

Any thoughts?

EDIT:
Well, I have invented my own workaround:
In the handling macro I put in:
JUMP if (ph_fileexists( "{TEMPERATURE_FILENAME}" )=1, somewhere, somewhere_else)

This handles the issue if the macro is triggered by a delete, it just exits and doesn't try to process information in the file.

This works, and I'm OK with it.

So, nevermind.

Edited by gg102 - January 16 2014 at 21:37
Back to Top View gg102's Profile Search for other posts by gg102
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 18 2014 at 18:27 | IP Logged Quote dhoward

gg,

Glad to hear you got it working to your satisfaction. I'll have to look into this plugin to determine why the enable command is working properly.

As an alternative, I was going to suggest using:

ph_pictrl("FILEMON","reinit",0)

This should reinitialize (and init) the plugin without having to do a reinit on PowerHome. Just another option if you're interested.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 245
Posted: January 18 2014 at 19:02 | IP Logged Quote gg102

Thank you Dave,

I did think about that, but I thought I read somewhere that said it might take a few seconds for PH to complete the reinit. I might be wrong on that. If true, that might cause other issues. So I thought if I could just turn it off, then back on, that would be ok.

It totally makes sense that a delete triggers the FILEMON, and I agree.

My macro initially only processed the file because it was a timed event with a long waiting period (not a real safe thing to do, but the processing macro deleted the file so I was pretty safe it was present). Now that it's a mod to the file that triggers it, I simply added code to handle that condition that the file may have been deleted. Probably safer code anyways.

Again, thanks.
Back to Top View gg102's Profile Search for other posts by gg102
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 245
Posted: January 20 2014 at 14:05 | IP Logged Quote gg102

Dave,

I discovered an inconvenience.

On a daily basis I have to change the name of my TEMPERATURE_FILENAME because of the way my temperature sensor device/software works. It names the file for example: TEMPERATURE-2013-11-09.log.

Well, as I change the name of my temperature sensor filename using ph_picmd ( 5, "FILEMON", 4, 1,0,"{TEMPERATURE_FILENAME}","0" ) (and that all works nicely) PH doesn't write it back to the .ini file. Here's the problem, if the system reboots, PH might have to wait for a new day roll-over (in my program) to poke the new name of the now-obsolete temperature_filename.

I made code to poke the name in the case of a reinit of PH, but what do you think about updating the .ini file if you update the filename using that command?   Maybe use a sub-parameter to the command for updating the .ini file for compatability.

Just an idea, I'd like to hear your thoughts.
Back to Top View gg102's Profile Search for other posts by gg102
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 26 2014 at 22:12 | IP Logged Quote dhoward

gg,

Ask and ye shall receive. Version 1.1 of the PH FileMonitor is available at http://www.power-home.com/download/ph_filemon.zip.

Only change is that command 4 makes use of the ldata2 parameter. If this parm is non-zero, it will update the INI file with the new filename. So your function call would now look like:
Code:
ph_picmd( 5, "FILEMON", 4, 1,1,"{TEMPERATURE_FILENAME}","" )


Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 245
Posted: January 27 2014 at 10:09 | IP Logged Quote gg102

Thank you Dave,

I loaded it, and it works nicely! Saves a lot of work.
Again, thank you.

Now, let's talk about the winning lottery numbers for next week!   
Back to Top View gg102's Profile Search for other posts by gg102
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum