Class: AIXM::Component::Frequency

Inherits:
Object
  • Object
show all
Includes:
Association, Memoize
Defined in:
lib/aixm/component/frequency.rb

Overview

Frequencies used by a service.

By default, #reception_f is set to the same value as #transmission_f since most services rely on simplex (aka: non-duplex) two-way communication. For services with one-way communication only such as ATIS, the #reception_f has to be set to nil explicitly!

Cheat Sheet in Pseudo Code:

frequency = AIXM.frequency(
  transmission_f: AIXM.f
  callsigns: Hash
)
frequency.reception_f = AIXM.f or nil
frequency.type = TYPES or nil
frequency.timetable = AIXM.timetable or nil
frequency.remarks = String or nil

Constant Summary collapse

TYPES =
{
  STD: :standard,
  ALT: :alternative,
  EMRG: :emergency,
  GUARD: :guard,
  MIL: :military,
  CIV: :civilian,
  OTHER: :other   # specify in remarks
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Memoize

cache, included, method

Methods included from Association

included

Constructor Details

#initialize(transmission_f:, callsigns:) ⇒ Frequency

Returns a new instance of Frequency.


65
66
67
68
# File 'lib/aixm/component/frequency.rb', line 65

def initialize(transmission_f:, callsigns:)
  self.transmission_f, self.callsigns = transmission_f, callsigns
  self.reception_f = transmission_f
end

Instance Attribute Details

#callsignsHash

Returns map from languages (ISO 639-1) to callsigns.

Examples:

{ en: "STRASBOURG CONTROL", fr: "STRASBOURG CONTROLE" }

Returns:

  • (Hash)

    map from languages (ISO 639-1) to callsigns


49
50
51
# File 'lib/aixm/component/frequency.rb', line 49

def callsigns
  @callsigns
end

#reception_fAIXM::F?

Note:

One-way services such as ATIS should set this to nil and simplex (aka: non-duplex) communication should set this to #transmission_f.

Returns frequency for reception (incoming).

Returns:

  • (AIXM::F, nil)

    frequency for reception (incoming)


54
55
56
# File 'lib/aixm/component/frequency.rb', line 54

def reception_f
  @reception_f
end

#remarksString?

Returns free text remarks.

Returns:

  • (String, nil)

    free text remarks


63
64
65
# File 'lib/aixm/component/frequency.rb', line 63

def remarks
  @remarks
end

#timetableAIXM::Component::Timetable?

Returns operating hours.

Returns:


60
61
62
# File 'lib/aixm/component/frequency.rb', line 60

def timetable
  @timetable
end

#transmission_fAIXM::F

Returns frequency for transmission (outgoing).

Returns:

  • (AIXM::F)

    frequency for transmission (outgoing)


43
44
45
# File 'lib/aixm/component/frequency.rb', line 43

def transmission_f
  @transmission_f
end

#typeSymbol?

Returns type of frequency (see TYPES).

Returns:

  • (Symbol, nil)

    type of frequency (see TYPES)


57
58
59
# File 'lib/aixm/component/frequency.rb', line 57

def type
  @type
end

Instance Method Details

#inspectString

Returns:

  • (String)

71
72
73
# File 'lib/aixm/component/frequency.rb', line 71

def inspect
  %Q(#<#{self.class} transmission_f=#{transmission_f.inspect} callsigns=#{callsigns.inspect}>)
end

#serviceAIXM::Component::Service

Returns service the frequency belongs to.

Returns:


40
# File 'lib/aixm/component/frequency.rb', line 40

belongs_to :service

#to_uidString

Returns UID markup.

Returns:

  • (String)

    UID markup


104
105
106
107
108
109
110
# File 'lib/aixm/component/frequency.rb', line 104

def to_uid
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.FqyUid do |fqy_uid|
    fqy_uid << service.to_uid.indent(2)
    fqy_uid.valFreqTrans(transmission_f.freq)
  end
end

#to_xmlString

Returns AIXM or OFMX markup.

Returns:

  • (String)

    AIXM or OFMX markup


114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/aixm/component/frequency.rb', line 114

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.Fqy do |fqy|
    fqy << to_uid.indent(2)
    fqy.valFreqRec(reception_f.freq) if reception_f
    fqy.uomFreq(transmission_f.unit.upcase.to_s)
    fqy << timetable.to_xml(as: :Ftt).indent(2) if timetable
    fqy.txtRmk(remarks) if remarks
    callsigns.each do |language, callsign|
      fqy.Cdl do |cdl|
        cdl.txtCallSign(callsign)
        cdl.codeLang(language.upcase.to_s)
      end
    end
    fqy.target!
  end
end