25 #ifndef MOCK_PLATFORM_HPP__
26 #define MOCK_PLATFORM_HPP__
32 #include <ccut/yml.hpp>
34 #include "Exception.hpp"
36 #include "device/DeviceBase.hpp"
37 #include "platform/PlatformBase.hpp"
39 #define MOCK_PLATFORM_STEPS_PER_MM 250
40 #define MOCK_PLATFORM_DELAY_MS 20
41 #define MOCK_PLATFORM_COMMAD_TIMEOUT_MS 40
57 static inline PlatformBase::Shared
create(
const ccut::yml::NodeRef &config)
64 inline std::shared_ptr<MockPlatform> shared_from_this()
66 return std::static_pointer_cast<MockPlatform>(
67 PlatformBase::shared_from_this());
70 inline std::shared_ptr<const MockPlatform> shared_from_this()
const
72 return std::static_pointer_cast<const MockPlatform>(
73 PlatformBase::shared_from_this());
90 friend std::ostream &operator<<(std::ostream &os,
MotorLocation l)
94 case MotorLocation::X: os <<
"X";
return os;
95 case MotorLocation::Y: os <<
"Y";
return os;
96 case MotorLocation::Z: os <<
"Z";
return os;
97 case MotorLocation::A: os <<
"A";
return os;
98 case MotorLocation::B: os <<
"B";
return os;
99 case MotorLocation::C: os <<
"C";
return os;
100 default:
throw Exception(ErrorCode::InvalidArguments);
107 return MotorLocation::X;
111 return MotorLocation::Y;
115 return MotorLocation::Z;
119 return MotorLocation::A;
123 return MotorLocation::B;
127 return MotorLocation::C;
129 throw Exception(ErrorCode::InvalidArguments);
132 using PlatformBase::stop;
135 DeviceTypeList getSupportedDevices()
const override;
136 DeviceList generateDevices(
const DeviceTypeList &deviceType)
override;
138 size_t getPlatformId()
const;
140 void setMotorPosition(
const std::string &motor,
141 units::Value::value_type destPosition);
142 units::Value::value_type getMotorPosition(
const std::string &motor);
144 units::Value::value_type getLvdtAngle(
const std::string &lvdt);
145 void setLvdtAngle(
const std::string &lvdt, units::Value::value_type value);
147 void setGpioState(
const std::string &gpio,
const units::io_port_t &state);
148 units::io_port_t getGpioState(
const std::string &gpio);
150 static const std::string s_loggerCat;
153 explicit MockPlatform(
const ccut::yml::NodeRef &node);
158 std::map<std::string, MotorLocation> m_motors;
159 std::map<MotorLocation, units::Value::value_type> m_motorPositions;
161 std::map<std::string, uint8_t> m_lvdts;
162 std::map<uint8_t, units::Value::value_type> m_lvdtPositions;
164 std::map<std::string, uint8_t> m_gpios;
165 std::map<uint8_t, units::io_port_t> m_gpioStates;
Exception thrown by MotionController in case of issues with command.
main motion-lib namespace