Skip to content

Class Factory for Radio Objects

Tom Schaefer edited this page Mar 5, 2024 · 3 revisions

To implement multiple types of Networked radio, the code currently has specific hooks for each type of networked radio. Currently this is just K4 and HamLib but Flex is in the wings are well as several Icom radios.

To make the code easier to maintain, I propose a Class Factory pattern be used to implement the different types of networked radios. Note I also plan on implementing each radio (regardless of serial or network) in a similar fashion. This would separate the implementation of each radio in LogRadio so there is no longer radio-specific code in the program functions. They just implement a Radio in a class derived from IRadio (I for Interface).

If you have not used Class Factories in Delphi, please read this material: https://blogs.embarcadero.com/this-is-how-to-use-the-factory-method-pattern-in-delphi/

This same concept can be used with IKeyer for different CW keyers, IExternalLogger for different external loggers and ISO2R for different SO2R boxes.

It may not make sense for each radio to own its own serial code but that remains to be explored.

Other thoughts

Using classes for each radio means polling from the main program is a thing of the past. We simply call radioObject.vfo[nrVFOA].frequency to get the last frequency filled in. Same for radioObject.vfo[nrVFOA].band. The object would be responsible for doing its own polling of the serial port of the network connected radio. Current Status and FilteredStatus go away. The radio just becomes an object to be checked like any other resource.