Class: Verizon::Management

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/management.rb

Overview

This represent the management container describing the meta information about the event, such as the detection time, the event’s location, the source of the event, and the notification distance.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(action_id = nil, detection_time = nil, reference_time = nil, event_position = nil, station_type = nil, awareness_distance = SKIP) ⇒ Management

Returns a new instance of Management.



106
107
108
109
110
111
112
113
114
115
# File 'lib/verizon/models/management.rb', line 106

def initialize(action_id = nil, detection_time = nil, reference_time = nil,
               event_position = nil, station_type = nil,
               awareness_distance = SKIP)
  @action_id = action_id
  @detection_time = detection_time
  @reference_time = reference_time
  @event_position = event_position
  @awareness_distance = awareness_distance unless awareness_distance == SKIP
  @station_type = station_type
end

Instance Attribute Details

#action_idActionId

TODO: Write general description for this method

Returns:



16
17
18
# File 'lib/verizon/models/management.rb', line 16

def action_id
  @action_id
end

#awareness_distanceAwarenessDistanceEnum

Specifies how far the event is relevant to.



35
36
37
# File 'lib/verizon/models/management.rb', line 35

def awareness_distance
  @awareness_distance
end

#detection_timeInteger

Timestamp in milliseconds since start of 2004 when event was first generated

Returns:

  • (Integer)


21
22
23
# File 'lib/verizon/models/management.rb', line 21

def detection_time
  @detection_time
end

#event_positionEventPosition

Timestamp in milliseconds since start of 2004 when the DENM message was generated.

Returns:



31
32
33
# File 'lib/verizon/models/management.rb', line 31

def event_position
  @event_position
end

#reference_timeInteger

Timestamp in milliseconds since start of 2004 when the DENM message was generated.

Returns:

  • (Integer)


26
27
28
# File 'lib/verizon/models/management.rb', line 26

def reference_time
  @reference_time
end

#station_typeInteger

The type of ITS station that generated the DENM. The value shall be set to:

  • 0 ‘unknown` - information about the ITS-S context is not

provided,

  • 1 ‘pedestrian` - ITS-S carried by human being not using a

mechanical device for their trip (VRU profile 1),

  • 2 ‘cyclist` - ITS-S mounted on non-motorized unicycles,

bicycles , tricycles, quadracycles (VRU profile 2),

  • 3 ‘moped` - ITS-S mounted on light motor vehicles with less

than four wheels as defined in UNECE/TRANS/WP.29/78/Rev.4 [16]

class L1, L2 (VRU Profile 3),
  • 4 ‘motorcycles` - ITS-S mounted on motor vehicles with less than

four wheels as defined in UNECE/TRANS/WP.29/78/Rev.4 [16]

class L3, L4, L5, L6, L7 (VRU Profile 3),
  • 5 ‘passengerCar` - ITS-S mounted on small passenger vehicles as

defined in UNECE/TRANS/WP.29/78/Rev.4 [16] class M1,

  • 6 ‘bus` - ITS-S mounted on large passenger vehicles as

defined in UNECE/TRANS/WP.29/78/Rev.4 [16] class M2, M3,

  • 7 ‘lightTruck` - ITS-S mounted on light Goods Vehicles as defined

in UNECE/TRANS/WP.29/78/Rev.4 [16] class N1,

  • 8 ‘heavyTruck` - ITS-S mounted on Heavy Goods Vehicles as defined

in UNECE/TRANS/WP.29/78/Rev.4 [16] class N2 and N3,

  • 9 ‘trailer` - ITS-S mounted on an unpowered vehicle that is

intended to be towed by a powered vehicle as defined in

UNECE/TRANS/WP.29/78/Rev.4 [16] class O,
  • 10 ‘specialVehicles` - ITS-S mounted on vehicles which have special

purposes other than the above (e.g. moving road works vehicle),

  • 11 ‘tram` - ITS-S mounted on a vehicle which runs on tracks

along public streets,

  • 12 ‘lightVruVehicle` - ITS-S carried by a human being traveling on light

vehicle , incl. possible use of roller skates or skateboards (VRU profile 2),

  • 13 ‘animal` - ITS-S carried by an animal presenting a safety

risk to other road users e.g. domesticated dog in a city or horse (VRU Profile 4),

  • 14 - reserved for future usage,

  • 15 ‘roadSideUnit` - ITS-S mounted on an infrastructure typically

positioned outside of the drivable roadway (e.g. on a gantry, on a pole,

on a stationary road works trailer); the

infrastructure is static during the entire operation period of the ITS-S (e.g. no stop and go activity),

  • 16-255 - are reserved for future usage.

Returns:

  • (Integer)


80
81
82
# File 'lib/verizon/models/management.rb', line 80

def station_type
  @station_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/verizon/models/management.rb', line 118

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  action_id = ActionId.from_hash(hash['actionId']) if hash['actionId']
  detection_time = hash.key?('detectionTime') ? hash['detectionTime'] : nil
  reference_time = hash.key?('referenceTime') ? hash['referenceTime'] : nil
  event_position = EventPosition.from_hash(hash['eventPosition']) if hash['eventPosition']
  station_type = hash.key?('stationType') ? hash['stationType'] : nil
  awareness_distance =
    hash.key?('awarenessDistance') ? hash['awarenessDistance'] : SKIP

  # Create object from extracted values.
  Management.new(action_id,
                 detection_time,
                 reference_time,
                 event_position,
                 station_type,
                 awareness_distance)
end

.namesObject

A mapping from model property names to API property names.



83
84
85
86
87
88
89
90
91
92
# File 'lib/verizon/models/management.rb', line 83

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['action_id'] = 'actionId'
  @_hash['detection_time'] = 'detectionTime'
  @_hash['reference_time'] = 'referenceTime'
  @_hash['event_position'] = 'eventPosition'
  @_hash['awareness_distance'] = 'awarenessDistance'
  @_hash['station_type'] = 'stationType'
  @_hash
end

.nullablesObject

An array for nullable fields



102
103
104
# File 'lib/verizon/models/management.rb', line 102

def self.nullables
  []
end

.optionalsObject

An array for optional fields



95
96
97
98
99
# File 'lib/verizon/models/management.rb', line 95

def self.optionals
  %w[
    awareness_distance
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Management | Hash)

    value against the validation is performed.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/verizon/models/management.rb', line 141

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.action_id,
                            ->(val) { ActionId.validate(val) },
                            is_model_hash: true) and
        APIHelper.valid_type?(value.detection_time,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.reference_time,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.event_position,
                              ->(val) { EventPosition.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.station_type,
                              ->(val) { val.instance_of? Integer })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['actionId'],
                          ->(val) { ActionId.validate(val) },
                          is_model_hash: true) and
      APIHelper.valid_type?(value['detectionTime'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['referenceTime'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['eventPosition'],
                            ->(val) { EventPosition.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['stationType'],
                            ->(val) { val.instance_of? Integer })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



186
187
188
189
190
191
192
# File 'lib/verizon/models/management.rb', line 186

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} action_id: #{@action_id.inspect}, detection_time:"\
  " #{@detection_time.inspect}, reference_time: #{@reference_time.inspect}, event_position:"\
  " #{@event_position.inspect}, awareness_distance: #{@awareness_distance.inspect},"\
  " station_type: #{@station_type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



178
179
180
181
182
183
# File 'lib/verizon/models/management.rb', line 178

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} action_id: #{@action_id}, detection_time: #{@detection_time},"\
  " reference_time: #{@reference_time}, event_position: #{@event_position},"\
  " awareness_distance: #{@awareness_distance}, station_type: #{@station_type}>"
end