Commit cadd6fd9 authored by Guenter Schwann's avatar Guenter Schwann
Browse files

662 Add pseudo function for HW boards

parent ecc9f866
......@@ -11,5 +11,12 @@
<Port name="eth5" asn1file="/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/ip.asn" asn1module="POHICDRIVER-IP" asn1type="IP-Conf-T" requiresBusAccess="ocarina_buses::ip.i"/>
<Port name="eth6" asn1file="/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/ip.asn" asn1module="POHICDRIVER-IP" asn1type="IP-Conf-T" requiresBusAccess="ocarina_buses::ip.i"/>
<Port name="eth7" asn1file="/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/ip.asn" asn1module="POHICDRIVER-IP" asn1type="IP-Conf-T" requiresBusAccess="ocarina_buses::ip.i"/>
<Pseudo_Function name="PrecisionTimer">
<Provided_Interface name="getTime">
</Provided_Interface>"
<Required_Interface name="init">
<Input_Parameter name="seed" type="MyInt" encoding="NATIVE"/>
</Required_Interface>"
</Pseudo_Function>
</Board>
</Boards>
......@@ -27,8 +27,8 @@
#include <conversion/common/qstringhash.h>
#include <conversion/common/translation/exceptions.h>
#include <ivcore/ivfunction.h>
#include <ivcore/parameter.h>
#include <seds/SedsModel/package/package.h>
#include <shared/parameter.h>
using conversion::translator::MissingGenericTypeMappingException;
using conversion::translator::TranslationException;
......@@ -101,8 +101,8 @@ void AsyncInterfaceCommandTranslator::translateArguments(const seds::model::Inte
buildAsn1SequenceType(command, requestedArgumentMode, asn1TypeName);
auto ivParameter = ivm::InterfaceParameter(m_interfaceParameterName, ivm::BasicParameter::Type::Other, asn1TypeName,
m_interfaceParameterEncoding, ivm::InterfaceParameter::Direction::IN);
auto ivParameter = shared::InterfaceParameter(m_interfaceParameterName, shared::BasicParameter::Type::Other,
asn1TypeName, m_interfaceParameterEncoding, shared::InterfaceParameter::Direction::IN);
ivInterface->addParam(ivParameter);
}
......
......@@ -39,6 +39,10 @@ target_sources(${LIB_NAME} PRIVATE
dvpropertytemplate.h
dvpropertytemplateconfig.cpp
dvpropertytemplateconfig.h
dvpseudofunction.cpp
dvpseudofunction.h
dvpseudointerface.cpp
dvpseudointerface.h
dvresources.qrc
dvxmlreader.cpp
dvxmlreader.h
......
......@@ -37,6 +37,8 @@ const QHash<QString, Props::Token> Props::TokensByName = {
{ "name", Token::name },
{ "value", Token::value },
{ "url", Token::url },
{ "type", Token::type },
{ "encoding", Token::encoding },
{ "port", Token::port },
{ "bus", Token::bus },
......@@ -64,6 +66,11 @@ const QHash<QString, Props::Token> Props::TokensByName = {
{ "Boards", Token::Boards },
{ "Board", Token::Board },
{ "Port", Token::Port },
{ "Pseudo_Function", Token::Pseudo_Function },
{ "Provided_Interface", Token::Provided_Interface },
{ "Required_Interface", Token::Required_Interface },
{ "Input_Parameter", Token::Input_Parameter },
{ "Output_Parameter", Token::Output_Parameter },
};
Props::Token Props::token(const QString &fromString)
......
......@@ -42,14 +42,22 @@ public:
Function,
Message,
// HW Library
Boards,
Board,
Port,
Pseudo_Function,
Provided_Interface,
Required_Interface,
Input_Parameter,
Output_Parameter,
// attrs:
name,
value,
url,
type,
encoding,
from_node,
from_port,
......
......@@ -25,6 +25,8 @@
#include "dvobject.h"
#include "dvpartition.h"
#include "dvport.h"
#include "dvpseudofunction.h"
#include "dvpseudointerface.h"
#include "errorhub.h"
#include <QDebug>
......@@ -80,6 +82,36 @@ void DVHWLibraryReader::processTagOpen(QXmlStreamReader &xml)
obj = port;
}
} break;
case meta::Props::Token::Pseudo_Function: {
Q_ASSERT(d->m_currentObject != nullptr);
if (auto board = qobject_cast<DVBoard *>(d->m_currentObject)) {
obj = new dvm::DVPseudoFunction(d->m_currentObject);
}
} break;
case meta::Props::Token::Provided_Interface:
case meta::Props::Token::Required_Interface: {
Q_ASSERT(d->m_currentObject != nullptr);
if (auto board = qobject_cast<DVPseudoFunction *>(d->m_currentObject)) {
auto interface = new dvm::DVPseudoInterface(d->m_currentObject);
obj = interface;
interface->setInterfaceType(t == meta::Props::Token::Provided_Interface
? dvm::DVPseudoInterface::InterfaceType::Provided
: dvm::DVPseudoInterface::InterfaceType::Required);
break;
}
break;
}
case meta::Props::Token::Output_Parameter:
case meta::Props::Token::Input_Parameter: {
auto iface = qobject_cast<DVPseudoInterface *>(d->m_currentObject);
Q_ASSERT(iface != nullptr);
const EntityAttributes attrs = attributes(xml.attributes());
const shared::InterfaceParameter param = addIfaceParameter(attrs,
t == meta::Props::Token::Input_Parameter ? shared::InterfaceParameter::Direction::IN
: shared::InterfaceParameter::Direction::OUT);
iface->addParam(param);
break;
}
default:
static const QString msg = tr("The '%1' is unknown/unexpected here: %2@%3 %4");
shared::ErrorHub::addError(shared::ErrorItem::Warning,
......
......@@ -40,6 +40,8 @@ public:
Board,
Port,
PseudoFunction,
PseudoInterface,
Node,
Partition,
......
/*
Copyright (C) 2021 European Space Agency - <maxime.perrotin@esa.int>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program. If not, see <https://www.gnu.org/licenses/lgpl-2.1.html>.
*/
#include "dvpseudofunction.h"
namespace dvm {
DVPseudoFunction::DVPseudoFunction(DVObject *parent)
: DVObject(DVObject::Type::PseudoFunction, {}, parent)
{
}
} // namespace dvm
/*
Copyright (C) 2021 European Space Agency - <maxime.perrotin@esa.int>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program. If not, see <https://www.gnu.org/licenses/lgpl-2.1.html>.
*/
#pragma once
#include "dvobject.h"
namespace dvm {
class DVPseudoFunction : public DVObject
{
Q_OBJECT
public:
explicit DVPseudoFunction(DVObject *parent = nullptr);
};
} // namespace dvm
/*
Copyright (C) 2021 European Space Agency - <maxime.perrotin@esa.int>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program. If not, see <https://www.gnu.org/licenses/lgpl-2.1.html>.
*/
#include "dvpseudointerface.h"
namespace dvm {
DVPseudoInterface::DVPseudoInterface(DVObject *parent)
: DVObject(DVObject::Type::PseudoInterface, {}, parent)
{
}
void DVPseudoInterface::setInterfaceType(InterfaceType type)
{
m_interfaceType = type;
}
DVPseudoInterface::InterfaceType DVPseudoInterface::interfaceType() const
{
return m_interfaceType;
}
QVector<shared::InterfaceParameter> DVPseudoInterface::params() const
{
return m_parameters;
}
shared::InterfaceParameter DVPseudoInterface::param(const QString &name) const
{
if (!name.isEmpty()) {
for (const shared::InterfaceParameter &param : m_parameters) {
if (param.name() == name) {
return param;
}
}
}
return {};
}
void DVPseudoInterface::setParams(const QVector<shared::InterfaceParameter> &params)
{
if (m_parameters != params) {
m_parameters = params;
Q_EMIT paramsChanged();
}
}
void DVPseudoInterface::addParam(const shared::InterfaceParameter &param)
{
if (!m_parameters.contains(param)) {
m_parameters.append(param);
Q_EMIT paramsChanged();
}
}
} // namespace dvm
/*
Copyright (C) 2021 European Space Agency - <maxime.perrotin@esa.int>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program. If not, see <https://www.gnu.org/licenses/lgpl-2.1.html>.
*/
#pragma once
#include "dvobject.h"
#include "parameter.h"
#include <QVector>
namespace dvm {
class DVPseudoInterface : public DVObject
{
Q_OBJECT
public:
enum class InterfaceType
{
Required,
Provided,
};
Q_ENUM(InterfaceType)
explicit DVPseudoInterface(DVObject *parent = nullptr);
void setInterfaceType(InterfaceType type);
InterfaceType interfaceType() const;
QVector<shared::InterfaceParameter> params() const;
shared::InterfaceParameter param(const QString &name) const;
void setParams(const QVector<shared::InterfaceParameter> &params);
void addParam(const shared::InterfaceParameter &param);
Q_SIGNALS:
void paramsChanged();
private:
InterfaceType m_interfaceType = InterfaceType::Provided;
QVector<shared::InterfaceParameter> m_parameters = {};
};
} // namespace dvm
......@@ -29,8 +29,6 @@ target_sources(${LIB_NAME} PRIVATE
ivinterfacegroup.h
ivmodel.cpp
ivmodel.h
parameter.cpp
parameter.h
ivtestutils.cpp
ivtestutils.h
ivxmlreader.cpp
......
......@@ -357,7 +357,7 @@ QString IVConnection::name() const
/*!
Returns the parameters. Usually that's the parameters of the provider interface
*/
QVector<InterfaceParameter> IVConnection::params() const
QVector<shared::InterfaceParameter> IVConnection::params() const
{
if (d->targetIface()) {
return d->targetIface()->params();
......
......@@ -92,7 +92,7 @@ public:
bool isOneDirection() const;
QString name() const;
QVector<InterfaceParameter> params() const;
QVector<shared::InterfaceParameter> params() const;
protected:
explicit IVConnection(
......
......@@ -174,7 +174,7 @@ void IVFunction::reflectContextParam()
reflectContextParams(d->m_fnType->contextParams());
}
void IVFunction::reflectContextParams(const QVector<ContextParameter> &params)
void IVFunction::reflectContextParams(const QVector<shared::ContextParameter> &params)
{
setContextParams(params);
}
......
......@@ -49,7 +49,7 @@ private:
struct OriginalPropsHolder {
// TODO: unite with IVInterface::OriginalPropsHolder
EntityAttributes attrs;
QVector<ContextParameter> params;
QVector<shared::ContextParameter> params;
QString name() const
{
......@@ -76,7 +76,7 @@ private:
void restoreInternals();
void reflectAttrs(const EntityAttributes &attrs);
void reflectContextParams(const QVector<ContextParameter> &params);
void reflectContextParams(const QVector<shared::ContextParameter> &params);
};
}
......@@ -32,7 +32,7 @@ namespace ivm {
struct IVFunctionTypePrivate {
QVector<IVObject *> m_children {};
QVector<ContextParameter> m_contextParams {};
QVector<shared::ContextParameter> m_contextParams {};
QVector<QPointer<IVFunction>> m_instances {};
QVector<IVFunctionType *> m_functionTypes;
......@@ -272,21 +272,21 @@ bool IVFunctionType::hasInterface(const QString &name, Qt::CaseSensitivity caseS
return false;
}
QVector<ContextParameter> IVFunctionType::contextParams() const
QVector<shared::ContextParameter> IVFunctionType::contextParams() const
{
return d->m_contextParams;
}
ContextParameter IVFunctionType::contextParam(const QString &name) const
shared::ContextParameter IVFunctionType::contextParam(const QString &name) const
{
if (!name.isEmpty())
for (const ContextParameter &param : contextParams())
for (const shared::ContextParameter &param : contextParams())
if (param.name() == name)
return param;
return {};
}
void IVFunctionType::addContextParam(const ContextParameter &param)
void IVFunctionType::addContextParam(const shared::ContextParameter &param)
{
if (!d->m_contextParams.contains(param)) {
d->m_contextParams.append(param);
......@@ -294,7 +294,7 @@ void IVFunctionType::addContextParam(const ContextParameter &param)
}
}
bool IVFunctionType::removeContextParam(const ContextParameter &param)
bool IVFunctionType::removeContextParam(const shared::ContextParameter &param)
{
const bool removed = d->m_contextParams.removeOne(param);
if (removed)
......@@ -312,7 +312,7 @@ void IVFunctionType::clearContextParams()
Q_EMIT contextParamsChanged();
}
void IVFunctionType::setContextParams(const QVector<ContextParameter> &params)
void IVFunctionType::setContextParams(const QVector<shared::ContextParameter> &params)
{
if (d->m_contextParams != params) {
d->m_contextParams = params;
......
......@@ -62,12 +62,12 @@ public:
bool hasNestedChildren() const;
bool hasInterface(const QString &name, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const;
QVector<ContextParameter> contextParams() const;
ContextParameter contextParam(const QString &name) const;
void addContextParam(const ContextParameter &param);
bool removeContextParam(const ContextParameter &param);
QVector<shared::ContextParameter> contextParams() const;
shared::ContextParameter contextParam(const QString &name) const;
void addContextParam(const shared::ContextParameter &param);
bool removeContextParam(const shared::ContextParameter &param);
void clearContextParams();
void setContextParams(const QVector<ContextParameter> &params);
void setContextParams(const QVector<shared::ContextParameter> &params);
QVector<QPointer<IVFunction>> instances() const;
void rememberInstance(IVFunction *function);
......
......@@ -30,7 +30,7 @@
namespace ivm {
IVInterface::CreationInfo::CreationInfo(IVModel *model, IVFunctionType *function, const QPointF &position,
IVInterface::InterfaceType type, const shared::Id &id, const QVector<InterfaceParameter> &parameters,
IVInterface::InterfaceType type, const shared::Id &id, const QVector<shared::InterfaceParameter> &parameters,
OperationKind kind, const QString &name, const CreationInfo::Policy policy, IVInterface *source)
: model(model)
, function(function)
......@@ -106,7 +106,7 @@ struct IVInterfacePrivate {
{
}
IVInterface::InterfaceType m_direction;
QVector<InterfaceParameter> m_params = {};
QVector<shared::InterfaceParameter> m_params = {};
QPointer<IVInterface> m_cloneOf { nullptr };
QVector<QPointer<IVInterface>> m_clones {};
};
......@@ -242,21 +242,21 @@ bool IVInterface::setKind(IVInterface::OperationKind k)
return false;
}
QVector<InterfaceParameter> IVInterface::params() const
QVector<shared::InterfaceParameter> IVInterface::params() const
{
return d->m_params;
}
InterfaceParameter IVInterface::param(const QString &name) const
shared::InterfaceParameter IVInterface::param(const QString &name) const
{
if (!name.isEmpty())
for (const InterfaceParameter &param : params())
for (const shared::InterfaceParameter &param : params())
if (param.name() == name)
return param;
return {};
}
void IVInterface::setParams(const QVector<InterfaceParameter> &params)
void IVInterface::setParams(const QVector<shared::InterfaceParameter> &params)
{
if (d->m_params != params) {
d->m_params = params;
......@@ -264,7 +264,7 @@ void IVInterface::setParams(const QVector<InterfaceParameter> &params)
}
}
void IVInterface::addParam(const InterfaceParameter &param)
void IVInterface::addParam(const shared::InterfaceParameter &param)
{
if (!d->m_params.contains(param)) {
d->m_params.append(param);
......@@ -442,7 +442,7 @@ QVariant IVInterface::originalAttributeValue(const QString &name) const
return m_originalFields.attrs.value(name).value();
}
QVector<InterfaceParameter> IVInterface::originalParams() const
QVector<shared::InterfaceParameter> IVInterface::originalParams() const
{
return m_originalFields.params;
}
......
......@@ -69,7 +69,7 @@ public:
};
CreationInfo(IVModel *model = nullptr, IVFunctionType *function = nullptr, const QPointF &position = QPointF(),
IVInterface::InterfaceType type = DefaultDirection, const shared::Id &id = shared::createId(),
const QVector<InterfaceParameter> &parameters = QVector<InterfaceParameter>(),
const QVector<shared::InterfaceParameter> &parameters = QVector<shared::InterfaceParameter>(),
OperationKind kind = OperationKind::Sporadic, const QString &name = QString(),
const CreationInfo::Policy policy = CreationInfo::Policy::Init, IVInterface *toBeCloned = nullptr);
IVModel *model { nullptr };
......@@ -77,7 +77,7 @@ public:
QPointF position = {};
IVInterface::InterfaceType type { DefaultDirection };
shared::Id id = {};
QVector<InterfaceParameter> parameters = {};
QVector<shared::InterfaceParameter> parameters = {};
OperationKind kind = { OperationKind::Sporadic };
QString name {};
CreationInfo::Policy policy { CreationInfo::Policy::Init };
......@@ -108,10 +108,10 @@ public:
OperationKind kind() const;
bool setKind(OperationKind k);
QVector<InterfaceParameter> params() const;
InterfaceParameter param(const QString &name) const;
void setParams(const QVector<InterfaceParameter> &params);
void addParam(const InterfaceParameter &param);
QVector<shared::InterfaceParameter> params() const;
shared::InterfaceParameter param(const QString &name) const;
void setParams(const QVector<shared::InterfaceParameter> &params);
void addParam(const shared::InterfaceParameter &param);
IVFunctionType *function() const;
......@@ -125,7 +125,7 @@ public:
static IVInterface *createIface(const CreationInfo &descr);
QVariant originalAttributeValue(const QString &name) const;
QVector<InterfaceParameter> originalParams() const;
QVector<shared::InterfaceParameter> originalParams() const;
void setCloneOrigin(IVInterface *source);
......@@ -157,7 +157,7 @@ protected:
struct OriginalPropsHolder {
// TODO: unite with IVFunction::OriginalPropsHolder
EntityAttributes attrs;
QVector<InterfaceParameter> params;
QVector<shared::InterfaceParameter> params;
inline QString name() const
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment