Add diagnostic bit support to Gateway Modbus
- Introduced new enum value `kShortDiagnosticBit` to `GatewayModbusGeneratedKind`. - Enhanced `GatewayModbusPoint` and `GatewayModbusPointBinding` structures to include diagnostic snapshot, boolean key, and device type. - Added new diagnostic bit specifications and updated the corresponding arrays for generated discrete inputs and holding registers. - Implemented `addGeneratedDiagnosticPoint` function to handle the creation of diagnostic points. - Updated `rebuildMap` method to include generated diagnostic points during the map rebuilding process. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -32,6 +33,7 @@ struct GatewayBacnetObjectBinding {
|
||||
std::string property{"presentValue"};
|
||||
bool out_of_service{false};
|
||||
uint32_t reliability{0};
|
||||
bool readable{false};
|
||||
};
|
||||
|
||||
struct GatewayBacnetServerStatus {
|
||||
@@ -46,13 +48,19 @@ using GatewayBacnetWriteCallback =
|
||||
std::function<bool(BridgeObjectType object_type, uint32_t object_instance,
|
||||
const std::string& property, const DaliValue& value)>;
|
||||
|
||||
using GatewayBacnetReadCallback =
|
||||
std::function<std::optional<DaliValue>(BridgeObjectType object_type,
|
||||
uint32_t object_instance,
|
||||
const std::string& property)>;
|
||||
|
||||
class GatewayBacnetServer {
|
||||
public:
|
||||
static GatewayBacnetServer& instance();
|
||||
|
||||
esp_err_t registerChannel(uint8_t gateway_id, const GatewayBacnetServerConfig& config,
|
||||
std::vector<GatewayBacnetObjectBinding> bindings,
|
||||
GatewayBacnetWriteCallback write_callback);
|
||||
GatewayBacnetWriteCallback write_callback,
|
||||
GatewayBacnetReadCallback read_callback = nullptr);
|
||||
GatewayBacnetServerStatus status() const;
|
||||
bool configCompatible(const GatewayBacnetServerConfig& config) const;
|
||||
bool handleWrite(BridgeObjectType object_type, uint32_t object_instance,
|
||||
@@ -70,6 +78,7 @@ class GatewayBacnetServer {
|
||||
|
||||
esp_err_t startStackLocked(const GatewayBacnetServerConfig& config);
|
||||
esp_err_t rebuildObjectsLocked();
|
||||
void refreshPresentValues();
|
||||
|
||||
static void TaskEntry(void* arg);
|
||||
void taskLoop();
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "bridge.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace gateway {
|
||||
|
||||
struct GatewayBacnetBridgeConfig {
|
||||
uint32_t deviceInstance{4194303};
|
||||
std::string localAddress;
|
||||
uint16_t udpPort{47808};
|
||||
};
|
||||
|
||||
struct GatewayBacnetModelBinding {
|
||||
std::string modelID;
|
||||
BridgeObjectType objectType{BridgeObjectType::unknown};
|
||||
int objectInstance{-1};
|
||||
std::string property;
|
||||
BridgeOperation operation{BridgeOperation::unknown};
|
||||
BridgeDaliTarget target;
|
||||
std::optional<int> bitIndex;
|
||||
};
|
||||
|
||||
class GatewayBacnetBridgeAdapter {
|
||||
public:
|
||||
explicit GatewayBacnetBridgeAdapter(DaliBridgeEngine& engine);
|
||||
|
||||
void setConfig(const GatewayBacnetBridgeConfig& config);
|
||||
const GatewayBacnetBridgeConfig& config() const;
|
||||
|
||||
DaliBridgeResult handlePropertyWrite(BridgeObjectType object_type,
|
||||
int object_instance,
|
||||
const std::string& property,
|
||||
const DaliValue& value) const;
|
||||
DaliBridgeResult readProperty(BridgeObjectType object_type,
|
||||
int object_instance,
|
||||
const std::string& property) const;
|
||||
std::optional<GatewayBacnetModelBinding> findObject(BridgeObjectType object_type,
|
||||
int object_instance,
|
||||
const std::string& property) const;
|
||||
std::vector<GatewayBacnetModelBinding> describeObjects() const;
|
||||
|
||||
private:
|
||||
DaliBridgeResult executeBinding(const GatewayBacnetModelBinding& binding,
|
||||
const std::string& sequence,
|
||||
const DaliValue* value) const;
|
||||
|
||||
DaliBridgeEngine& engine_;
|
||||
GatewayBacnetBridgeConfig config_;
|
||||
};
|
||||
|
||||
} // namespace gateway
|
||||
@@ -52,9 +52,20 @@ bool gateway_bacnet_stack_upsert_object(
|
||||
gateway_bacnet_object_kind_t object_kind,
|
||||
uint32_t object_instance,
|
||||
const char* object_name,
|
||||
const char* description,
|
||||
bool out_of_service,
|
||||
uint32_t reliability);
|
||||
const char* description,
|
||||
bool out_of_service,
|
||||
uint32_t reliability);
|
||||
|
||||
bool gateway_bacnet_stack_set_object_state(
|
||||
gateway_bacnet_object_kind_t object_kind,
|
||||
uint32_t object_instance,
|
||||
bool out_of_service,
|
||||
uint32_t reliability);
|
||||
|
||||
bool gateway_bacnet_stack_set_present_value(
|
||||
gateway_bacnet_object_kind_t object_kind,
|
||||
uint32_t object_instance,
|
||||
const gateway_bacnet_write_value_t* value);
|
||||
|
||||
bool gateway_bacnet_stack_clear_objects(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user