DUECA/DUSIME
|
Here is, as an example the header file for the PrimaryControls object, as it is generated by the code generator for DUECA:
/* ------------------------------------------------------------------ */ /* item : PrimaryControls.hxx generated by : Autobuild (abuild) date : Thu 28 Nov 2024 category : header file description : DUECA Communication Object (DCO) automatically generated by dueca-codegen codegen version : 111 language : C++ item : PrimaryControls.dco made by : Rene' van Paassen date : long ago... description : Typical set of variables to describe input from primary controls (stick or column, rudder pedals) copyright : (c) 2018-2022 TUDelft-AE-C&S : (c) 2022 René van Paassen license : EUPL-1.2 */ #pragma once #if !defined(__DCO_NOPACK) namespace dueca { class AmorphStore; class AmorphReStore; struct DataWriterArraySize; }; #endif #if !defined(__DCO_STANDALONE) namespace dueca { struct CommObjectDataTable; }; #include <gencodegen.h> #if GENCODEGEN != 111 #error "Generated PrimaryControls.hxx too old, please clean with 'make mrproper'" #endif #include <dueca/CommObjectTraits.hxx> #endif #include <iostream> #ifdef DUECA_CONFIG_HDF5 #include <H5Cpp.h> #include <hdf5utils/HDF5DCOMetaFunctor.hxx> #endif namespace dueca { /** Aircraft-oriented set of control inputs The input variables (ux, uy, etc.) may be scaled by the module doing the input, such as joystick control or control loading. The displacement, velocity and force/torque values should correspond to the inputs measured on the actual device. Note that these will typically may not be correct for joysticks that don't have force measurement. */ struct PrimaryControls { /** typedef for internal reference */ typedef PrimaryControls __ThisDCOType__; public: /** The name of this class. */ static const char* const classname; /** input around x-axis; roll, left positive */ float ux; /** input about y axis; pitch, forward positive */ float uy; /** input about z axis; yaw (pedals, twist..), left positive */ float uz; /** for helicopters, collective input */ float uc; /** displacement of the control about x axis */ float Sx; /** displacement of the control about y axis */ float Sy; /** displacement of the control about z axis */ float Sz; /** displacement of the control about collective axis */ float Sc; /** velocity of the control about x axis */ float dSx; /** velocity of the control about y axis */ float dSy; /** velocity of the control about z axis */ float dSz; /** velocity of the control about collective axis */ float dSc; /** moment of the control about x axis */ float Mx; /** moment of the control about y axis */ float My; /** moment of the control about z axis */ float Mz; /** moment of the control about collective axis */ float Mc; /** input left brake */ float fbrake_left; /** input right brake */ float fbrake_right; /** test input, used for end-to-end time delay measurement; it should be passed through model update and visual generation, and may there generate a visual indication */ int32_t test; public: /** a "magic" number, hashed out of the class definition, that will be used to check consistency of the sent objects across the dueca nodes. */ static const uint32_t magic_check_number; /** default constructor. */ PrimaryControls(); /** Constructor with arguments */ PrimaryControls( const float& ux, const float& uy, const float& uz, const float& uc, const float& Sx, const float& Sy, const float& Sz, const float& Sc, const float& dSx, const float& dSy, const float& dSz, const float& dSc, const float& Mx, const float& My, const float& Mz, const float& Mc, const float& fbrake_left, const float& fbrake_right, const int32_t& test); /** copy constructor. */ PrimaryControls(const PrimaryControls& o); #if !defined(__DCO_NOPACK) /** constructor to restore an PrimaryControls from amorphous storage. */ PrimaryControls(::dueca::AmorphReStore& r); #endif /** destructor. */ ~PrimaryControls(); #if !defined(__DCO_STANDALONE) /** new operator "new", which places objects not on a heap, but in one of the memory arenas. This to speed up memory management. */ static void* operator new(size_t size); /** new operator "delete", to go with the new version of operator new. */ static void operator delete(void* p); /** placement "new", needed for stl. */ inline static void* operator new(size_t size, PrimaryControls*& o) { return reinterpret_cast<void*>(o); } #endif #if !defined(__DCO_NOPACK) /** packs the PrimaryControls into amorphous storage. */ void packData(::dueca::AmorphStore& s) const; /** packs the PrimaryControls into amorphous storage. only differences with a previous object are packed. */ void packDataDiff(::dueca::AmorphStore& s, const PrimaryControls& ref) const; /** unpacks the PrimaryControls from an amorphous storage. */ void unPackData(::dueca::AmorphReStore& s); /** unpacks the differences for PrimaryControls from an amorphous storage. */ void unPackDataDiff(::dueca::AmorphReStore& s); #endif /** Test for equality. */ bool operator == (const PrimaryControls& o) const; /** Test for inequality. */ inline bool operator != (const PrimaryControls& o) const { return !(*this == o); } /** Assignment operator. */ PrimaryControls& operator=(const PrimaryControls& o); /** prints the PrimaryControls to a stream. */ std::ostream & print(std::ostream& s) const; }; } #if !defined(__DCO_NOPACK) /** pack the object into amorphous storage. */ inline void packData(::dueca::AmorphStore& s, const dueca::PrimaryControls& o) { o.packData(s); } /** pack the differences between this object and another into amorphous storage. */ inline void packDataDiff(dueca::AmorphStore& s, const dueca::PrimaryControls& o, const dueca::PrimaryControls& ref) { o.packDataDiff(s, ref); } /** unpack the object from amorphous storage. */ inline void unPackData(::dueca::AmorphReStore& s, dueca::PrimaryControls& o) { o.unPackData(s); } /** unpack the differences to this object from storage. */ inline void unPackDataDiff(dueca::AmorphReStore& s, dueca::PrimaryControls& o) { o.unPackDataDiff(s); } #endif namespace std { /** print to a stream. */ inline std::ostream & operator << (std::ostream& s, const dueca::PrimaryControls& o) { return o.print(s); } }; // specialization of classname template<> const char* dueca::getclassname<dueca::PrimaryControls>(); template <> inline const char* dueca::getclassname<const dueca::PrimaryControls>() { return dueca::getclassname<dueca::PrimaryControls>(); } #if !defined(__DCO_STANDALONE) namespace dueca { /** Template specialization, defines a trait that is needed if PrimaryControls is ever used inside other dco objects. */ template <> struct dco_nested<dueca::PrimaryControls> : public dco_isnested { }; }; #endif #if defined(DUECA_CONFIG_HDF5) // functors guarded in a separate namespace namespace PrimaryControls_space { // writes to file, reading from channel class HDF5DCOWriteFunctor: public dueca::hdf5log::HDF5DCOWriteFunctor { PrimaryControls example; public: // constructor, to be invoked by the metafunctor HDF5DCOWriteFunctor(std::weak_ptr<H5::H5File> file, const std::string& path, size_t chunksize, const std::string& label, bool compress, bool writeticks, const dueca::DataTimeSpec* startend); // the functor member used by channel reading code bool operator() (const void* dpointer, const dueca::DataTimeSpec& ts); }; // reads from file, writing to channel class HDF5DCOReadFunctor: public dueca::hdf5log::HDF5DCOReadFunctor { PrimaryControls example; public: // constructor, to be invoked by the metafunctor HDF5DCOReadFunctor(std::weak_ptr<H5::H5File> file, const std::string& path, bool readticks); // the functor member used by channel writing code bool operator() (void* dpointer); }; } // end namespace PrimaryControls_space #endif
The body with implementation looks like:
/* ------------------------------------------------------------------ */ /* item : PrimaryControls.cxx generated by : Autobuild (abuild) date : Thu 28 Nov 2024 category : body file description : DUECA Communication Object (DCO), automatically generated by dueca-codegen codegen version : 111 language : C++ */ #include "PrimaryControls.hxx" #include <iostream> #include <dueca/dcoprint.hxx> #include <dassert.h> #if !defined(__DCO_NOPACK) #include <dueca/AmorphStore.hxx> #include <dueca/PackUnpackTemplates.hxx> #endif #include <dueca/DataWriterArraySize.hxx> #define DOBS(A) #if !defined(__DCO_STANDALONE) #include <dueca/Arena.hxx> #include <dueca/ArenaPool.hxx> #include <dueca/DataClassRegistrar.hxx> #include <dueca/CommObjectMemberAccess.hxx> #include <dueca/DCOFunctor.hxx> #include <dueca/DCOMetaFunctor.hxx> #define DO_INSTANTIATE #include <dueca/DataSetSubsidiary.hxx> #endif #ifdef DUECA_CONFIG_HDF5 #include <hdf5utils/HDF5Templates.hxx> #endif // getclassname implementation, always namespace dueca namespace dueca { template<> const char* getclassname<::dueca::PrimaryControls>() { return "PrimaryControls"; } } namespace dueca { #if !defined(__DCO_STANDALONE) // static CommObjectMemberAccess objects, that can provide flexible access // to the members of a PrimaryControls object static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_ux(&PrimaryControls::ux, "ux"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_uy(&PrimaryControls::uy, "uy"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_uz(&PrimaryControls::uz, "uz"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_uc(&PrimaryControls::uc, "uc"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_Sx(&PrimaryControls::Sx, "Sx"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_Sy(&PrimaryControls::Sy, "Sy"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_Sz(&PrimaryControls::Sz, "Sz"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_Sc(&PrimaryControls::Sc, "Sc"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_dSx(&PrimaryControls::dSx, "dSx"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_dSy(&PrimaryControls::dSy, "dSy"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_dSz(&PrimaryControls::dSz, "dSz"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_dSc(&PrimaryControls::dSc, "dSc"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_Mx(&PrimaryControls::Mx, "Mx"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_My(&PrimaryControls::My, "My"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_Mz(&PrimaryControls::Mz, "Mz"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_Mc(&PrimaryControls::Mc, "Mc"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_fbrake_left(&PrimaryControls::fbrake_left, "fbrake_left"); static ::dueca::CommObjectMemberAccess <PrimaryControls,float > PrimaryControls_member_fbrake_right(&PrimaryControls::fbrake_right, "fbrake_right"); static ::dueca::CommObjectMemberAccess <PrimaryControls,int32_t > PrimaryControls_member_test(&PrimaryControls::test, "test"); // assemble the above entries into a table in the order in which they // appear in the PrimaryControls object static const ::dueca::CommObjectDataTable entriestable[] = { { &PrimaryControls_member_ux }, { &PrimaryControls_member_uy }, { &PrimaryControls_member_uz }, { &PrimaryControls_member_uc }, { &PrimaryControls_member_Sx }, { &PrimaryControls_member_Sy }, { &PrimaryControls_member_Sz }, { &PrimaryControls_member_Sc }, { &PrimaryControls_member_dSx }, { &PrimaryControls_member_dSy }, { &PrimaryControls_member_dSz }, { &PrimaryControls_member_dSc }, { &PrimaryControls_member_Mx }, { &PrimaryControls_member_My }, { &PrimaryControls_member_Mz }, { &PrimaryControls_member_Mc }, { &PrimaryControls_member_fbrake_left }, { &PrimaryControls_member_fbrake_right }, { &PrimaryControls_member_test }, { NULL } }; #endif // class name, static const char * const PrimaryControls::classname = "PrimaryControls"; // magic number, hashed from class name and member names / classes const uint32_t PrimaryControls::magic_check_number=0xfcf55184; #if !defined(__DCO_STANDALONE) // functor table, provides access to user-defined metafunctions through the // data class registry static dueca::functortable_type functortable; // register this class, provides access to a packing/unpacking object, // and to the member access tables static ::dueca::DataClassRegistrar registrar (PrimaryControls::classname, NULL, entriestable, &functortable, new ::dueca::DataSetSubsidiary<PrimaryControls>()); #endif #ifndef __CUSTOM_DEFAULT_CONSTRUCTOR PrimaryControls::PrimaryControls(): ux(0.0f), uy(0.0f), uz(0.0f), uc(0.0f), Sx(0.0f), Sy(0.0f), Sz(0.0f), Sc(0.0f), dSx(0.0f), dSy(0.0f), dSz(0.0f), dSc(0.0f), Mx(0.0f), My(0.0f), Mz(0.0f), Mc(0.0f), fbrake_left(0.0f), fbrake_right(0.0f), test(0) { DOBS("default constructor PrimaryControls"); } #endif #ifndef __CUSTOM_FULL_CONSTRUCTOR PrimaryControls::PrimaryControls( const float& ux, const float& uy, const float& uz, const float& uc, const float& Sx, const float& Sy, const float& Sz, const float& Sc, const float& dSx, const float& dSy, const float& dSz, const float& dSc, const float& Mx, const float& My, const float& Mz, const float& Mc, const float& fbrake_left, const float& fbrake_right, const int32_t& test) : ux(ux), uy(uy), uz(uz), uc(uc), Sx(Sx), Sy(Sy), Sz(Sz), Sc(Sc), dSx(dSx), dSy(dSy), dSz(dSz), dSc(dSc), Mx(Mx), My(My), Mz(Mz), Mc(Mc), fbrake_left(fbrake_left), fbrake_right(fbrake_right), test(test) { DOBS("complete constructor PrimaryControls"); } #endif #ifndef __CUSTOM_FULLSINGLES_CONSTRUCTOR #endif #ifndef __CUSTOM_COPY_CONSTRUCTOR PrimaryControls::PrimaryControls(const PrimaryControls& other): ux(other.ux), uy(other.uy), uz(other.uz), uc(other.uc), Sx(other.Sx), Sy(other.Sy), Sz(other.Sz), Sc(other.Sc), dSx(other.dSx), dSy(other.dSy), dSz(other.dSz), dSc(other.dSc), Mx(other.Mx), My(other.My), Mz(other.Mz), Mc(other.Mc), fbrake_left(other.fbrake_left), fbrake_right(other.fbrake_right), test(other.test) { DOBS("copy constructor PrimaryControls"); } #endif #if !defined(__CUSTOM_AMORPHRESTORE_CONSTRUCTOR) && !defined(__DCO_NOPACK) PrimaryControls::PrimaryControls(::dueca::AmorphReStore& s) { // { amorphconstructorbody } DOBS("amorph constructor PrimaryControls"); ::dueca::unpackobject(s, this->ux, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->uy, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->uz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->uc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sx, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sy, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSx, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSy, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Mx, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->My, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Mz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Mc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->fbrake_left, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->fbrake_right, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->test, dueca::dco_traits<int32_t>()); } #endif #if !defined(__CUSTOM_ARRAY_SIZE_INIT_CONSTRUCTOR) #endif #ifndef __CUSTOM_DESTRUCTOR PrimaryControls::~PrimaryControls() { DOBS("destructor PrimaryControls"); } #endif #if !defined(__DCO_STANDALONE) void* PrimaryControls::operator new(size_t size) { DOBS("operator new PrimaryControls"); static ::dueca::Arena* my_arena = arena_pool.findArena (sizeof(PrimaryControls)); return my_arena->alloc(size); } void PrimaryControls::operator delete(void* v) { DOBS("operator delete PrimaryControls"); static ::dueca::Arena* my_arena = arena_pool.findArena (sizeof(PrimaryControls)); my_arena->free(v); } #endif #if !defined(__CUSTOM_FUNCTION_PACKDATADIFF) && !defined(__DCO_NOPACK) void PrimaryControls::packDataDiff(::dueca::AmorphStore& s, const PrimaryControls& ref) const { DOBS("packDataDiff PrimaryControls"); ::dueca::IndexMemory im;// { amorphpackdiff } ::dueca::checkandpackdiff(this->ux, ref.ux, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->uy, ref.uy, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->uz, ref.uz, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->uc, ref.uc, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->Sx, ref.Sx, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->Sy, ref.Sy, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->Sz, ref.Sz, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->Sc, ref.Sc, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->dSx, ref.dSx, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->dSy, ref.dSy, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->dSz, ref.dSz, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->dSc, ref.dSc, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->Mx, ref.Mx, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->My, ref.My, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->Mz, ref.Mz, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->Mc, ref.Mc, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->fbrake_left, ref.fbrake_left, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->fbrake_right, ref.fbrake_right, s, im, dueca::dco_traits<float>()); ::dueca::checkandpackdiff(this->test, ref.test, s, im, dueca::dco_traits<int32_t>()); im.closeoff(s); } #endif #if !defined(__CUSTOM_FUNCTION_UNPACKDATA) && !defined(__DCO_NOPACK) void PrimaryControls::unPackData(::dueca::AmorphReStore& s) { DOBS("unPackData PrimaryControls"); //{ amorphunpackfirst } //{ amorphunpacksecond } ::dueca::unpackobject(s, this->ux, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->uy, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->uz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->uc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sx, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sy, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Sc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSx, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSy, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->dSc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Mx, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->My, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Mz, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->Mc, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->fbrake_left, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->fbrake_right, dueca::dco_traits<float>()); ::dueca::unpackobject(s, this->test, dueca::dco_traits<int32_t>()); } #endif #if !defined(__CUSTOM_FUNCTION_UNPACKDATADIFF) && !defined(__DCO_NOPACK) void PrimaryControls::unPackDataDiff(::dueca::AmorphReStore& s) { DOBS("unPackDataDiff PrimaryControls"); ::dueca::IndexRecall im;// { amorphunpackdiff } ::dueca::checkandunpackdiff(this->ux, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->uy, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->uz, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->uc, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->Sx, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->Sy, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->Sz, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->Sc, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->dSx, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->dSy, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->dSz, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->dSc, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->Mx, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->My, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->Mz, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->Mc, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->fbrake_left, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->fbrake_right, s, im, dueca::dco_traits<float>()); ::dueca::checkandunpackdiff(this->test, s, im, dueca::dco_traits<int32_t>()); } #endif #ifndef __CUSTOM_OPERATOR_EQUAL bool PrimaryControls::operator == (const PrimaryControls& other) const { DOBS("operator == PrimaryControls"); if (this->ux != other.ux) return false; if (this->uy != other.uy) return false; if (this->uz != other.uz) return false; if (this->uc != other.uc) return false; if (this->Sx != other.Sx) return false; if (this->Sy != other.Sy) return false; if (this->Sz != other.Sz) return false; if (this->Sc != other.Sc) return false; if (this->dSx != other.dSx) return false; if (this->dSy != other.dSy) return false; if (this->dSz != other.dSz) return false; if (this->dSc != other.dSc) return false; if (this->Mx != other.Mx) return false; if (this->My != other.My) return false; if (this->Mz != other.Mz) return false; if (this->Mc != other.Mc) return false; if (this->fbrake_left != other.fbrake_left) return false; if (this->fbrake_right != other.fbrake_right) return false; if (this->test != other.test) return false; return true; } #endif #ifndef __CUSTOM_OPERATOR_ASSIGN PrimaryControls& PrimaryControls::operator=(const PrimaryControls& other) { DOBS("operator = PrimaryControls"); if (this == &other) return *this; this->ux = other.ux; this->uy = other.uy; this->uz = other.uz; this->uc = other.uc; this->Sx = other.Sx; this->Sy = other.Sy; this->Sz = other.Sz; this->Sc = other.Sc; this->dSx = other.dSx; this->dSy = other.dSy; this->dSz = other.dSz; this->dSc = other.dSc; this->Mx = other.Mx; this->My = other.My; this->Mz = other.Mz; this->Mc = other.Mc; this->fbrake_left = other.fbrake_left; this->fbrake_right = other.fbrake_right; this->test = other.test; return *this; } #endif #if !defined(__CUSTOM_FUNCTION_PACKDATA) && !defined(__DCO_NOPACK) void PrimaryControls::packData(::dueca::AmorphStore& s) const { DOBS("packData PrimaryControls"); //{ amorphpackfirst }{ amorphpacksecond } ::dueca::packobject(s, this->ux, dueca::dco_traits<float>()); ::dueca::packobject(s, this->uy, dueca::dco_traits<float>()); ::dueca::packobject(s, this->uz, dueca::dco_traits<float>()); ::dueca::packobject(s, this->uc, dueca::dco_traits<float>()); ::dueca::packobject(s, this->Sx, dueca::dco_traits<float>()); ::dueca::packobject(s, this->Sy, dueca::dco_traits<float>()); ::dueca::packobject(s, this->Sz, dueca::dco_traits<float>()); ::dueca::packobject(s, this->Sc, dueca::dco_traits<float>()); ::dueca::packobject(s, this->dSx, dueca::dco_traits<float>()); ::dueca::packobject(s, this->dSy, dueca::dco_traits<float>()); ::dueca::packobject(s, this->dSz, dueca::dco_traits<float>()); ::dueca::packobject(s, this->dSc, dueca::dco_traits<float>()); ::dueca::packobject(s, this->Mx, dueca::dco_traits<float>()); ::dueca::packobject(s, this->My, dueca::dco_traits<float>()); ::dueca::packobject(s, this->Mz, dueca::dco_traits<float>()); ::dueca::packobject(s, this->Mc, dueca::dco_traits<float>()); ::dueca::packobject(s, this->fbrake_left, dueca::dco_traits<float>()); ::dueca::packobject(s, this->fbrake_right, dueca::dco_traits<float>()); ::dueca::packobject(s, this->test, dueca::dco_traits<int32_t>()); } #endif #ifndef __CUSTOM_FUNCTION_PRINT std::ostream & PrimaryControls::print(std::ostream& s) const { s << "PrimaryControls("; s << "ux="; ::dueca::dcoprint(s, this->ux, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "uy="; ::dueca::dcoprint(s, this->uy, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "uz="; ::dueca::dcoprint(s, this->uz, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "uc="; ::dueca::dcoprint(s, this->uc, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "Sx="; ::dueca::dcoprint(s, this->Sx, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "Sy="; ::dueca::dcoprint(s, this->Sy, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "Sz="; ::dueca::dcoprint(s, this->Sz, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "Sc="; ::dueca::dcoprint(s, this->Sc, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "dSx="; ::dueca::dcoprint(s, this->dSx, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "dSy="; ::dueca::dcoprint(s, this->dSy, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "dSz="; ::dueca::dcoprint(s, this->dSz, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "dSc="; ::dueca::dcoprint(s, this->dSc, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "Mx="; ::dueca::dcoprint(s, this->Mx, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "My="; ::dueca::dcoprint(s, this->My, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "Mz="; ::dueca::dcoprint(s, this->Mz, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "Mc="; ::dueca::dcoprint(s, this->Mc, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "fbrake_left="; ::dueca::dcoprint(s, this->fbrake_left, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "fbrake_right="; ::dueca::dcoprint(s, this->fbrake_right, typename ::dueca::dco_traits<float>::ptype()); s << ","; s << "test="; ::dueca::dcoprint(s, this->test, typename ::dueca::dco_traits<int32_t>::ptype()); s << ")"; return s; } #endif } #if defined(DUECA_CONFIG_HDF5) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Winvalid-offsetof" // guarded in a separate namespace namespace PrimaryControls_space { #if !defined(__CUSTOM_HDF5_WRITE_FUNCTOR) HDF5DCOWriteFunctor:: HDF5DCOWriteFunctor(std::weak_ptr<H5::H5File> file, const std::string& path, size_t chunksize, const std::string& label, bool compress, bool writeticks, const dueca::DataTimeSpec* startend) : dueca::hdf5log::HDF5DCOWriteFunctor(file, path, chunksize, label, 19, compress, writeticks, startend) { // add memspaces for all elements this->configureDataSet(0, "/data/ux", HOFFSET(PrimaryControls, ux), dueca::get_hdf5_elt_type(example.ux), dueca::get_hdf5_elt_length(example.ux)); this->configureDataSet(1, "/data/uy", HOFFSET(PrimaryControls, uy), dueca::get_hdf5_elt_type(example.uy), dueca::get_hdf5_elt_length(example.uy)); this->configureDataSet(2, "/data/uz", HOFFSET(PrimaryControls, uz), dueca::get_hdf5_elt_type(example.uz), dueca::get_hdf5_elt_length(example.uz)); this->configureDataSet(3, "/data/uc", HOFFSET(PrimaryControls, uc), dueca::get_hdf5_elt_type(example.uc), dueca::get_hdf5_elt_length(example.uc)); this->configureDataSet(4, "/data/Sx", HOFFSET(PrimaryControls, Sx), dueca::get_hdf5_elt_type(example.Sx), dueca::get_hdf5_elt_length(example.Sx)); this->configureDataSet(5, "/data/Sy", HOFFSET(PrimaryControls, Sy), dueca::get_hdf5_elt_type(example.Sy), dueca::get_hdf5_elt_length(example.Sy)); this->configureDataSet(6, "/data/Sz", HOFFSET(PrimaryControls, Sz), dueca::get_hdf5_elt_type(example.Sz), dueca::get_hdf5_elt_length(example.Sz)); this->configureDataSet(7, "/data/Sc", HOFFSET(PrimaryControls, Sc), dueca::get_hdf5_elt_type(example.Sc), dueca::get_hdf5_elt_length(example.Sc)); this->configureDataSet(8, "/data/dSx", HOFFSET(PrimaryControls, dSx), dueca::get_hdf5_elt_type(example.dSx), dueca::get_hdf5_elt_length(example.dSx)); this->configureDataSet(9, "/data/dSy", HOFFSET(PrimaryControls, dSy), dueca::get_hdf5_elt_type(example.dSy), dueca::get_hdf5_elt_length(example.dSy)); this->configureDataSet(10, "/data/dSz", HOFFSET(PrimaryControls, dSz), dueca::get_hdf5_elt_type(example.dSz), dueca::get_hdf5_elt_length(example.dSz)); this->configureDataSet(11, "/data/dSc", HOFFSET(PrimaryControls, dSc), dueca::get_hdf5_elt_type(example.dSc), dueca::get_hdf5_elt_length(example.dSc)); this->configureDataSet(12, "/data/Mx", HOFFSET(PrimaryControls, Mx), dueca::get_hdf5_elt_type(example.Mx), dueca::get_hdf5_elt_length(example.Mx)); this->configureDataSet(13, "/data/My", HOFFSET(PrimaryControls, My), dueca::get_hdf5_elt_type(example.My), dueca::get_hdf5_elt_length(example.My)); this->configureDataSet(14, "/data/Mz", HOFFSET(PrimaryControls, Mz), dueca::get_hdf5_elt_type(example.Mz), dueca::get_hdf5_elt_length(example.Mz)); this->configureDataSet(15, "/data/Mc", HOFFSET(PrimaryControls, Mc), dueca::get_hdf5_elt_type(example.Mc), dueca::get_hdf5_elt_length(example.Mc)); this->configureDataSet(16, "/data/fbrake_left", HOFFSET(PrimaryControls, fbrake_left), dueca::get_hdf5_elt_type(example.fbrake_left), dueca::get_hdf5_elt_length(example.fbrake_left)); this->configureDataSet(17, "/data/fbrake_right", HOFFSET(PrimaryControls, fbrake_right), dueca::get_hdf5_elt_type(example.fbrake_right), dueca::get_hdf5_elt_length(example.fbrake_right)); this->configureDataSet(18, "/data/test", HOFFSET(PrimaryControls, test), dueca::get_hdf5_elt_type(example.test), dueca::get_hdf5_elt_length(example.test)); if (writeticks) { dueca::TimeTickType tex; this->configureDataSet(19, "/tick", 0, dueca::get_hdf5_elt_type(tex), 1); } } #pragma GCC diagnostic pop // the functor member used by channel reading code, writes data in HDF5 file bool HDF5DCOWriteFunctor::operator() (const void* dpointer, const dueca::DataTimeSpec& ts) { while (ts.getValidityEnd() <= startend->getValidityStart()) { return true; } if (ts.getValidityStart() >= startend->getValidityEnd()) { return false; } this->prepareRow(); this->sets[0].writeNew(dpointer, chunkidx, example.ux); this->sets[1].writeNew(dpointer, chunkidx, example.uy); this->sets[2].writeNew(dpointer, chunkidx, example.uz); this->sets[3].writeNew(dpointer, chunkidx, example.uc); this->sets[4].writeNew(dpointer, chunkidx, example.Sx); this->sets[5].writeNew(dpointer, chunkidx, example.Sy); this->sets[6].writeNew(dpointer, chunkidx, example.Sz); this->sets[7].writeNew(dpointer, chunkidx, example.Sc); this->sets[8].writeNew(dpointer, chunkidx, example.dSx); this->sets[9].writeNew(dpointer, chunkidx, example.dSy); this->sets[10].writeNew(dpointer, chunkidx, example.dSz); this->sets[11].writeNew(dpointer, chunkidx, example.dSc); this->sets[12].writeNew(dpointer, chunkidx, example.Mx); this->sets[13].writeNew(dpointer, chunkidx, example.My); this->sets[14].writeNew(dpointer, chunkidx, example.Mz); this->sets[15].writeNew(dpointer, chunkidx, example.Mc); this->sets[16].writeNew(dpointer, chunkidx, example.fbrake_left); this->sets[17].writeNew(dpointer, chunkidx, example.fbrake_right); this->sets[18].writeNew(dpointer, chunkidx, example.test); if (writeticks) { this->sets[19].writeNew(&ts); } return true; } #endif #if !defined(__CUSTOM_HDF5_READ_FUNCTOR) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Winvalid-offsetof" HDF5DCOReadFunctor:: HDF5DCOReadFunctor(std::weak_ptr<H5::H5File> file, const std::string& path, bool readticks) : dueca::hdf5log::HDF5DCOReadFunctor(file, path, 19, readticks) { // add memspaces for all elements this->configureDataSet(0, "/data/ux", HOFFSET(PrimaryControls, ux), dueca::get_hdf5_elt_type(example.ux), dueca::get_hdf5_elt_length(example.ux)); this->configureDataSet(1, "/data/uy", HOFFSET(PrimaryControls, uy), dueca::get_hdf5_elt_type(example.uy), dueca::get_hdf5_elt_length(example.uy)); this->configureDataSet(2, "/data/uz", HOFFSET(PrimaryControls, uz), dueca::get_hdf5_elt_type(example.uz), dueca::get_hdf5_elt_length(example.uz)); this->configureDataSet(3, "/data/uc", HOFFSET(PrimaryControls, uc), dueca::get_hdf5_elt_type(example.uc), dueca::get_hdf5_elt_length(example.uc)); this->configureDataSet(4, "/data/Sx", HOFFSET(PrimaryControls, Sx), dueca::get_hdf5_elt_type(example.Sx), dueca::get_hdf5_elt_length(example.Sx)); this->configureDataSet(5, "/data/Sy", HOFFSET(PrimaryControls, Sy), dueca::get_hdf5_elt_type(example.Sy), dueca::get_hdf5_elt_length(example.Sy)); this->configureDataSet(6, "/data/Sz", HOFFSET(PrimaryControls, Sz), dueca::get_hdf5_elt_type(example.Sz), dueca::get_hdf5_elt_length(example.Sz)); this->configureDataSet(7, "/data/Sc", HOFFSET(PrimaryControls, Sc), dueca::get_hdf5_elt_type(example.Sc), dueca::get_hdf5_elt_length(example.Sc)); this->configureDataSet(8, "/data/dSx", HOFFSET(PrimaryControls, dSx), dueca::get_hdf5_elt_type(example.dSx), dueca::get_hdf5_elt_length(example.dSx)); this->configureDataSet(9, "/data/dSy", HOFFSET(PrimaryControls, dSy), dueca::get_hdf5_elt_type(example.dSy), dueca::get_hdf5_elt_length(example.dSy)); this->configureDataSet(10, "/data/dSz", HOFFSET(PrimaryControls, dSz), dueca::get_hdf5_elt_type(example.dSz), dueca::get_hdf5_elt_length(example.dSz)); this->configureDataSet(11, "/data/dSc", HOFFSET(PrimaryControls, dSc), dueca::get_hdf5_elt_type(example.dSc), dueca::get_hdf5_elt_length(example.dSc)); this->configureDataSet(12, "/data/Mx", HOFFSET(PrimaryControls, Mx), dueca::get_hdf5_elt_type(example.Mx), dueca::get_hdf5_elt_length(example.Mx)); this->configureDataSet(13, "/data/My", HOFFSET(PrimaryControls, My), dueca::get_hdf5_elt_type(example.My), dueca::get_hdf5_elt_length(example.My)); this->configureDataSet(14, "/data/Mz", HOFFSET(PrimaryControls, Mz), dueca::get_hdf5_elt_type(example.Mz), dueca::get_hdf5_elt_length(example.Mz)); this->configureDataSet(15, "/data/Mc", HOFFSET(PrimaryControls, Mc), dueca::get_hdf5_elt_type(example.Mc), dueca::get_hdf5_elt_length(example.Mc)); this->configureDataSet(16, "/data/fbrake_left", HOFFSET(PrimaryControls, fbrake_left), dueca::get_hdf5_elt_type(example.fbrake_left), dueca::get_hdf5_elt_length(example.fbrake_left)); this->configureDataSet(17, "/data/fbrake_right", HOFFSET(PrimaryControls, fbrake_right), dueca::get_hdf5_elt_type(example.fbrake_right), dueca::get_hdf5_elt_length(example.fbrake_right)); this->configureDataSet(18, "/data/test", HOFFSET(PrimaryControls, test), dueca::get_hdf5_elt_type(example.test), dueca::get_hdf5_elt_length(example.test)); if (readticks) { dueca::TimeTickType tex; this->configureDataSet(19, "/tick", 0, dueca::get_hdf5_elt_type(tex), 1); } } #pragma GCC diagnostic pop bool HDF5DCOReadFunctor::operator() (void* dpointer) { this->sets[0].readObjectPart(dpointer, example.ux); this->sets[1].readObjectPart(dpointer, example.uy); this->sets[2].readObjectPart(dpointer, example.uz); this->sets[3].readObjectPart(dpointer, example.uc); this->sets[4].readObjectPart(dpointer, example.Sx); this->sets[5].readObjectPart(dpointer, example.Sy); this->sets[6].readObjectPart(dpointer, example.Sz); this->sets[7].readObjectPart(dpointer, example.Sc); this->sets[8].readObjectPart(dpointer, example.dSx); this->sets[9].readObjectPart(dpointer, example.dSy); this->sets[10].readObjectPart(dpointer, example.dSz); this->sets[11].readObjectPart(dpointer, example.dSc); this->sets[12].readObjectPart(dpointer, example.Mx); this->sets[13].readObjectPart(dpointer, example.My); this->sets[14].readObjectPart(dpointer, example.Mz); this->sets[15].readObjectPart(dpointer, example.Mc); this->sets[16].readObjectPart(dpointer, example.fbrake_left); this->sets[17].readObjectPart(dpointer, example.fbrake_right); this->sets[18].readObjectPart(dpointer, example.test); return true; } #endif /** Metafunctor, can be accessed through the table, and can produce a functor object and the HDF5 data type */ class HDF5DCOMetaFunctor: public dueca::hdf5log::HDF5DCOMetaFunctor { HDF5DCOWriteFunctor* getWriteFunctor(std::weak_ptr<H5::H5File> file, const std::string& path, size_t chunksize, const std::string& label, const dueca::DataTimeSpec* startend, bool compress, bool writeticks=true) { return new HDF5DCOWriteFunctor(file, path, chunksize, label, compress, writeticks, startend); } HDF5DCOReadFunctor* getReadFunctor(std::weak_ptr<H5::H5File> file, const std::string& path, bool writeticks=true) { return new HDF5DCOReadFunctor(file, path, writeticks); } }; #if !defined(__DCO_STANDALONE) // loads the metafunctor in the table static dueca::LoadMetaFunctor<HDF5DCOMetaFunctor> load_functor(functortable, "hdf5"); #endif } // end namespace PrimaryControls_space #endif
All this code is generated from a compact representation in the PrimaryControls.dco file:
;; -*-scheme-*- (Header " item : PrimaryControls.dco made by : Rene' van Paassen date : long ago... description : Typical set of variables to describe input from primary controls (stick or column, rudder pedals) copyright : (c) 2018-2022 TUDelft-AE-C&S : (c) 2022 René van Paassen license : EUPL-1.2") ;; float as the basic type for data (Type float) ;; we add a test value, used for start-to-end time delay tests (Type int32_t) ;; Aircraft-oriented set of control inputs ;; ;; The input variables (ux, uy, etc.) may be scaled by the module ;; doing the input, such as joystick control or control loading. The ;; displacement, velocity and force/torque values should correspond to ;; the inputs measured on the actual device. Note that these will ;; typically may not be correct for joysticks that don't have force ;; measurement. (Object PrimaryControls (Option hdf5) ;; input around x-axis; roll, left positive (float ux (Default 0.0f)) ;; input about y axis; pitch, forward positive (float uy (Default 0.0f)) ;; input about z axis; yaw (pedals, twist..), left positive (float uz (Default 0.0f)) ;; for helicopters, collective input (float uc (Default 0.0f)) ;; displacement of the control about x axis (float Sx (Default 0.0f)) ;; displacement of the control about y axis (float Sy (Default 0.0f)) ;; displacement of the control about z axis (float Sz (Default 0.0f)) ;; displacement of the control about collective axis (float Sc (Default 0.0f)) ;; velocity of the control about x axis (float dSx (Default 0.0f)) ;; velocity of the control about y axis (float dSy (Default 0.0f)) ;; velocity of the control about z axis (float dSz (Default 0.0f)) ;; velocity of the control about collective axis (float dSc (Default 0.0f)) ;; moment of the control about x axis (float Mx (Default 0.0f)) ;; moment of the control about y axis (float My (Default 0.0f)) ;; moment of the control about z axis (float Mz (Default 0.0f)) ;; moment of the control about collective axis (float Mc (Default 0.0f)) ;; input left brake (float fbrake_left (Default 0.0f)) ;; input right brake (float fbrake_right (Default 0.0f)) ;; test input, used for end-to-end time delay measurement; it ;; should be passed through model update and visual ;; generation, and may there generate a visual indication (int32_t test (Default 0)) )