Readings directly to shm

Talks about metering
Post Reply
mstuetz
Posts: 73
Joined: Sun Dec 29, 2013 1:20 pm

Readings directly to shm

Post by mstuetz » Thu May 11, 2017 1:20 pm

Hi Jean-Marc!
I am using both, 123solar and meterN since a while and I am very happy with it.
Over the years my programming abilities grew and I am using shared memory objects in my scripts too.

Would it be possible to write logged data directly into the shared memory area of meterN? This would save "time" and another interface between logged data and meterN.
Therefor the momory layout of meterN's shared memory would be needed, right?
-Mario

jeanmarc
Posts: 1501
Joined: Thu Aug 29, 2013 7:16 am

Re: Readings directly to shm

Post by jeanmarc » Thu May 11, 2017 2:10 pm

Hi Mario,
That's never been easier than before with latest versions : mN write/read directly on plain text files, default location is /dev/shm (set in/config/memory.php)
To read

Code: Select all

<?php
include(config/memory.php');
$data     = file_get_contents($MEMORY);
$array   = json_decode($data, true);
print_r($array);

$data     = file_get_contents($LIVEMEMORY);
$array   = json_decode($data, true);
print_r($array);

$data     = file_get_contents($ILIVEMEMORY);
$array   = json_decode($data, true);
print_r($array);
php?>
What do you wish to write in there ?

mstuetz
Posts: 73
Joined: Sun Dec 29, 2013 1:20 pm

Re: Readings directly to shm

Post by mstuetz » Fri May 12, 2017 6:06 am

Cool - thx!
I will try to modify my pollers to write directly to this mem.
Do you have a similar script for 123solar too? Cannot find memory.php there.

jeanmarc
Posts: 1501
Joined: Thu Aug 29, 2013 7:16 am

Re: Readings directly to shm

Post by jeanmarc » Fri May 12, 2017 1:10 pm

Yup, It's the same with latest version of 123s.
But it's not wise to write into these files with another process than mN or 123s :?
I don't know how your "poolers" work but you can make virtuals meters that have his own space to save previous values, retrieve the latest then make the difference to increment a virtual meter (like pooltot example)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest