As software engineers, we often dive into solving problems headfirst, eager to write code and see results. But a recent experience reminded me of the importance of following a proper engineering approach—especially when dealing with complex standards like MTConnect. Here’s a blog post about how we resolved a tricky issue, the time we wasted by taking the wrong path, and the lessons I’ll carry forward.
While working on an MTConnect-to-OPC UA adapter, we encountered an issue with a DataItem called cvars
. This DataItem, defined as an EVENT of type VARIABLE
, was supposed to display a set of key-value pairs (e.g., "100: 55.2; 101: 11; 103: ON; ..."
). However, our code kept falling back to "UNAVAILABLE"
, even when the data was present in the /current
response. The XML structure used VariableDataSet
with Entry
elements, but our parsing logic wasn’t handling it correctly.
Initially, we took a reverse approach:
- Jumped to Implementation: We started by analyzing the
/current
response and tweaking the code to parse theVariableDataSet
structure, assuming it was a table-like DataItem. - Resorted to Hardcoding: When the logic didn’t work, we hardcoded
cvars
to be treated as aTABLE
DataItem, which temporarily fixed the issue but wasn’t scalable or standards-compliant. - Wasted Time on Trial-and-Error: We spent hours debugging, tweaking, and testing, only to realize we were missing a fundamental understanding of the MTConnect standard.
This approach led to frustration, wasted time, and a brittle solution that wouldn’t hold up for other DataItems using VariableDataSet
.
The breakthrough came when we stepped back and followed a proper engineering approach, as any seasoned engineer should:
- Document Analysis
We consulted the MTConnect standard (ANSI/MTC1.5-2020) and analyzed the definition ofVariableDataSet
. We learned that:
VariableDataSet
is used for EVENT DataItems of typeVARIABLE
to represent key-value pairs.- It can contain
Entry
elements or a simple value (e.g.,"UNAVAILABLE"
). - Entries with
removed="true"
should be excluded.
- System Analysis
We compared the standard to our implementation:
- The
/probe
response definedcvars
as an EVENT DataItem withtype="VARIABLE"
andrepresentation="VALUE"
, notTABLE
. - Our code wasn’t handling the variability of
VariableDataSet
(e.g., switching betweenEntry
elements and"UNAVAILABLE"
). - We needed a dedicated parsing logic for
VariableDataSet
.
- System Design
We designed a solution that aligned with the standard:
- Added a
parseVariableDataSet
function to handle theVariableDataSet
structure, filtering outremoved="true"
entries and formatting the data into a string. - Updated the
updateDataItem
function to use this logic for EVENT DataItems of typeVARIABLE
. - Ensured the solution was general, avoiding hardcoding for
cvars
.
- Implementation and Validation
We implemented the solution, tested it with real data, and validated it using an OPC UA client. The result?cvars
now correctly showed"100: 55.2; 101: 11; 103: ON; 104: 18; 105: 151; 106: #3"
when data was present, and"UNAVAILABLE"
when appropriate.
By following this structured approach, we resolved the issue in a way that was:
- Standards-Driven: Aligned with the MTConnect standard, ensuring correctness.
- Scalable: General enough to handle other DataItems using
VariableDataSet
. - Maintainable: No hardcoding, with detailed logging for future debugging.
This experience taught me a valuable lesson about the right way to tackle software design challenges:
- Start with Documentation
Always begin by thoroughly reading the relevant standards, specifications, or documentation. For us, this meant diving into the MTConnect standard to understandVariableDataSet
before writing a single line of code. - Analyze Before Designing
Compare the standard to your system to identify gaps. Understand the problem domain fully before jumping to solutions. - Design with Scalability in Mind
Avoid quick fixes like hardcoding. Design solutions that are general, robust, and aligned with the standard, so they can handle future cases. - Implement and Test Thoroughly
Build with detailed logging to aid debugging, and test with real data to catch edge cases early. - Document and Iterate
Document your solution and reasoning for future reference, and be ready to iterate if new issues arise.
By initially skipping the documentation and analysis steps, we wasted hours on trial-and-error, produced a temporary fix that didn’t scale, and delayed the real solution. Following the proper path—documents, analysis, and then system design—saved us from further headaches and resulted in a much better outcome.
As engineers, it’s tempting to dive into coding right away, but taking the time to understand the problem domain first is always worth it. The next time you face a complex issue, remember: documents, analysis, and then system design. It’s the path to robust, maintainable software—and it saves you from the frustration of going in circles.
Get the Bufferstack.IO OPCUA MTConnect Adapter Shareware installer from this link – https://github.com/hj91/MTConnect-OPCUA-Server-Installer
Previous Posts
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
RSS Feed
Latest from Bufferstack.IO
- Bufferstack.IO OPC UA MTConnect Adapter Development Notes April 4, 2025As software engineers, we often dive into solving problems headfirst, eager to write code and see results. But a recent experience reminded me of the importance of following a proper engineering approach—especially when dealing with complex standards like MTConnect. Here’s a blog post about how we resolved a tricky issue, the time we wasted by […]harshadjoshi
- Introducing Bufferstack.IO Universal OPCUA Server Shareware November 29, 2024We are excited to announce the release of our latest shareware application: the Bufferstack.IO Universal OPCUA Server. This versatile tool is designed for developers, engineers, and learners to explore OPC UA server functionality, integrate with Modbus devices, and evaluate secure industrial communication standards. This shareware version is intended for evaluation purposes only. What is the […]harshadjoshi
- Enhancing Security on Bufferstack.IO Super Container OS with TOTP July 22, 2024How to add totp security feature to Bufferstack.IO Super Container OS and this information can also be used for other #Debian derived distros.harshadjoshi
- Super Container OS Release Notes 14-06-2024 June 14, 2024The Bufferstack.IO team is thrilled to announce the latest iteration of Super Container OS, bringing a wave of advancements for streamlined container orchestration and infrastructure deployment. This release empowers developers and IT professionals with a robust platform to manage their containerized applications with greater ease and efficiency. Enhanced Core: Streamlined Infrastructure as Code: Vagrant is […]harshadjoshi
- IIoT Gateway Release Notes 11-06-2024 June 11, 2024June begins with the release of next generation updated version of Bufferstack.IO IIoT Gateway, which like its previous releases is a Linux based Live+Install iso IIoT Gateway now focuses on designing, testing and deploying Smart Factory applications using latest version of Bufferstack.IO IIoT Middleware (based in Node-RED 3-1-9) and includes many custom developed nodes by […]harshadjoshi
- Introducing Web browser based Andon System May 25, 2024I am pleased to Introduce Web Andon System based on Bufferstack.IO industrial Systems Framework – it is designed to meet the demands of modern manufacturing environments, our Web Andon Display provides real-time monitoring and visualization of critical parameters essential for maintaining operational efficiency and productivity. With customizable features, including company name and logo display, shift […]harshadjoshi
- InfluxDB database status monitoring using influxdb-mqtt-monitor April 30, 2024This application monitors changes in a dataset stored in InfluxDB and publishes notifications via MQTT when new data is available. Additionally, it provides a REST API endpoint to retrieve the latest data and its change status. Features Potential Use Cases Conclusion This application provides a versatile solution for real-time data monitoring and notifications, suitable for […]harshadjoshi
- Enhancing Industrial Automation Reliability with Persistent Relay Node March 13, 2024In the dynamic landscape of industrial automation, reliability is not just a desirable trait—it’s an absolute necessity. Whether it’s managing critical machinery on the factory floor or overseeing complex processes in a chemical plant, the ability to maintain uninterrupted operations is crucial for maximizing productivity and ensuring safety. Enter the Persistent Relay Node—a game-changer in […]harshadjoshi
- node-red-contrib-relay just released March 7, 2024In the realm of IoT (Internet of Things) and IIoT (Industrial Internet of Things), efficient data flow management is paramount. As devices become increasingly interconnected, the ability to control and route data with precision is essential for optimizing performance and ensuring seamless operation. Enter the Node-RED Relay Node, a powerful tool designed to streamline data […]harshadjoshi
- Turning LowCode development platform to NoCode deployment platform March 5, 2024Turning Low-Code developement platforms like Node-RED into No-Code deployment platforms in the IoT (Internet of Things) and IIoT (Industrial Internet of Things) sectors can significantly reduce barriers to entry and democratize access to these technologies. Here’s how: Overall, transforming Low-Code platforms into No-Code platforms democratizes IoT and IIoT development by making these technologies more accessible, […]harshadjoshi