Simplification of communication protocol
This commit is contained in:
parent
7b8cf3fa4f
commit
8d9b4c4d8c
@ -33,7 +33,9 @@ Ingress and Egress Messages
|
||||
Similarly, the oneof field ensures that only one response type is included.
|
||||
|
||||
EngressMessages can also send a message that is not a response to given request but also
|
||||
Failure or temperature updates
|
||||
Failure or temperature updates
|
||||
|
||||
Each top level message (ingress or egress) contains number of request/response submessages and those needs to contain
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
//import "nanopb.proto";
|
||||
// import "nanopb.proto";
|
||||
package ctrl;
|
||||
|
||||
// Control Layer
|
||||
|
||||
// Messages in this package control the behavior of physical power output.
|
||||
// Each output is hardwired to a Zero-Cross Detector (ZCD) internally and can be controlled either by:
|
||||
// * Grouping AC cycles (e.g., power level 23 means 23% of cycles are ON) – suitable for heating control.
|
||||
// * Phase control (e.g., power level 23 means 23% of a single AC cycle is ON) – required for dimming capability.
|
||||
// Each output is hardwired to a Zero-Cross Detector (ZCD) internally and can be controlled either
|
||||
// by:
|
||||
// * Grouping AC cycles (e.g., power level 23 means 23% of cycles are ON) – suitable for heating
|
||||
// control.
|
||||
// * Phase control (e.g., power level 23 means 23% of a single AC cycle is ON) – required for
|
||||
// dimming capability.
|
||||
|
||||
enum Error {
|
||||
NoError = 0;
|
||||
@ -34,16 +37,43 @@ enum PowerControlAlgorithm {
|
||||
PhaseModulation = 2;
|
||||
}
|
||||
|
||||
// Request message for configuring Group Modulation parameters.
|
||||
message GroupModulationConfig
|
||||
{
|
||||
// The maximum number of ON cycles for Group Modulation.
|
||||
uint32 cycles_max = 1;
|
||||
}
|
||||
|
||||
message PhaseModulationConfig
|
||||
{
|
||||
}
|
||||
|
||||
message ModulationConfig
|
||||
{
|
||||
oneof config
|
||||
{
|
||||
GroupModulationConfig constant_temperature = 1;
|
||||
PhaseModulationConfig temperature_slope = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message PowerControlAlgorithmData
|
||||
{
|
||||
PowerControlAlgorithm alg = 2;
|
||||
// optional configuration for selected mode, value ignored when mode is not set
|
||||
ModulationConfig modulation_config = 3;
|
||||
}
|
||||
|
||||
message PowerControlAlgorithmRequest
|
||||
{
|
||||
uint32 channel_id = 1;
|
||||
optional PowerControlAlgorithm alg = 2;
|
||||
optional PowerControlAlgorithmData alg = 2;
|
||||
}
|
||||
|
||||
message PowerControlAlgorithmResponse
|
||||
{
|
||||
uint32 channel_id = 1;
|
||||
PowerControlAlgorithm alg = 2;
|
||||
PowerControlAlgorithmData alg = 2;
|
||||
optional Error error = 254;
|
||||
}
|
||||
|
||||
@ -72,83 +102,7 @@ message PowerLevelResponse
|
||||
optional Error error = 3;
|
||||
}
|
||||
|
||||
// Request message for configuring Group Modulation parameters.
|
||||
message GroupModulationConfigRequest
|
||||
{
|
||||
// The channel ID to which the request is directed.
|
||||
uint32 channel_id = 1;
|
||||
|
||||
// The maximum number of ON cycles for Group Modulation.
|
||||
optional uint32 cycles_max = 2;
|
||||
}
|
||||
|
||||
// Response message for returning the Group Modulation configuration.
|
||||
message GroupModulationConfigResponse
|
||||
{
|
||||
// The channel ID associated with the response.
|
||||
uint32 channel_id = 1;
|
||||
|
||||
// The current setting of maximum ON cycles for Group Modulation.
|
||||
uint32 cycles_max = 2;
|
||||
|
||||
// Optional error field. If present, indicates an error occurred.
|
||||
optional Error error = 254;
|
||||
}
|
||||
|
||||
message GroupModulationControlRequest
|
||||
{
|
||||
// The channel ID to which the request is directed.
|
||||
uint32 channel_id = 1;
|
||||
|
||||
// Number of cycles ON for GroupModulation.
|
||||
optional uint32 cycles = 2;
|
||||
}
|
||||
|
||||
message GroupModulationControlResponse
|
||||
{
|
||||
// The channel ID associated with the response.
|
||||
uint32 channel_id = 1;
|
||||
|
||||
uint32 cycles = 2;
|
||||
|
||||
optional Error error = 254;
|
||||
}
|
||||
|
||||
message PhaseModulationConfigRequest
|
||||
{
|
||||
// The channel ID to which the request is directed.
|
||||
uint32 channel_id = 1;
|
||||
}
|
||||
|
||||
message PhaseModulationConfigResponse
|
||||
{
|
||||
// The channel ID associated with the response.
|
||||
uint32 channel_id = 1;
|
||||
|
||||
optional Error error = 254;
|
||||
}
|
||||
|
||||
message PhaseModulationControlRequest
|
||||
{
|
||||
// The channel ID to which the request is directed.
|
||||
uint32 channel_id = 1;
|
||||
|
||||
// Phase angle for PhaseModulation (0 to 180 degrees).
|
||||
optional float phase_angle = 2;
|
||||
}
|
||||
|
||||
message PhaseModulationControlResponse
|
||||
{
|
||||
// The channel ID associated with the response.
|
||||
uint32 channel_id = 1;
|
||||
float phase_angle = 2;
|
||||
optional Error error = 254;
|
||||
}
|
||||
|
||||
/// TODO softstart for phase modulation
|
||||
|
||||
// Only these messages are sent through the interface.
|
||||
|
||||
message IngressMessage
|
||||
{
|
||||
uint32 request_id = 255;
|
||||
@ -157,12 +111,6 @@ message IngressMessage
|
||||
PowerControlAlgorithmRequest power_control_algorithm_request = 1;
|
||||
|
||||
PowerLevelRequest power_level_request = 3;
|
||||
|
||||
GroupModulationConfigRequest group_modulation_config_request = 10;
|
||||
GroupModulationControlRequest group_modulation_control_request = 11;
|
||||
|
||||
PhaseModulationConfigRequest phase_modulation_config_request = 12;
|
||||
PhaseModulationControlRequest phase_modulation_control_request = 13;
|
||||
}
|
||||
};
|
||||
|
||||
@ -174,11 +122,5 @@ message EgressMessage
|
||||
PowerControlAlgorithmResponse power_control_algorithm_response = 1;
|
||||
|
||||
PowerLevelResponse power_level_response = 3;
|
||||
|
||||
GroupModulationConfigResponse group_modulation_config_response = 10;
|
||||
GroupModulationControlResponse group_modulation_control_response = 11;
|
||||
|
||||
PhaseModulationConfigResponse phase_modulation_config_response = 12;
|
||||
PhaseModulationControlResponse phase_modulation_control_response = 13;
|
||||
}
|
||||
};
|
||||
|
||||
@ -29,9 +29,6 @@ enum Error {
|
||||
|
||||
enum FilterType {
|
||||
None = 0;
|
||||
Kalman = 1;
|
||||
EMA = 2;
|
||||
Avarage = 3;
|
||||
}
|
||||
|
||||
/* CONFIGURATION */
|
||||
@ -47,21 +44,6 @@ message SamplerConfig
|
||||
optional uint32 period_ms = 4;
|
||||
}
|
||||
|
||||
message KalmanFilterParams
|
||||
{
|
||||
optional float Q = 1;
|
||||
optional float R = 2;
|
||||
}
|
||||
|
||||
message EMAFilterParams
|
||||
{
|
||||
optional float alpha = 1;
|
||||
}
|
||||
|
||||
message AverageFilterParams
|
||||
{
|
||||
optional uint32 samples = 1;
|
||||
}
|
||||
|
||||
/* INTERNAL STRUCTURES */
|
||||
|
||||
@ -87,41 +69,12 @@ message SamplerConfigResponse
|
||||
optional Error error = 254;
|
||||
}
|
||||
|
||||
/*
|
||||
Filter configuration, can be set to any filter, despite what filter is currently enabled
|
||||
*/
|
||||
message FilterConfigRequest
|
||||
{
|
||||
uint32 channel_id = 1;
|
||||
// skips info about current parameters in response message
|
||||
bool skip_full_response = 5;
|
||||
|
||||
optional KalmanFilterParams kalman_pilter_params = 2;
|
||||
optional EMAFilterParams ema_filter_params = 3;
|
||||
optional AverageFilterParams average_filter_params = 4;
|
||||
}
|
||||
message FilterConfigResponse
|
||||
{
|
||||
uint32 channel_id = 1;
|
||||
|
||||
KalmanFilterParams kalman_filter_params = 2;
|
||||
EMAFilterParams ema_filter_params = 3;
|
||||
AverageFilterParams average_filter_params = 4;
|
||||
|
||||
optional Error error = 254;
|
||||
}
|
||||
|
||||
message FilterRequest
|
||||
{
|
||||
uint32 channel_id = 1;
|
||||
optional FilterType filter_type = 2;
|
||||
}
|
||||
message FilterResponse
|
||||
{
|
||||
uint32 channel_id = 1;
|
||||
FilterType filter_type = 2;
|
||||
optional Error error = 254;
|
||||
}
|
||||
//enum FilterType {
|
||||
// None = 0;
|
||||
// Kalman = 1;
|
||||
// EMA = 2;
|
||||
// Avarage = 3;
|
||||
//}
|
||||
|
||||
// API
|
||||
// Read
|
||||
@ -156,8 +109,6 @@ message IngressMessage
|
||||
|
||||
// configuration
|
||||
SamplerConfigRequest sampler_config_request = 3;
|
||||
FilterConfigRequest filter_config_request = 4;
|
||||
FilterRequest filter_request = 5;
|
||||
}
|
||||
};
|
||||
|
||||
@ -172,7 +123,5 @@ message EgressMessage
|
||||
|
||||
// configuration
|
||||
SamplerConfigResponse sampler_config_response = 3;
|
||||
FilterConfigResponse filter_config_response = 4;
|
||||
FilterResponse filter_response = 5;
|
||||
}
|
||||
};
|
||||
|
||||
@ -11,18 +11,7 @@ template <> constexpr int tag<ctrl_PowerControlAlgorithmRequest>() {
|
||||
template <> constexpr int tag<ctrl_PowerLevelRequest>() {
|
||||
return ctrl_IngressMessage_power_level_request_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_GroupModulationConfigRequest>() {
|
||||
return ctrl_IngressMessage_group_modulation_config_request_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_GroupModulationControlRequest>() {
|
||||
return ctrl_IngressMessage_group_modulation_control_request_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_PhaseModulationConfigRequest>() {
|
||||
return ctrl_IngressMessage_phase_modulation_config_request_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_PhaseModulationControlRequest>() {
|
||||
return ctrl_IngressMessage_phase_modulation_control_request_tag;
|
||||
}
|
||||
|
||||
|
||||
template <> constexpr int tag<ctrl_PowerControlAlgorithmResponse>() {
|
||||
return ctrl_EgressMessage_power_control_algorithm_response_tag;
|
||||
@ -30,38 +19,18 @@ template <> constexpr int tag<ctrl_PowerControlAlgorithmResponse>() {
|
||||
template <> constexpr int tag<ctrl_PowerLevelResponse>() {
|
||||
return ctrl_EgressMessage_power_level_response_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_GroupModulationConfigResponse>() {
|
||||
return ctrl_EgressMessage_group_modulation_config_response_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_GroupModulationControlResponse>() {
|
||||
return ctrl_EgressMessage_group_modulation_control_response_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_PhaseModulationConfigResponse>() {
|
||||
return ctrl_EgressMessage_phase_modulation_config_response_tag;
|
||||
}
|
||||
template <> constexpr int tag<ctrl_PhaseModulationControlResponse>() {
|
||||
return ctrl_EgressMessage_phase_modulation_control_response_tag;
|
||||
}
|
||||
|
||||
template <typename MsgT>
|
||||
constexpr bool is_ctrl_ingress_msg_v = is_any_of_v<
|
||||
MsgT,
|
||||
ctrl_PowerControlAlgorithmRequest,
|
||||
ctrl_PowerLevelRequest,
|
||||
ctrl_GroupModulationConfigRequest,
|
||||
ctrl_GroupModulationControlRequest,
|
||||
ctrl_PhaseModulationConfigRequest,
|
||||
ctrl_PhaseModulationControlRequest>;
|
||||
ctrl_PowerLevelRequest>;
|
||||
|
||||
template <typename MsgT>
|
||||
constexpr bool is_ctrl_egress_msg_v = is_any_of_v<
|
||||
MsgT,
|
||||
ctrl_PowerControlAlgorithmResponse,
|
||||
ctrl_PowerLevelResponse,
|
||||
ctrl_GroupModulationConfigResponse,
|
||||
ctrl_GroupModulationControlResponse,
|
||||
ctrl_PhaseModulationConfigResponse,
|
||||
ctrl_PhaseModulationControlResponse>;
|
||||
ctrl_PowerLevelResponse>;
|
||||
|
||||
template <> struct ResponseSelector<ctrl_PowerControlAlgorithmRequest> {
|
||||
using response_t = ctrl_PowerControlAlgorithmResponse;
|
||||
@ -69,17 +38,6 @@ template <> struct ResponseSelector<ctrl_PowerControlAlgorithmRequest> {
|
||||
template <> struct ResponseSelector<ctrl_PowerLevelRequest> {
|
||||
using response_t = ctrl_PowerLevelResponse;
|
||||
};
|
||||
template <> struct ResponseSelector<ctrl_GroupModulationConfigRequest> {
|
||||
using response_t = ctrl_GroupModulationConfigResponse;
|
||||
};
|
||||
template <> struct ResponseSelector<ctrl_GroupModulationControlRequest> {
|
||||
using response_t = ctrl_GroupModulationControlResponse;
|
||||
};
|
||||
template <> struct ResponseSelector<ctrl_PhaseModulationConfigRequest> {
|
||||
using response_t = ctrl_PhaseModulationConfigResponse;
|
||||
};
|
||||
template <> struct ResponseSelector<ctrl_PhaseModulationControlRequest> {
|
||||
using response_t = ctrl_PhaseModulationControlResponse;
|
||||
};
|
||||
|
||||
|
||||
} // namespace rims
|
||||
|
||||
@ -44,7 +44,7 @@ TStack temperatureSamplerStack{k_temperatureSamplerStack, K_THREAD_STACK_SIZEOF(
|
||||
static K_THREAD_STACK_DEFINE(k_zeroCrossDetectionStack, 1300);
|
||||
TStack zeroCrossDetectionStack{k_zeroCrossDetectionStack, K_THREAD_STACK_SIZEOF(k_zeroCrossDetectionStack)};
|
||||
|
||||
static K_THREAD_STACK_DEFINE(k_phaseModulationStack, 1400);
|
||||
static K_THREAD_STACK_DEFINE(k_phaseModulationStack, 1600);
|
||||
TStack phaseModulationStack{k_phaseModulationStack, K_THREAD_STACK_SIZEOF(k_phaseModulationStack)};
|
||||
|
||||
static K_THREAD_STACK_DEFINE(k_gpioStack, 1000);
|
||||
@ -56,11 +56,6 @@ TStack threadAnalyzerStack{k_threadAnalyzerStack, K_THREAD_STACK_SIZEOF(k_thread
|
||||
static K_THREAD_STACK_DEFINE(k_operationStack, 2000);
|
||||
TStack operationStack{k_operationStack, K_THREAD_STACK_SIZEOF(k_operationStack)};
|
||||
|
||||
/// TOP LEVEL TODOS ;)
|
||||
/// TODO power control implementation
|
||||
/// TODO power measurement thread
|
||||
/// TODO status led thread, print statues
|
||||
|
||||
template <typename T> class LazyInit {
|
||||
alignas(T) std::byte _buf[sizeof(T)];
|
||||
unique_placed_ptr<T> obj;
|
||||
|
||||
@ -45,12 +45,23 @@ struct control_channel_disabled : error {
|
||||
control_channel_disabled() : error{op_Error_ControlChannelDisabled} {
|
||||
}
|
||||
};
|
||||
|
||||
struct mode_does_not_accept_target_temperature : error {
|
||||
mode_does_not_accept_target_temperature() : error{op_Error_ModeDoesNotHandleTargetTemperatureMessage} {
|
||||
}
|
||||
};
|
||||
} // namespace op
|
||||
|
||||
template <typename T>
|
||||
concept HasSetTargetTemperature = requires(T t, float temp) {
|
||||
{ t.setTargetTemperature(temp) } -> std::same_as<void>;
|
||||
};
|
||||
template <typename T>
|
||||
concept HasTargetTemperature = requires(T t) {
|
||||
{ t.targetTemperature() } -> std::convertible_to<float>;
|
||||
};
|
||||
|
||||
|
||||
K_FIFO_DEFINE(operationIngress);
|
||||
K_FIFO_DEFINE(operationEggress);
|
||||
|
||||
@ -241,15 +252,6 @@ void ConstantTemperatureMode::update() {
|
||||
_powerControl.get().setPower(outputPower);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
concept HasSetTargetTemperature = requires(T t, float temp) {
|
||||
{ t.setTargetTemperature(temp) } -> std::same_as<void>;
|
||||
};
|
||||
template <typename T>
|
||||
concept HasTargetTemperature = requires(T t) {
|
||||
{ t.targetTemperature() } -> std::convertible_to<float>;
|
||||
};
|
||||
|
||||
void OperationOrchestrator::handle_targetTemperatureRequest(const TargetTemperatureRequest &req, TargetTemperatureResponse &resp) {
|
||||
ULOG_INFO("target temperature request handler");
|
||||
if (not channelExists(req.channel_id)) throw op::channel_not_found{};
|
||||
@ -363,7 +365,7 @@ PowerControl::PowerControl(std::span<uint8_t> channels) : _control_channels{chan
|
||||
throw op::error{};
|
||||
}
|
||||
|
||||
if (resp->alg == ctrl_PowerControlAlgorithm_NoModulation) {
|
||||
if (resp->alg.alg == ctrl_PowerControlAlgorithm_NoModulation) {
|
||||
ULOG_WARNING("ctrl channel %d disabled", resp->channel_id);
|
||||
throw op::control_channel_disabled{};
|
||||
}
|
||||
|
||||
@ -54,13 +54,9 @@ fifo_queue<ctrl_EgressMessage, 2> ctrlEgressQueue{ctrlEggress};
|
||||
|
||||
constexpr auto ctrl_factory = handler_factory<ctrl_IngressMessage, ctrl_EgressMessage, ctrl::error>{};
|
||||
|
||||
constexpr std::array<handler, 6> ctrl_modeHandlers = {
|
||||
constexpr std::array<handler, 2> ctrl_modeHandlers = {
|
||||
ctrl_factory.make_handler<PowerControlAlgorithmRequest, &PhaseModulationOrchestrator::handler_powerControlAlgorithmRequest>(),
|
||||
ctrl_factory.make_handler<PowerLevelRequest, &PhaseModulationOrchestrator::handler_powerLevelRequest>(),
|
||||
ctrl_factory.make_handler<GroupModulationConfigRequest, &PhaseModulationOrchestrator::handler_groupModulationConfigRequest>(),
|
||||
ctrl_factory.make_handler<GroupModulationControlRequest, &PhaseModulationOrchestrator::handler_groupModulationControlRequest>(),
|
||||
ctrl_factory.make_handler<PhaseModulationConfigRequest, &PhaseModulationOrchestrator::handler_phaseModulationConfigRequest>(),
|
||||
ctrl_factory.make_handler<PhaseModulationControlRequest, &PhaseModulationOrchestrator::handler_phaseModulationControlRequest>()
|
||||
ctrl_factory.make_handler<PowerLevelRequest, &PhaseModulationOrchestrator::handler_powerLevelRequest>()
|
||||
};
|
||||
|
||||
constexpr std::array<gpio_dt_spec, MaxChannels> pins = {
|
||||
@ -179,7 +175,7 @@ void PhaseModulationOrchestrator::handler_powerControlAlgorithmRequest(
|
||||
setPowerControlAlgorithm(request.channel_id, request.alg);
|
||||
}
|
||||
|
||||
resp.alg = powerControlAlgorithm(request.channel_id);
|
||||
// resp.alg = powerControlAlgorithm(request.channel_id);
|
||||
}
|
||||
|
||||
void PhaseModulationOrchestrator::handler_powerLevelRequest( //
|
||||
@ -196,66 +192,14 @@ void PhaseModulationOrchestrator::handler_powerLevelRequest( //
|
||||
resp.level = strategy(request.channel_id).power();
|
||||
}
|
||||
|
||||
void PhaseModulationOrchestrator::handler_groupModulationConfigRequest( //
|
||||
const GroupModulationConfigRequest &request,
|
||||
GroupModulationConfigResponse &resp
|
||||
) {
|
||||
ULOG_INFO("GroupModulationConfigRequest request handler");
|
||||
// checkChannel(request.channel_id);
|
||||
// checkCurrentMode(request.channel_id, ctrl_ModeOfOperation_GroupModulation);
|
||||
|
||||
// auto &alg = std::get<GroupModulation>(_channel[request.channel_id]);
|
||||
|
||||
// if (request.has_cycles_max) {
|
||||
// alg.setCyclesMax(request.cycles_max);
|
||||
// }
|
||||
|
||||
// resp.cycles_max = alg.getCyclesMax();
|
||||
}
|
||||
|
||||
void PhaseModulationOrchestrator::handler_groupModulationControlRequest( //
|
||||
const GroupModulationControlRequest &request,
|
||||
GroupModulationControlResponse &resp
|
||||
) {
|
||||
ULOG_INFO("GroupModulationControlRequest request handler");
|
||||
// checkChannel(request.channel_id);
|
||||
// checkCurrentMode(request.channel_id, ctrl_ModeOfOperation_GroupModulation);
|
||||
|
||||
// auto &alg = std::get<GroupModulation>(_channel[request.channel_id]);
|
||||
|
||||
// if (request.has_cycles) {
|
||||
// alg.setCycles(request.cycles);
|
||||
// }
|
||||
|
||||
// resp.cycles = alg.getCycles();
|
||||
}
|
||||
|
||||
void PhaseModulationOrchestrator::handler_phaseModulationConfigRequest( //
|
||||
const PhaseModulationConfigRequest &request,
|
||||
PhaseModulationConfigResponse &resp
|
||||
) {
|
||||
ULOG_INFO("PhaseModulationConfigRequest request handler");
|
||||
checkChannel(request.channel_id);
|
||||
// checkCurrentMode(request.channel_id, ctrl_ModeOfOperation_PhaseModulation);
|
||||
}
|
||||
|
||||
void PhaseModulationOrchestrator::handler_phaseModulationControlRequest( //
|
||||
const PhaseModulationControlRequest &request,
|
||||
PhaseModulationControlResponse &resp
|
||||
) {
|
||||
ULOG_INFO("PhaseModulationControlRequest request handler");
|
||||
checkChannel(request.channel_id);
|
||||
// checkCurrentMode(request.channel_id, ctrl_ModeOfOperation_PhaseModulation);
|
||||
}
|
||||
|
||||
void PhaseModulationOrchestrator::checkChannel(uint8_t channel_id) {
|
||||
if (channel_id >= MaxChannels) throw ctrl::wrong_channel{};
|
||||
}
|
||||
|
||||
void PhaseModulationOrchestrator::setPowerControlAlgorithm(uint8_t ch, PowerControlAlgorithm alg) {
|
||||
void PhaseModulationOrchestrator::setPowerControlAlgorithm(uint8_t ch, const ctrl_PowerControlAlgorithmData &alg) {
|
||||
checkChannel(ch);
|
||||
|
||||
switch (alg) {
|
||||
switch (alg.alg) {
|
||||
case ctrl_PowerControlAlgorithm_NoModulation:
|
||||
_chPowerControlStrategy[ch].emplace<NoModulation>();
|
||||
break;
|
||||
|
||||
@ -24,16 +24,6 @@ using PowerControlAlgorithmResponse = ctrl_PowerControlAlgorithmResponse;
|
||||
using PowerLevelRequest = ctrl_PowerLevelRequest;
|
||||
using PowerLevelResponse = ctrl_PowerLevelResponse;
|
||||
|
||||
using GroupModulationConfigRequest = ctrl_GroupModulationConfigRequest;
|
||||
using GroupModulationConfigResponse = ctrl_GroupModulationConfigResponse;
|
||||
using GroupModulationControlRequest = ctrl_GroupModulationControlRequest;
|
||||
using GroupModulationControlResponse = ctrl_GroupModulationControlResponse;
|
||||
|
||||
using PhaseModulationConfigRequest = ctrl_PhaseModulationConfigRequest;
|
||||
using PhaseModulationConfigResponse = ctrl_PhaseModulationConfigResponse;
|
||||
using PhaseModulationControlRequest = ctrl_PhaseModulationControlRequest;
|
||||
using PhaseModulationControlResponse = ctrl_PhaseModulationControlResponse;
|
||||
|
||||
constexpr int MaxChannels = 2;
|
||||
|
||||
class PowerControlStrategy {
|
||||
@ -138,15 +128,6 @@ class NoModulation : public PowerControlStrategy {
|
||||
}
|
||||
};
|
||||
|
||||
class Linked : public PowerControlStrategy {
|
||||
void zeroCrossDetectionTick(ZeroCrossDetectionEvent::Data) override {
|
||||
}
|
||||
void on() const override {
|
||||
}
|
||||
void off() const override {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* class represents a power controll thread for channels, it only needs to set given power and react to ZCD event, thats it.
|
||||
*/
|
||||
@ -162,19 +143,12 @@ class PhaseModulationOrchestrator {
|
||||
|
||||
void handler_powerControlAlgorithmRequest(const PowerControlAlgorithmRequest &request, PowerControlAlgorithmResponse &resp);
|
||||
void handler_powerLevelRequest(const PowerLevelRequest &request, PowerLevelResponse &response);
|
||||
|
||||
void handler_groupModulationConfigRequest(const GroupModulationConfigRequest &request, GroupModulationConfigResponse &resp);
|
||||
void handler_groupModulationControlRequest(const GroupModulationControlRequest &request, GroupModulationControlResponse &resp);
|
||||
|
||||
void handler_phaseModulationConfigRequest(const PhaseModulationConfigRequest &request, PhaseModulationConfigResponse &resp);
|
||||
void handler_phaseModulationControlRequest(const PhaseModulationControlRequest &request, PhaseModulationControlResponse &resp);
|
||||
|
||||
private:
|
||||
void event_zeroCrossDetection();
|
||||
void event_ctrlMessageArrived();
|
||||
|
||||
/// Helpers
|
||||
void setPowerControlAlgorithm(uint8_t ch, PowerControlAlgorithm alg);
|
||||
void setPowerControlAlgorithm(uint8_t ch, const ctrl_PowerControlAlgorithmData& alg);
|
||||
PowerControlAlgorithm powerControlAlgorithm(uint8_t ch);
|
||||
|
||||
bool setup();
|
||||
|
||||
@ -55,9 +55,7 @@ constexpr auto temperature_factory = handler_factory<temperature_IngressMessage,
|
||||
constexpr std::array<handler, 5> temp_handlers = {
|
||||
temperature_factory.make_handler<GetTemperatureRequest, &TemperatureSamplerOrchestrator::handle_getTemperatureRequest>(),
|
||||
temperature_factory.make_handler<GetActiveChannelsRequest, &TemperatureSamplerOrchestrator::handle_activeChannelsRequest>(),
|
||||
temperature_factory.make_handler<SamplerConfigRequest, &TemperatureSamplerOrchestrator::handle_samplerConfigRequest>(),
|
||||
temperature_factory.make_handler<FilterConfigRequest, &TemperatureSamplerOrchestrator::handle_filterConfigRequest>(),
|
||||
temperature_factory.make_handler<FilterRequest, &TemperatureSamplerOrchestrator::handle_filterRequest>()
|
||||
temperature_factory.make_handler<SamplerConfigRequest, &TemperatureSamplerOrchestrator::handle_samplerConfigRequest>()
|
||||
};
|
||||
|
||||
namespace {
|
||||
@ -377,34 +375,6 @@ void TemperatureSamplerOrchestrator::handle_samplerConfigRequest( //
|
||||
resp.config = _temperatureSamplerChannels[req.channel_id].samplerConfig();
|
||||
}
|
||||
|
||||
void TemperatureSamplerOrchestrator::handle_filterConfigRequest( //
|
||||
const FilterConfigRequest &req,
|
||||
FilterConfigResponse &resp
|
||||
) const {
|
||||
if (unknownChannelError(req, resp)) return;
|
||||
|
||||
if (req.has_ema_filter_params) {
|
||||
/// TODO set
|
||||
}
|
||||
|
||||
if (req.has_kalman_pilter_params) {
|
||||
/// TODO set
|
||||
}
|
||||
|
||||
if (req.has_average_filter_params) {
|
||||
/// TODO set
|
||||
}
|
||||
|
||||
if (not req.skip_full_response) {
|
||||
}
|
||||
}
|
||||
|
||||
void TemperatureSamplerOrchestrator::handle_filterRequest( //
|
||||
const FilterRequest &req,
|
||||
FilterResponse &resp
|
||||
) const {
|
||||
if (unknownChannelError(req, resp)) return;
|
||||
}
|
||||
|
||||
void TemperatureSamplerOrchestrator::action_samplersTick() {
|
||||
zephyr::semaphore::k_sem_take_now(_samplerTickSem);
|
||||
|
||||
@ -32,10 +32,6 @@ using GetActiveChannelsRequest = temperature_GetActiveChannelsRequest;
|
||||
using GetActiveChannelsResponse = temperature_GetActiveChannelsResponse;
|
||||
using SamplerConfigRequest = temperature_SamplerConfigRequest;
|
||||
using SamplerConfigResponse = temperature_SamplerConfigResponse;
|
||||
using FilterConfigRequest = temperature_FilterConfigRequest;
|
||||
using FilterConfigResponse = temperature_FilterConfigResponse;
|
||||
using FilterRequest = temperature_FilterRequest;
|
||||
using FilterResponse = temperature_FilterResponse;
|
||||
|
||||
using SampleConfig = temperature_SamplerConfig;
|
||||
using TemperatureCurrent = temperature_TemperatureCurrent;
|
||||
@ -168,8 +164,6 @@ class TemperatureSamplerOrchestrator {
|
||||
void handle_getTemperatureRequest(const GetTemperatureRequest &req, GetTemperatureResponse &resp) const;
|
||||
void handle_activeChannelsRequest(const GetActiveChannelsRequest &req, GetActiveChannelsResponse &resp) const;
|
||||
void handle_samplerConfigRequest(const SamplerConfigRequest &req, SamplerConfigResponse &resp);
|
||||
void handle_filterConfigRequest(const FilterConfigRequest &req, FilterConfigResponse &resp) const;
|
||||
void handle_filterRequest(const FilterRequest &req, FilterResponse &resp) const;
|
||||
|
||||
private:
|
||||
// events handled in main loop
|
||||
|
||||
@ -18,14 +18,6 @@ template <> constexpr int tag<temperature_SamplerConfigRequest>() {
|
||||
return temperature_IngressMessage_sampler_config_request_tag;
|
||||
}
|
||||
|
||||
template <> constexpr int tag<temperature_FilterConfigRequest>() {
|
||||
return temperature_IngressMessage_filter_config_request_tag;
|
||||
}
|
||||
|
||||
template <> constexpr int tag<temperature_FilterRequest>() {
|
||||
return temperature_IngressMessage_filter_request_tag;
|
||||
}
|
||||
|
||||
template <> constexpr int tag<temperature_GetTemperatureResponse>() {
|
||||
return temperature_EgressMessage_temperature_response_tag;
|
||||
}
|
||||
@ -38,31 +30,20 @@ template <> constexpr int tag<temperature_SamplerConfigResponse>() {
|
||||
return temperature_EgressMessage_sampler_config_response_tag;
|
||||
}
|
||||
|
||||
template <> constexpr int tag<temperature_FilterConfigResponse>() {
|
||||
return temperature_EgressMessage_filter_config_response_tag;
|
||||
}
|
||||
|
||||
template <> constexpr int tag<temperature_FilterResponse>() {
|
||||
return temperature_EgressMessage_filter_response_tag;
|
||||
}
|
||||
|
||||
template <typename MsgT>
|
||||
constexpr bool is_temperature_ingress_msg_v = is_any_of_v<
|
||||
MsgT, //
|
||||
temperature_GetTemperatureRequest,
|
||||
temperature_GetActiveChannelsRequest,
|
||||
temperature_SamplerConfigRequest,
|
||||
temperature_FilterConfigRequest,
|
||||
temperature_FilterRequest>;
|
||||
temperature_SamplerConfigRequest>;
|
||||
|
||||
template <typename MsgT>
|
||||
constexpr bool is_temperature_egress_msg_v = is_any_of_v<
|
||||
MsgT, //
|
||||
temperature_GetTemperatureResponse,
|
||||
temperature_GetActiveChannelsResponse,
|
||||
temperature_SamplerConfigResponse,
|
||||
temperature_FilterConfigResponse,
|
||||
temperature_FilterResponse>;
|
||||
temperature_SamplerConfigResponse>;
|
||||
|
||||
template <> struct ResponseSelector<temperature_GetTemperatureRequest> {
|
||||
using response_t = temperature_GetTemperatureResponse;
|
||||
@ -76,12 +57,5 @@ template <> struct ResponseSelector<temperature_SamplerConfigRequest> {
|
||||
using response_t = temperature_SamplerConfigResponse;
|
||||
};
|
||||
|
||||
template <> struct ResponseSelector<temperature_FilterConfigRequest> {
|
||||
using response_t = temperature_FilterConfigResponse;
|
||||
};
|
||||
|
||||
template <> struct ResponseSelector<temperature_FilterRequest> {
|
||||
using response_t = temperature_FilterResponse;
|
||||
};
|
||||
|
||||
} // namespace rims
|
||||
|
||||
Loading…
Reference in New Issue
Block a user