IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
IMS_ModuleFunctionData_Thruster Class Reference

Stores the static data of a basic thruster. More...

Inheritance diagram for IMS_ModuleFunctionData_Thruster:
IMS_ModuleFunctionData_Base IMS_ModuleFunctionData_Rcs

Public Member Functions

THRUSTERMODEGetThrusterMode (int mode)
 
int getNumberOfModes ()
 
THRUSTEREXHAUSTGetThrusterExhaust (int idx)
 
int GetNumberOfExhausts ()
 
VECTOR3 GetThrustDirection ()
 
VECTOR3 GetThrusterPosition ()
 
virtual bool HasGui ()
 This function serves to check whether a module function has a GUI before creating it. More...
 
- Public Member Functions inherited from IMS_ModuleFunctionData_Base
virtual bool LoadFromFile (string configfile, IMSFILE cfg)
 Loads the data from config file. More...
 
FUNCTIONTYPE GetType ()
 
string GetName ()
 

Protected Member Functions

virtual bool processConfigLine (vector< string > &tokens)
 Receives all lines of the config file that concern this ModuleFunction one by one. More...
 
virtual bool validateData (string configfile)
 Validates the data for completeness after loading. More...
 

Protected Attributes

vector< THRUSTERMODEthrustermodes
 
vector< THRUSTEREXHAUSTexhausts
 
VECTOR3 thrustdirection = _V(0, 0, 0)
 
VECTOR3 thrusterpos = _V(0, 0, 0)
 
- Protected Attributes inherited from IMS_ModuleFunctionData_Base
FUNCTIONTYPE type
 Stores the type of the ModuleFunction.
 
string name = ""
 Stores the Name of the ModuleFunction.
 

Private Member Functions

void processMode (vector< string > &tokens)
 processes a senario line for a thrustermode More...
 
void processExhaust (vector< string > &tokens)
 processes a senario line for an exhaust definition More...
 
void validateModes ()
 validates the thruster modes read from the config file More...
 
void validateExhausts ()
 validates the exhausts read from the config file More...
 

Detailed Description

Stores the static data of a basic thruster.

Config parameters

general parameters

dir = <float x> <float y> <float z> //The direction of thrust as a normalised vector, relative to the module. Direction of thrust means "the direction the thruster is pushing towards", not "the direction stuff is flying out of the thruster"!
[pos] = <float x> <float y> <float z> //The position of the point the thrust is originating at, relative to the module. Default is 0 0 0 which will be perfectly fine for most applications.

Exhaust definitions

BEGIN_EXHAUST //Begins an exhaust definition block. Thrusters can have an arbitrary number of exhausts, but must have at least one!
length = <float> //The length of the exhaust plume at maximum thrust, in meters.
width = <float> //The width of the exhaust plume at maximum thrust, in meters.
pos = <float x> <float y> <float z> //The origin of the exhaust plume, relative to the module.
[dir] = <float x> <float y> <float z> //The direction of the exhaust plume. Default is the inverted direction of thrust of the thruster.
END_EXHAUST //Ends an exhaust definition block.

thruster mode definitions

BEGIN_THRUSTERMODE <string thrustermode_name> //Begins a new thrustermode definition block. A thruster can have an arbitrary amount of thrustermodes, but must have at least one!
[exhaustlength] = <float> //A scaling factor for the length of the exhaust plume at maximum thrust, between 0 and 1. Default is 1.
[exhaustwidth] = <float> //A scaling factor for the width of the exhaust plume at maximum thrust, between 0 and 1. Default is 1.
consumable = <string id> <float weight> //The shorthand of a consumable (see Consumables.cfg for valid values) the thruster uses as propellant, followed by its weight in the mixture.
//An arbitrary number of consumables can be declared per thrustermode. The weight for the mixture is in "parts", e.g. a consumable with a weight of 1 and a consumable with a weight of 2.5 results in a ratio of 1:2.5.
thrust = <float N> //The maximum thrust of the thruster, in Newton.
isp = <float m/s> //The exhaust velocity of the thruster, in m/s.
END_THRUSTERMODE //Ends a thrustermode definition block.

Config example

BEGIN_MODULEFUNCTION THRUSTER
name = F1
dir = 0 0 1
BEGIN_EXHAUST
length = 20
width = 1
pos = 0 0 -1
END_EXHAUST
BEGIN_THRUSTERMODE default
Consumable = LOX 2.56
Consumable = RP1 1
Thrust = 7740500
Isp = 2982
END_THRUSTERMODE
END_MODULEFUNCTION

Member Function Documentation

int IMS_ModuleFunctionData_Thruster::getNumberOfModes ( )
inline
Returns
The number of modes supported by this thruster
VECTOR3 IMS_ModuleFunctionData_Thruster::GetThrustDirection ( )
inline
Returns
The direction of thrust of the thruster, module relative
THRUSTERMODE * IMS_ModuleFunctionData_Thruster::GetThrusterMode ( int  mode)
Returns
A pointer to the thrustermode with the requested index
Parameters
modeThe index of the requested thrustermode in the thrustermode list
VECTOR3 IMS_ModuleFunctionData_Thruster::GetThrusterPosition ( )
inline
Returns
The position of the thruster, module relative.
virtual bool IMS_ModuleFunctionData_Thruster::HasGui ( )
inlinevirtual

This function serves to check whether a module function has a GUI before creating it.

Note
If your ModuleFunction has its own GUI, overload this function and return true, as simple as that.
Returns
Always false

Reimplemented from IMS_ModuleFunctionData_Base.

Reimplemented in IMS_ModuleFunctionData_Rcs.

bool IMS_ModuleFunctionData_Thruster::processConfigLine ( vector< string > &  tokens)
protectedvirtual

Receives all lines of the config file that concern this ModuleFunction one by one.

Overload this function to receive the relevant data of your module.

Parameters
tokensa vector of strings that contains the individual parts of the line, delimited by whitespace or '='
Note
Throw runtime_error with an error message if you encounter an invalid line! The message will be loged in Orbiter.log together with the name of the config file.
Returns
true if the passed line was processed, false if not.

Implements IMS_ModuleFunctionData_Base.

Reimplemented in IMS_ModuleFunctionData_Rcs.

void IMS_ModuleFunctionData_Thruster::processExhaust ( vector< string > &  tokens)
private

processes a senario line for an exhaust definition

Parameters
tokensThe scenario line split into single items
void IMS_ModuleFunctionData_Thruster::processMode ( vector< string > &  tokens)
private

processes a senario line for a thrustermode

Parameters
tokensThe scenario line split into single items
bool IMS_ModuleFunctionData_Thruster::validateData ( string  configfile)
protectedvirtual

Validates the data for completeness after loading.

Implement this function to validate your data at the end of the loading process. Check if everything's there that needs to be, and write log messages if it isn't.

Parameters
configfileThe name of the configfile, so you can add it to your messages so config writers find their mistakes faster.
Returns
False if the modulefunction is unable to function, otherwise return true.
Note
If your Implementation returns false, The loading process will be aborted by forcing orbiter to crash, so be sure to keep your loging straight!

Implements IMS_ModuleFunctionData_Base.

Reimplemented in IMS_ModuleFunctionData_Rcs.

void IMS_ModuleFunctionData_Thruster::validateExhausts ( )
private

validates the exhausts read from the config file

Exceptions
invalid_argumentif there is a problem with exhausts
void IMS_ModuleFunctionData_Thruster::validateModes ( )
private

validates the thruster modes read from the config file

Exceptions
invalid_argumentif there is a problem with thruster modes

The documentation for this class was generated from the following files: