objects.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # SPDX-License-Identifier: Apache-2.0
  2. # Copyright 2020 Contributors to OpenLEADR
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. from dataclasses import dataclass
  13. from typing import List
  14. from datetime import datetime, timezone, timedelta
  15. @dataclass
  16. class AggregatedPNode:
  17. node: str
  18. @dataclass
  19. class EndDeviceAsset:
  20. mrid: str
  21. @dataclass
  22. class MeterAsset:
  23. mrid: str
  24. @dataclass
  25. class PNode:
  26. node: str
  27. @dataclass
  28. class FeatureCollection:
  29. id: str
  30. location: dict
  31. @dataclass
  32. class ServiceArea:
  33. feature_collection: FeatureCollection
  34. @dataclass
  35. class ServiceDeliveryPoint:
  36. node: str
  37. @dataclass
  38. class ServiceLocation:
  39. node: str
  40. @dataclass
  41. class TransportInterface:
  42. point_of_receipt: str
  43. point_of_delivery: str
  44. @dataclass
  45. class Target:
  46. aggregated_p_node: AggregatedPNode = None
  47. end_device_asset: EndDeviceAsset = None
  48. meter_asset: MeterAsset = None
  49. p_node: PNode = None
  50. service_area: ServiceArea = None
  51. service_delivery_point: ServiceDeliveryPoint = None
  52. service_location: ServiceLocation = None
  53. transport_interface: TransportInterface = None
  54. group_id: str = None
  55. group_name: str = None
  56. resource_id: str = None
  57. ven_id: str = None
  58. party_id: str = None
  59. @dataclass
  60. class EventDescriptor:
  61. event_id: int
  62. modification_number: int
  63. market_context: str
  64. event_status: str
  65. created_date_time: datetime = None
  66. modification_date_time: datetime = None
  67. priority: int = 0
  68. test_event: bool = False
  69. vtn_comment: str = None
  70. def __post_init__(self):
  71. print("Calling Post Init")
  72. if self.modification_date_time is None:
  73. self.modification_date_time = datetime.now(timezone.utc)
  74. if self.created_date_time is None:
  75. self.created_date_time = datetime.now(timezone.utc)
  76. if self.modification_number is None:
  77. self.modification_number = 0
  78. @dataclass
  79. class ActivePeriod:
  80. dtstart: datetime
  81. duration: timedelta
  82. tolerance: dict = None
  83. notification: dict = None
  84. ramp_up: dict = None
  85. recovery: dict = None
  86. @dataclass
  87. class Interval:
  88. dtstart: datetime
  89. duration: timedelta
  90. signal_payload: float
  91. uid: int = None
  92. @dataclass
  93. class EventSignal:
  94. intervals: List[Interval]
  95. signal_name: str
  96. signal_type: str
  97. signal_id: str
  98. current_value: float
  99. targets: List[Target] = None
  100. @dataclass
  101. class Event:
  102. event_descriptor: EventDescriptor
  103. active_period: ActivePeriod
  104. event_signals: EventSignal
  105. targets: List[Target]
  106. @dataclass
  107. class Response:
  108. response_code: int
  109. response_description: str
  110. request_id: str