Class: AIXM::Component::Service

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

Overview

Service provided by a unit.

Cheat Sheet in Pseudo Code:

service = AIXM.service(
  type: TYPES
)
service.timetable = AIXM.timetable or nil
service.remarks = String or nil
service.add_frequency(AIXM.frequency)

Constant Summary collapse

TYPES =
{
  ACS: :area_control_service,
  ADS: :automatic_dependent_surveillance_service,
  ADVS: :advisory_service,
  AFIS: :aerodrome_flight_information_service,
  AFS: :aeronautical_fixed_service,
  AIS: :aeronautical_information_service,
  ALRS: :alerting_service,
  AMS: :aeronautical_mobile_service,
  AMSS: :aeronautical_mobile_satellite_service,
  APP: :approach_control_service,
  'APP-ARR': :approach_control_service_for_arrival,
  'APP-DEP': :approach_control_service_for_departure,
  ARTCC: :air_route_traffic_control_centre_service,
  ATC: :air_traffic_control_service,
  ATFM: :air_traffic_flow_management_service,
  ATIS: :automated_terminal_information_service,
  'ATIS-ARR': :automated_terminal_information_service_for_arrival,
  'ATIS-DEP': :automated_terminal_information_service_for_departure,
  ATM: :air_traffic_management_service,
  ATS: :air_traffic_service,
  BOF: :briefing_service,
  BS: :commercial_broadcasting_service,
  COM: :communications_service,
  CTAF: :common_traffic_advisory_frequency_service,
  DVDF: :doppler_vdf_service,
  EFAS: :en_route_flight_advisory_service,
  ENTRY: :entry_clearance_service,
  EXIT: :exit_clearance_service,
  FCST: :forecasting_service,
  FIS: :flight_information_service,
  FISA: :automated_flight_information_service,
  FSS: :flight_service_station_service,
  GCA: :ground_controlled_approach_service,
  INFO: :information_provision_service,
  MET: :meteorological_service,
  NOF: :international_notam_service,
  OAC: :oceanic_area_control_service,
  OVERFLT: :overflight_clearance_service,
  PAR: :precision_approach_radar_service,
  RAC: :rules_of_the_air_and_air_traffic_services,
  RADAR: :radar_service,
  RAF: :regional_area_forecasting_service,
  RCC: :rescue_coordination_service,
  SAR: :search_and_rescue_service,
  SIGMET: :sigmet_service,
  SMC: :surface_movement_control_service,
  SMR: :surface_movement_radar_service,
  SRA: :surveillance_radar_approach_service,
  SSR: :secondary_surveillance_radar_service,
  TAR: :terminal_area_radar_service,
  TWEB: :transcribed_weather_broadcast_service,
  TWR: :aerodrome_control_tower_service,
  UAC: :upper_area_control_service,
  UDF: :uhf_direction_finding_service,
  VDF: :vhf_direction_finding_service,
  VOLMET: :volmet_service,
  VOT: :vor_test_facility,
  OTHER: :other   # specify in remarks
}.freeze
GUESSED_UNIT_TYPES_MAP =

Map service types to guessed unit types

{
  :advisory_service => :advisory_centre,
  :aerodrome_control_tower_service => :aerodrome_control_tower,
  :aerodrome_flight_information_service => :aerodrome_control_tower,
  :aeronautical_information_service => :aeronautical_information_services_office,
  :air_route_traffic_control_centre_service => :air_route_traffic_control_centre,
  :air_traffic_control_service => :air_traffic_control_centre,
  :air_traffic_flow_management_service => :air_traffic_flow_management_unit,
  :air_traffic_management_service => :air_traffic_management_unit,
  :air_traffic_service => :air_traffic_services_unit,
  :approach_control_service => :approach_control_office,
  :approach_control_service_for_arrival => :arrivals_approach_control_office,
  :approach_control_service_for_departure => :depatures_approach_control_office,
  :area_control_service => :area_control_centre,
  :automated_terminal_information_service => :aerodrome_control_tower,
  :automated_terminal_information_service_for_arrival => :aerodrome_control_tower,
  :automated_terminal_information_service_for_departure => :aerodrome_control_tower,
  :automatic_dependent_surveillance_service => :automatic_dependent_surveillance_unit,
  :briefing_service => :briefing_office,
  :commercial_broadcasting_service => :commercial_broadcasting_station,
  :communications_service => :communications_office,
  :flight_information_service => :flight_information_centre,
  :flight_service_station_service => :flight_service_station,
  :forecasting_service => :forecasting_office,
  :ground_controlled_approach_service => :ground_controlled_approach_systems_office,
  :international_notam_service => :international_notam_office,
  :meteorological_service => :meteorological_office,
  :oceanic_area_control_service => :oceanic_control_centre,
  :precision_approach_radar_service => :precision_approach_radar_centre,
  :radar_service => :radar_office,
  :regional_area_forecasting_service => :regional_area_forecast_centre,
  :rescue_coordination_service => :rescue_coordination_centre,
  :search_and_rescue_service => :search_and_rescue_centre,
  :secondary_surveillance_radar_service => :secondary_surveillance_radar_centre,
  :sigmet_service => :meteorological_office,
  :surface_movement_control_service => :surface_movement_control_office,
  :surface_movement_radar_service => :surface_movement_radar_office,
  :surveillance_radar_approach_service => :surveillance_radar_approach_centre,
  :terminal_area_radar_service => :terminal_area_surveillance_radar_centre,
  :transcribed_weather_broadcast_service => :meteorological_office,
  :uhf_direction_finding_service => :uhf_direction_finding_station,
  :upper_area_control_service => :upper_area_control_centre,
  :vhf_direction_finding_service => :vdf_direction_finding_station,
  :volmet_service => :meteorological_office,
  :other => :other
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Memoize

cache, included, method

Methods included from Association

included

Constructor Details

#initialize(type:) ⇒ Service

Returns a new instance of Service.


153
154
155
156
# File 'lib/aixm/component/service.rb', line 153

def initialize(type:)
  self.type = type
  @sequence = 1
end

Instance Attribute Details

#remarksString?

Returns free text remarks.

Returns:

  • (String, nil)

    free text remarks


151
152
153
# File 'lib/aixm/component/service.rb', line 151

def remarks
  @remarks
end

#timetableAIXM::Component::Timetable?

Returns operating hours.

Returns:


148
149
150
# File 'lib/aixm/component/service.rb', line 148

def timetable
  @timetable
end

#typeSymbol

Returns type of service (see TYPES).

Returns:

  • (Symbol)

    type of service (see TYPES)


145
146
147
# File 'lib/aixm/component/service.rb', line 145

def type
  @type
end

Instance Method Details

#add_frequency(frequency) ⇒ Object

Parameters:


134
# File 'lib/aixm/component/service.rb', line 134

has_many :frequencies

#frequenciesArray<AIXM::Component::Frequency>

Returns frequencies used by this service.

Returns:


134
# File 'lib/aixm/component/service.rb', line 134

has_many :frequencies

#guessed_unit_typeSymbol?

Guess the unit type for this service

Returns:

  • (Symbol, nil)

    guessed unit type or nil if unmappable


179
180
181
# File 'lib/aixm/component/service.rb', line 179

def guessed_unit_type
  GUESSED_UNIT_TYPES_MAP[type]
end

#inspectString

Returns:

  • (String)

159
160
161
# File 'lib/aixm/component/service.rb', line 159

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

#layerAIXM::Component::Layer

Returns airspace layer this service is provided within.

Returns:


142
# File 'lib/aixm/component/service.rb', line 142

belongs_to :layer

#to_uidString

Returns UID markup.

Returns:

  • (String)

    UID markup


184
185
186
187
188
189
190
191
192
# File 'lib/aixm/component/service.rb', line 184

def to_uid
  resequence!
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.SerUid do |ser_uid|
    ser_uid << unit.to_uid.indent(2)
    ser_uid.codeType(TYPES.key(type).to_s)
    ser_uid.noSeq(@sequence)
  end
end

#to_xmlString

Returns AIXM or OFMX markup.

Returns:

  • (String)

    AIXM or OFMX markup


196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/aixm/component/service.rb', line 196

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.comment! ["Service: #{TYPES.key(type)}", unit&.send(:name_with_type)].compact.join(' by ')
  builder.Ser do |ser|
    ser << to_uid.indent(2)
    ser << timetable.to_xml(as: :Stt).indent(2) if timetable
    ser.txtRmk(remarks) if remarks
  end
  frequencies.each do |frequency|
    builder << frequency.to_xml
  end
  builder.target!
end

#unitAIXM::Feature::Unit

Returns unit providing this service.

Returns:


138
# File 'lib/aixm/component/service.rb', line 138

belongs_to :unit