Skip to content

Commit bce2c76

Browse files
committed
Add per-item counters for structure complexity and show() them
1 parent 485922c commit bce2c76

12 files changed

+68
-28
lines changed

devOpcuaSup/UaSdk/DataElementUaSdkLeaf.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2025 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -39,11 +39,19 @@ namespace DevOpcua
3939
{
4040

4141
DataElementUaSdkLeaf::DataElementUaSdkLeaf (const std::string &name,
42-
class ItemUaSdk *pitem,
42+
class ItemUaSdk *item,
4343
class RecordConnector *pconnector)
44-
: DataElementUaSdk(name, pitem)
44+
: DataElementUaSdk(name, item)
4545
, incomingQueue(pconnector->plinkinfo->clientQueueSize, pconnector->plinkinfo->discardOldest)
46-
{}
46+
{
47+
item->dataTreeNoOfLeafs++;
48+
}
49+
50+
DataElementUaSdkLeaf::~DataElementUaSdkLeaf()
51+
{
52+
delete enumChoices;
53+
pitem->dataTreeNoOfLeafs--;
54+
}
4755

4856
/* Explicitly implement the destructor here (allows the compiler to place the vtable) */
4957
DataElementUaSdk::~DataElementUaSdk() = default;

devOpcuaSup/UaSdk/DataElementUaSdkLeaf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2025 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -241,8 +241,8 @@ class DataElementUaSdkLeaf
241241
* @param pitem pointer to corresponding ItemUaSdk
242242
* @param pconnector pointer to record connector to link to
243243
*/
244-
DataElementUaSdkLeaf(const std::string &name, ItemUaSdk *pitem, RecordConnector *pconnector);
245-
virtual ~DataElementUaSdkLeaf () override { delete enumChoices; }
244+
DataElementUaSdkLeaf(const std::string &name, ItemUaSdk *item, RecordConnector *pconnector);
245+
virtual ~DataElementUaSdkLeaf () override;
246246

247247
/* ElementTree node interface methods */
248248
virtual bool isLeaf () const override { return true; }

devOpcuaSup/UaSdk/DataElementUaSdkNode.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2025 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -34,11 +34,18 @@
3434

3535
namespace DevOpcua {
3636

37-
DataElementUaSdkNode::DataElementUaSdkNode (const std::string &name, class ItemUaSdk *item)
38-
: DataElementUaSdk(name, item)
37+
DataElementUaSdkNode::DataElementUaSdkNode (const std::string &name, class ItemUaSdk *pitem)
38+
: DataElementUaSdk(name, pitem)
3939
, timesrc(-1)
4040
, mapped(false)
41-
{}
41+
{
42+
pitem->dataTreeNoOfNodes++;
43+
}
44+
45+
DataElementUaSdkNode::~DataElementUaSdkNode()
46+
{
47+
pitem->dataTreeNoOfNodes--;
48+
}
4249

4350
void
4451
DataElementUaSdkNode::addChild (std::weak_ptr<DataElementUaSdk> elem)

devOpcuaSup/UaSdk/DataElementUaSdkNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2025 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -27,8 +27,8 @@ namespace DevOpcua {
2727
class DataElementUaSdkNode : public DataElementUaSdk
2828
{
2929
public:
30-
DataElementUaSdkNode(const std::string &name, class ItemUaSdk *item);
31-
virtual ~DataElementUaSdkNode () override {}
30+
DataElementUaSdkNode(const std::string &name, class ItemUaSdk *pitem);
31+
virtual ~DataElementUaSdkNode () override;
3232

3333
/* ElementTree node interface methods */
3434
virtual bool isLeaf() const override { return false; }

devOpcuaSup/UaSdk/ItemUaSdk.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2021 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -47,6 +47,8 @@ ItemUaSdk::ItemUaSdk (const linkInfo &info)
4747
, revisedSamplingInterval(0.0)
4848
, revisedQueueSize(0)
4949
, dataTreeDirty(false)
50+
, dataTreeNoOfNodes(0)
51+
, dataTreeNoOfLeafs(0)
5052
, lastStatus(OpcUa_BadServerNotConnected)
5153
, lastReason(ProcessReason::connectionLoss)
5254
{
@@ -112,7 +114,10 @@ ItemUaSdk::show (int level) const
112114
std::cout << " bini=" << linkOptionBiniString(linkinfo.bini) << " output=" << (linkinfo.isOutput ? "y" : "n")
113115
<< " monitor=" << (linkinfo.monitor ? "y" : "n")
114116
<< " registered=" << (registered ? nodeid->toString().toUtf8() : "-") << "("
115-
<< (linkinfo.registerNode ? "y" : "n") << ")" << std::endl;
117+
<< (linkinfo.registerNode ? "y" : "n") << ")";
118+
if (!(dataTreeNoOfNodes == 0 && dataTreeNoOfLeafs == 1))
119+
std::cout << " dataNodes=" << dataTreeNoOfNodes << " dataLeafs=" << dataTreeNoOfLeafs;
120+
std::cout << std::endl;
116121

117122
if (level >= 1) {
118123
if (auto re = dataTree.root().lock()) {

devOpcuaSup/UaSdk/ItemUaSdk.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ class ItemUaSdk : public Item
225225
OpcUa_Double revisedSamplingInterval; /**< server-revised sampling interval */
226226
OpcUa_UInt32 revisedQueueSize; /**< server-revised queue size */
227227
ElementTree<DataElementUaSdkNode, DataElementUaSdk, ItemUaSdk> dataTree; /**< data element tree */
228-
epicsMutex dataTreeWriteLock; /**< lock for dirty flag */
228+
epicsMutex dataTreeWriteLock; /**< lock for dirty flag */
229229
bool dataTreeDirty; /**< true if any element has been modified */
230+
unsigned int dataTreeNoOfNodes; /**< number of nodes */
231+
unsigned int dataTreeNoOfLeafs; /**< number of leafs */
230232
UaStatusCode lastStatus; /**< status code of most recent service */
231233
ProcessReason lastReason; /**< most recent processing reason */
232234
epicsTime tsClient; /**< client (local) time stamp */

devOpcuaSup/open62541/DataElementOpen62541Leaf.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2023 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -36,6 +36,13 @@ DataElementOpen62541Leaf::DataElementOpen62541Leaf (const std::string &name,
3636
{
3737
UA_Variant_init(&incomingData);
3838
UA_Variant_init(&outgoingData);
39+
item->dataTreeNoOfLeafs++;
40+
}
41+
42+
DataElementOpen62541Leaf::~DataElementOpen62541Leaf()
43+
{
44+
delete enumChoices;
45+
pitem->dataTreeNoOfLeafs--;
3946
}
4047

4148
/* Explicitly implement the destructor here (allows the compiler to place the vtable) */

devOpcuaSup/open62541/DataElementOpen62541Leaf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2023 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -207,7 +207,7 @@ class DataElementOpen62541Leaf
207207
* @param pconnector pointer to record connector to link to
208208
*/
209209
DataElementOpen62541Leaf(const std::string &name, ItemOpen62541 *pitem, RecordConnector *pconnector);
210-
virtual ~DataElementOpen62541Leaf() override { delete enumChoices; }
210+
virtual ~DataElementOpen62541Leaf() override;
211211

212212
/* ElementTree node interface methods */
213213
virtual bool isLeaf () const override { return true; }

devOpcuaSup/open62541/DataElementOpen62541Node.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2023 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/
@@ -125,9 +125,13 @@ DataElementOpen62541Node::DataElementOpen62541Node (const std::string &name, Ite
125125
{
126126
UA_Variant_init(&incomingData);
127127
UA_Variant_init(&outgoingData);
128+
item->dataTreeNoOfNodes++;
128129
}
129130

130-
DataElementOpen62541Node::~DataElementOpen62541Node() = default;
131+
DataElementOpen62541Node::~DataElementOpen62541Node()
132+
{
133+
pitem->dataTreeNoOfNodes--;
134+
}
131135

132136
void
133137
DataElementOpen62541Node::createMap (const UA_DataType *type, const std::string *timefrom)

devOpcuaSup/open62541/DataElementOpen62541Node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*************************************************************************\
2-
* Copyright (c) 2018-2023 ITER Organization.
2+
* Copyright (c) 2018-2026 ITER Organization.
33
* This module is distributed subject to a Software License Agreement found
44
* in file LICENSE that is included with this distribution.
55
\*************************************************************************/

0 commit comments

Comments
 (0)