mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#include "Station.h"
|
|
#include "database/DAO.h"
|
|
#include "database/SQL.h"
|
|
|
|
Station::Station(int id) : id(id)
|
|
{
|
|
}
|
|
|
|
void Station::addDevice(int deviceId, std::shared_ptr<Device> device)
|
|
{
|
|
mapDevice_[deviceId] = device;
|
|
}
|
|
|
|
std::shared_ptr<Device> Station::getDevice(int deviceId)
|
|
{
|
|
auto iter = mapDevice_.find(deviceId);
|
|
if (iter!=mapDevice_.end())
|
|
{
|
|
return iter->second;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void Station::setWorkMode(int modeId)
|
|
{
|
|
std::string sql = SQL(SQL::TYPE::update).table(DMStation::TABLENAME)
|
|
.update(DMStation::WORK_MODE_ID, std::to_string(modeId))
|
|
.where(DMStation::STATION_ID + "=" + std::to_string(id)).str();
|
|
Errcode err = DAO::exec(NULL, sql);
|
|
if (err != Errcode::OK)
|
|
{
|
|
XLOGE() << "set station work mode failed.";
|
|
}
|
|
}
|
|
|
|
void Station::setPolicy(int policyId)
|
|
{
|
|
std::string sql = SQL(SQL::TYPE::update).table(DMStation::TABLENAME)
|
|
.update(DMStation::POLICY_ID, std::to_string(policyId))
|
|
.where(DMStation::STATION_ID + "=" + std::to_string(id)).str();
|
|
Errcode err = DAO::exec(NULL, sql);
|
|
if (err != Errcode::OK)
|
|
{
|
|
XLOGE() << "set station policy failed.";
|
|
}
|
|
} |