Module Base

This module contains the BASE class.

1) #BASE class

The #BASE class is the super class for all the classes defined within MOOSE.

It handles:

  • The construction and inheritance of child classes.
  • The tracing of objects during mission execution within the DCS.log file, under the "Saved Games\DCS\Logs" folder.

Note: Normally you would not use the BASE class unless you are extending the MOOSE framework with new classes.

1.1) BASE constructor

Any class derived from BASE, must use the Base#BASE.New method how this is done.

1.2) BASE Trace functionality

The BASE class contains trace methods to trace progress within a mission execution of a certain object. Note that these trace methods are inherited by each MOOSE class interiting BASE. As such, each object created from derived class from BASE can use the tracing functions to trace its execution.

1.2.1) Tracing functions

There are basically 3 types of tracing methods available within BASE:

  • BASE.F: Trace the beginning of a function and its given parameters. An F is indicated at column 44 in the DCS.log file.
  • BASE.T: Trace further logic within a function giving optional variables or parameters. A T is indicated at column 44 in the DCS.log file.
  • BASE.E: Trace an exception within a function giving optional variables or parameters. An E is indicated at column 44 in the DCS.log file. An exception will always be traced.

1.2.2) Tracing levels

There are 3 tracing levels within MOOSE.
These tracing levels were defined to avoid bulks of tracing to be generated by lots of objects.

As such, the F and T methods have additional variants to trace level 2 and 3 respectively:

  • BASE.F2: Trace the beginning of a function and its given parameters with tracing level 2.
  • BASE.F3: Trace the beginning of a function and its given parameters with tracing level 3.
  • BASE.T2: Trace further logic within a function giving optional variables or parameters with tracing level 2.
  • BASE.T3: Trace further logic within a function giving optional variables or parameters with tracing level 3.

1.3) BASE Inheritance support

The following methods are available to support inheritance:

Future

Further methods may be added to BASE whenever there is a need to make "overall" functions available within MOOSE.


Global(s)

BASE
FORMATION

Type BASE

BASE:AddEvent(Event, EventFunction)

Set a new listener for the class.

BASE.ClassID

The ID number of the class.

BASE.ClassName

The name of the class.

BASE.ClassNameAndID

The name of the class concatenated with the ID number of the class.

BASE:ClearState(Object, StateName)
BASE:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace)

Creation of a Birth Event.

BASE:CreateEventCrash(EventTime, Initiator)

Creation of a Crash Event.

BASE:DisableEvents()

Disable the event listeners for the class.

BASE:E(Arguments)

Log an exception which will be traced always.

BASE:EnableEvents()

Enable the event listeners for the class.

BASE:Event()

Returns the event dispatcher

BASE.Events
BASE:F(Arguments)

Trace a function call.

BASE:F2(Arguments)

Trace a function call level 2.

BASE:F3(Arguments)

Trace a function call level 3.

BASE:GetClassID()

Get the ClassID of the class instance.

BASE:GetClassName()

Get the ClassName of the class instance.

BASE:GetClassNameAndID()

Get the ClassName + ClassID of the class instance.

BASE:GetState(Object, StateName)
BASE:Inherit(Child, Parent)

This is the worker method to inherit from a parent class.

BASE:Inherited(Child)

This is the worker method to retrieve the Parent class.

BASE:New()

The base constructor.

BASE:SetState(Object, StateName, State)
BASE.States
BASE:T(Arguments)

Trace a function logic level 1.

BASE:T2(Arguments)

Trace a function logic level 2.

BASE:T3(Arguments)

Trace a function logic level 3.

BASE:TraceAll(TraceAll)

Trace all methods in MOOSE

BASE:TraceClass(Class)

Set tracing for a class

BASE:TraceClassMethod(Class, Method)

Set tracing for a specific method of class

BASE:TraceLevel(Level)

Set trace level

BASE.TraceOnOff(BASE, TraceOnOff, self)

Set trace on or off Note that when trace is off, no debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

BASE:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function call.

BASE:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function logic.

BASE:onEvent(event)

Type FORMATION

FORMATION.Cone

A cone formation.

Global(s)

#BASE BASE
#FORMATION FORMATION

Type Base

Type BASE

The BASE Class

Field(s)

BASE:AddEvent(Event, EventFunction)

Set a new listener for the class.

Parameters

Return value

#BASE:

BASE.ClassID

The ID number of the class.

BASE.ClassName

The name of the class.

BASE.ClassNameAndID

The name of the class concatenated with the ID number of the class.

BASE:ClearState(Object, StateName)

Parameters

  • Object :

  • StateName :

BASE:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace)

Creation of a Birth Event.

Parameters

  • DCSTypes#Time EventTime : The time stamp of the event.

  • DCSObject#Object Initiator : The initiating object of the event.

  • #string IniUnitName : The initiating unit name.

  • place :

  • subplace :

BASE:CreateEventCrash(EventTime, Initiator)

Creation of a Crash Event.

Parameters

BASE:DisableEvents()

Disable the event listeners for the class.

Return value

#BASE:

BASE:E(Arguments)

Log an exception which will be traced always.

Can be anywhere within the function logic.

Parameter

  • Arguments : A #table or any field.

BASE:EnableEvents()

Enable the event listeners for the class.

Return value

#BASE:

BASE:Event()

Returns the event dispatcher

Return value

Event#EVENT:

BASE.Events
BASE:F(Arguments)

Trace a function call.

Must be at the beginning of the function logic.

Parameter

  • Arguments : A #table or any field.

BASE:F2(Arguments)

Trace a function call level 2.

Must be at the beginning of the function logic.

Parameter

  • Arguments : A #table or any field.

BASE:F3(Arguments)

Trace a function call level 3.

Must be at the beginning of the function logic.

Parameter

  • Arguments : A #table or any field.

BASE:GetClassID()

Get the ClassID of the class instance.

Return value

#string: The ClassID of the class instance.

BASE:GetClassName()

Get the ClassName of the class instance.

Return value

#string: The ClassName of the class instance.

BASE:GetClassNameAndID()

Get the ClassName + ClassID of the class instance.

The ClassName + ClassID is formatted as '%s#%09d'.

Return value

#string: The ClassName + ClassID of the class instance.

BASE:GetState(Object, StateName)

Parameters

  • Object :

  • StateName :

BASE:Inherit(Child, Parent)

This is the worker method to inherit from a parent class.

Parameters

  • Child : is the Child class that inherits.

  • #BASE Parent : is the Parent class that the Child inherits from.

Return value

#BASE: Child

BASE:Inherited(Child)

This is the worker method to retrieve the Parent class.

Parameter

  • #BASE Child : is the Child class from which the Parent class needs to be retrieved.

Return value

#BASE:

BASE:New()

The base constructor.

This is the top top class of all classed defined within the MOOSE. Any new class needs to be derived from this class for proper inheritance.

Return value

#BASE: The new instance of the BASE class.

Usage:

-- This declares the constructor of the class TASK, inheriting from BASE.
--- TASK constructor
-- @param #TASK self
-- @param Parameter The parameter of the New constructor.
-- @return #TASK self
function TASK:New( Parameter )

    local self = BASE:Inherit( self, BASE:New() )
    
    self.Variable = Parameter 

    return self
end
BASE:SetState(Object, StateName, State)

Parameters

  • Object :

  • StateName :

  • State :

BASE.States
BASE:T(Arguments)

Trace a function logic level 1.

Can be anywhere within the function logic.

Parameter

  • Arguments : A #table or any field.

BASE:T2(Arguments)

Trace a function logic level 2.

Can be anywhere within the function logic.

Parameter

  • Arguments : A #table or any field.

BASE:T3(Arguments)

Trace a function logic level 3.

Can be anywhere within the function logic.

Parameter

  • Arguments : A #table or any field.

BASE:TraceAll(TraceAll)

Trace all methods in MOOSE

Parameter

  • #boolean TraceAll : true = trace all methods in MOOSE.

BASE:TraceClass(Class)

Set tracing for a class

Parameter

  • #string Class :

BASE:TraceClassMethod(Class, Method)

Set tracing for a specific method of class

Parameters

  • #string Class :

  • #string Method :

BASE:TraceLevel(Level)

Set trace level

Parameter

  • #number Level :

BASE.TraceOnOff(BASE, TraceOnOff, self)

Set trace on or off Note that when trace is off, no debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

So tracing must be switched on manually in your mission if you are using Moose statically. When moose is loading dynamically (for moose class development), tracing is switched on by default.

Parameters

  • BASE : self

  • #boolean TraceOnOff : Switch the tracing on or off.

  • self :

Usage:

-- Switch the tracing On
BASE:TraceOn( true )

-- Switch the tracing Off
BASE:TraceOn( false )
BASE:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function call.

This function is private.

Parameters

  • Arguments : A #table or any field.

  • DebugInfoCurrentParam :

  • DebugInfoFromParam :

BASE:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function logic.

Parameters

  • Arguments : A #table or any field.

  • DebugInfoCurrentParam :

  • DebugInfoFromParam :

BASE:onEvent(event)

TODO: Complete DCSTypes#Event structure.
- The main event handling function... This function captures all events generated for the class. @param #BASE self @param DCSTypes#Event event

Parameter

  • event :

Type FORMATION

The Formation Class

Field(s)

FORMATION.Cone

A cone formation.