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 Optional, Dict, Union
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=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
81 data.alarmState if data and data.alarmState else 0
84 data.usageState if data and data.usageState else UsageState.UNUSED
87 data.utilization if data and data.utilization else 0
103 def name(self, value):
107 def administrativeState(self):
108 return self._administrativeState
110 @administrativeState.setter
111 def administrativeState(self, value):
112 self._administrativeState = value
115 def operationalState(self):
116 return self._operationalState
118 @operationalState.setter
119 def operationalState(self, value):
120 self._operationalState = value
123 def lifeCycleState(self):
124 return self._lifeCycleState
126 @lifeCycleState.setter
127 def lifeCycleState(self, value):
128 self._lifeCycleState = value
131 def alarmState(self):
132 return self._alarmState
135 def alarmState(self, value):
136 self._alarmState = value
139 def usageState(self):
140 return self._usageState
143 def usageState(self, value):
144 self._usageState = value
147 def utilization(self):
148 return self._utilization
151 def utilization(self, value):
152 self._utilization = value
158 "administrativeState": self.administrativeState.value,
159 "operationalState": self.operationalState.value,
160 "lifeCycleState": self.lifeCycleState.value,
161 "alarmState": self.alarmState,
162 "usageState": self.usageState.value,
163 "utilization": self.utilization,
167 return str(self.json())