Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

Studying the CAT project

Drax
Drax Member
edited February 2017 in SmartSDR API
Could someone write up the theory of how the CAT project works?  

I'm studying it trying to figure out the order of operations for instantiating the API objects, finding the radio, opening a panadapter and a slice.  

I have a basic understanding of interfaces, events, etc., but the outline of the concrete process is eluding me as the CAT program seems to use many layers of interfaces and then dynamically generated classes, events, and function calls.  

Stepping through the program I didn't even see where the debugger stepped into Slice.cs or the other Flexlib source code.

Answers

  • Drax
    Drax Member
    edited February 2014
    It seems the secret is Spring and AOP.
  • BobT
    BobT Company Adviser
    edited February 2014


    Hi Drax,

    I'm not quite sure just what information you need but I'll be glad to try to answer your questions. 

    With respect to the CAT core itself, you are correct, Spring and AOP are the important elements in CAT.  The most important part is the Spring XMLClassFactory that lets us store the definition of a particular CAT command in an external file and dynamically build CAT command classes on the fly. 

    In PowerSDR, all the CAT commands were individual methods, hard-coded and buried in the guts of the code.  It was not particularly hard code to generate, there was just a lot of repetition.  Not a real model of object oriented development :>).  In the new code I can change the parameters of a CAT command by editing an XML file.

    AOP is not widely used in the current CAT code though the initial plan was to use it more extensively.  The main usage now is to trap and log errors that may occur during CAT class construction (CatAroundAdvice.cs).  There was another interceptor, CatAfterAdvice.cs, that is no longer used (but still present in the code in case I find a use for it).  It was initially used to post-process CAT commands (like adding leading zeros, etc.) but a better way was found to do that.

    You statement about not seeing the debugger step into Slice.cs, etc. deserves an answer.  CAT only talks to the FlexLib.API.  It subscribe to API events and monitors property changes that are broadcast via those events.  CAT doesn't know that radio.cs or slice.cs even exist.

    I tried to add some code examples here, with more explanation, but this reflector doesn't like my format.  I'll find the Help file for this thing and get back to you with more explanation.  Meanwhile, if you have specific questions, I'll be glad to give the a shot.

    73,

    BobT, K5KDN


  • Drax
    Drax Member
    edited February 2014
    I never knew what Spring was until I encountered it in CAT.  I was thinking it might just be some minor functionality and then it turns out to be the means.  Looking through the code at first, with my unenlightened eyes, I was thinking the author was either a madman, a lover of complexity, or a pure genius.   I couldn't tell.  So I watched some YouTube videos on Spring last night and now I understand!

    Do the API objects such as Radio.cs ever get instantiated?  Or are you subscribing them to CAT command events?   If I want to set the frequency of a slice where is that happening in the CAT code?

  • Drax
    Drax Member
    edited February 2014
    Would you email me those code examples?    draxfelton@gmail.com
  • BobT
    BobT Company Adviser
    edited February 2014


    Stand by, I'm writing a "novel" on how cat works and hope to finish it today.

    Short answer to you question:  No, CAT only uses the API events.  I have an example of how frequency is read/set in what I'm writing now.


    Bob

  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin
    edited February 2017
    If I understand correctly what you're asking, here's the basics of how you connect to a radio:

    1. You call API.Init() in the FlexLib.dll (make sure to add a reference in your project).
    2. You subscribe to the RadioAdded event.  You can see examples of this in the CAT code if you search for _RadioAdded.
    3. In the handler for RadioAdded, you will likely want to setup handlers for the Radio events SliceAdded, SliceRemoved, PanadapterAdded, PanadapterRemoved, etc.
    4. In each of those (and probably in the Radio class), you may also want to subscribe to the PropertyChanged event so that you can keep up with which things are changing in each of the objects.

    Is this what you were looking for?
  • Drax
    Drax Member
    edited February 2014
    Exactly.
  • Drax
    Drax Member
    edited February 2014
    Thanks.  That's great learning.
  • BobT
    BobT Company Adviser
    edited February 2014


    We'll have my "How CAT Works" write-up posted here as soon as I can figure out how to do it :>)

    Bob, K5KDN

  • Steve-N5AC
    Steve-N5AC Community Manager admin
    edited February 2017
    OK here's a link to Bob's document:  How CAT Works
  • Bill - K7UOP
    Bill - K7UOP Member ✭✭
    edited February 2014

    Thanks for the write up Bob. Very helpful, especially to someone just getting their feet wet with ideas like AOP, Dependency Injection, etc. Always thought an interceptor was just a type of military aircraft. All part of the learning experience... pretty neat.

    Bill - K7UOP

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.