Skip to content

parse VAL_ attribute #14

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

Merged
merged 6 commits into from
Jul 27, 2023
Merged

parse VAL_ attribute #14

merged 6 commits into from
Jul 27, 2023

Conversation

Murmele
Copy link
Contributor

@Murmele Murmele commented Feb 9, 2023

Reason: It can be used to give the signal states for its values

@Murmele
Copy link
Contributor Author

Murmele commented Feb 9, 2023

Actually I never wrote a parser, so I don't know if it is performant or not ...

@Murmele
Copy link
Contributor Author

Murmele commented Apr 13, 2023

@LinuxDevon

Copy link
Owner

@LinuxDevon LinuxDevon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Letf a few comments @Murmele. I apologize for the delay. I have been pretty busy and not motivated to maintain this repo lately. I appreciate the effort here!
I am trying to get some automation in here and refactor the repo some. I am not too happy with the current structure since it was the first stab at learning on some of these ideas.

@@ -29,8 +29,9 @@ struct Message {
ParseSignalsStatus parseSignals(const std::vector<uint8_t>& data, std::vector<double>& values) const;

void appendSignal(const Signal& signal);
const std::vector<Signal> signals() const;
const std::vector<Signal>& getSignals() const;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the reference here since that ties it to the lifetime of the object now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I can change this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LinuxDevon I updated this

std::vector<libdbc::Signal::SignalValueDescriptions> vd;
};

bool parseVal(const std::string& str, VALObject& obj) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a member on the class of signal not external imo. External classes shouldn't know of these details just that they get the members after. Also not a huge fan of how long this function is. Perhaps split this up into some sub functions?

I am trying to follow what is going on and having a bit of a hard time. I will take another look again when I get a chance here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think so, because this is related parsing the val object. It does the same thing like the regular expression, but in a different way because of the unknown numbers of value labels available. Therefore regex is not possible here

Comment on lines +240 to +242
std::vector<VALObject> sv;

VALObject obj;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This come back to the comment before that the message shouldn't be parsing this. Maybe the val should be found first then passed to the signal to find the ones it needs? I guess I need to think about this some and maybe the function being a member on the signal isn't the right choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was first parsing the dbc file and then assigning the val object to the signal

@@ -133,6 +250,7 @@ void DbcParser::parse_dbc_messages(const std::vector<std::string>& lines) {
Message msg(id, name, size, node);

messages.push_back(msg);
continue;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we continue here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the regex matches a message is found and therefore it is not needed to check the others, because they will never match. So I can go directly to the next line

for (const auto& obj : sv) {
for (auto& msg : messages) {
if (msg.id() == obj.can_id) {
msg.addValueDescription(obj.signal_name, obj.vd);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that this is done through a function on the message. I see why it is done this way now I think.

@Murmele
Copy link
Contributor Author

Murmele commented Apr 26, 2023

@LinuxDevon thank you for thre review! I will work on your comments. Currently in Labplot we are using my patched version, but if we get my stuff in I can switch to upstream. I know it is a big work to maintain a project if a lot will change. On my side I don't have much more work on this library, so I think those are the last MR from my side.

@Murmele Murmele requested a review from LinuxDevon July 18, 2023 08:29
Copy link
Owner

@LinuxDevon LinuxDevon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Murmele sorry for the delay. Not sure if all the points were addressed but going to approve this and come back later to clean up. I will work on a release of this. The interface might change a bit in the future.

@LinuxDevon LinuxDevon merged commit a3b941a into LinuxDevon:master Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants