diff --git a/Moose Development/Moose/Core/Radio.lua b/Moose Development/Moose/Core/Radio.lua index f50898918..41cd582ff 100644 --- a/Moose Development/Moose/Core/Radio.lua +++ b/Moose Development/Moose/Core/Radio.lua @@ -1,10 +1,8 @@ ---- This module contains the **Core - RADIO** class. The RADIO class is responsible for **transmitting radio communications**. +--- **Core** - The RADIO class is responsible for **transmitting radio communications**. -- --- 1) @{Radio#RADIO} class, extends @{Base#BASE} --- ================================================= +-- --- bitmap -- --- 1.1) General radio transmssion setup --- ------------------------------------ +-- === -- -- What are radio communications in DCS ? -- @@ -27,10 +25,17 @@ -- like the A10C or the Mirage 2000C. They will **hear the transmission** if they are tuned on the **right frequency and modulation** (and if they are close enough - more on that below). -- If a FC3 airacraft is used, it will **hear every communication, whatever the frequency and the modulation** is set to. -- --- 1.2) @{Radio#RADIO} usage --- ------------------------- +-- === +-- +-- ### Authors: Hugues "Grey_Echo" Bousquet +-- +-- @module Radio + +--- # 1) RADIO class, extends @{Base#BASE} -- --- There are 3 steps to a successful radio transmission +-- ## 1.1) RADIO usage +-- +-- There are 3 steps to a successful radio transmission. -- -- * First, you need to **"add" a @{#RADIO} object** to your @{Positionable#POSITIONABLE}. This is done using the @{Positionable#POSITIONABLE.GetRadio}() function, -- * Then, you will **set the relevant parameters** to the transmission (see below), @@ -61,13 +66,7 @@ -- * This an automated DCS calculation you have no say on, -- * For reference, a standard VOR station has a 100W antenna, a standard AA TACAN has a 120W antenna, and civilian ATC's antenna usually range between 300 and 500W, -- * Note that if the transmission has a subtitle, it will be readable, regardless of the quality of the transmission. --- ---### Authors: Hugues "Grey_Echo" Bousquet --- --- @module Radio --- @author Grey-Echo - ---- The RADIO class +-- -- @type RADIO -- @field Wrapper.Positionable#POSITIONABLE Positionable The transmiter -- @field #string FileName Name of the sound file @@ -91,52 +90,57 @@ RADIO = { } --- Create a new RADIO Object. This doesn't broadcast a transmission, though, use @{#RADIO.Broadcast} to actually broadcast --- @param Wrapper.Positionable#POSITIONABLE Positionable +-- @param #RADIO self +-- @param Wrapper.Positionable#POSITIONABLE Positionable The @{Positionable} that will receive radio capabilities. -- @return #RADIO Radio -- @return #nil If Positionable is invalid -- @usage -- -- If you want to create a RADIO, you probably should use @{Positionable#POSITIONABLE.GetRadio}() instead -function RADIO:New(positionable) - local self = BASE:Inherit( self, BASE:New() ) - self:F(positionable) - if positionable:GetPointVec2() ~= nil then -- It's stupid, but the only way I found to make sure positionable is valid - self.Positionable = positionable +function RADIO:New(Positionable) + local self = BASE:Inherit( self, BASE:New() ) -- Core.Radio#RADIO + + self:F(Positionable) + + if Positionable:GetPointVec2() ~= nil then -- It's stupid, but the only way I found to make sure positionable is valid + self.Positionable = Positionable return self - else - self:E({"The passed positionable is invalid, no RADIO created", positionable}) - return nil end + + self:E({"The passed positionable is invalid, no RADIO created", Positionable}) + return nil end --- Check validity of the filename passed and sets RADIO.FileName -- @param #RADIO self --- @param #string fileName File name of the sound file (i.e. "Noise.ogg") +-- @param #string FileName File name of the sound file (i.e. "Noise.ogg") -- @return #RADIO self -function RADIO:SetFileName(filename) - self:F2(filename) - if type(filename) == "string" then - if filename:find(".ogg") ~= nil or filename:find(".wav") ~= nil then - if filename:find("l10n/DEFAULT/") == nil then - filename = "l10n/DEFAULT/" .. filename +function RADIO:SetFileName(FileName) + self:F2(FileName) + + if type(FileName) == "string" then + if FileName:find(".ogg") ~= nil or FileName:find(".wav") ~= nil then + if FileName:find("l10n/DEFAULT/") == nil then + FileName = "l10n/DEFAULT/" .. FileName end - self.FileName = filename + self.FileName = FileName return self end end + self:E({"File name invalid. Maybe something wrong with the extension ?", self.FileName}) return self end --- Check validity of the frequency passed and sets RADIO.Frequency -- @param #RADIO self --- @param #number frequency in MHz (Ranges allowed for radio transmissions in DCS : 30-88 / 108-152 / 225-400MHz) +-- @param #number Frequency in MHz (Ranges allowed for radio transmissions in DCS : 30-88 / 108-152 / 225-400MHz) -- @return #RADIO self -function RADIO:SetFrequency(frequency) - self:F2(frequency) - if type(frequency) == "number" then +function RADIO:SetFrequency(Frequency) + self:F2(Frequency) + if type(Frequency) == "number" then -- If frequency is in range - if (frequency >= 30 and frequency < 88) or (frequency >= 108 and frequency < 152) or (frequency >= 225 and frequency < 400) then - self.Frequency = frequency * 1000000 -- Conversion in Hz + if (Frequency >= 30 and Frequency < 88) or (Frequency >= 108 and Frequency < 152) or (Frequency >= 225 and Frequency < 400) then + self.Frequency = Frequency * 1000000 -- Conversion in Hz -- If the RADIO is attached to a UNIT or a GROUP, we need to send the DCS Command "SetFrequency" to change the UNIT or GROUP frequency if self.Positionable.ClassName == "UNIT" or self.Positionable.ClassName == "GROUP" then self.Positionable:GetDCSObject():getController():setCommand({ @@ -156,13 +160,13 @@ end --- Check validity of the frequency passed and sets RADIO.Modulation -- @param #RADIO self --- @param #number modulation either radio.modulation.AM or radio.modulation.FM +-- @param #number Modulation either radio.modulation.AM or radio.modulation.FM -- @return #RADIO self -function RADIO:SetModulation(modulation) - self:F2(modulation) - if type(modulation) == "number" then - if modulation == radio.modulation.AM or modulation == radio.modulation.FM then --TODO Maybe make this future proof if ED decides to add an other modulation ? - self.Modulation = modulation +function RADIO:SetModulation(Modulation) + self:F2(Modulation) + if type(Modulation) == "number" then + if Modulation == radio.modulation.AM or Modulation == radio.modulation.FM then --TODO Maybe make this future proof if ED decides to add an other modulation ? + self.Modulation = Modulation return self end end @@ -174,10 +178,10 @@ end -- @param #RADIO self -- @param #number Power in W -- @return #RADIO self -function RADIO:SetPower(power) - self:F2(power) - if type(power) == "number" then - self.Power = math.floor(math.abs(power)) --TODO Find what is the maximum power allowed by DCS and limit power to that +function RADIO:SetPower(Power) + self:F2(Power) + if type(Power) == "number" then + self.Power = math.floor(math.abs(Power)) --TODO Find what is the maximum power allowed by DCS and limit power to that return self end self:E({"Power is invalid. Power unchanged.", self.Power}) @@ -189,10 +193,10 @@ end -- @param #boolean Loop -- @return #RADIO self -- @usage -function RADIO:SetLoop(loop) - self:F2(loop) - if type(loop) == "boolean" then - self.Loop = loop +function RADIO:SetLoop(Loop) + self:F2(Loop) + if type(Loop) == "boolean" then + self.Loop = Loop return self end self:E({"Loop is invalid. Loop unchanged.", self.Loop}) @@ -201,22 +205,22 @@ end --- Check validity of the subtitle and the subtitleDuration passed and sets RADIO.subtitle and RADIO.subtitleDuration -- @param #RADIO self --- @param #string Subtitle --- @param #number SubtitleDuration in s +-- @param #string SubTitle +-- @param #number SubTitleDuration in s -- @return #RADIO self -- @usage -- -- Both parameters are mandatory, since it wouldn't make much sense to change the Subtitle and not its duration -function RADIO:SetSubtitle(subtitle, subtitleDuration) - self:F2({subtitle, subtitleDuration}) - if type(subtitle) == "string" then - self.Subtitle = subtitle +function RADIO:SetSubtitle(SubTitle, SubTitleDuration) + self:F2({SubTitle, SubTitleDuration}) + if type(SubTitle) == "string" then + self.Subtitle = SubTitle else self.Subtitle = "" self:E({"Subtitle is invalid. Subtitle reset.", self.Subtitle}) end - if type(subtitleDuration) == "number" then - if math.floor(math.abs(subtitleDuration)) == subtitleDuration then - self.SubtitleDuration = subtitleDuration + if type(SubTitleDuration) == "number" then + if math.floor(math.abs(SubTitleDuration)) == SubTitleDuration then + self.SubtitleDuration = SubTitleDuration return self end end @@ -305,3 +309,4 @@ function RADIO:Broadcast() end return self end + diff --git a/docs/Documentation/Radio.html b/docs/Documentation/Radio.html index 1d61a7f87..1046d3a15 100644 --- a/docs/Documentation/Radio.html +++ b/docs/Documentation/Radio.html @@ -73,14 +73,13 @@

Module Radio

-

This module contains the Core - RADIO class.

+

Core - The RADIO class is responsible for transmitting radio communications.

-

The RADIO class is responsible for transmitting radio communications.

-

1) Radio#RADIO class, extends Base#BASE

+

--- bitmap

-

1.1) General radio transmssion setup

+

What are radio communications in DCS ?

@@ -109,49 +108,7 @@ like the A10C or the Mirage 2000C. They will hear the transmission if they are tuned on the right frequency and modulation (and if they are close enough - more on that below). If a FC3 airacraft is used, it will hear every communication, whatever the frequency and the modulation is set to.

-

1.2) Radio#RADIO usage

- -

There are 3 steps to a successful radio transmission

- - - -

Methods to set relevant parameters for both a Unit#UNIT or a Group#GROUP or any other Positionable#POSITIONABLE

- - - -

Additional Methods to set relevant parameters if the transmiter is a Unit#UNIT or a Group#GROUP

- - - -

Additional Methods to set relevant parameters if the transmiter is any other Wrapper.Positionable#POSITIONABLE

- - - -

What is this power thing ?

- - +

Authors: Hugues "Grey_Echo" Bousquet

@@ -204,7 +161,7 @@ If a FC3 airacraft is used, it will hear every communication, whatever t - RADIO.New(Positionable, self, positionable) + RADIO:New(Positionable)

Create a new RADIO Object.

@@ -234,37 +191,37 @@ If a FC3 airacraft is used, it will hear every communication, whatever t - RADIO:SetFileName(fileName, filename) + RADIO:SetFileName(FileName)

Check validity of the filename passed and sets RADIO.FileName

- RADIO:SetFrequency(frequency) + RADIO:SetFrequency(Frequency)

Check validity of the frequency passed and sets RADIO.Frequency

- RADIO:SetLoop(Loop, loop) + RADIO:SetLoop(Loop)

Check validity of the loop passed and sets RADIO.Loop

- RADIO:SetModulation(modulation) + RADIO:SetModulation(Modulation)

Check validity of the frequency passed and sets RADIO.Modulation

- RADIO:SetPower(Power, power) + RADIO:SetPower(Power)

Check validity of the power passed and sets RADIO.Power

- RADIO:SetSubtitle(Subtitle, SubtitleDuration, subtitle, subtitleDuration) + RADIO:SetSubtitle(SubTitle, SubTitleDuration)

Check validity of the subtitle and the subtitleDuration passed and sets RADIO.subtitle and RADIO.subtitleDuration

@@ -302,7 +259,54 @@ If a FC3 airacraft is used, it will hear every communication, whatever t

Type RADIO

-

The RADIO class

+

1) RADIO class, extends Base#BASE

+ +

1.1) RADIO usage

+ +

There are 3 steps to a successful radio transmission.

+ + + + + +

Methods to set relevant parameters for both a Unit#UNIT or a Group#GROUP or any other Positionable#POSITIONABLE

+ + + +

Additional Methods to set relevant parameters if the transmiter is a Unit#UNIT or a Group#GROUP

+ + + +

Additional Methods to set relevant parameters if the transmiter is any other Wrapper.Positionable#POSITIONABLE

+ + + +

What is this power thing ?

+ +
    +
  • If your transmission is sent by a Positionable#POSITIONABLE other than a Unit#UNIT or a Group#GROUP, you can set the power of the antenna,
  • +
  • Otherwise, DCS sets it automatically, depending on what's available on your Unit,
  • +
  • If the player gets too far from the transmiter, or if the antenna is too weak, the transmission will fade and become noisyer,
  • +
  • This an automated DCS calculation you have no say on,
  • +
  • For reference, a standard VOR station has a 100W antenna, a standard AA TACAN has a 120W antenna, and civilian ATC's antenna usually range between 300 and 500W,
  • +
  • Note that if the transmission has a subtitle, it will be readable, regardless of the quality of the transmission. +
  • +

Field(s)

@@ -406,7 +410,7 @@ self

-RADIO.New(Positionable, self, positionable) +RADIO:New(Positionable)
@@ -416,21 +420,12 @@ self

This doesn't broadcast a transmission, though, use RADIO.Broadcast to actually broadcast

-

Parameters

+

Parameter

@@ -604,25 +599,20 @@ but it will work for any POSITIONABLE
-RADIO:SetFileName(fileName, filename) +RADIO:SetFileName(FileName)

Check validity of the filename passed and sets RADIO.FileName

-

Parameters

+

Parameter

  • -

    #string fileName : +

    #string FileName : File name of the sound file (i.e. "Noise.ogg")

    -
  • -
  • - -

    filename :

    -

Return value

@@ -636,7 +626,7 @@ self

-RADIO:SetFrequency(frequency) +RADIO:SetFrequency(Frequency)
@@ -647,7 +637,7 @@ self

@@ -3202,20 +3193,6 @@ True = Continue Scheduler

- -
-
-
- - - -SPAWN.uncontrolled - -
-
- - -
diff --git a/docs/Documentation/index.html b/docs/Documentation/index.html index 3ac55dfd9..003801339 100644 --- a/docs/Documentation/index.html +++ b/docs/Documentation/index.html @@ -318,7 +318,7 @@ are design patterns allowing efficient (long-lasting) processes and workflows. Radio -

This module contains the Core - RADIO class.

+

Core - The RADIO class is responsible for transmitting radio communications.