mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 10:49:25 +08:00
修改运行监控显示信息,提交electron代码
This commit is contained in:
3
electron/config/conf.json
Normal file
3
electron/config/conf.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"weburl": "http://118.195.161.113"
|
||||
}
|
||||
BIN
electron/icons/MaterialSymbolsEnergyProgramTimeUsedSharp.png
Normal file
BIN
electron/icons/MaterialSymbolsEnergyProgramTimeUsedSharp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
electron/icons/favicon.ico
Normal file
BIN
electron/icons/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
BIN
electron/icons/icon.ico
Normal file
BIN
electron/icons/icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
electron/icons/yhicon.ico
Normal file
BIN
electron/icons/yhicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
85
electron/main.js
Normal file
85
electron/main.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const { app, BrowserWindow, Menu, globalShortcut } = require('electron')
|
||||
|
||||
// 在主进程中
|
||||
const fs = require('fs').promises; // 使用 Promise 版本的 fs API
|
||||
const path = require('path');
|
||||
|
||||
const configPath = path.join(__dirname, 'config/conf.json'); // 建议使用 path.join 构造路径
|
||||
|
||||
|
||||
async function readConfig() {
|
||||
try {
|
||||
const data = await fs.readFile(configPath, 'utf8');
|
||||
const config = JSON.parse(data);
|
||||
return config;
|
||||
} catch (error) {
|
||||
console.error('read config file error:', error);
|
||||
// 处理错误,例如返回默认配置或抛出异常
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 保持一个对于 window 对象的全局引用,
|
||||
// window 会被自动地关闭
|
||||
var mainWindow = null
|
||||
Menu.setApplicationMenu(null);
|
||||
|
||||
function createWindow() {
|
||||
//当app准备好后,执行createWindow创建窗口
|
||||
mainWindow = new BrowserWindow({
|
||||
x: 0, //窗口位置x坐标
|
||||
y: 0, //窗口位置y坐标
|
||||
width: 1920, //窗口宽度
|
||||
height: 1080, //窗口高度
|
||||
title: '能源站监控与运行管理平台',
|
||||
autoHideMenuBar: true, //自动隐藏菜单档
|
||||
alwaysOnTop: false, //置顶
|
||||
show: false, // hide the window
|
||||
webPreferences: {
|
||||
partition: String(+new Date())
|
||||
},
|
||||
})
|
||||
|
||||
readConfig().then((data) => {
|
||||
console.log('read CONFIG:', data);
|
||||
//加载页面
|
||||
mainWindow.loadURL(data.weburl) // 'http://127.0.0.1:19601'
|
||||
});
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
})
|
||||
|
||||
//注册Ctr+x事件
|
||||
const ret = globalShortcut.register('CommandOrControl+F12', () => {
|
||||
console.log('CommandOrControl+F12 is pressed')
|
||||
mainWindow.setFullScreen(!mainWindow.isFullScreen())
|
||||
})
|
||||
|
||||
if (!ret) {
|
||||
console.log('registration failed')
|
||||
}
|
||||
|
||||
// 验证是否注册成功
|
||||
console.log("regist Ctrl+F12:", globalShortcut.isRegistered('CommandOrControl+F12'))
|
||||
// app.on('activate', function () {
|
||||
// // On macOS it's common to re-create a window in the app when the
|
||||
// // dock icon is clicked and there are no other windows open.
|
||||
// if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
// })
|
||||
}
|
||||
|
||||
app.on('ready', () => { createWindow() })
|
||||
app.whenReady().then();
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function () {
|
||||
// Unregister a shortcut.
|
||||
globalShortcut.unregister('F12')
|
||||
|
||||
// Unregister all shortcuts.
|
||||
globalShortcut.unregisterAll()
|
||||
// On macOS it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
17
electron/package.json
Normal file
17
electron/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "essclient",
|
||||
"version": "1.0.0",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "electron .",
|
||||
"package": "electron-packager . essclient --win --arch=x64 --out=dist --icon=icons/icon.ico --ignore=node_modules --overwrite --asar --electron-zip-dir=C:/Users/lixy/AppData/Local/electron/Cache/"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"devDependencies": {
|
||||
"electron": "^38.1.0",
|
||||
"electron-packager": "^17.1.2"
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
//std::vector<std::vector<std::string>> vecElectPeriods;
|
||||
|
||||
// 场站信息
|
||||
std::unordered_map<int, std::shared_ptr<Station>> mapStation;
|
||||
std::map<int, std::shared_ptr<Station>> mapStation;
|
||||
|
||||
// 角色信息
|
||||
std::unordered_map<int, std::shared_ptr<Role>> mapRole;
|
||||
|
||||
@@ -207,15 +207,69 @@ void Station::setGarewayWorkMode()
|
||||
string Station::getGatewayMode()
|
||||
{
|
||||
// 0:手动,1:峰谷套利,2:增网配容,3:应急供电,4:并网保电,5:自定时段
|
||||
if (workModeGateway == 0) { return "手动"; }
|
||||
else if (workModeGateway == 1) { return "峰谷套利"; }
|
||||
else if (workModeGateway == 2) { return "增网配容"; }
|
||||
else if (workModeGateway == 3) { return "应急供电"; }
|
||||
else if (workModeGateway == 4) { return "并网保电"; }
|
||||
else if (workModeGateway == 5) { return "自定时段"; }
|
||||
if (gatewayParam.mode == 0) { return "手动"; }
|
||||
else if (gatewayParam.mode == 1) { return "峰谷套利"; }
|
||||
else if (gatewayParam.mode == 2) { return "增网配容"; }
|
||||
else if (gatewayParam.mode == 3) { return "应急供电"; }
|
||||
else if (gatewayParam.mode == 4) { return "并网保电"; }
|
||||
else if (gatewayParam.mode == 5) { return "自定时段"; }
|
||||
else { return "--"; };
|
||||
}
|
||||
|
||||
static map<int, string> mapPeriodType =
|
||||
{
|
||||
{1, "谷"}, {2, "平"}, {3, "峰"}, {4, "尖"}
|
||||
};
|
||||
static map<int, string> mapPeriodOper =
|
||||
{
|
||||
{0, "停"}, {1, "充"}, {2, "充"}, {3, "放"}, {4, "放"}
|
||||
};
|
||||
|
||||
string Station::getGatewayParam()
|
||||
{
|
||||
stringstream ss;
|
||||
std::string str1 = "峰谷套利时段:<br>";
|
||||
std::string str2 = "自定时段:<br>";
|
||||
{
|
||||
njson json;
|
||||
if (JSON::parse(gatewayParam.param1, json))
|
||||
{
|
||||
for (int i = 0; i<json.size(); ++i)
|
||||
{
|
||||
str1 += "    " + std::to_string(i+1) + "月: ";
|
||||
|
||||
ss.str("");
|
||||
for (auto& jsonitem : json[i])
|
||||
{
|
||||
ss << "(" << setw(2) << setfill('0') << jsonitem[0].get<int>();
|
||||
ss << ":" << setw(2) << setfill('0') << jsonitem[1].get<int>() << " ";
|
||||
ss << mapPeriodType[jsonitem[2].get<int>()] << ") ";
|
||||
}
|
||||
str1 += ss.str() + "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
njson json;
|
||||
if (JSON::parse(gatewayParam.param2, json))
|
||||
{
|
||||
for (int i = 0; i<json.size(); ++i)
|
||||
{
|
||||
str2 += "    时段" + std::to_string(i+1) + ": ";
|
||||
ss.str("");
|
||||
for (auto& jsonitem : json[i])
|
||||
{
|
||||
ss << "(" << setw(2) << setfill('0') << jsonitem[0].get<int>();
|
||||
ss << ":" << setw(2) << setfill('0') << jsonitem[1].get<int>() << " ";
|
||||
ss << mapPeriodOper[jsonitem[2].get<int>()] << ") ";
|
||||
}
|
||||
str2 += ss.str() + "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
return str1 + "<br/>" + str2;
|
||||
}
|
||||
|
||||
void Station::checkDevice()
|
||||
{
|
||||
for (auto& item: mapDevice)
|
||||
@@ -263,14 +317,37 @@ void Station::readRuntimeData(int deviceNo, string addr, int val)
|
||||
statData.ts = Utils::time();
|
||||
if (addr == "0x002F") { statData.dayElectIn = val; } //日充电电量 R uint32 1kWh 0x002F
|
||||
else if (addr == "0x0031") { statData.dayElectOut = val; } //日放电电量 R uint32 1kWh 0x0031
|
||||
else if (addr == "0x0033") { statData.dayFeeIn = val; } //日充电费用 R uint32 1RMB 0x0033
|
||||
else if (addr == "0x0033") { statData.dayFeeIn = val; } //日充电费用 R uint32 1RMB 0x0033
|
||||
else if (addr == "0x0035") { statData.dayFeeOut = val; } //日放电费用 R uint32 1RMB 0x0035
|
||||
else if (addr == "0x0037") { statData.dayIncome = val; } //日收益 R int32 1RMB 0x0037
|
||||
else if (addr == "0x004D") { statData.totalElectIn = val; } //总充电电量 R uint32 1kWh 0x004D
|
||||
else if (addr == "0x004F") { statData.totalElectOut = val; } //总放电电量 R uint32 1kWh 0x004F
|
||||
else if (addr == "0x0051") { statData.totalFeeIn = val; } //总充电费用 R uint32 1RMB 0x0051
|
||||
else if (addr == "0x0053") { statData.totalFeeOut = val; } //总放电费用 R uint32 1RMB 0x0053
|
||||
else if (addr == "0x0051") { statData.totalFeeIn = val; } //总充电费用 R uint32 1RMB 0x0051
|
||||
else if (addr == "0x0053") { statData.totalFeeOut = val; } //总放电费用 R uint32 1RMB 0x0053
|
||||
else if (addr == "0x0055") { statData.totalIncome = val; } //总收益 R int32 1RMB 0x0055
|
||||
|
||||
else if (addr == "0x0039") { statData.dayElectIn_J = val; } //日正向尖有功电能 R uint32 1kWh 0x0039
|
||||
else if (addr == "0x003B") { statData.dayElectIn_F = val; } //日正向峰有功电能 R uint32 1kWh 0x003B
|
||||
else if (addr == "0x003D") { statData.dayElectIn_P = val; } //日正向平有功电能 R uint32 1kWh 0x003D
|
||||
else if (addr == "0x003F") { statData.dayElectIn_G = val; } //日正向谷有功电能 R uint32 1kWh 0x003F
|
||||
else if (addr == "0x0041") { statData.dayElectIn_Total = val; } //日正向总有功电能 R uint32 1kWh 0x0041
|
||||
|
||||
else if (addr == "0x0043") { statData.dayElectOut_J = val; } //日反向尖有功电能 R uint32 1kWh 0x0043
|
||||
else if (addr == "0x0045") { statData.dayElectOut_F = val; } //日反向峰有功电能 R uint32 1kWh 0x0045
|
||||
else if (addr == "0x0047") { statData.dayElectOut_P = val; } //日反向平有功电能 R uint32 1kWh 0x0047
|
||||
else if (addr == "0x0049") { statData.dayElectOut_G = val; } //日反向谷有功电能 R uint32 1kWh 0x0049
|
||||
else if (addr == "0x004B") { statData.dayElectOut_Total = val; } //日反向总有功电能 R uint32 1kWh 0x004B
|
||||
|
||||
else if (addr == "0x0057") { statData.totalElectIn_J = val; } //总正向尖有功电能 R uint32 1kWh 0x0057
|
||||
else if (addr == "0x0059") { statData.totalElectIn_F = val; } //总正向峰有功电能 R uint32 1kWh 0x0059
|
||||
else if (addr == "0x005B") { statData.totalElectIn_P = val; } //总正向平有功电能 R uint32 1kWh 0x005B
|
||||
else if (addr == "0x005D") { statData.totalElectIn_G = val; } //总正向谷有功电能 R uint32 1kWh 0x005D
|
||||
else if (addr == "0x005F") { statData.totalElectIn_Total = val; } //总正向总有功电能 R uint32 1kWh 0x005F
|
||||
else if (addr == "0x0061") { statData.totalElectOut_J = val; } //总反向尖有功电能 R uint32 1kWh 0x0061
|
||||
else if (addr == "0x0063") { statData.totalElectOut_F = val; } //总反向峰有功电能 R uint32 1kWh 0x0063
|
||||
else if (addr == "0x0065") { statData.totalElectOut_P = val; } //总反向平有功电能 R uint32 1kWh 0x0065
|
||||
else if (addr == "0x0067") { statData.totalElectOut_G = val; } //总反向谷有功电能 R uint32 1kWh 0x0067
|
||||
else if (addr == "0x0069") { statData.totalElectOut_Total = val; } //总反向总有功电能 R uint32 1kWh 0x0069
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,9 +419,12 @@ void Station::readCoolingData(int deviceNo, string addr, int val)
|
||||
else if (addr == "0x100E") { ; }// 出水压力传感器 R uint16 0:正常,1:告警 0x100E
|
||||
}
|
||||
|
||||
void Station::readGatewayMode(int mode)
|
||||
void Station::readGatewayMode(int mode, string p1, string p2, string p3)
|
||||
{
|
||||
this->workModeGateway = mode;
|
||||
this->gatewayParam.mode = mode;
|
||||
this->gatewayParam.param1 = p1;
|
||||
this->gatewayParam.param2 = p2;
|
||||
this->gatewayParam.param3 = p3;
|
||||
if (mode != this->workMode)
|
||||
{
|
||||
//this->setGarewayWorkMode();
|
||||
@@ -464,34 +544,6 @@ void Station::writeStatistic()
|
||||
|
||||
if (statData.ts > 0)
|
||||
{
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
fields.set("station_id", this->stationId);
|
||||
fields.set("device_id", 0);
|
||||
fields.set("elect_in", statData.dayElectIn);
|
||||
fields.set("elect_out", statData.dayElectOut);
|
||||
fields.set("fee_in", statData.dayFeeIn);
|
||||
fields.set("fee_out", statData.dayFeeOut);
|
||||
fields.set("income", statData.dayIncome);
|
||||
//fields.set("num_in", "");
|
||||
//fields.set("num_out", "");
|
||||
//fields.set("num_err", "");
|
||||
//fields.set("t_in", "");
|
||||
//fields.set("t_out", "");
|
||||
//fields.set("usage_rate", "");
|
||||
fields.set("elect_in_total", statData.totalElectIn);
|
||||
fields.set("elect_out_total", statData.totalElectOut);
|
||||
fields.set("fee_in_total", statData.totalFeeIn);
|
||||
fields.set("fee_out_total", statData.totalFeeOut);
|
||||
fields.set("income_total", statData.totalIncome);
|
||||
|
||||
dao->setTableName("stat_storage");
|
||||
std::vector<std::string> vecKeys = {
|
||||
"elect_in", "elect_out", "num_in", "num_out", "num_err", "t_in", "t_out", "usage_rate", "fee_in", "fee_out",
|
||||
"elect_in_total", "elect_out_total", "fee_in_total", "fee_out_total", "income_total"
|
||||
};
|
||||
dao->duplicateUpdate(fields, vecKeys);
|
||||
|
||||
{ // stat_day
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
@@ -503,14 +555,54 @@ void Station::writeStatistic()
|
||||
}
|
||||
{
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
fields.set("station_id", this->stationId);
|
||||
fields.set("elect_in", statData.dayElectIn);
|
||||
fields.set("elect_out", statData.dayElectOut);
|
||||
fields.set("income", statData.dayIncome);
|
||||
fields.set("E_in", statData.totalElectIn);
|
||||
fields.set("E_in_J", statData.totalElectIn_J);
|
||||
fields.set("E_in_F", statData.totalElectIn_F);
|
||||
fields.set("E_in_P", statData.totalElectIn_P);
|
||||
fields.set("E_in_G", statData.totalElectIn_G);
|
||||
fields.set("E_out", statData.totalElectOut);
|
||||
fields.set("E_out_J", statData.totalElectOut_J);
|
||||
fields.set("E_out_F", statData.totalElectOut_F);
|
||||
fields.set("E_out_P", statData.totalElectOut_P);
|
||||
fields.set("E_out_G", statData.totalElectOut_G);
|
||||
fields.set("fee_in", statData.totalFeeIn);
|
||||
fields.set("fee_Out", statData.totalFeeOut);
|
||||
fields.set("income", statData.totalIncome);
|
||||
dao->setTableName("stat_total");
|
||||
dao->duplicateUpdate(fields, {"elect_in", "elect_out", "income"});
|
||||
}
|
||||
|
||||
dao->duplicateUpdate(fields, {
|
||||
"E_in", "E_in_J", "E_in_F", "E_in_P", "E_in_G",
|
||||
"E_out", "E_out_J", "E_out_F", "E_out_P", "E_out_G",
|
||||
"fee_in", "fee_Out", "income"
|
||||
});
|
||||
}
|
||||
{
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
fields.set("station_id", this->stationId);
|
||||
fields.set("E_in", statData.dayElectIn);
|
||||
fields.set("E_in_J", statData.dayElectIn_J);
|
||||
fields.set("E_in_F", statData.dayElectIn_F);
|
||||
fields.set("E_in_P", statData.dayElectIn_P);
|
||||
fields.set("E_in_G", statData.dayElectIn_G);
|
||||
fields.set("E_out", statData.dayElectOut);
|
||||
fields.set("E_out_J", statData.dayElectOut_J);
|
||||
fields.set("E_out_F", statData.dayElectOut_F);
|
||||
fields.set("E_out_P", statData.dayElectOut_P);
|
||||
fields.set("E_out_G", statData.dayElectOut_G);
|
||||
fields.set("fee_in", statData.dayFeeIn);
|
||||
fields.set("fee_Out", statData.dayFeeOut);
|
||||
fields.set("income", statData.dayIncome);
|
||||
dao->setTableName("stat_total_day");
|
||||
|
||||
dao->duplicateUpdate(fields, {
|
||||
"E_in", "E_in_J", "E_in_F", "E_in_P", "E_in_G",
|
||||
"E_out", "E_out_J", "E_out_F", "E_out_P", "E_out_G",
|
||||
"fee_in", "fee_Out", "income"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -532,5 +624,4 @@ void Station::writeStatistic()
|
||||
fields.set("value", MapValueToJson(npos, mapCacheElectCharger));
|
||||
dao->duplicateUpdate(fields, {"value"});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,13 +116,14 @@ public:
|
||||
void checkDevice();
|
||||
|
||||
string getGatewayMode();
|
||||
string getGatewayParam();
|
||||
|
||||
void readAlert(std::shared_ptr<Device> device, std::string addr, int v, std::string text);
|
||||
void readRuntimeData(int deviceNo, string addr, int val);
|
||||
void readTHData(int deviceNo, string addr, int val);
|
||||
void readFire40Data(int deviceNo, string addr, int val);
|
||||
void readCoolingData(int deviceNo, string addr, int val);
|
||||
void readGatewayMode(int mode);
|
||||
void readGatewayMode(int mode, string p1, string p2, string p3);
|
||||
void readGatewayStatus(int cdzStatus, int emuStatus);
|
||||
|
||||
void setCache(int datatype, std::vector<float>& vd);
|
||||
@@ -144,9 +145,16 @@ public:
|
||||
bool isConnected {false};
|
||||
|
||||
int workMode {}; // 运行模式
|
||||
int workModeGateway { -1 }; // 运行模式
|
||||
int runPolicyId {}; // 运行策略
|
||||
|
||||
|
||||
struct {
|
||||
int mode {-1}; // 运行模式
|
||||
std::string param1;
|
||||
std::string param2;
|
||||
std::string param3;
|
||||
} gatewayParam;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 系统统计 ===
|
||||
// 累计发电量,单位:kWh
|
||||
@@ -163,22 +171,6 @@ public:
|
||||
// 储能容量
|
||||
double capacity {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 日统计 ===
|
||||
//double storageIn {}; // 储能充电电量
|
||||
//double storageOut {}; // 储能放电电量
|
||||
//int storageNumIn {}; // 储能充电次数
|
||||
//int storageNumOut {}; // 储能放电次数
|
||||
//int storageNumErr {}; // 储能故障次数
|
||||
//double solarGen {}; // 光伏发电电量
|
||||
//double solarGrid {}; // 光伏入网电量
|
||||
//int solarNumErr {}; // 光伏故障次数
|
||||
//double chargeElect {}; // 充电设备充电电量
|
||||
//int chargeNum {}; // 充电设备充电次数
|
||||
//int chargeNumErr {}; // 充电设备故障次数
|
||||
//double incomeElect {}; // 发电收益金额
|
||||
//double incomeCharge {}; // 充电收益金额
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// === 环境 ===
|
||||
// 光照度
|
||||
@@ -220,45 +212,41 @@ public:
|
||||
struct {
|
||||
int64_t ts {0};
|
||||
|
||||
float totalElectIn {0.0}; //总充电电量 R uint32 1kWh 6659(0x112D) 0x112C
|
||||
float totalElectOut {0.0}; //总放电电量 R uint32 1kWh 4925(0x112F) 0x112E
|
||||
float totalFeeIn {0.0}; //总充电费用 R uint32 1RMB 6605(0x1131) 0x1130
|
||||
float totalFeeOut {0.0}; //总放电费用 R uint32 1RMB 4949(0x1133) 0x1132
|
||||
float totalIncome {0.0}; //总收益 R int32 1RMB -1 0x1134
|
||||
//储能充放电时段hh R uint16 时 336 0x01 0x121C
|
||||
//储能充放电时段mm R uint16 分 0 0x01 0x121D
|
||||
//储能充放电时段ss R uint16 秒 0 0x01 0x121E
|
||||
float dayElectIn {0.0}; // 日充电电量 R uint32 1kWh 0x002F
|
||||
float dayElectOut {0.0}; // 日放电电量 R uint32 1kWh 0x0031
|
||||
float dayFeeIn {0.0}; // 日充电费用 R uint32 1RMB 0x0033
|
||||
float dayFeeOut {0.0}; // 日放电费用 R uint32 1RMB 0x0035
|
||||
float dayIncome {0.0}; // 日收益 R int32 1RMB 0x0037
|
||||
|
||||
float dayElectIn_J {0.0}; //日正向尖有功电能 R uint32 1kWh 0x0039
|
||||
float dayElectIn_F {0.0}; //日正向峰有功电能 R uint32 1kWh 0x003B
|
||||
float dayElectIn_P {0.0}; //日正向平有功电能 R uint32 1kWh 0x003D
|
||||
float dayElectIn_G {0.0}; //日正向谷有功电能 R uint32 1kWh 0x003F
|
||||
float dayElectIn_Total {0.0};//日正向总有功电能 R uint32 1kWh 0x0041
|
||||
|
||||
float totalDurationIn {0.0};
|
||||
float totalDurationOut {0.0};
|
||||
float dayElectOut_J {0.0}; //日反向尖有功电能 R uint32 1kWh 0x0043
|
||||
float dayElectOut_F {0.0}; //日反向峰有功电能 R uint32 1kWh 0x0045
|
||||
float dayElectOut_P {0.0}; //日反向平有功电能 R uint32 1kWh 0x0047
|
||||
float dayElectOut_G {0.0}; //日反向谷有功电能 R uint32 1kWh 0x0049
|
||||
float dayElectOut_Total {0.0}; //日反向总有功电能 R uint32 1kWh 0x004B
|
||||
|
||||
float dayElectIn {0.0}; // 日充电电量 R uint32 1kWh 0 0x110E
|
||||
float dayElectOut {0.0}; // 日放电电量 R uint32 1kWh 0 0x1110
|
||||
float dayFeeIn {0.0}; // 日充电费用 R uint32 1RMB 0 0x1112
|
||||
float dayFeeOut {0.0}; // 日放电费用 R uint32 1RMB 0 0x1114
|
||||
float dayIncome {0.0}; // 日收益 R int32 1RMB 0 0x1116
|
||||
float totalElectIn {0.0}; // 总充电电量 R uint32 1kWh 0x004D
|
||||
float totalElectOut {0.0}; // 总放电电量 R uint32 1kWh 0x004F
|
||||
float totalFeeIn {0.0}; // 总充电费用 R uint32 1RMB 0x0051
|
||||
float totalFeeOut {0.0}; // 总放电费用 R uint32 1RMB 0x0053
|
||||
float totalIncome {0.0}; // 总收益 R int32 1RMB 0x0055
|
||||
|
||||
//日正向尖有功电能 R uint32 1kWh 0x0039
|
||||
//日正向峰有功电能 R uint32 1kWh 0x003B
|
||||
//日正向平有功电能 R uint32 1kWh 0x003D
|
||||
//日正向谷有功电能 R uint32 1kWh 0x003F
|
||||
//日正向总有功电能 R uint32 1kWh 0x0041
|
||||
//日反向尖有功电能 R uint32 1kWh 0x0043
|
||||
//日反向峰有功电能 R uint32 1kWh 0x0045
|
||||
//日反向平有功电能 R uint32 1kWh 0x0047
|
||||
//日反向谷有功电能 R uint32 1kWh 0x0049
|
||||
//日反向总有功电能 R uint32 1kWh 0x004B
|
||||
float totalElectIn_J {0.0}; //总正向尖有功电能 R uint32 1kWh 0x0057
|
||||
float totalElectIn_F {0.0}; //总正向峰有功电能 R uint32 1kWh 0x0059
|
||||
float totalElectIn_P {0.0}; //总正向平有功电能 R uint32 1kWh 0x005B
|
||||
float totalElectIn_G {0.0}; //总正向谷有功电能 R uint32 1kWh 0x005D
|
||||
float totalElectIn_Total {0.0}; //总正向总有功电能 R uint32 1kWh 0x005F
|
||||
|
||||
//总正向尖有功电能 R uint32 1kWh 0x0057
|
||||
//总正向峰有功电能 R uint32 1kWh 0x0059
|
||||
//总正向平有功电能 R uint32 1kWh 0x005B
|
||||
//总正向谷有功电能 R uint32 1kWh 0x005D
|
||||
//总正向总有功电能 R uint32 1kWh 0x005F
|
||||
//总反向尖有功电能 R uint32 1kWh 0x0061
|
||||
//总反向峰有功电能 R uint32 1kWh 0x0063
|
||||
//总反向平有功电能 R uint32 1kWh 0x0065
|
||||
//总反向谷有功电能 R uint32 1kWh 0x0067
|
||||
//总反向总有功电能 R uint32 1kWh 0x0069
|
||||
float totalElectOut_J {0.0}; //总反向尖有功电能 R uint32 1kWh 0x0061
|
||||
float totalElectOut_F {0.0}; //总反向峰有功电能 R uint32 1kWh 0x0063
|
||||
float totalElectOut_P {0.0}; //总反向平有功电能 R uint32 1kWh 0x0065
|
||||
float totalElectOut_G {0.0}; //总反向谷有功电能 R uint32 1kWh 0x0067
|
||||
float totalElectOut_Total {0.0}; //总反向总有功电能 R uint32 1kWh 0x0069
|
||||
|
||||
} statData;
|
||||
|
||||
@@ -267,8 +255,8 @@ public:
|
||||
} runtimeData;
|
||||
|
||||
|
||||
int cdzStatus {-1};
|
||||
int emuStatus {-1};
|
||||
int cdzStatus {-1}; // 充电桩 1:在线,0:离线
|
||||
int emuStatus {-1}; // 储能 1:在线,0:离线
|
||||
|
||||
std::map<std::string, int64_t> mapAlertCache;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
int SM2_test()
|
||||
{
|
||||
|
||||
// 未压缩格式(最常见)
|
||||
// 前缀 : 04 (1字节) X坐标 : 32字节(64个十六进制字符), Y坐标 : 32字节(64个十六进制字符),总长度 : 1 + 32 + 32 = 65字节 = 130个十六进制字符
|
||||
std::string hex_pub_key = "04661013d0b881d817085a251f0c0a7024e72c76e6eb0fd22c0170a508b123864ef7514df30cecb45deecf9b35810d0315b5164d63199c971ac3323c228ab48606";
|
||||
@@ -166,6 +167,11 @@ void OpensslSM2_test()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
stringstream ss;
|
||||
|
||||
ss << "(" << setw(2) << setfill('0') << 1;
|
||||
std::cout << ss.str();
|
||||
|
||||
// 设置控制台输出为 UTF-8 编码
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
// 设置控制台输入为 UTF-8 编码(如果需要输入中文)
|
||||
|
||||
@@ -711,13 +711,18 @@ Errcode HttpEntity::queryStationOverview(const httplib::Request& req, njson& jso
|
||||
{
|
||||
return Errcode(ret);
|
||||
}
|
||||
njson jsonStorage = njson::parse(R"({"category":1, "gateway":0, "count":0, "power":0.0})");
|
||||
auto station = Application::data().getStation(Utils::toInt(stationId));
|
||||
jsonStorage["workmode"] = station ? station->getGatewayMode() : "--";
|
||||
|
||||
njson jsonStorage = njson::parse(R"({"category":1, "count":0, "power":0.0})");
|
||||
njson jsonCharge = njson::parse(R"({"category":2, "count":0, "power":0.0})");
|
||||
njson jsonSolar = njson::parse(R"({"category":3, "count":0, "power":0.0})");
|
||||
njson jsonSecurity = njson::parse(R"({"category":4, "count":0, "power":0.0})");
|
||||
//auto station = Application::data().getStation(Utils::toInt(stationId));
|
||||
//if (station)
|
||||
//{
|
||||
// jsonStorage["msg"] = station->getGatewayParam();
|
||||
// jsonStorage["workmode"] = station->getGatewayMode();
|
||||
// jsonStorage["emu"] = station->emuStatus == 1 ? "在线" : (station->emuStatus == 0 ? "离线" : "--");
|
||||
// jsonStorage["cdz"] = station->cdzStatus == 1 ? "在线" : (station->cdzStatus == 0 ? "离线" : "--");
|
||||
//}
|
||||
auto videoInfo = Config::getVideoInfo(stationId);
|
||||
if (videoInfo)
|
||||
{
|
||||
@@ -922,6 +927,16 @@ Errcode HttpEntity::queryDevicByCategory(const httplib::Request& req, njson& jso
|
||||
}
|
||||
}
|
||||
json["data"] = jsondata;
|
||||
|
||||
njson jsongateway = njson::object();
|
||||
if (station)
|
||||
{
|
||||
jsongateway["msg"] = station->getGatewayParam();
|
||||
jsongateway["workmode"] = station->getGatewayMode();
|
||||
jsongateway["emu"] = station->emuStatus == 1 ? "在线" : (station->emuStatus == 0 ? "离线" : "--");
|
||||
jsongateway["cdz"] = station->cdzStatus == 1 ? "在线" : (station->cdzStatus == 0 ? "离线" : "--");
|
||||
}
|
||||
json["gateway"] = jsongateway;
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
@@ -1011,6 +1026,7 @@ Errcode HttpEntity::queryPolicyByType(const httplib::Request& req, njson& json,
|
||||
std::string sql = "SELECT policy_id, `type`, name from policy WHERE `type`='" + type + "';";
|
||||
std::vector<Fields> result;
|
||||
int ret = DaoEntity::execOnce(sql, result);
|
||||
json["data"] = FieldsToJsonArray(result);
|
||||
return Errcode(ret);
|
||||
}
|
||||
|
||||
@@ -1080,14 +1096,14 @@ Errcode HttpEntity::queryStatSystem(const httplib::Request& req, njson& json, st
|
||||
{
|
||||
auto& appdata = Application::data();
|
||||
|
||||
double incomeTotal {};
|
||||
double station_num = appdata.getStationCount();
|
||||
double solarDeviceNum {};
|
||||
double capacityTotal {};
|
||||
double electGenTotal {};
|
||||
double electGridTotal {};
|
||||
double electStorageIn {};
|
||||
double electStorageOut {};
|
||||
float incomeTotal {};
|
||||
float station_num = appdata.getStationCount();
|
||||
float solarDeviceNum {};
|
||||
float capacityTotal {};
|
||||
float electGenTotal {};
|
||||
float electGridTotal {};
|
||||
float electStorageIn {};
|
||||
float electStorageOut {};
|
||||
for (auto& item : appdata.mapStation)
|
||||
{
|
||||
auto& station = item.second;
|
||||
@@ -1111,6 +1127,14 @@ Errcode HttpEntity::queryStatSystem(const httplib::Request& req, njson& json, st
|
||||
jsondata["storage_elect_in"] = electStorageIn; // : 储能充电总电量(kWh),精度0.001
|
||||
jsondata["storage_elect_out"] = electStorageOut; // : 储能放电总电量(kWh),精度0.001
|
||||
|
||||
std::string sql = "SELECT SUM(income_elect) income_total FROM stat_day;";
|
||||
std::vector<Fields> result;
|
||||
DAO::exec(NULL, sql, result);
|
||||
if (result.size() > 0)
|
||||
{
|
||||
jsondata["income_total"] = result[0].get<float>("income_total");
|
||||
}
|
||||
|
||||
json["data"] = jsondata;
|
||||
return Errcode::OK;
|
||||
}
|
||||
|
||||
@@ -298,18 +298,16 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
|
||||
|
||||
if (command == "Gateway_YC")
|
||||
{
|
||||
for (auto& item: json.items())
|
||||
{
|
||||
std::string key = item.key();
|
||||
auto& val = item.value();
|
||||
if (key == "40001")
|
||||
{
|
||||
station->readGatewayMode(val.get<int>());
|
||||
}
|
||||
//else if (key == "40002") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "峰谷时间段"); }
|
||||
//else if (key == "40021") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "自定时间段"); }
|
||||
//else if (key == "40038") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "其他参数"); }
|
||||
}
|
||||
int mode = -1;
|
||||
std::string param1;
|
||||
std::string param2;
|
||||
std::string param3 = json.dump();
|
||||
|
||||
JSON::read(json, "40001", mode);
|
||||
if (json.contains("40002")) { param1 = json["40002"].dump(); }
|
||||
if (json.contains("40021")) { param2 = json["40021"].dump(); }
|
||||
if (json.contains("40038")) { param3 = json["40038"].dump(); }
|
||||
station->readGatewayMode(mode, param1, param2, param3);
|
||||
}
|
||||
else if (command == "Gateway_YX")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user