MCPcopy Create free account
hub / github.com/comaps/comaps / AggregateChargeSocketKey

Method AggregateChargeSocketKey

libs/indexer/feature_charge_sockets.cpp:121–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121void ChargeSocketsHelper::AggregateChargeSocketKey(std::string const & k, std::string const & v)
122{
123 auto keys = strings::Tokenize(k, ":");
124 ASSERT(keys[0] == "socket", ()); // key must start with "socket:"
125 if (keys.size() < 2 || keys.size() > 3)
126 {
127 LOG(LWARNING, ("Invalid socket key:", k));
128 return;
129 }
130
131 std::string type(keys[1]);
132
133 bool isOutput = false;
134 if (keys.size() == 3)
135 {
136 if (keys[2] == "output")
137 isOutput = true;
138 else
139 return; // ignore other suffixes
140 }
141
142 // normalize type
143 static ankerl::unordered_dense::map<std::string_view, std::string_view> const kTypeMap = {
144 {"tesla_supercharger", "nacs"},
145 {"tesla_destination", "nacs"},
146 {"tesla_standard", "nacs"},
147 {"tesla", "nacs"},
148 {"tesla_supercharger_ccs", "type2_combo"},
149 {"ccs", "type2_combo"},
150 {"type1_cable", "type1"},
151 };
152
153 auto itMap = kTypeMap.find(type);
154 if (itMap != kTypeMap.end())
155 type = itMap->second;
156
157 if (std::find(SUPPORTED_TYPES.begin(), SUPPORTED_TYPES.end(), type) == SUPPORTED_TYPES.end())
158 type = UNKNOWN;
159
160 // Tokenize counts or powers
161 auto tokens = strings::Tokenize(v, ";");
162 if (tokens.empty())
163 return;
164
165 if (!isOutput)
166 {
167 // Parse counts
168 std::vector<unsigned int> counts;
169 for (auto & t : tokens)
170 {
171 strings::Trim(t);
172 if (t.empty())
173 continue;
174
175 if (t == "yes")
176 counts.push_back(0);
177 else
178 {

Callers 3

operator()Method · 0.80
ApplyJournalEntryMethod · 0.80
FromKVsFunction · 0.80

Calls 13

ASSERTFunction · 0.85
findFunction · 0.85
TrimFunction · 0.85
MakeLowerCaseFunction · 0.85
backMethod · 0.80
TokenizeFunction · 0.50
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by 1

FromKVsFunction · 0.64