Page 1 of 1

Readings directly to shm

Posted: Thu May 11, 2017 1:20 pm
by mstuetz
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

Re: Readings directly to shm

Posted: Thu May 11, 2017 2:10 pm
by jeanmarc
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 ?

Re: Readings directly to shm

Posted: Fri May 12, 2017 6:06 am
by mstuetz
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.

Re: Readings directly to shm

Posted: Fri May 12, 2017 1:10 pm
by jeanmarc
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)