Skip to content

Commit

Permalink
Added fix for general BaseDataVariableType handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdornaus committed Aug 1, 2023
1 parent 887f693 commit a276a1c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
8 changes: 1 addition & 7 deletions DashboardClient/Converter/ModelToJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,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->ofBaseDataVariableType;
}

std::string ModelToJson::nodeClassToString(ModelOpcUa::NodeClass_t nodeClass) {
Expand Down
22 changes: 20 additions & 2 deletions DashboardClient/OpcUaTypeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
LOG(WARNING) << "Unable to find namespace " << notFoundObjectTypeNamespace;
}

// printTypeMapYaml();
for (auto mapIterator = m_typeMap->begin(); mapIterator != m_typeMap->end(); mapIterator++)
{
this->updateBaseDataVariableTypes(mapIterator->second);
}
//printTypeMapYaml();
updateTypeMap();
updateObjectTypeNames();
}
Expand Down Expand Up @@ -122,6 +126,20 @@
ModelOpcUa::StructureNode::printYamlIntern(mapIterator->second, static_cast<std::string>(mapIterator->first), 1, std::cout);
}
}
void OpcUaTypeReader::updateBaseDataVariableTypes(const std::shared_ptr<ModelOpcUa::StructureNode> &node) {
if(std::find(this->BaseDataVariableTypes.begin(), this->BaseDataVariableTypes.end(), node->SpecifiedTypeNodeId) != this->BaseDataVariableTypes.end()) {
node->ofBaseDataVariableType = true;
}
if (!node->SpecifiedChildNodes->empty()){
for (auto childNodesIterator = node->SpecifiedChildNodes->begin(); childNodesIterator != node->SpecifiedChildNodes->end(); childNodesIterator++){
updateBaseDataVariableTypes(childNodesIterator.operator*());
if ((childNodesIterator != node->SpecifiedChildNodes->end()) && (childNodesIterator != --node->SpecifiedChildNodes->end())) {
}
}
}
}



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

this->BaseDataVariableTypes.push_back(entry.NodeId);
bool isObjectType = ModelOpcUa::ObjectType == entry.NodeClass;
bool isVariableType = ModelOpcUa::VariableType == entry.NodeClass;
ModelOpcUa::StructureBiNode node(
Expand Down
3 changes: 2 additions & 1 deletion DashboardClient/OpcUaTypeReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Umati
/// \todo make the following internal structures private and provide access via funcitons
std::map<ModelOpcUa::NodeId_t, ModelOpcUa::NodeId_t> m_identificationTypeOfTypeDefinition;
std::map<std::string, NamespaceInformation_t> m_availableObjectTypeNamespaces;
std::vector<ModelOpcUa::NodeId_t> BaseDataVariableTypes;
std::vector<std::string> m_expectedObjectTypeNamespaces;
std::vector<std::string> m_expectedObjectTypeNames;
std::vector<ModelOpcUa::NodeId_t> m_knownMachineTypeDefinitions;
Expand All @@ -60,7 +61,7 @@ namespace Umati
const ModelOpcUa::NodeId_t &startNodeId,
BiDirTypeMap_t bidirectionalTypeMap,
bool ofBaseDataVariableType);

void updateBaseDataVariableTypes(const std::shared_ptr<ModelOpcUa::StructureNode> &node);
void printTypeMapYaml();
void updateObjectTypeNames();
void updateTypeMap();
Expand Down

0 comments on commit a276a1c

Please sign in to comment.