mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
修改HTTP接口测试问题
This commit is contained in:
@@ -35,7 +35,7 @@ void Station::setFields(Fields& fields)
|
||||
{
|
||||
this->stationId = fields.get<int>(DMStation::STATION_ID);
|
||||
this->name = fields.value(DMStation::NAME);
|
||||
this->energyCapacity = fields.get<double>(DMStation::CAPACITY);
|
||||
this->capacity = fields.get<double>(DMStation::CAPACITY);
|
||||
this->workModeId = fields.get<int>(DMStation::WORK_MODE);
|
||||
this->code = fields.value(DMStation::CODE);
|
||||
this->status = fields.get<int>(DMStation::STATUS);
|
||||
@@ -47,6 +47,22 @@ void Station::addDevice(int deviceId, std::shared_ptr<Device> device)
|
||||
mapDeviceGroup[device->category].push_back(device);
|
||||
}
|
||||
|
||||
void Station::addDevice(Fields& fields)
|
||||
{
|
||||
int deviceId = fields.get<int>(DMDevice::DEVICE_ID);
|
||||
int stationId = fields.get<int>(DMDevice::STATION_ID);
|
||||
if (mapDevice.find(deviceId) != mapDevice.end())
|
||||
{
|
||||
mapDevice[deviceId]->setFields(fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto device = Device::create(fields);
|
||||
mapDevice[deviceId] = device;
|
||||
mapDeviceGroup[device->category].push_back(device);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Device> Station::getDevice(int deviceId)
|
||||
{
|
||||
auto iter = mapDevice.find(deviceId);
|
||||
@@ -82,8 +98,13 @@ void Station::getDeviceByType(int deviceType, std::vector<std::shared_ptr<Device
|
||||
}
|
||||
}
|
||||
|
||||
int Station::getDeviceNumByGroup(int category)
|
||||
int Station::getDeviceCount(int category)
|
||||
{
|
||||
auto iter = mapDeviceGroup.find(category);
|
||||
if (iter != mapDeviceGroup.end())
|
||||
{
|
||||
return iter->second.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -159,3 +180,12 @@ void Station::writeRuntimeData(std::string dt, int npos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Station::polling()
|
||||
{
|
||||
if (mqttCli)
|
||||
{
|
||||
mqttCli->polling();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user