Code Refactoring: Add inverter reference to each command
Instead of just adding the target_address to a command this patch adds a reference to the whole inverter instance
This commit is contained in:
parent
6358b1ebee
commit
6a7bed0ecf
@ -22,9 +22,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<T> prepareCommand()
|
std::shared_ptr<T> prepareCommand(InverterAbstract* inv)
|
||||||
{
|
{
|
||||||
return std::make_shared<T>();
|
return std::make_shared<T>(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -25,8 +25,8 @@ ID Target Addr Source Addr Cmd SCmd ? Limit Type CRC16 CRC8
|
|||||||
|
|
||||||
#define CRC_SIZE 6
|
#define CRC_SIZE 6
|
||||||
|
|
||||||
ActivePowerControlCommand::ActivePowerControlCommand(const uint64_t target_address, const uint64_t router_address)
|
ActivePowerControlCommand::ActivePowerControlCommand(InverterAbstract* inv, const uint64_t router_address)
|
||||||
: DevControlCommand(target_address, router_address)
|
: DevControlCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
_payload[10] = 0x0b;
|
_payload[10] = 0x0b;
|
||||||
_payload[11] = 0x00;
|
_payload[11] = 0x00;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ typedef enum { // ToDo: to be verified by field tests
|
|||||||
|
|
||||||
class ActivePowerControlCommand : public DevControlCommand {
|
class ActivePowerControlCommand : public DevControlCommand {
|
||||||
public:
|
public:
|
||||||
explicit ActivePowerControlCommand(const uint64_t target_address = 0, const uint64_t router_address = 0);
|
explicit ActivePowerControlCommand(InverterAbstract* inv, const uint64_t router_address = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -23,8 +23,8 @@ ID Target Addr Source Addr Idx DT ? Time Gap AlarmId Pa
|
|||||||
#include "AlarmDataCommand.h"
|
#include "AlarmDataCommand.h"
|
||||||
#include "inverters/InverterAbstract.h"
|
#include "inverters/InverterAbstract.h"
|
||||||
|
|
||||||
AlarmDataCommand::AlarmDataCommand(const uint64_t target_address, const uint64_t router_address, const time_t time)
|
AlarmDataCommand::AlarmDataCommand(InverterAbstract* inv, const uint64_t router_address, const time_t time)
|
||||||
: MultiDataCommand(target_address, router_address)
|
: MultiDataCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setDataType(0x11);
|
setDataType(0x11);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class AlarmDataCommand : public MultiDataCommand {
|
class AlarmDataCommand : public MultiDataCommand {
|
||||||
public:
|
public:
|
||||||
explicit AlarmDataCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const time_t time = 0);
|
explicit AlarmDataCommand(InverterAbstract* inv, const uint64_t router_address = 0, const time_t time = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,8 @@ ID Target Addr Source Addr ? ? ? CH ? CRC8
|
|||||||
*/
|
*/
|
||||||
#include "ChannelChangeCommand.h"
|
#include "ChannelChangeCommand.h"
|
||||||
|
|
||||||
ChannelChangeCommand::ChannelChangeCommand(const uint64_t target_address, const uint64_t router_address, const uint8_t channel)
|
ChannelChangeCommand::ChannelChangeCommand(InverterAbstract* inv, const uint64_t router_address, const uint8_t channel)
|
||||||
: CommandAbstract(target_address, router_address)
|
: CommandAbstract(inv, router_address)
|
||||||
{
|
{
|
||||||
_payload[0] = 0x56;
|
_payload[0] = 0x56;
|
||||||
_payload[13] = 0x14;
|
_payload[13] = 0x14;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
class ChannelChangeCommand : public CommandAbstract {
|
class ChannelChangeCommand : public CommandAbstract {
|
||||||
public:
|
public:
|
||||||
explicit ChannelChangeCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const uint8_t channel = 0);
|
explicit ChannelChangeCommand(InverterAbstract* inv, const uint64_t router_address = 0, const uint8_t channel = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -29,13 +29,16 @@ Source Address: 80 12 23 04
|
|||||||
#include "CommandAbstract.h"
|
#include "CommandAbstract.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "../inverters/InverterAbstract.h"
|
||||||
|
|
||||||
CommandAbstract::CommandAbstract(const uint64_t target_address, const uint64_t router_address)
|
CommandAbstract::CommandAbstract(InverterAbstract* inv, const uint64_t router_address)
|
||||||
{
|
{
|
||||||
memset(_payload, 0, RF_LEN);
|
memset(_payload, 0, RF_LEN);
|
||||||
_payload_size = 0;
|
_payload_size = 0;
|
||||||
|
|
||||||
setTargetAddress(target_address);
|
_inv = inv;
|
||||||
|
|
||||||
|
setTargetAddress(_inv->serial());
|
||||||
setRouterAddress(router_address);
|
setRouterAddress(router_address);
|
||||||
setSendCount(0);
|
setSendCount(0);
|
||||||
setTimeout(0);
|
setTimeout(0);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class InverterAbstract;
|
|||||||
|
|
||||||
class CommandAbstract {
|
class CommandAbstract {
|
||||||
public:
|
public:
|
||||||
explicit CommandAbstract(const uint64_t target_address = 0, const uint64_t router_address = 0);
|
explicit CommandAbstract(InverterAbstract* inv, const uint64_t router_address = 0);
|
||||||
virtual ~CommandAbstract() {};
|
virtual ~CommandAbstract() {};
|
||||||
|
|
||||||
const uint8_t* getDataPayload();
|
const uint8_t* getDataPayload();
|
||||||
@ -21,7 +21,6 @@ public:
|
|||||||
|
|
||||||
uint8_t getDataSize() const;
|
uint8_t getDataSize() const;
|
||||||
|
|
||||||
void setTargetAddress(const uint64_t address);
|
|
||||||
uint64_t getTargetAddress() const;
|
uint64_t getTargetAddress() const;
|
||||||
|
|
||||||
void setRouterAddress(const uint64_t address);
|
void setRouterAddress(const uint64_t address);
|
||||||
@ -56,6 +55,9 @@ protected:
|
|||||||
uint64_t _targetAddress;
|
uint64_t _targetAddress;
|
||||||
uint64_t _routerAddress;
|
uint64_t _routerAddress;
|
||||||
|
|
||||||
|
InverterAbstract* _inv;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setTargetAddress(const uint64_t address);
|
||||||
static void convertSerialToPacketId(uint8_t buffer[], const uint64_t serial);
|
static void convertSerialToPacketId(uint8_t buffer[], const uint64_t serial);
|
||||||
};
|
};
|
||||||
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -23,8 +23,8 @@ ID Target Addr Source Addr Cmd Payload CRC16 CRC8
|
|||||||
#include "DevControlCommand.h"
|
#include "DevControlCommand.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
|
|
||||||
DevControlCommand::DevControlCommand(const uint64_t target_address, const uint64_t router_address)
|
DevControlCommand::DevControlCommand(InverterAbstract* inv, const uint64_t router_address)
|
||||||
: CommandAbstract(target_address, router_address)
|
: CommandAbstract(inv, router_address)
|
||||||
{
|
{
|
||||||
_payload[0] = 0x51;
|
_payload[0] = 0x51;
|
||||||
_payload[9] = 0x81;
|
_payload[9] = 0x81;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class DevControlCommand : public CommandAbstract {
|
class DevControlCommand : public CommandAbstract {
|
||||||
public:
|
public:
|
||||||
explicit DevControlCommand(const uint64_t target_address = 0, const uint64_t router_address = 0);
|
explicit DevControlCommand(InverterAbstract* inv, const uint64_t router_address = 0);
|
||||||
|
|
||||||
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
virtual bool handleResponse(InverterAbstract& inverter, const fragment_t fragment[], const uint8_t max_fragment_id);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -21,8 +21,8 @@ ID Target Addr Source Addr Idx DT ? Time Gap Pa
|
|||||||
#include "DevInfoAllCommand.h"
|
#include "DevInfoAllCommand.h"
|
||||||
#include "inverters/InverterAbstract.h"
|
#include "inverters/InverterAbstract.h"
|
||||||
|
|
||||||
DevInfoAllCommand::DevInfoAllCommand(const uint64_t target_address, const uint64_t router_address, const time_t time)
|
DevInfoAllCommand::DevInfoAllCommand(InverterAbstract* inv, const uint64_t router_address, const time_t time)
|
||||||
: MultiDataCommand(target_address, router_address)
|
: MultiDataCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setDataType(0x01);
|
setDataType(0x01);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class DevInfoAllCommand : public MultiDataCommand {
|
class DevInfoAllCommand : public MultiDataCommand {
|
||||||
public:
|
public:
|
||||||
explicit DevInfoAllCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const time_t time = 0);
|
explicit DevInfoAllCommand(InverterAbstract* inv, const uint64_t router_address = 0, const time_t time = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -21,8 +21,8 @@ ID Target Addr Source Addr Idx DT ? Time Gap Pa
|
|||||||
#include "DevInfoSimpleCommand.h"
|
#include "DevInfoSimpleCommand.h"
|
||||||
#include "inverters/InverterAbstract.h"
|
#include "inverters/InverterAbstract.h"
|
||||||
|
|
||||||
DevInfoSimpleCommand::DevInfoSimpleCommand(const uint64_t target_address, const uint64_t router_address, const time_t time)
|
DevInfoSimpleCommand::DevInfoSimpleCommand(InverterAbstract* inv, const uint64_t router_address, const time_t time)
|
||||||
: MultiDataCommand(target_address, router_address)
|
: MultiDataCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setDataType(0x00);
|
setDataType(0x00);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class DevInfoSimpleCommand : public MultiDataCommand {
|
class DevInfoSimpleCommand : public MultiDataCommand {
|
||||||
public:
|
public:
|
||||||
explicit DevInfoSimpleCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const time_t time = 0);
|
explicit DevInfoSimpleCommand(InverterAbstract* inv, const uint64_t router_address = 0, const time_t time = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -22,8 +22,8 @@ ID Target Addr Source Addr Idx DT ? Time Gap Pa
|
|||||||
#include "Hoymiles.h"
|
#include "Hoymiles.h"
|
||||||
#include "inverters/InverterAbstract.h"
|
#include "inverters/InverterAbstract.h"
|
||||||
|
|
||||||
GridOnProFilePara::GridOnProFilePara(const uint64_t target_address, const uint64_t router_address, const time_t time)
|
GridOnProFilePara::GridOnProFilePara(InverterAbstract* inv, const uint64_t router_address, const time_t time)
|
||||||
: MultiDataCommand(target_address, router_address)
|
: MultiDataCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setDataType(0x02);
|
setDataType(0x02);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class GridOnProFilePara : public MultiDataCommand {
|
class GridOnProFilePara : public MultiDataCommand {
|
||||||
public:
|
public:
|
||||||
explicit GridOnProFilePara(const uint64_t target_address = 0, const uint64_t router_address = 0, const time_t time = 0);
|
explicit GridOnProFilePara(InverterAbstract* inv, const uint64_t router_address = 0, const time_t time = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -28,8 +28,9 @@ ID Target Addr Source Addr Idx DT ? Time Gap Pa
|
|||||||
#include "MultiDataCommand.h"
|
#include "MultiDataCommand.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
|
|
||||||
MultiDataCommand::MultiDataCommand(const uint64_t target_address, const uint64_t router_address, const uint8_t data_type, const time_t time)
|
MultiDataCommand::MultiDataCommand(InverterAbstract* inv, const uint64_t router_address, const uint8_t data_type, const time_t time)
|
||||||
: CommandAbstract(target_address, router_address)
|
: CommandAbstract(inv, router_address)
|
||||||
|
, _cmdRequestFrame(inv)
|
||||||
{
|
{
|
||||||
_payload[0] = 0x15;
|
_payload[0] = 0x15;
|
||||||
_payload[9] = 0x80;
|
_payload[9] = 0x80;
|
||||||
@ -79,7 +80,6 @@ time_t MultiDataCommand::getTime() const
|
|||||||
|
|
||||||
CommandAbstract* MultiDataCommand::getRequestFrameCommand(const uint8_t frame_no)
|
CommandAbstract* MultiDataCommand::getRequestFrameCommand(const uint8_t frame_no)
|
||||||
{
|
{
|
||||||
_cmdRequestFrame.setTargetAddress(getTargetAddress());
|
|
||||||
_cmdRequestFrame.setFrameNo(frame_no);
|
_cmdRequestFrame.setFrameNo(frame_no);
|
||||||
|
|
||||||
return &_cmdRequestFrame;
|
return &_cmdRequestFrame;
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class MultiDataCommand : public CommandAbstract {
|
class MultiDataCommand : public CommandAbstract {
|
||||||
public:
|
public:
|
||||||
explicit MultiDataCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const uint8_t data_type = 0, const time_t time = 0);
|
explicit MultiDataCommand(InverterAbstract* inv, const uint64_t router_address = 0, const uint8_t data_type = 0, const time_t time = 0);
|
||||||
|
|
||||||
void setTime(const time_t time);
|
void setTime(const time_t time);
|
||||||
time_t getTime() const;
|
time_t getTime() const;
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
#include "ParaSetCommand.h"
|
#include "ParaSetCommand.h"
|
||||||
|
|
||||||
ParaSetCommand::ParaSetCommand(const uint64_t target_address, const uint64_t router_address)
|
ParaSetCommand::ParaSetCommand(InverterAbstract* inv, const uint64_t router_address)
|
||||||
: CommandAbstract(target_address, router_address)
|
: CommandAbstract(inv, router_address)
|
||||||
{
|
{
|
||||||
_payload[0] = 0x52;
|
_payload[0] = 0x52;
|
||||||
}
|
}
|
||||||
@ -5,5 +5,5 @@
|
|||||||
|
|
||||||
class ParaSetCommand : public CommandAbstract {
|
class ParaSetCommand : public CommandAbstract {
|
||||||
public:
|
public:
|
||||||
explicit ParaSetCommand(const uint64_t target_address = 0, const uint64_t router_address = 0);
|
explicit ParaSetCommand(InverterAbstract* inv, const uint64_t router_address = 0);
|
||||||
};
|
};
|
||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -26,8 +26,8 @@ ID Target Addr Source Addr Cmd SCmd ? CRC16 CRC8
|
|||||||
|
|
||||||
#define CRC_SIZE 2
|
#define CRC_SIZE 2
|
||||||
|
|
||||||
PowerControlCommand::PowerControlCommand(const uint64_t target_address, const uint64_t router_address)
|
PowerControlCommand::PowerControlCommand(InverterAbstract* inv, const uint64_t router_address)
|
||||||
: DevControlCommand(target_address, router_address)
|
: DevControlCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
_payload[10] = 0x00; // TurnOn
|
_payload[10] = 0x00; // TurnOn
|
||||||
_payload[11] = 0x00;
|
_payload[11] = 0x00;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class PowerControlCommand : public DevControlCommand {
|
class PowerControlCommand : public DevControlCommand {
|
||||||
public:
|
public:
|
||||||
explicit PowerControlCommand(const uint64_t target_address = 0, const uint64_t router_address = 0);
|
explicit PowerControlCommand(InverterAbstract* inv, const uint64_t router_address = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -22,8 +22,8 @@ ID Target Addr Source Addr Idx DT ? Time Gap Pa
|
|||||||
#include "Hoymiles.h"
|
#include "Hoymiles.h"
|
||||||
#include "inverters/InverterAbstract.h"
|
#include "inverters/InverterAbstract.h"
|
||||||
|
|
||||||
RealTimeRunDataCommand::RealTimeRunDataCommand(const uint64_t target_address, const uint64_t router_address, const time_t time)
|
RealTimeRunDataCommand::RealTimeRunDataCommand(InverterAbstract* inv, const uint64_t router_address, const time_t time)
|
||||||
: MultiDataCommand(target_address, router_address)
|
: MultiDataCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setDataType(0x0b);
|
setDataType(0x0b);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class RealTimeRunDataCommand : public MultiDataCommand {
|
class RealTimeRunDataCommand : public MultiDataCommand {
|
||||||
public:
|
public:
|
||||||
explicit RealTimeRunDataCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const time_t time = 0);
|
explicit RealTimeRunDataCommand(InverterAbstract* inv, const uint64_t router_address = 0, const time_t time = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -22,8 +22,8 @@ ID Target Addr Source Addr Frm CRC8
|
|||||||
*/
|
*/
|
||||||
#include "RequestFrameCommand.h"
|
#include "RequestFrameCommand.h"
|
||||||
|
|
||||||
RequestFrameCommand::RequestFrameCommand(const uint64_t target_address, const uint64_t router_address, uint8_t frame_no)
|
RequestFrameCommand::RequestFrameCommand(InverterAbstract* inv, const uint64_t router_address, uint8_t frame_no)
|
||||||
: SingleDataCommand(target_address, router_address)
|
: SingleDataCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
if (frame_no > 127) {
|
if (frame_no > 127) {
|
||||||
frame_no = 0;
|
frame_no = 0;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class RequestFrameCommand : public SingleDataCommand {
|
class RequestFrameCommand : public SingleDataCommand {
|
||||||
public:
|
public:
|
||||||
explicit RequestFrameCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, uint8_t frame_no = 0);
|
explicit RequestFrameCommand(InverterAbstract* inv, const uint64_t router_address = 0, uint8_t frame_no = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -19,8 +19,8 @@ ID Target Addr Source Addr CRC8
|
|||||||
*/
|
*/
|
||||||
#include "SingleDataCommand.h"
|
#include "SingleDataCommand.h"
|
||||||
|
|
||||||
SingleDataCommand::SingleDataCommand(const uint64_t target_address, const uint64_t router_address)
|
SingleDataCommand::SingleDataCommand(InverterAbstract* inv, const uint64_t router_address)
|
||||||
: CommandAbstract(target_address, router_address)
|
: CommandAbstract(inv, router_address)
|
||||||
{
|
{
|
||||||
_payload[0] = 0x15;
|
_payload[0] = 0x15;
|
||||||
setTimeout(100);
|
setTimeout(100);
|
||||||
|
|||||||
@ -5,5 +5,5 @@
|
|||||||
|
|
||||||
class SingleDataCommand : public CommandAbstract {
|
class SingleDataCommand : public CommandAbstract {
|
||||||
public:
|
public:
|
||||||
explicit SingleDataCommand(const uint64_t target_address = 0, const uint64_t router_address = 0);
|
explicit SingleDataCommand(InverterAbstract* inv, const uint64_t router_address = 0);
|
||||||
};
|
};
|
||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -22,8 +22,8 @@ ID Target Addr Source Addr Idx DT ? Time Gap Pa
|
|||||||
#include "Hoymiles.h"
|
#include "Hoymiles.h"
|
||||||
#include "inverters/InverterAbstract.h"
|
#include "inverters/InverterAbstract.h"
|
||||||
|
|
||||||
SystemConfigParaCommand::SystemConfigParaCommand(const uint64_t target_address, const uint64_t router_address, const time_t time)
|
SystemConfigParaCommand::SystemConfigParaCommand(InverterAbstract* inv, const uint64_t router_address, const time_t time)
|
||||||
: MultiDataCommand(target_address, router_address)
|
: MultiDataCommand(inv, router_address)
|
||||||
{
|
{
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setDataType(0x05);
|
setDataType(0x05);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class SystemConfigParaCommand : public MultiDataCommand {
|
class SystemConfigParaCommand : public MultiDataCommand {
|
||||||
public:
|
public:
|
||||||
explicit SystemConfigParaCommand(const uint64_t target_address = 0, const uint64_t router_address = 0, const time_t time = 0);
|
explicit SystemConfigParaCommand(InverterAbstract* inv, const uint64_t router_address = 0, const time_t time = 0);
|
||||||
|
|
||||||
virtual String getCommandName() const;
|
virtual String getCommandName() const;
|
||||||
|
|
||||||
|
|||||||
@ -18,10 +18,9 @@ bool HMS_Abstract::sendChangeChannelRequest()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cmdChannel = _radio->prepareCommand<ChannelChangeCommand>();
|
auto cmdChannel = _radio->prepareCommand<ChannelChangeCommand>(this);
|
||||||
cmdChannel->setCountryMode(Hoymiles.getRadioCmt()->getCountryMode());
|
cmdChannel->setCountryMode(Hoymiles.getRadioCmt()->getCountryMode());
|
||||||
cmdChannel->setChannel(Hoymiles.getRadioCmt()->getChannelFromFrequency(Hoymiles.getRadioCmt()->getInverterTargetFrequency()));
|
cmdChannel->setChannel(Hoymiles.getRadioCmt()->getChannelFromFrequency(Hoymiles.getRadioCmt()->getInverterTargetFrequency()));
|
||||||
cmdChannel->setTargetAddress(serial());
|
|
||||||
_radio->enqueCommand(cmdChannel);
|
_radio->enqueCommand(cmdChannel);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -20,10 +20,9 @@ bool HMT_Abstract::sendChangeChannelRequest()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cmdChannel = _radio->prepareCommand<ChannelChangeCommand>();
|
auto cmdChannel = _radio->prepareCommand<ChannelChangeCommand>(this);
|
||||||
cmdChannel->setCountryMode(Hoymiles.getRadioCmt()->getCountryMode());
|
cmdChannel->setCountryMode(Hoymiles.getRadioCmt()->getCountryMode());
|
||||||
cmdChannel->setChannel(Hoymiles.getRadioCmt()->getChannelFromFrequency(Hoymiles.getRadioCmt()->getInverterTargetFrequency()));
|
cmdChannel->setChannel(Hoymiles.getRadioCmt()->getChannelFromFrequency(Hoymiles.getRadioCmt()->getInverterTargetFrequency()));
|
||||||
cmdChannel->setTargetAddress(serial());
|
|
||||||
_radio->enqueCommand(cmdChannel);
|
_radio->enqueCommand(cmdChannel);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Thomas Basler and others
|
* Copyright (C) 2022-2024 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
#include "HM_Abstract.h"
|
#include "HM_Abstract.h"
|
||||||
#include "HoymilesRadio.h"
|
#include "HoymilesRadio.h"
|
||||||
@ -30,9 +30,8 @@ bool HM_Abstract::sendStatsRequest()
|
|||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
auto cmd = _radio->prepareCommand<RealTimeRunDataCommand>();
|
auto cmd = _radio->prepareCommand<RealTimeRunDataCommand>(this);
|
||||||
cmd->setTime(now);
|
cmd->setTime(now);
|
||||||
cmd->setTargetAddress(serial());
|
|
||||||
_radio->enqueCommand(cmd);
|
_radio->enqueCommand(cmd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -62,9 +61,8 @@ bool HM_Abstract::sendAlarmLogRequest(const bool force)
|
|||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
auto cmd = _radio->prepareCommand<AlarmDataCommand>();
|
auto cmd = _radio->prepareCommand<AlarmDataCommand>(this);
|
||||||
cmd->setTime(now);
|
cmd->setTime(now);
|
||||||
cmd->setTargetAddress(serial());
|
|
||||||
EventLog()->setLastAlarmRequestSuccess(CMD_PENDING);
|
EventLog()->setLastAlarmRequestSuccess(CMD_PENDING);
|
||||||
_radio->enqueCommand(cmd);
|
_radio->enqueCommand(cmd);
|
||||||
|
|
||||||
@ -85,14 +83,12 @@ bool HM_Abstract::sendDevInfoRequest()
|
|||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
auto cmdAll = _radio->prepareCommand<DevInfoAllCommand>();
|
auto cmdAll = _radio->prepareCommand<DevInfoAllCommand>(this);
|
||||||
cmdAll->setTime(now);
|
cmdAll->setTime(now);
|
||||||
cmdAll->setTargetAddress(serial());
|
|
||||||
_radio->enqueCommand(cmdAll);
|
_radio->enqueCommand(cmdAll);
|
||||||
|
|
||||||
auto cmdSimple = _radio->prepareCommand<DevInfoSimpleCommand>();
|
auto cmdSimple = _radio->prepareCommand<DevInfoSimpleCommand>(this);
|
||||||
cmdSimple->setTime(now);
|
cmdSimple->setTime(now);
|
||||||
cmdSimple->setTargetAddress(serial());
|
|
||||||
_radio->enqueCommand(cmdSimple);
|
_radio->enqueCommand(cmdSimple);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -112,9 +108,8 @@ bool HM_Abstract::sendSystemConfigParaRequest()
|
|||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
auto cmd = _radio->prepareCommand<SystemConfigParaCommand>();
|
auto cmd = _radio->prepareCommand<SystemConfigParaCommand>(this);
|
||||||
cmd->setTime(now);
|
cmd->setTime(now);
|
||||||
cmd->setTargetAddress(serial());
|
|
||||||
SystemConfigPara()->setLastLimitRequestSuccess(CMD_PENDING);
|
SystemConfigPara()->setLastLimitRequestSuccess(CMD_PENDING);
|
||||||
_radio->enqueCommand(cmd);
|
_radio->enqueCommand(cmd);
|
||||||
|
|
||||||
@ -134,9 +129,8 @@ bool HM_Abstract::sendActivePowerControlRequest(float limit, const PowerLimitCon
|
|||||||
_activePowerControlLimit = limit;
|
_activePowerControlLimit = limit;
|
||||||
_activePowerControlType = type;
|
_activePowerControlType = type;
|
||||||
|
|
||||||
auto cmd = _radio->prepareCommand<ActivePowerControlCommand>();
|
auto cmd = _radio->prepareCommand<ActivePowerControlCommand>(this);
|
||||||
cmd->setActivePowerLimit(limit, type);
|
cmd->setActivePowerLimit(limit, type);
|
||||||
cmd->setTargetAddress(serial());
|
|
||||||
SystemConfigPara()->setLastLimitCommandSuccess(CMD_PENDING);
|
SystemConfigPara()->setLastLimitCommandSuccess(CMD_PENDING);
|
||||||
_radio->enqueCommand(cmd);
|
_radio->enqueCommand(cmd);
|
||||||
|
|
||||||
@ -160,9 +154,8 @@ bool HM_Abstract::sendPowerControlRequest(const bool turnOn)
|
|||||||
_powerState = 0;
|
_powerState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cmd = _radio->prepareCommand<PowerControlCommand>();
|
auto cmd = _radio->prepareCommand<PowerControlCommand>(this);
|
||||||
cmd->setPowerOn(turnOn);
|
cmd->setPowerOn(turnOn);
|
||||||
cmd->setTargetAddress(serial());
|
|
||||||
PowerCommand()->setLastPowerCommandSuccess(CMD_PENDING);
|
PowerCommand()->setLastPowerCommandSuccess(CMD_PENDING);
|
||||||
_radio->enqueCommand(cmd);
|
_radio->enqueCommand(cmd);
|
||||||
|
|
||||||
@ -177,9 +170,8 @@ bool HM_Abstract::sendRestartControlRequest()
|
|||||||
|
|
||||||
_powerState = 2;
|
_powerState = 2;
|
||||||
|
|
||||||
auto cmd = _radio->prepareCommand<PowerControlCommand>();
|
auto cmd = _radio->prepareCommand<PowerControlCommand>(this);
|
||||||
cmd->setRestart();
|
cmd->setRestart();
|
||||||
cmd->setTargetAddress(serial());
|
|
||||||
PowerCommand()->setLastPowerCommandSuccess(CMD_PENDING);
|
PowerCommand()->setLastPowerCommandSuccess(CMD_PENDING);
|
||||||
_radio->enqueCommand(cmd);
|
_radio->enqueCommand(cmd);
|
||||||
|
|
||||||
@ -219,9 +211,8 @@ bool HM_Abstract::sendGridOnProFileParaRequest()
|
|||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
auto cmd = _radio->prepareCommand<GridOnProFilePara>();
|
auto cmd = _radio->prepareCommand<GridOnProFilePara>(this);
|
||||||
cmd->setTime(now);
|
cmd->setTime(now);
|
||||||
cmd->setTargetAddress(serial());
|
|
||||||
_radio->enqueCommand(cmd);
|
_radio->enqueCommand(cmd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user