I am trying to have Variables of the type AnalogItemType which contain a Method. This Method should be able to delete the selected node from the adress space. Right now I'm struggling with the Error OpcUa_BadNodeIdUnknown when trying to call the Method. So when calling the underlying method of a variable I guess the Server does not find the corresponding NodeId of the Method (the variable itself works). Is it even possible to do what I'm trying to do?
I tried by having my own AnalogItemClasses, a base class inheriting from AnalogItemType and MethodManager:
Code: Select all
#include "opcua_analogitemtype.h"
#include "my_nodemanager.h"
#include "methodmanager.h"
class NmMy;
class UaMethodGeneric;
namespace OpcUa {
class SERVER_CORE_EXPORT my_analogitemtypebase
: public AnalogItemType, public MethodManager
{
UA_DISABLE_COPY(my_analogitemtypebase);
public:
my_analogitemtypebase(
UaNode* pParentNode,
UaVariable* pInstanceDeclarationVariable,
NodeManagerConfig* pNodeConfig,
UaMutexRefCounted* pSharedMutex = NULL);
my_analogitemtypebase(
const UaNodeId& nodeId,
const UaString& name,
OpcUa_UInt16 browseNameNameSpaceIndex,
const UaVariant& initialValue,
OpcUa_Byte accessLevel,
NodeManagerConfig* pNodeConfig,
UaMutexRefCounted* pSharedMutex = NULL,
NmMy* pNodeManager = NULL);
virtual ~my_analogitemtypebase();
MethodManager* getMethodManager(UaMethod* pMethod) const;
virtual UaStatus beginCall(
MethodManagerCallback* pCallback,
const ServiceContext& serviceContext,
OpcUa_UInt32 callbackHandle,
MethodHandle* pMethodHandle,
const UaVariantArray& inputArguments);
// Own synchronous call implementation the can be overridden in subclasses
virtual UaStatus call(
UaMethod* /*pMethod*/,
const UaVariantArray& /*inputArguments*/,
UaVariantArray& /*outputArguments*/,
UaStatusCodeArray& /*inputArgumentResults*/,
UaDiagnosticInfos& /*inputArgumentDiag*/) { return OpcUa_BadMethodInvalid; }
virtual int deleteVariable(UaNodeId nodeID);
protected:
private:
UaMethodGeneric* m_pMethodDelete;
};
}
#endif /* MYANALOGITEMTYPE_H_ */
Code: Select all
#ifndef MYANALOGITEM_H_
#define MYANALOGITEM_H_
#include "myanalogitemtypebase.h"
class NmMy;
class UaMethodGeneric;
namespace OpcUa {
class myanalogitem
: public my_analogitemtypebase
{
public:
myanalogitem(
UaNode* pParentNode,
UaVariable* pInstanceDeclarationVariable,
NodeManagerConfig* pNodeConfig,
UaMutexRefCounted* pSharedMutex = NULL);
myanalogitem(
const UaNodeId& nodeId,
const UaString& name,
OpcUa_UInt16 browseNameNameSpaceIndex,
const UaVariant& initialValue,
OpcUa_Byte accessLevel,
NodeManagerConfig* pNodeConfig,
UaMutexRefCounted* pSharedMutex = NULL,
NmMy* pNodeManager = NULL);
virtual ~myanalogitem();
//override Controller::call()
virtual UaStatus call(
UaMethod* pMethod,
const UaVariantArray& inputArguments,
UaVariantArray& /*outputArguments*/,
UaStatusCodeArray& inputArgumentResults,
UaDiagnosticInfos& /*inputArgumentDiag*/);
private:
UaMethodGeneric* m_pMethodDelete;
};
}
#endif /* MYANALOGITEM_H_ */
Cheers and regards,
Florian