1 # Copyright 2023 highstreet technologies GmbH
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
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 An abstract Class for all classes
21 from abc import ABC, abstractmethod
22 from typing import Any
23 from model.python.type_definitions import (
32 from model.python.geo_location import GeoLocation
35 # Define the ITop interface
41 administrativeState: AdministrativeState = None,
42 operationalState: OperationalState = None,
43 lifeCycleState: LifeCycleState = None,
44 alarmState: AlarmState = None,
45 usageState: UsageState = None,
46 utilization: Utilization = None,
50 self.administrativeState = administrativeState
51 self.operationalState = operationalState
52 self.lifeCycleState = lifeCycleState
53 self.alarmState = alarmState
54 self.usageState = usageState
55 self.utilization = utilization
58 # Define the Top class
60 def __init__(self, data: [dict[str, Any] | None] = None):
61 self._id = data.id if data and data.id else str(uuid.uuid4())
63 data.name if data and data.name else " ".join(["Name", "of", self._id])
65 self._administrativeState = (
66 data.administrativeState
67 if data and data.administrativeState
68 else AdministrativeState.LOCKED
70 self._operationalState = (
72 if data and data.operationalState
73 else OperationalState.DISABLED
75 self._lifeCycleState = (
77 if data and data.lifeCycleState
78 else LifeCycleState.PLANNED
80 self._alarmState = data.alarmState if data and data.alarmState else 0
82 data.usageState if data and data.usageState else UsageState.UNUSED
84 self._utilization = data.utilization if data and data.utilization else 0
91 def id(self, value: str):
95 def name(self) -> str:
99 def name(self, value: str):
103 def administrativeState(self) -> AdministrativeState:
104 return self._administrativeState
106 @administrativeState.setter
107 def administrativeState(self, value: AdministrativeState):
108 self._administrativeState = value
111 def operationalState(self) -> OperationalState:
112 return self._operationalState
114 @operationalState.setter
115 def operationalState(self, value: OperationalState):
116 self._operationalState = value
119 def lifeCycleState(self) -> LifeCycleState:
120 return self._lifeCycleState
122 @lifeCycleState.setter
123 def lifeCycleState(self, value: LifeCycleState):
124 self._lifeCycleState = value
127 def alarmState(self) -> AlarmState:
128 return self._alarmState
131 def alarmState(self, value: AlarmState):
132 self._alarmState = value
135 def usageState(self) -> UsageState:
136 return self._usageState
139 def usageState(self, value: UsageState):
140 self._usageState = value
143 def utilization(self) -> Utilization:
144 return self._utilization
147 def utilization(self, value: Utilization):
148 self._utilization = value
150 def json(self) -> dict[str, Any]:
154 "administrativeState": self.administrativeState.value,
155 "operationalState": self.operationalState.value,
156 "lifeCycleState": self.lifeCycleState.value,
157 "alarmState": self.alarmState,
158 "usageState": self.usageState.value,
159 "utilization": self.utilization,
162 def __str__(self) -> str:
163 return str(self.json())