-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
112 lines (91 loc) · 4.83 KB
/
main.py
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
import json
from RouteEstimator.BaseTypes.Contracts.ApplicationBase import Application
from RouteEstimator.BaseTypes.Handlers.DispatcherBase import Dispatcher
from RouteEstimator.Implementations.E3Objects.DeviceComponent import Device
from RouteEstimator.Implementations.E3Objects.JobComponent import Job
from RouteEstimator.BaseTypes.Handlers.RefereceManager import ReferenceContainer, E3InteropReferences
from RouteEstimator.Implementations.E3Objects.PinComponent import Pin
from RouteEstimator.EstimatorAlgorithm.Implementation import Estimator
import importlib.resources as res
def GetDistanceInformation(deviceList: list[Device]) -> list:
results = []
for device in deviceList:
device_count = device.pinCount
# appHndl.RaiseMessage(f"--------------------------")
# appHndl.RaiseMessage(f"- Nome do Dispositivo - [{device.name}]")
# appHndl.RaiseMessage(f"- Contagem de pinos: {device_count}")
# appHndl.RaiseMessage(f"- Distâncias entre conexões:\n")
for pin in device.pins:
destination_count, destination_ids = pin.GetPinDestinationIds()
if destination_ids is None or destination_count is 0:
continue
for destination in destination_ids:
if destination is not None:
pp = Pin(destination)
cartesian_distance = pin.DistanceTo(pp)
destination_device = Device.Create(destination)
# appHndl.RaiseMessage(
# f"- [{device.name} -> {destination_device.name}] - [{pin.pId}] <-> {destination}]\n"
# f" - x: [{cartesian_distance.xPos / 100}]\n"
# f" - y: [{cartesian_distance.yPos / 100}]\n"
# f" - z: [{cartesian_distance.zPos / 100}]\n"
# f" - Euclidiana : [{pin.physicalPosition[1].coordinates.EuclideanDistance(pp.physicalPosition[1].coordinates) / 100}]\n")
fetch = \
{
"main-device-name": device.name,
"main-device-ref": device,
"main-device-id": device.id,
"pin": {pin.pId},
"device-pin-destinations":
{
destination:
{
"device-ref": destination_device,
"device-name": destination_device.name,
"destination-id": destination,
"distance-to-parent":
{
"absolute":
{
"x-position": cartesian_distance.xPos / 100,
"y-position": cartesian_distance.yPos / 100,
"z-position": cartesian_distance.zPos / 100,
},
"euclidean": pin.physicalPosition[1].coordinates.EuclideanDistance(pp.physicalPosition[1].coordinates) / 100
},
}
}
}
results.append(fetch)
#
#
# appHndl.RaiseMessage(f"\n")
return results
def ParseAttributeInformation(formatted:list):
for device in formatted:
pass
if __name__ == "__main__":
# Just for tests if some action needs to be performed on a class
# like a functional script this container refs can be injected through inject decorator
container = ReferenceContainer()
container.wire(modules=[__name__], packages=[
"RouteEstimator.BaseTypes",
"RouteEstimator.Implementations",
])
#Initializing Estimator Algorithm
# stm = Estimator()
# Just in case that has a separate python package to wire as dependency to inject
jobHandl: Job = container.currentJob()
appHndl: Application = container.application()
dispatchHndl: Dispatcher = container.dispatcher()
e3DtoHndl: E3InteropReferences = container.interop()
#gathering devices information for all project
current_selected_devices = jobHandl.allDevices
#fetching initial information about placed connections and distances
fetch_information = GetDistanceInformation(current_selected_devices)
#recurse fetch data finding desired attributes
with open("RouteEstimator/Resources/ATT_CONFIG.json") as cfg:
content = json.load(cfg)
for device in fetch_information:
p = device["main-device-ref"]
print('q')