@@ -196,6 +196,20 @@ namespace fmu4cpp {
196196 }
197197 }
198198
199+ void set_binary (const unsigned int vr[], size_t nvr, const uint8_t *value[], const size_t size[]) {
200+ #ifdef FMI2
201+ static_assert (" set_binary not available for FMI2" );
202+ #endif
203+
204+ for (unsigned i = 0 ; i < nvr; i++) {
205+ const auto ref = vr[i];
206+ const auto idx = vrToBinaryIndices_.at (ref);
207+ const uint8_t *ptr = value[i];
208+ const size_t len = size[i];
209+ binary_[idx].set (std::string (reinterpret_cast <const char *>(ptr), len));
210+ }
211+ }
212+
199213 [[nodiscard]] std::string guid () const ;
200214
201215 [[nodiscard]] std::string make_description () const ;
@@ -246,10 +260,17 @@ namespace fmu4cpp {
246260 const std::function<std::string()> &getter,
247261 const std::optional<std::function<void(std::string)>> &setter = std::nullopt);
248262
263+ BinaryVariable binary (const std::string &name, std::string *ptr, const std::function<void (std::string)> &onChange = {});
264+ BinaryVariable binary (const std::string &name,
265+ const std::function<std::string()> &getter,
266+ const std::optional<std::function<void(std::string)>> &setter = std::nullopt);
267+
249268 void register_variable (IntVariable v);
250269 void register_variable (RealVariable v);
251270 void register_variable (BoolVariable v);
252271 void register_variable (StringVariable v);
272+ void register_variable (BinaryVariable v);
273+
253274
254275 virtual void enter_initialisation_mode ();
255276 virtual bool do_step (double dt) = 0;
@@ -283,6 +304,11 @@ namespace fmu4cpp {
283304 std::vector<StringVariable> strings_;
284305 std::vector<std::string> stringBuffer_;
285306 std::unordered_map<unsigned int , size_t > vrToStringIndices_;
307+
308+ std::vector<StringVariable> binary_;
309+ std::vector<std::string> binaryBuffer_;
310+ std::unordered_map<unsigned int , size_t > vrToBinaryIndices_;
311+
286312 };
287313
288314
0 commit comments