Description
A computer is a class that acts as a storage and execution environment for flight software modules. Flight software blocks perform specific tasks of computing messages that can be passed to the next flight software module. The computer is tasked with storing the modules, connecting them together, and managing their execution state through startup, shutdown, and safe mode transitions. However, the base functionality for the computer class is limited. There are more advanced computer modules (such as guidance and operation computers) that perform more advanced operations.
Example Use Cases
- Creating Flight Software: Using a computer allows flight software to be added to a spacecraft or ground station and connected together.
- Tracking Clock Time: The onboard computer clock tracks a simulated tick speed.
- Managing Power States: The computer can transition between running, shutdown, and safe mode states with configurable transition times.
Module Implementation
Onboard Clock
The computer has an in-built clock that ticks up every simulation step. The clock is a non-relativistic clock and does not take into account any form of time dilation.
Here, the clock increases its seconds every simulation tick based on the step interval. The new time is equal to the sum of the previous frame time and the change in time . The clock stores time as nanoseconds since the UNIX epoch (January 1st, 1970), which can be accessed as either nanoseconds or seconds.
The clock can be synced to match a specific DateTime. When synced, the UNIX time is calculated and updated in the clock. By not syncing a time, the clock will begin at 12:00:00 AM, January 1st, 1970.
The clock continues to advance during transitional states (starting, shutting down, entering safe mode, exiting safe mode) but does not advance when the computer is fully shut down.
State Machine
The computer operates as a state machine with seven possible states: three stable states and four transitional states.
Stable States:
- Running: The computer is fully operational and all enabled software modules are executing.
- Shutdown: The computer is powered off and no software modules are executing.
- Safe: The computer is in a low-power safe mode.
Transitional States:
- Starting: Transitioning from Shutdown to Running.
- ShuttingDown: Transitioning from Running to Shutdown.
- EnteringSafeMode: Transitioning to Safe mode.
- ExitingSafeMode: Transitioning from Safe to Running.
State Transitions
Each transition can have a configurable duration in seconds. If the transition time is set to 0, the transition occurs instantly. Otherwise, the computer enters the transitional state and counts down the remaining time each simulation tick:
When , the transition completes and the computer enters the target stable state.
The configurable transition times are:
BootTimeSeconds: Time to transition from Shutdown to Running.ShutdownTimeSeconds: Time to transition to Shutdown.EnterSafeModeTimeSeconds: Time to transition to Safe mode.ExitSafeModeTimeSeconds: Time to transition from Safe to Running.
Software Management
When the computer transitions to Shutdown, all attached software modules are disabled. The computer caches which software modules were active before shutdown. When the computer transitions back to Running, these previously active software modules are re-enabled.
Software modules can be attached to and detached from the computer dynamically. The computer maintains a list of all attached software and tracks the count via the NumSoftware property.
Assumptions/Limitations
- More advanced computers perform better functionality on flight software. This base computer does not call any flight software or make any flight logic decisions.
- The current computer does not have a clock frequency system on board to update software at a particular rate. The computer is assumed to be synced to the simulation tick.
- The clock is perfectly accurate and does not model clock drift or relativistic effects.
- During transitional states, the computer cannot accept new state change commands until the current transition completes.