Class: TestPack1::StatusItem

Inherits:
BaseModel show all
Defined in:
lib/test_pack_1/models/status_item.rb

Overview

A status that may contain statuses of the same type as sub-statuses. Note that for sub-statuses the fields ‘categoryIec`, `categoryContract`, and `subStatus` will always be null.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(device_id = nil, timestamp_start = nil, timestamp_end = nil, has_timestamp_end = nil, category = nil, code = nil, message = nil, comment = nil, lost_production = nil, category_iec = nil, category_contract = nil, sub_status = nil, acknowledged = nil) ⇒ StatusItem

Returns a new instance of StatusItem.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/test_pack_1/models/status_item.rb', line 89

def initialize(device_id = nil,
               timestamp_start = nil,
               timestamp_end = nil,
               has_timestamp_end = nil,
               category = nil,
               code = nil,
               message = nil,
               comment = nil,
               lost_production = nil,
               category_iec = nil,
               category_contract = nil,
               sub_status = nil,
               acknowledged = nil)
  @device_id = device_id
  @timestamp_start = timestamp_start
  @timestamp_end = timestamp_end
  @has_timestamp_end = has_timestamp_end
  @category = category
  @code = code
  @message = message
  @comment = comment
  @lost_production = lost_production
  @category_iec = category_iec
  @category_contract = category_contract
  @sub_status = sub_status
  @acknowledged = acknowledged
end

Instance Attribute Details

#acknowledgedBoolean

Indicates whether the status has been acknowledged.

Returns:

  • (Boolean)


68
69
70
# File 'lib/test_pack_1/models/status_item.rb', line 68

def acknowledged
  @acknowledged
end

#categoryStatusCategoryEnum

The category a status belongs to.

Returns:



32
33
34
# File 'lib/test_pack_1/models/status_item.rb', line 32

def category
  @category
end

#category_contractObject

The status category as defined the availability contract assigned to the site.

Returns:

  • (Object)


60
61
62
# File 'lib/test_pack_1/models/status_item.rb', line 60

def category_contract
  @category_contract
end

#category_iecString

The status category as defined by the IEC.

Returns:



55
56
57
# File 'lib/test_pack_1/models/status_item.rb', line 55

def category_iec
  @category_iec
end

#codeFloat

The status code.

Returns:

  • (Float)


36
37
38
# File 'lib/test_pack_1/models/status_item.rb', line 36

def code
  @code
end

#commentString

A user comment associated with the status.

Returns:



44
45
46
# File 'lib/test_pack_1/models/status_item.rb', line 44

def comment
  @comment
end

#device_idInteger

The id of the device affected by the status.

Returns:

  • (Integer)


14
15
16
# File 'lib/test_pack_1/models/status_item.rb', line 14

def device_id
  @device_id
end

#has_timestamp_endBoolean

Indicates whether the status has a duration.

Returns:

  • (Boolean)


28
29
30
# File 'lib/test_pack_1/models/status_item.rb', line 28

def has_timestamp_end
  @has_timestamp_end
end

#lost_productionFloat

The lost production in kWh associated with the status. This field will be null if the caller is not authorized for the system-configured lost production signal. The configured lost production signal is available via the ‘/configuration.json` endpoint (`DataSignalConfiguration` schema).

Returns:

  • (Float)


51
52
53
# File 'lib/test_pack_1/models/status_item.rb', line 51

def lost_production
  @lost_production
end

#messageString

A description of the status code.

Returns:



40
41
42
# File 'lib/test_pack_1/models/status_item.rb', line 40

def message
  @message
end

#sub_statusList of StatusItem

Statuses of the same type that have been grouped under this status.

Returns:



64
65
66
# File 'lib/test_pack_1/models/status_item.rb', line 64

def sub_status
  @sub_status
end

#timestamp_endDateTime

The timestamp when the status ended. The timestamp is in your system-configured time zone without UTC offset.

Returns:

  • (DateTime)


24
25
26
# File 'lib/test_pack_1/models/status_item.rb', line 24

def timestamp_end
  @timestamp_end
end

#timestamp_startDateTime

The timestamp when the status began. The timestamp is in your system-configured time zone without UTC offset.

Returns:

  • (DateTime)


19
20
21
# File 'lib/test_pack_1/models/status_item.rb', line 19

def timestamp_start
  @timestamp_start
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/test_pack_1/models/status_item.rb', line 118

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  device_id = hash['deviceId']
  timestamp_start = APIHelper.rfc3339(hash['timestampStart']) if
    hash['timestampStart']
  timestamp_end = APIHelper.rfc3339(hash['timestampEnd']) if
    hash['timestampEnd']
  has_timestamp_end = hash['hasTimestampEnd']
  category = hash['category']
  code = hash['code']
  message = hash['message']
  comment = hash['comment']
  lost_production = hash['lostProduction']
  category_iec = hash['categoryIec']
  category_contract = hash['categoryContract']
  # Parameter is an array, so we need to iterate through it

  sub_status = nil
  unless hash['subStatus'].nil?
    sub_status = []
    hash['subStatus'].each do |structure|
      sub_status << (StatusItem.from_hash(structure) if structure)
    end
  end
  acknowledged = hash['acknowledged']

  # Create object from extracted values.

  StatusItem.new(device_id,
                 timestamp_start,
                 timestamp_end,
                 has_timestamp_end,
                 category,
                 code,
                 message,
                 comment,
                 lost_production,
                 category_iec,
                 category_contract,
                 sub_status,
                 acknowledged)
end

.namesObject

A mapping from model property names to API property names.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/test_pack_1/models/status_item.rb', line 71

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['device_id'] = 'deviceId'
  @_hash['timestamp_start'] = 'timestampStart'
  @_hash['timestamp_end'] = 'timestampEnd'
  @_hash['has_timestamp_end'] = 'hasTimestampEnd'
  @_hash['category'] = 'category'
  @_hash['code'] = 'code'
  @_hash['message'] = 'message'
  @_hash['comment'] = 'comment'
  @_hash['lost_production'] = 'lostProduction'
  @_hash['category_iec'] = 'categoryIec'
  @_hash['category_contract'] = 'categoryContract'
  @_hash['sub_status'] = 'subStatus'
  @_hash['acknowledged'] = 'acknowledged'
  @_hash
end