-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatt_test.php
71 lines (57 loc) · 2.08 KB
/
batt_test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
Copyright 2017 Seth Mos <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
declare(ticks=1); // PHP internal, make signal handling work
// Import Config
ini_set ('include_path', '.:/home/pi/baf');
include("vars.php");
include("functions.php");
if (!function_exists('pcntl_signal')) {
printf("Error, you need to enable the pcntl extension in your php binary, see http://www.php.net/manual/en/pcntl.installation.php for more info%s", PHP_EOL);
exit(1);
}
$shm_batt_id = open_shm($shm_batt_key, $seg_size, "w");
$state = array();
/* this decides the direction from -2 to +2 */
$state[-2] = 0;
$state[-1] = 0;
$state[0] = time();
$state[1] = 0;
$state[2] = 0;
$state['duration'][-2] = 0;
$state['duration'][-1] = 0;
$state['duration'][0] = 0;
$state['duration'][1] = 0;
$state['duration'][2] = 0;
$state['operation'] = 0;
$state['charger_pwm'] = 0;
$state['inverter_pwm'] = 0;
$state['battery_connect'] = false;
$state['battery'] = "";
$state['message'] = "Starting up";
$state['message_time'] = date("Y-m-d H:i:s");
$state['inverters'][1]['ac'] = false;
$state['inverters'][1]['dc'] = false;
$state['chargers'][1]['ac'] = false;
$state['chargers'][1]['dc'] = false;
// Pre flight check
$cfg['simulate'] = false;
$cfg['batt_cells'] = 8;
$battstate = array();
// Battery status should connect the battery for us if it's good
$battstate = battery_status($cfg, $battstate);
// print_r(return_chargers_power($cfg));
// print_r(return_inverters_power($cfg));
print_r($battstate);
?>