-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.py
166 lines (126 loc) · 5.46 KB
/
Cell.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import csv
import preferences
# Stores the shape colors corresponding to the english words
COLORS = {
"Beige":(0.6667,0.4902,0.3176),
"Black":(0.0, 0.0, 0.0),
"Translucent (Hidden)":(0.0, 0.0, 0.0),
"Blue":(0.0, 0.0, 1.0),
"Blue / Green (Light)":(0.0, 0.0, 1.0),
"Blue (Light)":(0.0, 0.8, 1.0),
"Blue - Light":(0.0, 0.8, 1.0),
"Blue - Sky":(0.0, 0.8, 1.0),
"Blue (Transparent)":(0.0, 0.8, 1.0),
"Brown":(0.329, 0.188, 0.050),
"Cardboard (Natural)":(0.329, 0.188, 0.050),
"Cyan Blue":(0.0, 0.8, 1.0),
"Cyan / Sky Blue":(0.0, 0.8, 1.0),
"Gray":(0.670, 0.670, 0.670),
"Green":(0.0,1.0,0.4980),
"Green / Apple":(0.0,1.0,0.4980),
"Green / Blue":(0.0,1.0,0.4980),
"Green-Blue":(0.0392,0.3412,0.3725),
"Green-Cyan":(0.0,0.6667,0.5882),
"Green (Light)":(0.0,1.0,0.4980),
"Khaki-Yellow":(0.333, 0.333, 0.0),
"Khaki-Yellow (Erbsensuppe)":(0.333, 0.333, 0.0),
"Mustard":(0.333, 0.333, 0.0),
"Orange":(1.0,0.3333,0.0),
"Peach":(1.0, 0.8, 0.7),
"Pink":(1.0,0.3333,1.0),
"Purple":(0.6667,0.3333,1.0),
"Purple (Light)":(0.6667,0.0,1.0),
"Purple / Maroon":(0.6667,0.0,1.0),
"Purple / Pink":(1.0,0.3333,1.0),
"Slate/Purple":(1.0,0.3333,1.0),
"Red":(1.0, 0.0, 0.0),
"Salmon":(0.776, 0.607, 0.443),
"Teal":(0.0, 0.5, 0.5),
"Turquoise":(0.0,1.0,0.7333),
"White":(1.0, 1.0, 1.0),
"White (translucent)":(1.0, 1.0, 1.0),
"White / Translucent":(1.0, 1.0, 1.0),
"Yellow":(1.0, 1.0, 0.0),
"Yellow - Green (Dirty)":(1.0, 1.0, 0.0),
"Yellow - Green (Light)":(1.0, 1.0, 0.0),
"Maroon":(0.1020,0.0745,0.0471),
}
CURRENCY_SYMBOLS = [
"$",
"€",
"£",
"¥",
"₿"
]
class Cell:
def setup_price_attributes(self, s):
found = False
for sym in CURRENCY_SYMBOLS:
if sym in s:
found = True
s = s.replace(sym, "")
self.currency = sym
if not found:
print("NO CURRENCY SYMBOL FOUND")
s = s.replace(" ", "")
self.price = float(s)
# Construction by the Model number.
# Mainly assigns the values from the .csv and put some default values when needed
def __init__(self, model_number, freecad_dir):
# IDENTIFICATION REF
found = False
with open(freecad_dir+"Mod/battery_pack/identification_ref.csv", newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
if row['Model (Markings)'] == model_number:
found = True
self.brand = row['Brand']
self.model = row['Model (Markings)']
self.capacity = row['Capacity (mAh)']
self.discharge = row['Discharge A (Max)']
self.charging = row['Charging A (Max)']
self.chemistry = row['Chemistry']
self.colorWrap = row['Color (Wrap)']
self.colorRing = row['Color (Ring)']
if (self.colorWrap == None) and (self.colorRing != None):
self.colorWrap = self.colorRing
if (self.colorRing == None) and (self.colorWrap != None):
self.colorRing = self.colorWrap
if self.colorWrap == None:
self.colorWrap = preferences.DEFAULT_CELL_COLOR
if self.colorRing == None:
self.colorRing = preferences.DEFAULT_CELL_COLOR
self.dataSheet = row['Data Sheet']
self.dataSheetBackup = row['Data Sheet (Backup)']
self.web = row['Web']
self.notes = row['Notes']
self.radius = preferences.DEFAULT_CELL_RADIUS
if not found:
print(model_number)
print("ERROR : could not find the matching model number in identification_ref.csv")
# PRICE PERFORMANCE
found = False
with open(freecad_dir+"Mod/battery_pack/price_performance.csv", newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
if row['Model'] == model_number:
found = True
self.setup_price_attributes(row['Price (Euro - nkon.nl)'])
self.weight = float(row['max. Weight in g (Datasheet)'])
self.perf_notes = row['Notes']
if not found:
print(model_number)
print("ERROR : could not find the matching model number in price_performance.csv")
print("Using the same values as for the Samsung INR18650-35E")
self.price = 3.25
self.weight = 50.0
self.perf_notes = "default values"
self.radius = preferences.DEFAULT_CELL_RADIUS
self.height = preferences.DEFAULT_CELL_HEIGHT
def getShapeColor(self):
try:
return COLORS[self.colorWrap]
except KeyError:
return COLORS[preferences.DEFAULT_CELL_COLOR]
def getLineColor(self):
return COLORS[preferences.DEFAULT_CELL_LINE_COLOR]