Code Refactoring for a remote monitoring solution
A leader in remote monitoring and network management solution in North America was experiencing high maintenance cost in supporting different hardware variants for their monitoring solution. The customer was looking for a partner to make the maintenance and future feature upgrades at an optimized schedule and cost.
Solution Description
Refactoring
- Gadgeon re-architected the existing software stack to cater to all variants of the customer’s product family and used Embedded Linux, C++, Luci/ Lua
- System management will read the hardware variant and generate a data model based on the number of IO points in the system.
- Remote Firmware upgrade including the rootfs, os and application. Primary and secondary boot partitions for fail safe upgrade.
- Multiple boot options with priorities (primary, secondary or USB)
Configuration Management
- Developed a unified configuration management interface to support CLI, Web GUI and SNMP V2/V3.
Outcome and Benefits Delivered
Outcome:
- Any feature on any hardware platform made a reality with otimal schedule and cost on the newly refcatored sotfware stack.
- Unified Monitoring and Alarm handling system implemented based on reusable database models
- Unified Configuration management supports Web GUI, CLI, and SNMP V2/V3
- IP security features compliant with Federal Standards
Benefits:
- 60% saving in total cost of ownership for supporting different hardware variants on the newly refcatored software stack.
System Architecture Description
Application Management
Event managers, Event generation/notification, Alarm Handler, Internal Faults and Statistics. POCO libraries for thread handling and notification between threads.
Protocol Management
Protocol libraries for TL1, TBOS, TABS,DCP/F, DCM, Port handling, Protocol Wrapper, Client proprietary protocols
Device Security
System boots only if pre-calculated checksum stored in EEPROM matches with file system checksum. Security enhancement with Ip tables, restricting port access, IP filters used for restricting source IP addresses.
![System-Architecture-Description](https://gadgeon.com/manage/theme/js/editor/ckeditor/ckfinder/userfiles/files/System-Architecture-Description.jpg)
Code Refactoring for the Project
Main Challenges
- Mix of C and C++ code, 11 C++ libraries had to be integrated, as well as legacy C++ code.
- Hardware interaction was in multiple places
- Multiple functionalities as part of single module
- Header files were not organized properly
- Object oriented concepts were not followed
- Multiple hardware variants having similar code was spread across two branches
- Maintenance was difficult as modularization was not followed
- DB was accessed haphazardly from all interfaces
- Business logic was scattered across the code base.
- Above 150K LOCs
Refactoring approach implemented
- Converted all code to C++11 after proper object oriented design
- Hardware interaction concentrated into a single module, interfaces defined
- Singleton pattern brought in, and similar functionality grouped together
- Base classes were defined to bring in common functionality, and diversions made into derived classes
- Single compilation with defines for separate hardware variants
- Modularization of code strictly followed
- A framework defined for DB handling to unify external interfaces.
- Business logic put in concentrated places
- Proper thread handling and critical sections defined using mutexes