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.
17 from dataclasses import dataclass
18 from typing import List
19 from model.python.hexagon import Hex
21 class SpiralRadiusProfile:
22 def __init__(self, data=None):
23 self._oRanSmoSpiralRadiusOfNearRtRics = data.get("oRanSmoSpiralRadiusOfNearRtRics", 1) if data else 1
24 self._oRanNearRtRicSpiralRadiusOfOCus = data.get("oRanNearRtRicSpiralRadiusOfOCus", 1) if data else 1
25 self._oRanCuSpiralRadiusOfODus = data.get("oRanCuSpiralRadiusOfODus", 1) if data else 1
26 self._oRanDuSpiralRadiusOfTowers = data.get("oRanDuSpiralRadiusOfTowers", 1) if data else 1
30 return f"{self._oRanDuSpiralRadiusOfTowers}{self._oRanCuSpiralRadiusOfODus}{self._oRanNearRtRicSpiralRadiusOfOCus}{self._oRanSmoSpiralRadiusOfNearRtRics}"
39 for ru in range(self._oRanDuSpiralRadiusOfTowers + 1):
40 towers = towers + 6 * ru
42 for du in range(self._oRanCuSpiralRadiusOfODus + 1):
45 for cu in range(self._oRanNearRtRicSpiralRadiusOfOCus + 1):
48 for ric in range(self._oRanSmoSpiralRadiusOfNearRtRics + 1):
51 return towers * dus * cus * rics
54 def oRanSmoSpiralRadiusOfNearRtRics(self):
55 return self._oRanSmoSpiralRadiusOfNearRtRics
57 @oRanSmoSpiralRadiusOfNearRtRics.setter
58 def oRanSmoSpiralRadiusOfNearRtRics(self, value):
59 self._oRanSmoSpiralRadiusOfNearRtRics = value
62 def oRanNearRtRicSpiralRadiusOfOCus(self):
63 return self._oRanNearRtRicSpiralRadiusOfOCus
65 @oRanNearRtRicSpiralRadiusOfOCus.setter
66 def oRanNearRtRicSpiralRadiusOfOCus(self, value):
67 self._oRanNearRtRicSpiralRadiusOfOCus = value
70 def oRanCuSpiralRadiusOfODus(self):
71 return self._oRanCuSpiralRadiusOfODus
73 @oRanCuSpiralRadiusOfODus.setter
74 def oRanCuSpiralRadiusOfODus(self, value):
75 self._oRanCuSpiralRadiusOfODus = value
78 def oRanDuSpiralRadiusOfTowers(self):
79 return self._oRanDuSpiralRadiusOfTowers
81 @oRanDuSpiralRadiusOfTowers.setter
82 def oRanDuSpiralRadiusOfTowers(self, value):
83 self._oRanDuSpiralRadiusOfTowers = value
90 def sectors(self, value):
94 def nrDuCellsPerSector(self):
95 return self._nrDuCellsPerSector
97 @nrDuCellsPerSector.setter
98 def nrDuCellsPerSector(self, value):
99 self._nrDuCellsPerSector = value
101 def oRanDuDirections(self):
102 q = 2 * self._oRanDuSpiralRadiusOfTowers + 1
103 r = - self._oRanDuSpiralRadiusOfTowers - 1
106 Hex(q, r, s), Hex(-s, -q, -r), Hex(r, s, q),
107 Hex(-q, -r, -s), Hex(s, q, r), Hex(-r, -s, -q)
110 def oRanDuNeighbor(self, cube, direction):
111 return Hex.add(cube, self.oRanDuDirections[direction])
113 def oRanDuRing(self, center, radius):
115 raise ValueError('Invalid radius. The radius around the hex center must be greater than 0 rings.')
117 hex = Hex.add(center, Hex.scale(self.oRanDuDirections[4], radius))
119 for j in range(radius):
121 hex = self.oRanDuNeighbor(hex, i)
124 def oRanDuSpiral(self, center, radius):
126 for k in range(1, radius + 1):
127 result.extend(self.oRanDuRing(center, k))
130 def oRanCuDirections(self):
131 q0 = 2 * self._oRanCuSpiralRadiusOfODus + 3 * self._oRanCuSpiralRadiusOfODus * self._oRanDuSpiralRadiusOfTowers + self._oRanDuSpiralRadiusOfTowers + 1
132 r0 = self._oRanDuSpiralRadiusOfTowers - self._oRanCuSpiralRadiusOfODus
133 q = 3 * q0 - self._oRanNearRtRicSpiralRadiusOfOCus
134 r = -r0 - self._oRanNearRtRicSpiralRadiusOfOCus
135 switch_id = self.id[2:-1]
136 if switch_id in ("111", "112", "113", "114"):