Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fix for general BaseDataVariableType handling. #582

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions DashboardClient/Converter/ModelToJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "ModelToJson.hpp"
#include "../../ModelOpcUa/src/ModelOpcUa/ModelInstance.hpp"
#include "../NodeIdsWellKnown.hpp"
#include <easylogging++.h>

namespace Umati {
Expand Down Expand Up @@ -100,13 +101,7 @@ ModelToJson::ModelToJson(
// TODO use another function to check for i=17570 aka AnalogUnitRangeType and i=2755 aka StateVariableType
// Set ofBaseDataVariableType somewhere?
bool ModelToJson::isBaseDataVariableType(const std::shared_ptr<const ModelOpcUa::SimpleNode> &pSimpleNode) {
auto ret =
(pSimpleNode->SpecifiedTypeNodeId.Uri == "" &&
(pSimpleNode->SpecifiedTypeNodeId.Id == "i=63" || pSimpleNode->SpecifiedTypeNodeId.Id == "i=17570" || pSimpleNode->SpecifiedTypeNodeId.Id == "i=2755" ||
pSimpleNode->SpecifiedTypeNodeId.Id == "i=17497" || pSimpleNode->SpecifiedTypeNodeId.Id == "i=15318" || pSimpleNode->SpecifiedTypeNodeId.Id == "i=2368" ||
pSimpleNode->SpecifiedTypeNodeId.Id == "i=2760")) ||
pSimpleNode->ofBaseDataVariableType;
return ret;
return (pSimpleNode->NodeClass == ModelOpcUa::NodeClass_t::Variable || pSimpleNode->NodeClass == ModelOpcUa::NodeClass_t::VariableType) && !(pSimpleNode->NodeId == Umati::Dashboard::NodeId_PropertyType);
}

std::string ModelToJson::nodeClassToString(ModelOpcUa::NodeClass_t nodeClass) {
Expand Down
3 changes: 2 additions & 1 deletion DashboardClient/NodeIdsWellKnown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace Umati
const ModelOpcUa::NodeId_t NodeId_HasTypeDefinition = {ns0Uri, "i=40"};
const ModelOpcUa::NodeId_t NodeId_HasInterface = {ns0Uri, "i=17603"};
const ModelOpcUa::NodeId_t NodeId_Organizes = {ns0Uri, "i=35"};
const ModelOpcUa::NodeId_t NodeId_BaseVariableType = {ns0Uri, "i=63"};
const ModelOpcUa::NodeId_t NodeId_BaseVariableType = {"", "i=63"};
const ModelOpcUa::NodeId_t NodeId_PropertyType = {"", "i=68"};
const ModelOpcUa::NodeId_t NodeId_BaseDataType {ns0Uri, "i=24"};
const ModelOpcUa::NodeId_t NodeId_Structure {ns0Uri, "i=22"};
const ModelOpcUa::NodeId_t NodeId_OPC_Binary {ns0Uri, "i=93"};
Expand Down
9 changes: 5 additions & 4 deletions DashboardClient/OpcUaTypeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@
std::shared_ptr<ModelOpcUa::StructureBiNode>>>();
initialize(notFoundObjectTypeNamespaces);
LOG(INFO) << "Browsing variable types.";
browseObjectOrVariableTypeAndFillBidirectionalTypeMap(NodeId_BaseVariableType, bidirectionalTypeMap, true);
browseObjectOrVariableTypeAndFillBidirectionalTypeMap(ModelOpcUa::NodeId_t({"", "i=63"}), bidirectionalTypeMap, true);
LOG(INFO) << "Browsing variable types finished, continuing browsing object types";

browseObjectOrVariableTypeAndFillBidirectionalTypeMap(NodeId_BaseObjectType, bidirectionalTypeMap, false);
LOG(INFO) << "Browsing object types finished";


auto namespaces = m_pClient->Namespaces();
for (std::size_t iNamespace = 0; iNamespace < namespaces.size(); ++iNamespace)
{
Expand All @@ -84,8 +85,7 @@
{
LOG(WARNING) << "Unable to find namespace " << notFoundObjectTypeNamespace;
}

// printTypeMapYaml();
//printTypeMapYaml();
updateTypeMap();
updateObjectTypeNames();
}
Expand Down Expand Up @@ -122,6 +122,8 @@
ModelOpcUa::StructureNode::printYamlIntern(mapIterator->second, static_cast<std::string>(mapIterator->first), 1, std::cout);
}
}



void OpcUaTypeReader::updateTypeMap()
{
Expand Down Expand Up @@ -292,7 +294,6 @@
const std::weak_ptr<ModelOpcUa::StructureBiNode> &parent, ModelOpcUa::ModellingRule_t modellingRule,
bool ofBaseDataVariableType)
{

bool isObjectType = ModelOpcUa::ObjectType == entry.NodeClass;
bool isVariableType = ModelOpcUa::VariableType == entry.NodeClass;
ModelOpcUa::StructureBiNode node(
Expand Down
1 change: 0 additions & 1 deletion DashboardClient/OpcUaTypeReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ namespace Umati
const ModelOpcUa::NodeId_t &startNodeId,
BiDirTypeMap_t bidirectionalTypeMap,
bool ofBaseDataVariableType);

void printTypeMapYaml();
void updateObjectTypeNames();
void updateTypeMap();
Expand Down