Update sdv_packager (#6)

This commit is contained in:
tompzf
2026-03-27 14:12:49 +01:00
committed by GitHub
parent 234be8917f
commit aefefd52f7
717 changed files with 42252 additions and 11334 deletions

View File

@@ -8,5 +8,6 @@ Class = "Hello_Component"
[[Component]]
Path = "example_general_component.sdv"
Class = "Hello_Component"
[Component.Parameters]
number = 42

View File

@@ -8,6 +8,7 @@ Class = "Hello_Component"
[[Component]]
Path = "example_general_component_with_initialization.sdv"
Class = "Hello_Component_With_Initialization"
[Component.Parameters]
number = 42
[[Component]]

View File

@@ -28,7 +28,7 @@ public:
END_SDV_INTERFACE_MAP()
DECLARE_OBJECT_CLASS_NAME("Access_Component")
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::BasicService);
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::basic_service);
/**
* @brief Show messages, implements the function of IShowExample

View File

@@ -52,7 +52,7 @@ public:
END_SDV_INTERFACE_MAP()
DECLARE_OBJECT_CLASS_NAME("BasicService_Component")
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::BasicService);
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::basic_service);
/**
* @brief Set brake force

View File

@@ -54,7 +54,7 @@ public:
END_SDV_INTERFACE_MAP()
DECLARE_OBJECT_CLASS_NAME("ComplexService_Component")
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::ComplexService);
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::complex_service);
/**
* @brief Set speed

View File

@@ -23,7 +23,7 @@ public:
SDV_INTERFACE_ENTRY(ISayGoodbye)
END_SDV_INTERFACE_MAP()
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::Device)
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::device)
DECLARE_OBJECT_CLASS_NAME("Hello_Component")
/**

View File

@@ -5,7 +5,6 @@
class CTestComponentWithInitialization
: public sdv::CSdvObject
, public sdv::IObjectControl
, public ISayHello
, public ISayGoodbye
{
@@ -22,63 +21,30 @@ public:
BEGIN_SDV_INTERFACE_MAP()
SDV_INTERFACE_ENTRY(ISayHello)
SDV_INTERFACE_ENTRY(ISayGoodbye)
SDV_INTERFACE_ENTRY(sdv::IObjectControl)
END_SDV_INTERFACE_MAP()
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::Device)
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::device)
DECLARE_OBJECT_CLASS_NAME("Hello_Component_With_Initialization")
/**
* @brief Initialize the object. Overload of sdv::IObjectControl::Initialize.
* @param[in] ssObjectConfig Optional configuration string.
*/
inline virtual void Initialize(const sdv::u8string& ssObjectConfig) override
{
if (!ParseConfigurationString(ssObjectConfig))
{
m_status = sdv::EObjectStatus::initialization_failure;
return;
}
m_status = sdv::EObjectStatus::initialized;
};
// Parameter map
BEGIN_SDV_PARAM_MAP()
SDV_PARAM_ENTRY(m_Number, "number", -1, "", "A number")
END_SDV_PARAM_MAP()
/**
* @brief Set the component operation mode. Overload of sdv::IObjectControl::SetOperationMode.
* @param[in] eMode The operation mode, the component should run in.
*/
void SetOperationMode(/*in*/ sdv::EOperationMode eMode) override
* @brief Initialization event, called after object configuration was loaded. Overload of sdv::CSdvObject::OnInitialize.
* @return Returns 'true' when the initialization was successful, 'false' when not.
*/
virtual bool OnInitialize() override
{
switch (eMode)
{
case sdv::EOperationMode::configuring:
if (m_status == sdv::EObjectStatus::running || m_status == sdv::EObjectStatus::initialized)
m_status = sdv::EObjectStatus::configuring;
break;
case sdv::EOperationMode::running:
if (m_status == sdv::EObjectStatus::configuring || m_status == sdv::EObjectStatus::initialized)
m_status = sdv::EObjectStatus::running;
break;
default:
break;
}
return true;
}
/**
* @brief Get the current status of the object. Overload of sdv::IObjectControl::GetStatus.
* @return Return the current status of the object.
* @brief Shutdown the object. Overload of sdv::CSdvObject::OnShutdown.
*/
inline virtual sdv::EObjectStatus GetStatus() const override
{
return m_status;
};
/**
* @brief Shutdown called before the object is destroyed. Overload of sdv::IObjectControl::Shutdown.
*/
inline virtual void Shutdown() override
{
m_status = sdv::EObjectStatus::destruction_pending;
}
virtual void OnShutdown() override
{}
/**
* @brief Show messages, implements the function of IShowExample
@@ -97,31 +63,7 @@ public:
}
private:
bool ParseConfigurationString(const sdv::u8string& objectConfig)
{
try
{
sdv::toml::CTOMLParser config(objectConfig.c_str());
// get any settings from the configuration
auto nodeNumber = config.GetDirect("number");
if (nodeNumber.GetType() == sdv::toml::ENodeType::node_integer)
{
m_Number = static_cast<int32_t>(nodeNumber.GetValue());
}
}
catch (const sdv::toml::XTOMLParseException& e)
{
std::cout << "Configuration could not be read:" << e.what() << std::endl;
return false;
}
std::cout << "Initialization number: " << std::to_string(m_Number) << std::endl;
return true;
}
int32_t m_Number = -1;
std::atomic<sdv::EObjectStatus> m_status = { sdv::EObjectStatus::initialization_pending }; //!< To update the object status when it changes.
};
DEFINE_SDV_OBJECT(CTestComponentWithInitialization)

View File

@@ -38,7 +38,7 @@ public:
SDV_INTERFACE_ENTRY(vss::Device::ITransferSignalBrakeForce)
END_SDV_INTERFACE_MAP()
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::Device)
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::vehicle_bus)
DECLARE_OBJECT_CLASS_NAME("VehicleDevice_Component")
~CVehicleDevice()