-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
Actually I never wrote a parser, so I don't know if it is performant or not ... |
Reason, in a previous commit a second message was added
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.
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.
include/libdbc/message.hpp
Outdated
@@ -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; |
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.
I don't like the reference here since that ties it to the lifetime of the object now.
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.
Good point, I can change this
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.
@LinuxDevon I updated this
std::vector<libdbc::Signal::SignalValueDescriptions> vd; | ||
}; | ||
|
||
bool parseVal(const std::string& str, VALObject& obj) { |
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.
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.
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.
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
std::vector<VALObject> sv; | ||
|
||
VALObject obj; |
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.
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.
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.
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; |
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 do we continue here?
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.
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); |
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.
I see now that this is done through a function on the message. I see why it is done this way now I think.
@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. |
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.
@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.
Reason: It can be used to give the signal states for its values