Exemplo n.º 1
0
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Turbine Rotor Gust', 'RPM', $rpmg, '', '', true);
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Turbine Rotor Count', '', $rpmc, '', '', true);
/* wind vane on big tower */
/* MOD(ROUND((^^analog1Current/4096.0)*360.0+145.0,0),360) AS windDirection */
$wd = ($r[21] * XR2G_VIN_V_PER_BIT * 360.0 + 145.0) % 360;
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Wind Direction', '°', $wd, '', '', true);
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Supply Voltage', 'volts', $r[19] * XR2G_VIN_V_PER_BIT);
$temperatureAmbient = $r[28] * XRW2G_5VOLT_V_PER_BIT * 100.0 - 273.15;
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Ambient Temperature', '°C', $temperatureAmbient, 'temperature', 'c', true);
/* meta data */
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Modbus Host', '', '192.168.8.2:505');
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Sequence Number', '', $r[42], '', '', true);
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Ticks', 'seconds', $r[43] / 100.0, '', '', true);
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Uptime', 'minutes', $r[44], '', '', true);
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Packet Date', 'UTC', $datetime, '', '', true);
$jd[$dname]['A4258'] += pcwx_encodeForBroadcast('Run Date', '', $_SERVER['REQUEST_TIME_FLOAT'], '', '', true);
/* send data to broadcast server(s) */
print_r($jd);
sendDataTCP($dest, $jd);
/* 
add to powerPeformance table 

mysql> describe powerPerformance;
+--------------------+------------+------+-----+---------+-------+
| Field              | Type       | Null | Key | Default | Extra |
+--------------------+------------+------+-----+---------+-------+
| packet_date        | datetime   | NO   | PRI | NULL    |       |
| wx_time            | double     | YES  |     | NULL    |       |
| windAverage0       | float      | YES  |     | NULL    |       |
| windSpeed0         | float      | YES  |     | NULL    |       |
| windGust0          | float      | YES  |     | NULL    |       |
Exemplo n.º 2
0
if ('cam' == substr($hostname, 0, 3)) {
    $hostname = substr($hostname, 3);
}
if ($_SERVER['argc'] != 2 || false === strpos($_SERVER['argv'][1], ':')) {
    printf("usage: %s hostname:destination[,hostname1:port1,...hostnameN:portN]\n", $_SERVER['argv'][0]);
    return 1;
}
$dest = $_SERVER['argv'][1];
/* modbus registers read from XRW2G */
$r = array();
/* current value registers */
$r = $r + getModbusRegisters('localhost', 38, 0, 47);
$jd = array();
$jd[$hostname]['sensors'] = array();
$ws = pcwx_anemometer(0.765, 0.35, $r[1]);
$wg = pcwx_anemometer(0.765, 0.35, $r[2]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Wind Speed', 'm/s', $ws, 'speed', 'm/s');
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Wind Gust', 'm/s', $wg, 'speed', 'm/s');
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Input Voltage', 'volts', $r[18] * 0.024477);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Temperature', '°C', $r[30] * 0.001220703 * 39.394 - 30.0, 'temperature', 'c');
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Relative Humidity', '%', $r[33] * 0.001220703 * 30.303);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Sequence Number', '', $r[42]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Ticks', 'seconds', $r[43] * 0.001);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Uptime', 'minutes', $r[44]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Watchdog Timer', 'seconds', $r[45]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Packet Date', 'UTC', date("Y-m-d H:i:s"));
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Linux Uptime', '', exec("uptime"));
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('802.11 Signal', '', exec('iwconfig wlan0 | grep Quality | cut -c 11-'));
/* send data to broadcast server(s) */
print_r($jd);
sendDataTCP($dest, $jd);
Exemplo n.º 3
0
    $hostname = substr($hostname, 3);
}
/* allow overriding hostname */
if ($_SERVER['argc'] == 3) {
    $hostname = $_SERVER['argv'][2];
    $_SERVER['argc']--;
}
if ($_SERVER['argc'] != 2 || false === strpos($_SERVER['argv'][1], ':')) {
    printf("usage: %s hostname:destination[,hostname1:port1,...hostnameN:portN]\n", $_SERVER['argv'][0]);
    return 1;
}
$dest = $_SERVER['argv'][1];
/* modbus registers read from pcp board */
$r = array();
/* current value registers */
$r = $r + getModbusRegisters('localhost', 38, 0, 20);
$jd = array();
$jd[$hostname]['sensors'] = array();
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Input Voltage', 'volts', $r[1] * 0.03418);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Magnetic Switch State', '', $r[6]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Magnetic Switch Latch', '', $r[7]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Sequence Number', '', $r[10]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Ticks', 'seconds', $r[11] * 0.001);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Uptime', 'minutes', $r[12]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Watchdog Timer', 'seconds', $r[13]);
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Packet Date', 'UTC', date("Y-m-d H:i:s"));
$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('Linux Uptime', '', exec("uptime"));
//$jd[$hostname]['sensors'] += pcwx_encodeForBroadcast('802.11 Signal','',exec('iwconfig wlan0 | grep Quality | cut -c 11-'));
/* send data to broadcast server(s) */
print_r($jd);
sendDataTCP($dest, $jd);
Exemplo n.º 4
0
}
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Heatsink Temperature', '°C', $r[13], 'temperature', 'c');
if ($r[14] > 32767) {
    $r[14] -= 65536;
}
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Battery Temperature', '°C', $r[14], 'temperature', 'c');
if ($r[15] > 32767) {
    $r[15] -= 65536;
}
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Ambient Temperature', '°C', $r[15], 'temperature', 'c');
if ($r[16] > 32767) {
    $r[16] -= 65536;
}
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Remote Battery Temperature', '°C', $r[16], 'temperature', 'c');
/* need to write library decoding functions */
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Charge State', '', $r[17]);
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Array Fault', '', $r[18]);
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Battery Voltage, slow', 'VDC', $r[19] * 100 * pow(2, -15));
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Battery Regulator Reference Voltage', 'VDC', $r[20] * 96.667 * pow(2, -15));
/* not working */
/*
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Ah charge, resettable','Ah',($r[21]<<16 + $r[22])*0.1);
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Ah charge, total','Ah',($r[23]<<16 + $r[24])*0.1);

$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('kWh charge','kWh',$r[25]);
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Load State','',$r[26]);
$jd[$hostname]['SunSaverMPPT'] += pcwx_encodeForBroadcast('Load Fault','',$r[27]);
*/
/* send data to broadcast server(s) */
print_r($jd);
sendDataTCP($dest, $jd);