Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Constant globle variable writes Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: July 16 2014 at 21:12 | IP Logged Quote lizaoreo

So, question. I have rigged up a C#.net app that runs a timer. Every minute it polls my MySQL server for thermostat data that is mined from my thermostat every minute from a PowerShell script and put into the MySQL database. It takes that data and writes it to several global variables I created in PowerHome.

Initially I did this just using an ODBC connection to the database directly, but I've since started using a dll someone here made because PowerHome didn't recognize the global variables changed writing straight to the database. Using the dll, which uses the PowerHome socket connection, does get recognized as a Global Variable changing. This led to a ton of log entries, so I turned off logging of the global variable changes.

My concern is basically this, is there anything I should worry about doing a write to several global variables every minute? Is there a possibility of a overload on PowerHome or something that might cause it to crash or become unstable. I've not done anything quite this extensive before and am just slightly uneasy about it.
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: July 17 2014 at 20:02 | IP Logged Quote dhoward

lizaoreo,

You should have no need to worry. PowerHome can easily
handle updates of global variables every minute. It
shouldnt crash it or make it unstable either. The only
adverse effect may be a slight pause in execution during
the update but if you havent noticed it yet, then its
most likely not an issue.

You might try a different approach however. Version 2.1.5
and up includes a new generic ODBC plugin. You could have
a PowerHome timed event fire every so often and have the
plugin (which runs in its own thread) make the connection
to the MySQL database and retrieve the data and update
the global directly within PowerHome.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: July 18 2014 at 07:57 | IP Logged Quote lizaoreo

Oh, that would be cool. I'd seen the stuff about the ODBC plugin, but haven't looked at it yet. I was actually trying to get the growl plugin working though.


That does kind of bring up something else though, I've not had a chance to really look through the material, but I can't figure out how to enable a plugin :)
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: July 20 2014 at 12:09 | IP Logged Quote dhoward

lizaoreo,

Plugins are setup in the PowerHome Explorer under PowerHome->Setup->Plugins. Be sure and check out the help file for more detailed information on plugins.

Below is the documentation that I have so far for the PH ODBC plugin:

PH generic ODBC plugin documentation

Launch Data (ActiveX Classname):
PH_ODBC.phodbc

Initialization Data: The full path and filename of the phodbc.ini file.

This plugin allows the user to connect to a database via ODBC (including the PowerHome database). Using this plugin, you can access MySQL, Excel, Access or any other database that is capable of being connected to with ODBC.

You must configure the phodbc.ini file before using this plugin. The [main] section holds a single parameter (connectioncount). This should be set to the number of unique ODBC database connections you plan to make. The max number of connections allowed is 5. Connections can be reused. If you require more than 5 connections, you can create another instance of the PH ODBC plugin within the plugin definition screen. The example demonstrates 2 connections (2 databases).

The remaining sections define the individual database connections. If you plan to connect to a single database, then connectioncount would be 1 and you would describe this connection within a section named [connect_1]. If you had a connectioncount of 2 or 3 then you would also have sections [connect_2] and [connect_3] respectively.

Each "connect" section has 3 parameters. The DSN (defined in ODBC Administrator), the database loginid, and the database password.

Use the ph_picmd function to execute commands via the PH ODBC plugin. Individual commands are documented below. The command numbers will go in the CMD parameter of the ph_picmd function. Other parameters for the function will be detailed as appropriate:

The following commands detail setting up and connecting to a database.

CMD 1 - Returns the connection count.
CMD 2 - Return the status of a connection. Place the connection number you wish to status in the data1 parameter. 1 will be returned if the connection is connected. 0 will be returned if not connected. -997 will be returned if the connection number is not defined.
CMD 3 - Return the DSN of the connection. Place the connection number in data1.
CMD 4 - Return the loginid of the connection. Place the connection number in data1.
CMD 5 - Set the DSN for a connection number. Place the connection number in data1. Place DSN in data3.
CMD 6 - Set the loginid and password for a connection. Place the connection number in data1. The loginid is in data3 and the password is in data4.
CMD 7 - Connect to the specified connection. The connection number is data1. 0 is returned if the connection is successful.
CMD 8 - Disconnect the specified connection. The connection number is in data1.

The next block of commands will execute SQL against a connected database. The SQL is indivdual and unique from any previous or post SQL that is executed. These commands are standalone and do not interact with other commands.

CMD 100 - Create a datastore within memory and run a SQL select statement within it. The data returned will be the SQL result set. The connection number is in data1. The format of the returned data is in data2. Valid values are 0 for CSV data, 1 for raw syntax, 2 for XML, and 3 for HTML. The SQL select should be in data3.
CMD 101 - Execute a SQL statement using a cursor and return the output. The connection number is in data1. The SQL is in data3.
CMD 102 - Execute a SQL select using a datastore and return multiple columns of data for the first row in local variables. Place the connection number in data1, the starting local variable number in data2, the SQL select in data3.

The next block of commands allows the user to open temporary storage areas (datastores) and execute subsequent commands against them. There are a total of 10 datastores per connection count.

CMD 110 - Execute a SQL select statement within a datastore. Keeps datastore open and returns number of rows retrieved. Connection number is in data1, datastore number is in data2. Place the SQL select statement in data3.
CMD 111 - Destroy a datastore created using cmd 110. Connection number in data1, datastore number in data2.
CMD 112 - Verify that a datastore created with cmd 110 is valid. Connection number in data1 and datastore number in data2. Returns 1 if valid, 0 if not.
CMD 113 - Returns the number of rows currently within a datastore created with cmd 110. Connection number in data1, datastore number in data2.
CMD 114 - Returns the number of columns currently within a datastore created with cmd 110. Connection number in data1, datastore number in data2.
CMD 115 - Return the name of a column in a cmd 110 created datastore. Connection number goes in data1, datastore number in data2, column number (stored as a string) in data3.
CMD 116 - Return a columns data type in a cmd 110 datastore. Connection number goes in data1, datastore number in data2, column number (stored as a string) in data3.
CMD 117 - Search through a cmd 110 created datastore for a specified condition. Return the first row number within the datastore that matches the search condition. Connection number goes in data1, datastore number in data2. In data3 is your specified search condition (see examples below). In data4, place the row number to start searching for (all rows from this number on) or a start and end number separated by a tab (~t) character. Search conditions are strings such as:
"id='ABC'"
"#4>100"
CMD 118 - Return the data in a specific row and column from a cmd 110 created datastore. Connection number goes in data1, datastore number in data2, row number (stored as a string) in data3, column number (stored as a string) in data4.
CMD 119 - Return the data in a specific row and column from a cmd 110 created datastore. Connection number goes in data1, datastore number in data2, row number (stored as a string) in data3, column name in data4.
CMD 120 - Return specific row, multiple columns of data from a 110 datastore into local variables. Connection number goes in data1, datastore number in data2, row number (stored as a string) in data3, local variable start in data4 (stored as a string).

The next block of commands deals with direct actions against a database.

CMD 130 - Execute a direct SQL statement agains a connection. The SQL can be insert, update, and delete statements. Place the connection number in data1 and the SQL to execute in data3.

The next block of commands execute SQL select statements against a connection but will also fire a PowerHome trigger. The trigger that will be fired is a generic plugin trigger with a Trigger ID matching the ID you assigned the PH ODBC plugin. The trigger number will be the connection number. The trigger value will be the cmd number.

CMD 200 - Execute a SQL statement (same as cmd 100) and fire a PH trigger with the results. Same parameters as cmd 100.
CMD 201 - Execute a SQL statement (same as cmd 101) and fire a PH trigger with the results. Same parameters as cmd 101.
CMD 202 - Execute a SQL statement (same as cmd 102) and fire a PH trigger with the results. Same parameters as cmd 102.

The next block of commands also fire a PowerHome trigger.

CMD 210 - Execute a SQL statement creating a datastore(same as cmd 110). Fire a PH trigger with the results. Same parameters as cmd 110.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: July 21 2014 at 09:18 | IP Logged Quote lizaoreo

Sweet, got my first plugin loaded. What are the ActiveX class names for the Roku and Growl.

Also, is there an easier way to figure that out? Maybe I'm missing something obvious, the manual just said to ask the dev so...

I just hate having to bug you about it, I know you've got to be busy.
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 
dhoward
Admin Group
Admin Group
Avatar

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

lizaoreo,

Excellent! Glad to hear its working.

The classname for the Roku plugin should be PH_Roku.phroku. The classname for the Growl plugin should be PH_Growl.phgrowl.

I was pretty sure the Growl plugin had a readme file with it (in the plugins directory) but I'll have to verify it when I get home. The Roku plugin is probably not yet documented so I'll work that up and post as well.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: July 22 2014 at 09:35 | IP Logged Quote lizaoreo

Awesome, thanks ^_^

Yes, Growl has a guide with it, just didn't have the classname listed.

Looking forward to playing with this :)
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: July 22 2014 at 10:34 | IP Logged Quote lizaoreo

Question, on the documentation for the growl plugin, it says to do commands similar to:
ph_picmd(5,"PHGROWL",3,"Title","Message",0,2)
But that gets a syntax error.

Looking at the documentation for the ph_picmd command, I noticed the first two data parameters are longs and the last two are strings. So I flipped the command to:
ph_picmd(5,"PHGROWL",3,0,2,"Title","Message")

Now it doesn't give me a syntax error, but still doesn't seem to do anything with growl :/
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: July 22 2014 at 20:21 | IP Logged Quote dhoward

lizaoreo,

You are correct...my quick docs are wrong. The help file has the correct syntax for the ph_picmd function and your second example is correct.

Not sure why you're not seeing anything. Send me what you're using for the Initialization Data (next column after classname) and send me your phgrowl.ini file. I'll try to determine what is going on.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: July 24 2014 at 08:35 | IP Logged Quote lizaoreo

Thanks, actually, doing a bit of experimentation, it seems growl (which is on a different computer) is not receiving remotely sent growl messages. I may just have to install it locally and have it pass the growl notifications to the other computer.

So I had two problems I guess, glad to know what syntax to use though, I'll update my quick doc with the correct form so I know
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 

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