Skip to content

Commit

Permalink
Merge pull request opengd#5 from geeks-r-us/master
Browse files Browse the repository at this point in the history
added support fpr UB2000 LiFePo4 Batteries from PylonTech
  • Loading branch information
opengd authored Mar 8, 2019
2 parents 3ab0c16 + c39a8a3 commit 6f7488f
Show file tree
Hide file tree
Showing 9 changed files with 433 additions and 5 deletions.
3 changes: 2 additions & 1 deletion example/MPI10kWHybrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "solar-sis_mpi",
"version": "1.0.0",
"dependencies": {
"solar-sis": "latest"
"solar-sis": "latest",
"serialport": "4.0.7"
}
}
21 changes: 21 additions & 0 deletions example/PIP4084/calls.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@
"charging_scc_acc": ["device_status", "8", "7", "8"]
}
},
"extended_status": {
"hide": false,
"influx": true,
"cache": true,
"command": "QPIGS2",
"crc16": true,
"response": {
"pv_input_current_2": 1,
"pv_input_voltage_2": 1,
"battery_voltage_from_scc_2": 1,
"pv_charging_power_2": 1,
"device_status_2": 1,
"ac_charging_current": 1,
"ac_charging_power": 1,
"pv_input_current_3": 1,
"pv_input_voltage_3": 1,
"battery_voltage_from_scc_3": 1,
"pv_charging_power_3": 1,
"pv_total_charging_power": 1
}
},
"device_rated_information": {
"command": "QPIRI",
"influx": true,
Expand Down
3 changes: 2 additions & 1 deletion example/PIP4084/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "solar-sis_pip",
"version": "1.0.1",
"dependencies": {
"solar-sis": "latest"
"solar-sis": "latest",
"serialport": "4.0.7"
}
}
223 changes: 223 additions & 0 deletions example/US2000B/calls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
{
"query_config": {
"start_bit": "",
"command_type": "P",
"response_type": "D",
"data_length_bits": 3,
"seperator": " ",
"ending_character": "\r",
"crc_length": 2,
"response_start": "~",
"response_header_length": 14
},
"query": {
"get_analog_value": {
"command": "~20014642E002FFFD0A",
"influx": true,
"cache": true,
"LENID": 2,
"crc16": false,
"variables": {
"Command": 1
},
"response": {
"Ammount_of_Pack": 1,
"Cells_count": 1,
"Cell1_voltage": -2,
"Cell2_voltage": -2,
"Cell3_voltage": -2,
"Cell4_voltage": -2,
"Cell5_voltage": -2,
"Cell6_voltage": -2,
"Cell7_voltage": -2,
"Cell8_voltage": -2,
"Cell9_voltage": -2,
"Cell10_voltage": -2,
"Cell11_voltage": -2,
"Cell12_voltage": -2,
"Cell13_voltage": -2,
"Cell14_voltage": -2,
"Cell15_voltage": -2,
"Temperature_count": 1,
"Temperature_1": -2,
"Temperature_2": -2,
"Temperature_3": -2,
"Temperature_4": -2,
"Temperature_5": -2,
"Pack_current": -2,
"Pack_voltage": 2,
"Pack_remains_mAh": 2,
"User_defined": 1,
"Pack_total_mAh": 2,
"Pack_cycle": 2,
"Cells_count_P2": 1,
"Cell1_voltage_P2": -2,
"Cell2_voltage_P2": -2,
"Cell3_voltage_P2": -2,
"Cell4_voltage_P2": -2,
"Cell5_voltage_P2": -2,
"Cell6_voltage_P2": -2,
"Cell7_voltage_P2": -2,
"Cell8_voltage_P2": -2,
"Cell9_voltage_P2": -2,
"Cell10_voltage_P2": -2,
"Cell11_voltage_P2": -2,
"Cell12_voltage_P2": -2,
"Cell13_voltage_P2": -2,
"Cell14_voltage_P2": -2,
"Cell15_voltage_P2": -2,
"Temperature_count_P2": 1,
"Temperature_1_P2": -2,
"Temperature_2_P2": -2,
"Temperature_3_P2": -2,
"Temperature_4_P2": -2,
"Temperature_5_P2": -2,
"Pack_current_P2": -2,
"Pack_voltage_P2": 2,
"Pack_remains_mAh_P2": 2,
"User_defined_P2": 1,
"Pack_total_mAh_P2": 2,
"Pack_cycle_P2": 2,
"Cells_count_P3": 1,
"Cell1_voltage_P3": -2,
"Cell2_voltage_P3": -2,
"Cell3_voltage_P3": -2,
"Cell4_voltage_P3": -2,
"Cell5_voltage_P3": -2,
"Cell6_voltage_P3": -2,
"Cell7_voltage_P3": -2,
"Cell8_voltage_P3": -2,
"Cell9_voltage_P3": -2,
"Cell10_voltage_P3": -2,
"Cell11_voltage_P3": -2,
"Cell12_voltage_P3": -2,
"Cell13_voltage_P3": -2,
"Cell14_voltage_P3": -2,
"Cell15_voltage_P3": -2,
"Temperature_count_P3": 1,
"Temperature_1_P3": -2,
"Temperature_2_P3": -2,
"Temperature_3_P3": -2,
"Temperature_4_P3": -2,
"Temperature_5_P3": -2,
"Pack_current_P3": -2,
"Pack_voltage_P3": 2,
"Pack_remains_mAh_P3": 2,
"User_defined_P3": 1,
"Pack_total_mAh_P3": 2,
"Pack_cycle_P3": 2,
"Cells_count_P4": 1,
"Cell1_voltage_P4": -2,
"Cell2_voltage_P4": -2,
"Cell3_voltage_P4": -2,
"Cell4_voltage_P4": -2,
"Cell5_voltage_P4": -2,
"Cell6_voltage_P4": -2,
"Cell7_voltage_P4": -2,
"Cell8_voltage_P4": -2,
"Cell9_voltage_P4": -2,
"Cell10_voltage_P4": -2,
"Cell11_voltage_P4": -2,
"Cell12_voltage_P4": -2,
"Cell13_voltage_P4": -2,
"Cell14_voltage_P4": -2,
"Cell15_voltage_P4": -2,
"Temperature_count_P4": 1,
"Temperature_1_P4": -2,
"Temperature_2_P4": -2,
"Temperature_3_P4": -2,
"Temperature_4_P4": -2,
"Temperature_5_P4": -2,
"Pack_current_P4": -2,
"Pack_voltage_P4": 2,
"Pack_remains_mAh_P4": 2,
"User_defined_P4": 1,
"Pack_total_mAh_P4": 2,
"Pack_cycle_P4": 2
},
"MQTTConfig": {
"Pack_current": 1,
"Pack_current_P2": 1,
"Pack_current_P3": 1,
"Pack_current_P4": 1,
"Pack_remains_mAh": 2,
"Pack_remains_mAh_P2": 2,
"Pack_remains_mAh_P3": 2,
"Pack_remains_mAh_P4": 2
}
}
},
"set_config": {
"start_bit": "",
"command_type": "S",
"response_type": "",
"data_length_bits": 0,
"seperator": " ",
"ending_character": "\r",
"crc_length": 2,
"crc16":true,
"response_accept_command": 1,
"response_refuse_command": 0,
"variable_length_fillout": "0",
"response_start": "(",
"response_header_length": 0
},
"set": {
"output_source_priority" : {
"command" : "POP",
"crc16": true,
"variables": {
"source": ""
}
},
"charger_priority": {
"command" : "PCP",
"crc16": true,
"variables" : {
"source" : ""
}
},
"bulk_charging": {
"command" : "PCVV",
"crc16": true,
"variables" : {
"voltage" : ""
}
},
"float_charging": {
"command" : "PBFT",
"crc16": true,
"variables" : {
"voltage" : ""
}
},
"utility_max_charging": {
"command" : "MUCHGC0",
"crc16": true,
"variables" : {
"current" : ""
}
},
"max_charging": {
"command" : "MCHGC0",
"crc16": true,
"variables" : {
"current" : ""
}
},
"back_to_grid": {
"command" : "PBCV",
"crc16": true,
"variables" : {
"voltage" : ""
}
},
"back_to_battery": {
"command" : "PBDV",
"crc16": true,
"variables" : {
"voltage" : ""
}
}
}
}
8 changes: 8 additions & 0 deletions example/US2000B/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "solar-sis_pylon",
"version": "1.0.1",
"dependencies": {
"solar-sis": "latest",
"serialport": "4.0.7"
}
}
87 changes: 87 additions & 0 deletions example/US2000B/project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
'use strict';

var mpi = require("../../index");

var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://localhost')

function MyMpiCallbacks () {
var fr = 0;
var fs = 0;
var ft = 0;

this.power_status = function (qc, data, arr, json, influx) {
//console.log("mpi_power: influx : " + influx);
//mpi.SendDataToInflux('mpi_power ' + influx);

client.publish('solar/pylon', (Number(arr[0]) + Number(arr[1])).toString());
}

this.feeding_grid_power_calibration = function (qc, data, arr) {
//console.log("feeding_grid_power_calibration: " + data);
//console.log("feeding_grid_power_calibration: arr: " + arr);

fr = arr[3];
fs = arr[5];
ft = arr[7];

console.log("fr: " + fr + " fs: " + fs + " ft: " + ft);

if (data) {
mpi.SendDataToInflux('mpi_calibration fas_r=' + fr + ',fas_s=' + fs + ',fas_t=' + ft);
}
}

this.before_f1 = function (values) {
console.log("fr: " + fr + " fs: " + fs + " ft: " + ft);

var watt = values.w;
var fase = values.f;

if (values.a == 1) {
if (fase == 'R') { watt = Number(fr) + Number(watt);}
if (fase == 'S') { watt = Number(fs) + Number(watt);}
if (fase == 'T') { watt = Number(ft) + Number(watt);}
}

console.log('watt: ' + watt + ' fase:' + fase);

return ({"fase" : fase + "ADJ1", "watt" : watt});
}

this.callback_f1 = function (qc, data, arr) {
myMpi.SendQuickCommand("feeding_grid_power_calibration");
}

this.customMerge = function(json, queryValues) {
var c = 0;
var respvalue = 0;
var ByteNum = 0;
//console.log('queryvalues: ' + JSON.stringify(queryValues));
var data = queryValues[0]
var s = JSON.parse(JSON.stringify(json), (key, value) => {
if (typeof value === 'number') {
if (value > 0) {
ByteNum = value;
respvalue = parseInt(data.substring(c, c+2*ByteNum),16);
//console.log("key: " + key + " value: " + value + ' c: ' + c + ' ByteNum: ' + ByteNum + ' respvalue: ' + respvalue);
}
else {
ByteNum = -value;
respvalue = parseInt(data.substring(c, c+2*ByteNum),16);
if (respvalue > 0x7FFF) respvalue = respvalue - 0xFFFF;
//console.log("key: " + key + " value: " + value + ' c: ' + c + ' ByteNum: ' + ByteNum + ' respvalue: ' + respvalue);
}
c+= 2*ByteNum;
return respvalue;
}
else return value;
});

return s;
}
}

var myMpi = new mpi.mpi();
var callbacks = new MyMpiCallbacks();
myMpi.init(callbacks);
Loading

0 comments on commit 6f7488f

Please sign in to comment.