Skip to content

Commit 56a1b4e

Browse files
author
Silver Valdvee
committed
Merge branch 'main' of github.com:OpenCyphal/yukon
# Conflicts: # yukon/version.py
2 parents a0133d5 + 6f54490 commit 56a1b4e

13 files changed

Lines changed: 198 additions & 57 deletions

yukon/domain/avatar.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ def to_builtin(self) -> Any:
272272
software_version = getattr(info, "software_version")
273273
hardware_version = getattr(info, "hardware_version")
274274
software_vcs_revision_id = getattr(info, "software_vcs_revision_id")
275+
if software_vcs_revision_id:
276+
software_vcs_revision_id = hex(software_vcs_revision_id)
275277
software_major_version = getattr(software_version, "major", 0)
276278
software_minor_version = getattr(getattr(info, "software_version"), "minor", 0)
277279
hardware_major_version = getattr(hardware_version, "major", 0)
@@ -339,6 +341,16 @@ def to_builtin(self) -> Any:
339341
^ hash(frozenset(self._ports.sub))
340342
^ hash(frozenset(self._ports.cln))
341343
^ hash(frozenset(self._ports.srv))
344+
^ hash(
345+
json.dumps(
346+
{
347+
"vendor_specific_status_code": vendor_specific_status_code,
348+
"mode": mode_value,
349+
"health": health_value,
350+
},
351+
sort_keys=True,
352+
)
353+
)
342354
^ hash(self._info.name.tobytes().decode() if self._info is not None else None)
343355
^ hash(self.random_str_for_forced_update) # This accounts for is_disappeared and is_being_queried
344356
^ hash(self.disappeared_since)

yukon/services/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Datatype:
5252
is_fixed_id: bool
5353
name: str
5454
class_reference: typing.Any
55+
is_service: bool
5556

5657
def __hash__(self) -> int:
5758
return hash(self.name)
@@ -115,6 +116,7 @@ def scan_package_look_for_classes(
115116
break
116117
counter += 1
117118
module_or_class, previous_module_or_class = queue.get_nowait()
119+
is_potentially_a_service = False
118120
# Get all modules and classes that are seen in the imported module
119121
elements = inspect.getmembers(module_or_class, lambda x: inspect.ismodule(x) or inspect.isclass(x))
120122
for element in elements:
@@ -133,7 +135,13 @@ def scan_package_look_for_classes(
133135
except Exception:
134136
logger.exception("Failed to get model for %s", _class)
135137
continue
136-
classes.append(Datatype(hasattr(_class, "_FIXED_PORT_ID_"), model.full_name, _class))
138+
if _class.__name__ == "Request" or _class.__name__ == "Response":
139+
is_potentially_a_service = True
140+
classes.append(
141+
Datatype(
142+
hasattr(_class, "_FIXED_PORT_ID_"), model.full_name, _class, is_service=is_potentially_a_service
143+
)
144+
)
137145
except Empty:
138146
pass
139147
# logger.debug(f"Loop {loop_unique_id} took {time.time() - loop_start} seconds")
@@ -152,12 +160,14 @@ def get_datatype_return_dto(all_classes: typing.List[Datatype]) -> typing.Any:
152160
return_object["fixed_id_messages"][str(datatype.class_reference._FIXED_PORT_ID_)] = {
153161
"short_name": datatype.class_reference.__name__,
154162
"name": datatype.name,
163+
"is_service": datatype.is_service,
155164
}
156165
else:
157166
return_object["variable_id_messages"].append(
158167
{
159168
"short_name": datatype.class_reference.__name__,
160169
"name": datatype.name,
170+
"is_service": datatype.is_service,
161171
}
162172
)
163173
except Exception as e:

yukon/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2023.3.42"
1+
__version__ = "2023.3.44"

yukon/web/modules/context-menu.module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ export function make_context_menus(yukon_state) {
562562
},
563563
click: async (e, elementOpenedOn) => {
564564
const portNr = parseInt(elementOpenedOn.getAttribute("data-port"));
565-
const datatypes = await getDatatypesForPort(portNr, yukon_state);
565+
const datatypes = await getDatatypesForPort(portNr, "pub", yukon_state);
566566
const response = await yukon_state.zubax_apij.make_simple_publisher_with_datatype_and_port_id(datatypes[0], portNr);
567567
const portType = elementOpenedOn.getAttribute("data-port-type"); // sub or pub or cln or srv
568568
if (response && response.success) {

yukon/web/modules/meanings.module.js

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function getLinkInfo(subject_id, node_id, yukon_state) {
4242
}
4343
return Array.from(new Set(infos));
4444
}
45-
export function getRelatedLinks(port, yukon_state) {
45+
export function getRelatedLinks(port, port_type, yukon_state) {
4646
let links = [];
4747
for (const avatar of yukon_state.current_avatars) {
4848
const registersKeys = Object.keys(avatar.registers_values);
@@ -56,11 +56,62 @@ export function getRelatedLinks(port, yukon_state) {
5656
const link_name = results[2];
5757
const value = avatar.registers_values[register_name];
5858
if (parseInt(value) === parseInt(port) && register_name.endsWith(".id")) {
59+
if((port_type === "pub" || port_type === "sub") && (link_type === "cln" || link_type === "srv")) continue;
5960
const datatype_key = registersKeys.find((a) => a.endsWith(link_name + ".type"));
6061
const datatype = avatar.registers_values[datatype_key];
6162
links.push({ name: link_name, node_id: avatar.node_id, "port": port, type: link_type, "register_name": register_name, "datatype": datatype });
6263
}
6364
}
6465
}
6566
return Array.from(new Set(links));
67+
}
68+
export function decodeTelegaVSSC(vssc) {
69+
const high_number = vssc / 16;
70+
const low_number = vssc % 16;
71+
if (low_number !== 0) {
72+
if(high_number === 0) {
73+
return "Fault in Standby, fault code: " + low_number;
74+
} else if (high_number == 1) {
75+
// self test
76+
return "Fault in Self test, fault code: " + low_number;
77+
} else if (high_number == 2) {
78+
return "Fault in Motor ID, fault code: " + low_number;
79+
} else if (high_number == 5) {
80+
// drive
81+
if(low_number === 1) {
82+
return "Torque control mode";
83+
} else if(low_number === 2) {
84+
return "Voltage control mode";
85+
} else if(low_number === 3) {
86+
return "Velocity control mode";
87+
} else if(low_number === 9) {
88+
// Ratiometric torque control mode
89+
return "Ratiometric torque control mode";
90+
} else if (low_number === 10) {
91+
// Ratiometric voltage control mode
92+
return "Ratiometric voltage control mode";
93+
} else {
94+
return "Fault in Drive, fault code: " + low_number;
95+
}
96+
} else if (high_number == 7) {
97+
// servo
98+
return "Fault in Servo, fault code: " + low_number;
99+
}
100+
} else {
101+
if (high_number === 0) {
102+
return "Standby";
103+
} else if (high_number == 1) {
104+
// self test
105+
return "Self test";
106+
} else if (high_number == 2) {
107+
return "Motor ID";
108+
} else if (high_number == 5) {
109+
// drive
110+
return "Drive";
111+
} else if (high_number == 7) {
112+
// servo
113+
return "Servo";
114+
}
115+
}
116+
return "Unknown code";
66117
}

yukon/web/modules/panels/monitor2/highlights.module.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ export function setPortStateAsUnhiglighted(portNr, yukon_state) {
3838
}
3939
export function highlightElement(element, color, settings, yukon_state) {
4040
if (element.classList.contains("arrowhead")) {
41-
element.style.setProperty("border-top-color", color);
41+
element.style.setProperty("border-top-color", color, "important");
4242
} else if (element.classList.contains("horizontal_line_label") && element.tagName === "LABEL") {
43-
element.style.setProperty("background-color", settings.LinkLabelHighlightColor);
44-
element.style.setProperty("color", settings.LinkLabelHighlightTextColor);
43+
element.style.setProperty("background-color", settings.LinkLabelHighlightColor, "important");
44+
element.style.setProperty("color", settings.LinkLabelHighlightTextColor, "important");
4545
} else if (element.classList.contains("horizontal_line") || element.classList.contains("line") || element.classList.contains("circle")) {
46-
element.style.setProperty("background-color", color);
46+
element.style.setProperty("background-color", color, "important");
4747
}
4848
}
4949
export function highlightElements(objects, settings, yukon_state) {

0 commit comments

Comments
 (0)