Compare commits

...
1 Commits
+18 -1
View File
@@ -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) { function mapIpsymconVariable(source, variable, categoryId, index) {
const variableId = Number(variable?.id); const variableId = Number(variable?.id);
const variableType = normalizeText(variable?.variable_type || variable?.type || ""); const variableType = normalizeText(variable?.variable_type || variable?.type || "");
const kind = variableType === "boolean" || typeof variable?.value === "boolean" ? "digital" : "analog"; 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 { return {
id: `${source.id}::ipsymcon::${variableId}`, id: `${source.id}::ipsymcon::${variableId}`,
protocol: "ipsymcon", protocol: "ipsymcon",