Skip to content

Commit

Permalink
Two different fixes, one for typing and one for an issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Silver Valdvee committed Nov 22, 2023
1 parent fb8024b commit c8dabdb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion yukon/services/enhanced_json_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
_logger = logging.getLogger(__name__)

# Flask has some broken code around this, making my own
def jsonify(obj: typing.Any):
def jsonify(obj: typing.Any) -> Response:
return Response(json.dumps(obj, cls=EnhancedJSONEncoder), mimetype="application/json")

class EnhancedJSONEncoder(json.JSONEncoder):
Expand Down
6 changes: 6 additions & 0 deletions yukon/web/modules/context-menu.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ export function make_context_menus(yukon_state) {
click: async (e, elementOpenedOn) => {
const portNr = parseInt(elementOpenedOn.getAttribute("data-port"));
const datatypes = await getDatatypesForPort(portNr, "pub", yukon_state);
if(!datatypes[0]) {
console.error(```
Please make sure that registers exist for data type names for publication/subscription/client/server.
https://github.com/OpenCyphal/public_regulated_data_types/blob/935973babe11755d8070e67452b3508b4b6833e2/uavcan/register/384.Access.1.0.dsdl#L154-L162
```);
}
const response = await yukon_state.zubax_apij.make_simple_publisher_with_datatype_and_port_id(datatypes[0], portNr);
const portType = elementOpenedOn.getAttribute("data-port-type"); // sub or pub or cln or srv
if (response && response.success) {
Expand Down
21 changes: 20 additions & 1 deletion yukon/web/modules/panels/monitor2/monitor2.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,16 @@ async function update_monitor2(containerElement, monitor2Div, yukon_state, force
currentLinkDsdlDatatype = currentLinkObject.name + ":" + currentLinkDsdlDatatype;
}
} else {
currentLinkDsdlDatatype = fixed_datatype_full || "There is no info about this link";
currentLinkDsdlDatatype = fixed_datatype_full;
}
if(currentLinkDsdlDatatype) {
currentLinkDsdlDatatype = fixed_datatype_full;
} else {
// Handling a special case where the developer of a Cyphal node hasn't got registers set up for data type names
// https://github.com/OpenCyphal/public_regulated_data_types/blob/935973babe11755d8070e67452b3508b4b6833e2/uavcan/register/384.Access.1.0.dsdl#L154-L162
// https://forum.opencyphal.org/t/developing-pico-node-using-yukon/1978
// addHorizontalElements is going to give this a message and also make it clickable and hinted so that the link can be had from the label.
currentLinkDsdlDatatype = null;
}
let isLast = false;
// If this is the last iteration of the loop, set a variable to true
Expand Down Expand Up @@ -989,6 +998,16 @@ function addHorizontalElements(monitor2Div, matchingPort, currentLinkDsdlDatatyp
if (currentLinkDsdlDatatype.endsWith(".Response") || currentLinkDsdlDatatype.endsWith(".Request")) {
currentLinkDsdlDatatype = currentLinkDsdlDatatype.replace(".Response", "").replace(".Request", "");
}
if(!currentLinkDsdlDatatype) {
horizontal_line_label.addEventListener("mousedown", () => {
console.error(```
Please make sure that registers exist for data type names for publication/subscription/client/server.
https://github.com/OpenCyphal/public_regulated_data_types/blob/935973babe11755d8070e67452b3508b4b6833e2/uavcan/register/384.Access.1.0.dsdl#L154-L162
```);
});
horizontal_line_label.title = "Click for more information in console."
currentLinkDsdlDatatype = "Missing data type name registers.";
}
horizontal_line_label.innerHTML = currentLinkDsdlDatatype;
horizontal_line_label.style.zIndex = "3";
// horizontal_line_label.style.backgroundColor = settings["LinkLabelColor"];
Expand Down

0 comments on commit c8dabdb

Please sign in to comment.