Class: AIXM::Feature::NavigationalAid::DME

Inherits:
AIXM::Feature::NavigationalAid show all
Defined in:
lib/aixm/feature/navigational_aid/dme.rb

Overview

Distance measuring equipment (DME) is a transponder-based radio navigation technology which measures slant range distance by timing the propagation delay of VHF or UHF signals. They operate in the frequency band between 962 MHz and 1213 MHz.

Cheat Sheet in Pseudo Code:

dme = AIXM.dme(
  source: String or nil
  region: String or nil
  organisation: AIXM.organisation
  id: String
  name: String
  xy: AIXM.xy
  z: AIXM.z or nil
  channel: String   # either set channel directly
  ghost_f: AIXM.f   # or set channel via VOR ghost frequency
)
dme.timetable = AIXM.timetable or nil
dme.remarks = String or nil
dme.comment = Object or nil

Direct Known Subclasses

TACAN

Constant Summary collapse

CHANNEL_RE =
/\A([1-9]|[1-9]\d|1[0-1]\d|12[0-6])[XY]\z/.freeze
GHOST_MAP =
{
  108_00 => (17..59),
  112_30 => (70..126),
  133_30 => (60..69),
  134_40 => (1..16)
}.freeze

Constants inherited from AIXM::Feature

REGION_RE

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature::NavigationalAid

#id, #name, #xy, #z

Attributes included from Concerns::Remarks

#remarks

Attributes included from Concerns::Timetable

#timetable

Attributes inherited from AIXM::Feature

#comment, #region, #source

Attributes inherited from Component

#meta

Instance Method Summary collapse

Methods inherited from AIXM::Feature::NavigationalAid

#inspect, #kind, #organisation

Methods included from Concerns::Association

included

Methods inherited from AIXM::Feature

#==, #hash

Methods included from Concerns::HashEquality

#eql?, #hash

Methods included from Concerns::XMLBuilder

#build_fragment, #to_uid, #to_xml

Methods included from Concerns::Memoize

included, method

Constructor Details

#initialize(channel: nil, ghost_f: nil, **arguments) ⇒ DME

See the cheat sheet for examples on how to create instances of this class.



59
60
61
62
63
64
65
66
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 59

def initialize(channel: nil, ghost_f: nil, **arguments)
  super(**arguments)
  case
    when channel then self.channel = channel
    when ghost_f then self.ghost_f = ghost_f
    else fail(ArgumentError, "either channel or ghost_f must be set")
  end
end

Instance Attribute Details

#channelString #channel=(value) ⇒ Object #ghost_fAIXM::F #ghost_f=(value) ⇒ Object

Radio channel

Overloads:

  • #channelString

    Returns:

    • (String)
  • #channel=(value) ⇒ Object

    Parameters:

    • value (String)
  • #ghost_fAIXM::F

    Returns ghost frequency matching the #channel.

    Returns:

  • #ghost_f=(value) ⇒ Object

    Parameters:



55
56
57
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 55

def channel
  @channel
end

Instance Method Details

#ghost_fObject



85
86
87
88
89
90
91
92
93
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 85

def ghost_f
  if channel
    number, letter = channel.split(/(?=[XY])/)
    integer = GHOST_MAP.find { _2.include?(number.to_i) }.first
    integer += (number.to_i - GHOST_MAP[integer].min) * 10
    integer += 5 if letter == 'Y'
    AIXM.f(integer.to_f / 100, :mhz)
  end
end

#ghost_f=(value) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 73

def ghost_f=(value)
  fail(ArgumentError, "invalid ghost_f") unless value.is_a?(AIXM::F) && value.unit == :mhz
  integer, letter = (value.freq * 100).round, 'X'
  unless (integer % 10).zero?
    integer -= 5
    letter = 'Y'
  end
  base = GHOST_MAP.keys.reverse.bsearch { _1 <= integer }
  number = ((integer - base) / 10) + GHOST_MAP[base].min
  self.channel = "#{number}#{letter}"
end

#vorAIXM::Feature::NavigationalAid::VOR?

Returns associated VOR.

Returns:



43
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 43

belongs_to :vor, readonly: true