1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 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 116 117 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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
use crate::traits::{
SEIdentifiedObject, SEList, SEMeterReadingBase, SEReadingSetBase, SEResource, SEUsagePointBase,
Validate,
};
use sep2_common_derive::{
SEIdentifiedObject, SEList, SEMeterReadingBase, SEReadingSetBase, SEResource, SEUsagePointBase,
};
use yaserde::{YaDeserialize, YaSerialize};
use super::{
metering::{Reading, ReadingType},
primitives::{HexBinary160, Int48, String32, Uint32},
types::{
ConsumptionBlockType, DateTimeInterval, MRIDType, QualityFlags, RoleFlagsType, ServiceKind,
TOUType, TimeType, UsagePointStatus, VersionType,
},
};
#[derive(
Default,
PartialEq,
PartialOrd,
Eq,
Ord,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SEMeterReadingBase,
SEIdentifiedObject,
SEResource,
)]
#[yaserde(rename = "MirrorMeterReading")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct MirrorMeterReading {
/// The date and time of the last update.
#[yaserde(rename = "lastUpdateTime")]
pub last_update_time: Option<TimeType>,
#[yaserde(rename = "MirrorReadingSet")]
pub mirror_reading_set: Vec<MirrorReadingSet>,
/// The date and time of the next planned update.
#[yaserde(rename = "nextUpdateTime")]
pub next_update_time: Option<TimeType>,
#[yaserde(rename = "Reading")]
pub reading: Option<Reading>,
#[yaserde(rename = "ReadingType")]
pub reading_type: Option<ReadingType>,
/// The global identifier of the object.
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
/// The description is a human readable text describing or naming the object.
#[yaserde(rename = "description")]
pub description: Option<String32>,
/// Contains the version number of the object. See the type definition for
/// details.
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for MirrorMeterReading {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEList, SEResource)]
#[yaserde(rename = "MirrorMeterReadingList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct MirrorMeterReadingList {
#[yaserde(rename = "MirrorMeterReading")]
pub mirror_meter_reading: Vec<MirrorMeterReading>,
/// The number specifying "all" of the items in the list. Required on a
/// response to a GET, ignored otherwise.
#[yaserde(attribute, rename = "all")]
pub all: Uint32,
/// Indicates the number of items in this page of results.
#[yaserde(attribute, rename = "results")]
pub results: Uint32,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for MirrorMeterReadingList {}
#[derive(
Default,
PartialEq,
Eq,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SEIdentifiedObject,
SEResource,
SEMeterReadingBase,
)]
#[yaserde(rename = "MeterReadingBase")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct MeterReadingBase {
/// The global identifier of the object.
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
/// The description is a human readable text describing or naming the object.
#[yaserde(rename = "description")]
pub description: Option<String32>,
/// Contains the version number of the object. See the type definition for
/// details.
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for MeterReadingBase {}
#[derive(
Default,
PartialEq,
PartialOrd,
Eq,
Ord,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SEReadingSetBase,
SEIdentifiedObject,
SEResource,
)]
#[yaserde(rename = "MirrorReadingSet")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct MirrorReadingSet {
#[yaserde(rename = "Reading")]
pub reading: Vec<Reading>,
/// Specifies the time range during which the contained readings were taken.
#[yaserde(rename = "timePeriod")]
pub time_period: DateTimeInterval,
/// The global identifier of the object.
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
/// The description is a human readable text describing or naming the object.
#[yaserde(rename = "description")]
pub description: Option<String32>,
/// Contains the version number of the object. See the type definition for
/// details.
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for MirrorReadingSet {}
#[derive(
Default,
PartialEq,
Eq,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SEUsagePointBase,
SEIdentifiedObject,
SEResource,
)]
#[yaserde(rename = "MirrorUsagePoint")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct MirrorUsagePoint {
/// The LFDI of the device being mirrored.
#[yaserde(rename = "deviceLFDI")]
pub device_lfdi: HexBinary160,
#[yaserde(rename = "MirrorMeterReading")]
pub mirror_meter_reading: Vec<MirrorMeterReading>,
/// POST rate, or how often mirrored data should be POSTed, in seconds. A
/// client MAY indicate a preferred postRate when POSTing MirrorUsagePoint. A
/// server MAY add or modify postRate to indicate its preferred posting rate.
#[yaserde(rename = "postRate")]
pub post_rate: Option<Uint32>,
/// Specifies the roles that apply to the usage point.
#[yaserde(rename = "roleFlags")]
pub role_flags: RoleFlagsType,
/// The kind of service provided by this usage point.
#[yaserde(rename = "serviceCategoryKind")]
pub service_category_kind: ServiceKind,
/// Specifies the current status of the service at this usage point.
/// 0 = off
/// 1 = on
#[yaserde(rename = "status")]
pub status: UsagePointStatus,
/// The global identifier of the object.
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
/// The description is a human readable text describing or naming the object.
#[yaserde(rename = "description")]
pub description: Option<String32>,
/// Contains the version number of the object. See the type definition for
/// details.
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl MirrorUsagePoint {
pub fn add_reading(&mut self, reading: MirrorMeterReading) {
self.mirror_meter_reading.push(reading);
self.mirror_meter_reading.sort();
}
}
impl PartialOrd for MirrorUsagePoint {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for MirrorUsagePoint {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
// Primary Key - mRID (descending)
self.mrid.cmp(&other.mrid).reverse()
}
}
impl Validate for MirrorUsagePoint {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEList, SEResource)]
#[yaserde(rename = "MirrorUsagePointList")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct MirrorUsagePointList {
#[yaserde(rename = "MirrorUsagePoint")]
pub mirror_usage_point: Vec<MirrorUsagePoint>,
/// The default polling rate for this function set (this resource and all
/// resources below), in seconds. If not specified, a default of 900 seconds
/// (15 minutes) is used. It is RECOMMENDED a client poll the resources of
/// this function set every pollRate seconds.
#[yaserde(attribute, rename = "pollRate")]
pub poll_rate: Option<Uint32>,
/// The number specifying "all" of the items in the list. Required on a
/// response to a GET, ignored otherwise.
#[yaserde(attribute, rename = "all")]
pub all: Uint32,
/// Indicates the number of items in this page of results.
#[yaserde(attribute, rename = "results")]
pub results: Uint32,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for MirrorUsagePointList {}
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEResource)]
#[yaserde(rename = "ReadingBase")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct ReadingBase {
/// Indicates the consumption block related to the reading. REQUIRED if
/// ReadingType numberOfConsumptionBlocks is non-zero. If not specified, is
/// assumed to be "0 - N/A".
#[yaserde(rename = "consumptionBlock")]
pub consumption_block: Option<ConsumptionBlockType>,
/// List of codes indicating the quality of the reading, using specification:
/// Bit 0 - valid: data that has gone through all required validation checks
/// and either passed them all or has been verified
/// Bit 1 - manually edited: Replaced or approved by a human
/// Bit 2 - estimated using reference day: data value was replaced by a
/// machine computed value based on analysis of historical data using the
/// same type of measurement.
/// Bit 3 - estimated using linear interpolation: data value was computed
/// using linear interpolation based on the readings before and after it
/// Bit 4 - questionable: data that has failed one or more checks
/// Bit 5 - derived: data that has been calculated (using logic or
/// mathematical operations), not necessarily measured directly
/// Bit 6 - projected (forecast): data that has been calculated as a
/// projection or forecast of future readings
#[yaserde(rename = "qualityFlags")]
pub quality_flags: Option<QualityFlags>,
/// The time interval associated with the reading. If not specified, then
/// defaults to the intervalLength specified in the associated ReadingType.
#[yaserde(rename = "timePeriod")]
pub time_period: Option<DateTimeInterval>,
/// Indicates the time of use tier related to the reading. REQUIRED if
/// ReadingType numberOfTouTiers is non-zero. If not specified, is assumed to
/// be "0 - N/A".
#[yaserde(rename = "touTier")]
pub tou_tier: Option<TOUType>,
/// Value in units specified by ReadingType
#[yaserde(rename = "value")]
pub value: Option<Int48>,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for ReadingBase {}
#[derive(
Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEIdentifiedObject, SEResource,
)]
#[yaserde(rename = "ReadingSetBase")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct ReadingSetBase {
/// Specifies the time range during which the contained readings were taken.
#[yaserde(rename = "timePeriod")]
pub time_period: DateTimeInterval,
/// The global identifier of the object.
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
/// The description is a human readable text describing or naming the object.
#[yaserde(rename = "description")]
pub description: Option<String32>,
/// Contains the version number of the object. See the type definition for
/// details.
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for ReadingSetBase {}
#[derive(
Default,
PartialEq,
Eq,
Debug,
Clone,
YaSerialize,
YaDeserialize,
SEIdentifiedObject,
SEResource,
SEUsagePointBase,
)]
#[yaserde(rename = "UsagePointBase")]
#[yaserde(namespace = "urn:ieee:std:2030.5:ns")]
pub struct UsagePointBase {
/// Specifies the roles that apply to the usage point.
#[yaserde(rename = "roleFlags")]
pub role_flags: RoleFlagsType,
/// The kind of service provided by this usage point.
#[yaserde(rename = "serviceCategoryKind")]
pub service_category_kind: ServiceKind,
/// Specifies the current status of the service at this usage point.
/// 0 = off
/// 1 = on
#[yaserde(rename = "status")]
pub status: UsagePointStatus,
/// The global identifier of the object.
#[yaserde(rename = "mRID")]
pub mrid: MRIDType,
/// The description is a human readable text describing or naming the object.
#[yaserde(rename = "description")]
pub description: Option<String32>,
/// Contains the version number of the object. See the type definition for
/// details.
#[yaserde(rename = "version")]
pub version: Option<VersionType>,
/// A reference to the resource address (URI). Required in a response to a
/// GET, ignored otherwise.
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
impl Validate for UsagePointBase {}