|
- #pragma once
-
- #include "domain/control_logic_model.h"
-
- #include <string>
- #include <vector>
-
- class LogicEditorService;
-
- enum class LogicCommandOpcode
- {
- Load,
- LoadInverse,
- LoadRising,
- LoadFalling,
- CompareEqual,
- CompareNotEqual,
- CompareLessThan,
- CompareLessThanOrEqual,
- CompareGreaterThan,
- CompareGreaterThanOrEqual,
- And,
- AndInverse,
- Or,
- OrInverse,
- Output,
- Set,
- Reset,
- Move,
- Add,
- Subtract
- };
-
- struct ParsedLogicCommand
- {
- LogicCommandOpcode opcode = LogicCommandOpcode::Load;
- LogicNodeConfig config = ContactNodeConfig{
- RegisterAddress{RegisterArea::M, 0}, ContactMode::NormallyOpen};
- };
-
- struct LogicCommandParseResult
- {
- bool succeeded = false;
- std::string message;
- ParsedLogicCommand command;
- };
-
- struct LogicCommandSuggestion
- {
- std::string mnemonic;
- std::string description;
- std::string operand_hint;
- bool supported = true;
- };
-
- enum class LogicCommandTargetKind
- {
- EmptyColumn,
- BranchEmptyColumn,
- WireColumn,
- GapColumn,
- Output,
- ExistingNode
- };
-
- struct LogicCommandTarget
- {
- LogicCommandTargetKind kind = LogicCommandTargetKind::EmptyColumn;
- std::string rungId;
- std::string expressionId;
- int column = 0;
- };
-
- struct LogicCommandRequest
- {
- std::string logicId;
- std::string text;
- LogicCommandTarget target;
- bool continuing = false;
- std::string currentRungId;
- std::vector<std::string> parallelNodeIds;
- };
-
- struct LogicCommandResult
- {
- bool succeeded = false;
- std::string message;
- std::string id;
- std::string rungId;
- LogicCommandOpcode opcode = LogicCommandOpcode::Load;
- };
-
- // 将单条命令语解析并原子转换为现有结构化梯形图编辑操作
- class LogicCommandService
- {
- public:
- explicit LogicCommandService(LogicEditorService &editor_service);
-
- static LogicCommandParseResult parse(const std::string &text);
- static const std::vector<LogicCommandSuggestion> &suggestions();
-
- LogicCommandResult execute(const LogicCommandRequest &request);
-
- private:
- LogicEditorService &editor_service_;
- };
|