Studying the CAT project

  • 1
  • Question
  • Updated 6 years ago
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.
Photo of Drax

Drax

  • 99 Posts
  • 13 Reply Likes

Posted 6 years ago

  • 1
Photo of Drax

Drax

  • 99 Posts
  • 13 Reply Likes
It seems the secret is Spring and AOP.
Photo of BobT

BobT, Elmer

  • 59 Posts
  • 32 Reply Likes

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







Photo of Drax

Drax

  • 99 Posts
  • 13 Reply Likes
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?

Photo of Drax

Drax

  • 99 Posts
  • 13 Reply Likes
Would you email me those code examples?    draxfelton@gmail.com
Photo of BobT

BobT, Elmer

  • 59 Posts
  • 32 Reply Likes

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

Photo of Drax

Drax

  • 99 Posts
  • 13 Reply Likes
Thanks.  That's great learning.
Photo of Eric - KE5DTO

Eric - KE5DTO, Official Rep

  • 887 Posts
  • 338 Reply Likes
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?
Photo of Drax

Drax

  • 99 Posts
  • 13 Reply Likes
Exactly.
Photo of BobT

BobT, Elmer

  • 59 Posts
  • 32 Reply Likes

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

Bob, K5KDN

Photo of Steve - N5AC

Steve - N5AC, VP Engineering / CTO

  • 1057 Posts
  • 1097 Reply Likes
OK here's a link to Bob's document:  How CAT Works
Photo of Bill - K7UOP

Bill - K7UOP

  • 34 Posts
  • 6 Reply Likes
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