Skip to content

Commit 372286b

Browse files
author
Silver Valdvee
committed
Close #353, close #350, close #346
1 parent 77d5621 commit 372286b

8 files changed

Lines changed: 48 additions & 19 deletions

File tree

yukon/domain/avatar.py

Lines changed: 3 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,7 @@ 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(vendor_specific_status_code)
342345
^ hash(self._info.name.tobytes().decode() if self._info is not None else None)
343346
^ hash(self.random_str_for_forced_update) # This accounts for is_disappeared and is_being_queried
344347
^ 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.41"
1+
__version__ = "2023.3.42"

yukon/web/modules/meanings.module.js

Lines changed: 2 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,6 +56,7 @@ 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 });

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,23 @@ async function update_monitor2(containerElement, monitor2Div, yukon_state, force
455455
continue;
456456
}
457457
// Getting info about more links than necessary for later highlighting purposes
458-
const relatedLinks = getRelatedLinks(port.port, yukon_state);
458+
const relatedLinks = getRelatedLinks(port.port, port.type, yukon_state);
459459
const currentLinkObjects = relatedLinks.filter(link => link.port === port.port && link.type === matchingPort.type && link.node_id === avatar.node_id);
460460
function doStuff(currentLinkObject) {
461461
let toggledOn = { value: false };
462462
let currentLinkDsdlDatatype = null;
463463
let fixed_datatype_short = null;
464464
let fixed_datatype_full = null;
465465
if (datatypes_response["fixed_id_messages"] && datatypes_response["fixed_id_messages"][port.port] !== undefined) {
466-
fixed_datatype_short = datatypes_response["fixed_id_messages"][port.port]["short_name"];
467-
fixed_datatype_full = datatypes_response["fixed_id_messages"][port.port]["name"];
466+
const type_of_interest = datatypes_response["fixed_id_messages"][port.port];
467+
console.log(`Type of interest is ${type_of_interest} and is_service is ${type_of_interest.is_service}`);
468+
const is_a_service_and_for_a_service = type_of_interest.is_service && (port.type === "cln" || port.type === "srv");
469+
const is_a_message_and_for_a_message = !type_of_interest.is_service && (port.type === "pub" || port.type === "sub");
470+
console.log(`Port type is ${port.type} and is_a_service_and_for_a_service is ${is_a_service_and_for_a_service} and is_a_message_and_for_a_message is ${is_a_message_and_for_a_message}, port id is ${port.port}`);
471+
if(is_a_service_and_for_a_service || is_a_message_and_for_a_message) {
472+
fixed_datatype_short = datatypes_response["fixed_id_messages"][port.port]["short_name"];
473+
fixed_datatype_full = datatypes_response["fixed_id_messages"][port.port]["name"];
474+
}
468475
}
469476
if (currentLinkObject && !fixed_datatype_full) {
470477
currentLinkDsdlDatatype = currentLinkObject.datatype || "";
@@ -931,8 +938,8 @@ function addHorizontalElements(monitor2Div, matchingPort, currentLinkDsdlDatatyp
931938
horizontal_line_label.style.width = "fit-content"; // settings.LinkInfoWidth - settings.LabelLeftMargin + "px";
932939
horizontal_line_label.style.height = "fit-content";
933940
horizontal_line_label.style.position = "absolute";
934-
if (currentLinkDsdlDatatype.endsWith(".Response")) {
935-
currentLinkDsdlDatatype = currentLinkDsdlDatatype.replace(".Response", "");
941+
if (currentLinkDsdlDatatype.endsWith(".Response") || currentLinkDsdlDatatype.endsWith(".Request")) {
942+
currentLinkDsdlDatatype = currentLinkDsdlDatatype.replace(".Response", "").replace(".Request", "");
936943
}
937944
horizontal_line_label.innerHTML = currentLinkDsdlDatatype;
938945
horizontal_line_label.style.zIndex = "3";
@@ -1126,7 +1133,7 @@ function addVerticalLines(monitor2Div, ports, y_counter, containerElement, setti
11261133
potentialPopup.remove();
11271134
potentialPopup = null;
11281135
} else {
1129-
const datatypes = await getDatatypesForPort(port.port, yukon_state);
1136+
const datatypes = await getDatatypesForPort(port.port, port.type, yukon_state);
11301137
potentialPopup = document.createElement("div");
11311138
potentialPopup.classList.add("popup");
11321139
potentialPopup.style.position = "absolute";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ export async function drawSubscriptions(subscriptionsDiv, settings, yukon_state)
579579
const select = document.createElement("select");
580580
async function updateSelectElements() {
581581
select.innerHTML = "";
582-
const datatypesOfPort = await getDatatypesForPort(subject_id_display.value, yukon_state);
582+
const datatypesOfPort = await getDatatypesForPort(subject_id_display.value, "sub", yukon_state);
583583
for (const datatype of datatypesOfPort) {
584584
const option = document.createElement("option");
585585
option.value = datatype;

yukon/web/modules/utilities.module.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,23 @@ function createPortStructure(yukon_state) {
109109
}
110110
return ports;
111111
}
112-
export async function getDatatypesForPort(portNr, yukon_state) {
112+
export async function getDatatypesForPort(portNr, port_type, yukon_state) {
113113
const chosenDatatypes = {};
114-
const relatedLinks = getRelatedLinks(portNr, yukon_state);
114+
const relatedLinks = getRelatedLinks(portNr, port_type, yukon_state);
115115
//const ports = createPortStructure(yukon_state);
116116
const currentLinkObjects = relatedLinks.filter(link => link.port === portNr && (link.type === "sub" || link.type === "pub"));
117117
let fixed_datatype_short = null;
118118
let fixed_datatype_full = null;
119119
const datatypes_response = await yukon_state.zubax_apij.get_known_datatypes_from_dsdl();
120120
if (datatypes_response && datatypes_response["fixed_id_messages"] && datatypes_response["fixed_id_messages"][portNr] !== undefined) {
121-
fixed_datatype_short = datatypes_response["fixed_id_messages"][portNr]["short_name"];
122-
fixed_datatype_full = datatypes_response["fixed_id_messages"][portNr]["name"];
123-
chosenDatatypes[fixed_datatype_full] = 1;
121+
const fixed_datatype = datatypes_response["fixed_id_messages"][portNr];
122+
const is_a_service_and_for_a_service = fixed_datatype.is_service && (port_type === "cln" || port_type === "srv");
123+
const is_a_message_and_for_a_message = !fixed_datatype.is_service && (port_type === "pub" || port_type === "sub");
124+
if(is_a_service_and_for_a_service || is_a_message_and_for_a_message) {
125+
fixed_datatype_short = datatypes_response["fixed_id_messages"][portNr]["short_name"];
126+
fixed_datatype_full = datatypes_response["fixed_id_messages"][portNr]["name"];
127+
chosenDatatypes[fixed_datatype_full] = 1;
128+
}
124129
}
125130
if (currentLinkObjects.length > 0) {
126131
for (const link of currentLinkObjects) {

yukon/web/style/monitor2.css

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@
145145
border-right-style: solid;
146146
border-top-style: solid;
147147
}
148+
:root {
149+
--line-color: rgb(178, 115, 33);
150+
}
148151

149152
@media (prefers-color-scheme: dark) {
150153
#monitor2 .node {
@@ -153,16 +156,16 @@
153156
}
154157

155158
#monitor2 .line {
156-
background-color: rgb(69, 43, 9);
159+
background-color: var(--line-color);
157160
color: antiquewhite;
158161
}
159162

160163
#monitor2 .circle {
161-
background-color: rgb(69, 43, 9);
164+
background-color: var(--line-color);
162165
}
163166

164167
#monitor2 .horizontal_line {
165-
background-color: rgb(69, 43, 9);
168+
background-color: var(--line-color);
166169
color: antiquewhite;
167170
text-wrap: none;
168171
}
@@ -172,6 +175,6 @@
172175
}
173176

174177
#monitor2>.arrowhead {
175-
border-top-color: rgb(69, 43, 9);
178+
border-top-color: var(--line-color);
176179
}
177180
}

0 commit comments

Comments
 (0)