Files
LinuxMotion/MotionLib/Inc/Axis.h
T
chen 7f73fb48ef feat: 添加多线程框架与轴周期接口
- 新增 MotionTickThread 线程模块
- main.cpp: 引入双线程架构(UserAppThread + MotionTickThread)
- Axis: 新增 cycle() 接口,添加 #pragma once 头文件保护
- App/CMakeLists.txt: 链接 pthread,重组源文件列表
- .gitignore: 排除 docs/html、.vscode、compile_commands.json
2026-07-03 08:10:24 +00:00

70 lines
1.5 KiB
C++

/**
* @file Axis.h
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2026-07-02
*
* @copyright Copyright (c) 2026
*
*/
#pragma once
#include "Types.h"
namespace plcopen {
/**
* \enum MotionCommandType
* \brief 内部运动指令类型(功能块 → 轴模型映射)
*/
enum class MotionCommandType {
None, /*!< 无活动指令 */
PointToPoint, /*!< MC_MoveAbsolute / MC_MoveRelative */
Velocity, /*!< MC_MoveVelocity */
Stop, /*!< MC_Stop */
Halt, /*!< MC_Halt */
Home, /*!< MC_Home */
};
/**
* \struct MotionCommand
* \brief 当前活动运动指令的参数快照
*/
struct MotionCommand {
MotionCommandType type = MotionCommandType::None;
REAL targetPosition = 0.0;
REAL targetVelocity = 0.0;
REAL maxVelocity = 0.0;
REAL acceleration = 0.0;
REAL deceleration = 0.0;
REAL homePosition = 0.0;
MC_AXIS_STATE resultingState = MC_AXIS_STATE::DiscreteMotion;
};
/**
* \class Axis
* \brief 单轴仿真对象,实现 PLCopen 轴状态机与运动学
* \note 不要在功能块 cycle() 之外直接修改 Axis 内部状态。
*/
class Axis {
public:
/**
* \brief 构造轴
* \param axisNo 轴编号
* \param name 轴名称
*/
explicit Axis(UINT axisNo = 1, std::string name = "Axis1");
void cycle();
private:
AXIS_REF ref_;
MC_AXIS_STATE state_ = MC_AXIS_STATE::Disabled;
};
}