Meadville Space Center
Welcome, Guest. Please login or register.
October 30, 2020, 12:19:25 PM

Login with username, password and session length
Search:     Advanced search
25068 Posts in 2094 Topics by 2266 Members
Latest Member: twa517
* Home Help Search Login Register
+  Meadville Space Center
|-+  Project Apollo - NASSP
| |-+  Project Apollo - NASSP Development
| | |-+  Programming (Moderators: movieman, dseagrav, Swatch, lassombra)
| | | |-+  Toggleswitch change?
« previous next »
Pages: [1] Print
Author Topic: Toggleswitch change?  (Read 1070 times)
Hero Member
Posts: 1710

View Profile
« on: January 09, 2008, 03:32:41 PM »

BTW, I was thinking that we could potentially remove much of the complexity of the toggleswitch code by using pointers to member functions; so instead of creating new switch classes which would do specific things, we'd have switch classes for specific systems or spacecraft and give them a pointer to a function in that system. Then that function would be called with the switch as a parameter when the state changed.

So, for example, we'd have the SaturnSwitch take a pointer to a Saturn and a pointer to a function to execute in that Saturn when the switch state changes. That would save having to create a new class for each switch, and may mean that we could eliminate the PanelSwitchListener code.
Sr. Member
Posts: 410

View Profile Email
« Reply #1 on: January 09, 2008, 04:31:10 PM »

It might be worth looking into.

A word to the weary... function pointers is a thinly tread section of c++ with the exception of their use in DLL interfacing.

There is a lot of room to make errors there, so.... when a mistake is made... "He did it!" Tongue

On a more serious note, what you propose has a lot of merit.  The catch is in the process of loading/saving switch states.  And we also have to protect against the, quite popular in such implementations, problem of some bozo coming along and accessing the function itself instead of the switch.  I've been that bozo enough times to know what kind of havoc it can wreak.

My current Project Apollo work:

Quickstart to the Moon initiative (Quickstart_to_the_Moon): Done through earth orbit.  Working on new method of calculating TLI.

Checklist Controller: 
  • MFD Interface 99%(Minor cleanup and future features remain)
  • Panel Interface 99%
  • Excel interface and logic 99%
  • LEM Event code.0%
  • DSKY Interface code. Framework complete, creating "buttons"
  Approximately 80% done. (Checklist Controller
Project Apollo - NASSP
Hero Member
Posts: 3700

View Profile WWW
« Reply #2 on: January 09, 2008, 05:03:53 PM »

Yes, that sounds good for me, especially to get rid of the big case differentiations in the PanelSwitchListener function implementations would improve the design.


Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!