-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute can load #13
base: master
Are you sure you want to change the base?
Compute can load #13
Conversation
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.59%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
@@ -53,6 +54,10 @@ def __init__(self, msg: str, id: int, description: str): | |||
|
|||
self.bytes = [None] * 8 | |||
|
|||
self.frequency = frequency | |||
|
|||
self.frame_length = 47 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 47? Can you add a comment pointing to a source or explaining it.
return len(list(filter(lambda x: x is not None, self.bytes))) | ||
|
||
def get_frame_length(self): | ||
return 44 + 8 * self.get_length() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 44 and 8? Can you add a comment pointing to a source or explaining it.
loads = can.get_can_load_by_topic() | ||
ids = list(loads.keys()) | ||
ids.sort() | ||
for id in ids: | ||
print("Id: ", id, "load:", loads[id]) | ||
print("Total load:", round(can.get_can_load(),3), "%") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extract out these lines into a helper function?
modules = [] | ||
signature = [] | ||
ids = [] | ||
names = [] | ||
frequency = [] | ||
load = [] | ||
frame_length = [] | ||
description = [] | ||
|
||
for module in self.modules: | ||
for topic in module["topics"]: | ||
modules.append(module["name"]) | ||
signature.append(module["signature"]) | ||
ids.append(topic["id"]) | ||
names.append(topic["name"]) | ||
frequency.append(round(topic["frequency"],3)) | ||
load.append(round(self.get_topic_load(topic),3)) | ||
frame_length.append(topic["frame_length"]) | ||
description.append(topic["description"]) | ||
|
||
df = pd.DataFrame({ | ||
"modules":modules, | ||
"signature": signature, | ||
"name": names, | ||
"ids": ids, | ||
"frequency": frequency, | ||
"load": load, | ||
"frame_length": frame_length, | ||
"description": description, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this data is small it is okay doing it this way, but note that for bigger data, possibly it would be better convert it to a DataFrame first, then group / add / remove columns as you need.
# load = period for 1 msg * frequency * 100% | ||
# Reference: | ||
# https://support.vector.com/kb?id=kb_article_view&sysparm_article=KB0012332&sys_kb_id=99354e281b2614148e9a535c2e4bcb6d&spa=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always great to have references, move it on the beginning of the function
Compute bus load with the size of the frame, message frequency, and bit rate
And implement figures to better analyzes