plcopen 0.22.0
载入中...
搜索中...
未找到
bind.h
浏览该文件的文档.
1#pragma once
2
3// RT-SAFE: generated cycle-path FB dispatch for the ST VM. Native instances
4// are placement-constructed in caller-owned storage; every scalar/object
5// transfer is validated by the generated capability and type authorities.
6
7#include <cstdint>
8
9#include "fb/basic.h"
10#include "st/pins.h"
11
12namespace plcopen::core::st
13{
14
15inline void fb_init(FbType type, unsigned char *storage,
16 std::int64_t task_period_ns)
17{
19 switch(type) {
20 case FbType::ton:
21 reinterpret_cast<fb::TON *>(storage)
22 ->set_cycle_time(task_period_ns);
23 break;
24 case FbType::tof:
25 reinterpret_cast<fb::TOF *>(storage)
26 ->set_cycle_time(task_period_ns);
27 break;
28 case FbType::tp:
29 reinterpret_cast<fb::TP *>(storage)
30 ->set_cycle_time(task_period_ns);
31 break;
32 default: break;
33 }
34}
35
36inline void fb_destroy(FbType type, unsigned char *storage) noexcept
37{
39}
40
41inline bool fb_store_scalar(FbType type, unsigned char *storage,
42 std::uint16_t pin, std::uint64_t bits) noexcept
43{
44 return generated::st_binding_store_scalar(type, pin, storage, bits);
45}
46
47inline bool fb_load_scalar(FbType type, const unsigned char *storage,
48 std::uint16_t pin, std::uint64_t &bits) noexcept
49{
50 return generated::st_binding_load_scalar(type, pin, storage, bits);
51}
52
53inline bool fb_store_object(FbType type, unsigned char *storage,
54 std::uint8_t pin, const unsigned char *bytes,
55 TypeId type_id, std::uint32_t size) noexcept
56{
57 return generated::st_binding_store_object(type, pin, storage, bytes,
58 type_id, size);
59}
60
61inline bool fb_load_object(FbType type, const unsigned char *storage,
62 std::uint8_t pin, unsigned char *bytes,
63 TypeId type_id, std::uint32_t size) noexcept
64{
65 return generated::st_binding_load_object(type, pin, storage, bytes,
66 type_id, size);
67}
68
70 FbType type, unsigned char *storage, std::uint16_t pin,
72{
73 return generated::st_binding_store_sequence(type, pin, storage, value);
74}
75
76inline bool fb_load_sequence(
77 FbType type, const unsigned char *storage, std::uint16_t pin,
79{
80 return generated::st_binding_load_sequence(type, pin, storage, value);
81}
82
84 FbType type, unsigned char *storage, std::uint16_t pin, TypeId type_id,
86{
88 type, pin, storage, type_id, value);
89}
90
92 FbType type, const unsigned char *storage, std::uint16_t pin,
95{
97 type, pin, storage, type_id, value);
98}
99
100inline void fb_cycle(FbType type, unsigned char *storage,
101 std::int64_t task_period_ns = 0)
102{
103 // Timer periods are installed once in the load domain. The generated
104 // standalone invoke helper accepts an explicit period, so VM scans keep
105 // the timer's installed value through its direct cycle entry.
106 switch(type) {
107 case FbType::ton:
108 reinterpret_cast<fb::TON *>(storage)->cycle();
109 return;
110 case FbType::tof:
111 reinterpret_cast<fb::TOF *>(storage)->cycle();
112 return;
113 case FbType::tp:
114 reinterpret_cast<fb::TP *>(storage)->cycle();
115 return;
116 default: break;
117 }
118 (void)generated::st_binding_invoke(type, storage, task_period_ns);
119}
120
121} // namespace plcopen::core::st
bool st_binding_load_sequence(StBindingFbType type, std::uint16_t pin, const void *storage, StBindingNativeSequenceValue &value) noexcept
bool st_binding_store_tagged_reference(StBindingFbType type, std::uint16_t pin, void *storage, TypeId type_id, StBindingNativeTaggedReferenceValue value) noexcept
bool st_binding_destruct(StBindingFbType type, void *storage) noexcept
bool st_binding_invoke(StBindingFbType type, void *storage, std::int64_t task_period=0)
bool st_binding_store_scalar(StBindingFbType type, std::uint16_t pin, void *storage, std::uint64_t bits) noexcept
bool st_binding_store_sequence(StBindingFbType type, std::uint16_t pin, void *storage, StBindingNativeSequenceValue value) noexcept
bool st_binding_load_scalar(StBindingFbType type, std::uint16_t pin, const void *storage, std::uint64_t &bits) noexcept
bool st_binding_store_object(StBindingFbType type, std::uint16_t pin, void *storage, const unsigned char *bytes, TypeId type_id, std::uint32_t size) noexcept
bool st_binding_default_construct(StBindingFbType type, void *storage)
bool st_binding_load_tagged_reference(StBindingFbType type, std::uint16_t pin, const void *storage, TypeId type_id, StBindingNativeTaggedReferenceValue &value) noexcept
bool st_binding_load_object(StBindingFbType type, std::uint16_t pin, const void *storage, unsigned char *bytes, TypeId type_id, std::uint32_t size) noexcept
std::uint32_t TypeId
bool fb_load_object(FbType type, const unsigned char *storage, std::uint8_t pin, unsigned char *bytes, TypeId type_id, std::uint32_t size) noexcept
定义 bind.h:61
bool fb_store_tagged_reference(FbType type, unsigned char *storage, std::uint16_t pin, TypeId type_id, generated::StBindingNativeTaggedReferenceValue value) noexcept
定义 bind.h:83
void fb_cycle(FbType type, unsigned char *storage, std::int64_t task_period_ns=0)
定义 bind.h:100
bool fb_store_scalar(FbType type, unsigned char *storage, std::uint16_t pin, std::uint64_t bits) noexcept
定义 bind.h:41
bool fb_store_object(FbType type, unsigned char *storage, std::uint8_t pin, const unsigned char *bytes, TypeId type_id, std::uint32_t size) noexcept
定义 bind.h:53
void fb_init(FbType type, unsigned char *storage, std::int64_t task_period_ns)
定义 bind.h:15
bool fb_store_sequence(FbType type, unsigned char *storage, std::uint16_t pin, generated::StBindingNativeSequenceValue value) noexcept
定义 bind.h:69
bool fb_load_tagged_reference(FbType type, const unsigned char *storage, std::uint16_t pin, TypeId type_id, generated::StBindingNativeTaggedReferenceValue &value) noexcept
定义 bind.h:91
void fb_destroy(FbType type, unsigned char *storage) noexcept
定义 bind.h:36
constexpr TypeId type_id(Type type)
定义 types.h:52
bool fb_load_scalar(FbType type, const unsigned char *storage, std::uint16_t pin, std::uint64_t &bits) noexcept
定义 bind.h:47
bool fb_load_sequence(FbType type, const unsigned char *storage, std::uint16_t pin, generated::StBindingNativeSequenceValue &value) noexcept
定义 bind.h:76
generated::StBindingFbType FbType