Class: AIXM::Component::Frequency

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(transmission_f:, callsigns:) ⇒ Frequency


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

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" }

45
46
47
# File 'lib/aixm/component/frequency.rb', line 45

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)


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

def reception_f
  @reception_f
end

#remarksString?


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

def remarks
  @remarks
end

#serviceAIXM::Component::Service


36
37
38
# File 'lib/aixm/component/frequency.rb', line 36

def service
  @service
end

#timetableAIXM::Component::Timetable?


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

def timetable
  @timetable
end

#transmission_fAIXM::F


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

def transmission_f
  @transmission_f
end

#typeSymbol?


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

def type
  @type
end

Instance Method Details

#inspectString


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

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

#to_uidString


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

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


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

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