plcopen 0.22.0
载入中...
搜索中...
未找到
tracking.h
浏览该文件的文档.
1#pragma once
2
3#include <cstdint>
4
5#include "axis/group.h"
6#include "fb/motion.h"
7
8namespace plcopen::core::fb
9{
10
12{
13public:
15 bool execute = false;
19
20protected:
22 {
23 const bool rising = execute && !last_execute_;
24 last_execute_ = execute;
25 if(!execute) {
27 tracked_command_id_ = 0;
28 }
29 return rising;
30 }
31
32 void accept(const rt::Result<std::uint32_t> &accepted)
33 {
35 if(!accepted) {
36 outputs.error = true;
37 outputs.error_id = accepted.error();
38 return;
39 }
40 tracked_command_id_ = accepted.value();
41 outputs.command_id = tracked_command_id_;
42 outputs.command_accepted = true;
43 outputs.done = true;
44 outputs.busy = true;
45 }
46
47 void observe()
48 {
49 if(!execute || tracked_command_id_ == 0 || group_ref == nullptr) return;
50 const rt::ErrorCode error = group_ref->tracking_command_error(tracked_command_id_);
52 outputs.error = true;
53 outputs.error_id = error;
54 outputs.busy = false;
55 outputs.active = false;
56 tracked_command_id_ = 0;
57 return;
58 }
59 if(group_ref->tracking_command_busy(tracked_command_id_)) {
60 outputs.busy = true;
61 outputs.active = group_ref->tracking_command_active(tracked_command_id_);
62 return;
63 }
64 outputs.command_aborted =
65 group_ref->tracking_command_aborted(tracked_command_id_);
66 outputs.busy = false;
67 outputs.active = false;
68 tracked_command_id_ = 0;
69 }
70
71private:
72 bool last_execute_ = false;
73 std::uint32_t tracked_command_id_ = 0;
74};
75
94
115
136
137} // namespace plcopen::core::fb
void accept(const rt::Result< std::uint32_t > &accepted)
static constexpr Result failure(ErrorCode error)
定义 error.h:29
void clear(MotionOutputs &outputs)