Compare commits
1
Commits
4d8b07fc68
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f5f86452f |
+18
-1
@@ -904,11 +904,28 @@ async function requestIpsymconApi(source, payload) {
|
||||
}
|
||||
}
|
||||
|
||||
function getIpsymconLinkedName(variable, variableId) {
|
||||
const sources = Array.isArray(variable?.sources) ? variable.sources : [];
|
||||
for (const source of sources) {
|
||||
const links = Array.isArray(source?.link_chain) ? source.link_chain : [];
|
||||
for (const link of [...links].reverse()) {
|
||||
if (Number(link?.target_id) === variableId) {
|
||||
const linkName = normalizeText(link?.name);
|
||||
if (linkName) return linkName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function mapIpsymconVariable(source, variable, categoryId, index) {
|
||||
const variableId = Number(variable?.id);
|
||||
const variableType = normalizeText(variable?.variable_type || variable?.type || "");
|
||||
const kind = variableType === "boolean" || typeof variable?.value === "boolean" ? "digital" : "analog";
|
||||
const name = normalizeText(variable?.full_name || variable?.name || `Variable ${variableId}`) || `Variable ${variableId}`;
|
||||
// A named variable link is the operator-facing label and takes precedence over its target's name.
|
||||
const name = getIpsymconLinkedName(variable, variableId)
|
||||
|| normalizeText(variable?.full_name || variable?.name || `Variable ${variableId}`)
|
||||
|| `Variable ${variableId}`;
|
||||
return {
|
||||
id: `${source.id}::ipsymcon::${variableId}`,
|
||||
protocol: "ipsymcon",
|
||||
|
||||
Reference in New Issue
Block a user