Class: TestPack1::StatusItem
- 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
-
#acknowledged ⇒ Boolean
Indicates whether the status has been acknowledged.
-
#category ⇒ StatusCategoryEnum
The category a status belongs to.
-
#category_contract ⇒ Object
The status category as defined the availability contract assigned to the site.
-
#category_iec ⇒ String
The status category as defined by the IEC.
-
#code ⇒ Float
The status code.
-
#comment ⇒ String
A user comment associated with the status.
-
#device_id ⇒ Integer
The id of the device affected by the status.
-
#has_timestamp_end ⇒ Boolean
Indicates whether the status has a duration.
-
#lost_production ⇒ Float
The lost production in kWh associated with the status.
-
#message ⇒ String
A description of the status code.
-
#sub_status ⇒ List of StatusItem
Statuses of the same type that have been grouped under this status.
-
#timestamp_end ⇒ DateTime
The timestamp when the status ended.
-
#timestamp_start ⇒ DateTime
The timestamp when the status began.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#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
constructor
A new instance of StatusItem.
Methods inherited from BaseModel
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, = nil, = nil, = nil, category = nil, code = nil, = nil, comment = nil, lost_production = nil, category_iec = nil, category_contract = nil, sub_status = nil, acknowledged = nil) @device_id = device_id = = = @category = category @code = code = @comment = comment @lost_production = lost_production @category_iec = category_iec @category_contract = category_contract @sub_status = sub_status @acknowledged = acknowledged end |
Instance Attribute Details
#acknowledged ⇒ Boolean
Indicates whether the status has been acknowledged.
68 69 70 |
# File 'lib/test_pack_1/models/status_item.rb', line 68 def acknowledged @acknowledged end |
#category ⇒ StatusCategoryEnum
The category a status belongs to.
32 33 34 |
# File 'lib/test_pack_1/models/status_item.rb', line 32 def category @category end |
#category_contract ⇒ Object
The status category as defined the availability contract assigned to the site.
60 61 62 |
# File 'lib/test_pack_1/models/status_item.rb', line 60 def category_contract @category_contract end |
#category_iec ⇒ String
The status category as defined by the IEC.
55 56 57 |
# File 'lib/test_pack_1/models/status_item.rb', line 55 def category_iec @category_iec end |
#code ⇒ Float
The status code.
36 37 38 |
# File 'lib/test_pack_1/models/status_item.rb', line 36 def code @code end |
#comment ⇒ String
A user comment associated with the status.
44 45 46 |
# File 'lib/test_pack_1/models/status_item.rb', line 44 def comment @comment end |
#device_id ⇒ Integer
The id of the device affected by the status.
14 15 16 |
# File 'lib/test_pack_1/models/status_item.rb', line 14 def device_id @device_id end |
#has_timestamp_end ⇒ Boolean
Indicates whether the status has a duration.
28 29 30 |
# File 'lib/test_pack_1/models/status_item.rb', line 28 def end |
#lost_production ⇒ Float
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).
51 52 53 |
# File 'lib/test_pack_1/models/status_item.rb', line 51 def lost_production @lost_production end |
#message ⇒ String
A description of the status code.
40 41 42 |
# File 'lib/test_pack_1/models/status_item.rb', line 40 def end |
#sub_status ⇒ List of StatusItem
Statuses of the same type that have been grouped under this status.
64 65 66 |
# File 'lib/test_pack_1/models/status_item.rb', line 64 def sub_status @sub_status end |
#timestamp_end ⇒ DateTime
The timestamp when the status ended. The timestamp is in your system-configured time zone without UTC offset.
24 25 26 |
# File 'lib/test_pack_1/models/status_item.rb', line 24 def end |
#timestamp_start ⇒ DateTime
The timestamp when the status began. The timestamp is in your system-configured time zone without UTC offset.
19 20 21 |
# File 'lib/test_pack_1/models/status_item.rb', line 19 def 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'] = APIHelper.rfc3339(hash['timestampStart']) if hash['timestampStart'] = APIHelper.rfc3339(hash['timestampEnd']) if hash['timestampEnd'] = hash['hasTimestampEnd'] category = hash['category'] code = hash['code'] = 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, , , , category, code, , comment, lost_production, category_iec, category_contract, sub_status, acknowledged) end |
.names ⇒ Object
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 |