initial commit
This commit is contained in:
62
include/sequence.hpp
Normal file
62
include/sequence.hpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include "model_value.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Mirrors lib/dali/sequence.dart command type names.
|
||||
enum class DaliCommandType {
|
||||
setBright,
|
||||
on,
|
||||
off,
|
||||
toScene,
|
||||
setScene,
|
||||
removeScene,
|
||||
addToGroup,
|
||||
removeFromGroup,
|
||||
setFadeTime,
|
||||
setFadeRate,
|
||||
wait,
|
||||
modifyShortAddress,
|
||||
deleteShortAddress,
|
||||
};
|
||||
|
||||
std::string toString(DaliCommandType type);
|
||||
DaliCommandType commandTypeFromString(const std::string& name,
|
||||
DaliCommandType fallback = DaliCommandType::setBright);
|
||||
|
||||
struct DaliCommandParams {
|
||||
DaliValue::Object data;
|
||||
|
||||
DaliCommandParams() = default;
|
||||
explicit DaliCommandParams(DaliValue::Object d) : data(std::move(d)) {}
|
||||
|
||||
int getInt(const std::string& key, int def = 0) const;
|
||||
DaliCommandParams copy() const;
|
||||
|
||||
DaliValue::Object toJson() const;
|
||||
static DaliCommandParams fromJson(const DaliValue::Object& json);
|
||||
};
|
||||
|
||||
struct SequenceStep {
|
||||
std::string id;
|
||||
std::optional<std::string> remark;
|
||||
DaliCommandType type = DaliCommandType::setBright;
|
||||
DaliCommandParams params;
|
||||
|
||||
SequenceStep copy() const;
|
||||
|
||||
DaliValue::Object toJson() const;
|
||||
static SequenceStep fromJson(const DaliValue::Object& json);
|
||||
};
|
||||
|
||||
struct CommandSequence {
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::vector<SequenceStep> steps;
|
||||
|
||||
DaliValue::Object toJson() const;
|
||||
static CommandSequence fromJson(const DaliValue::Object& json);
|
||||
};
|
||||
Reference in New Issue
Block a user