Fix(slac): slac inline enum declaration#1898
Conversation
b27d42f to
73a2a88
Compare
|
|
||
| void slacImpl::ready() { | ||
| publish_state(state_to_string(state)); | ||
| publish_state(types::slac::string_to_state(state_to_string(state))); |
There was a problem hiding this comment.
Converting forth and back again to string look complicated. Maybe we should get rid of the utils/state.{c,hpp} in SlacSimulator completely now that we have a nice type?
There was a problem hiding this comment.
hmm yea you'r right, i'll take a look at this
There was a problem hiding this comment.
It is better now ?
4f4c3cc to
2594854
Compare
SebaLukas
left a comment
There was a problem hiding this comment.
Looking good 👍
See my comments
| void set_slac_state(const std::string& slac_state) { | ||
| sim_data.slac_state = slac_state; | ||
| } |
There was a problem hiding this comment.
Why did you change std::move to a const ref?
There was a problem hiding this comment.
I saw that the function was not modifying slac_state so i added const ref.
And from what i understand its not logical to move a const value.
If you think it was better before i can change it back :p
There was a problem hiding this comment.
In the previous function defintion it was not a const ref.
So I think move a std::string with std::move is valid. So please revert it back 👍
There was a problem hiding this comment.
I put the old definition back as it was. But about std::move im not sure how to do it.
Now that im catching a throw, i need slac_state in EVLOG_error and at this time, it might be empty with an std::move.
| } | ||
|
|
||
| void set_slac_state(types::slac::State slac_state) { | ||
| sim_data.slac_state = types::slac::state_to_string(slac_state); |
There was a problem hiding this comment.
If we have now this nice types::slac::State type, then it should be used as well in the EvManager and not a std::string.
There was a problem hiding this comment.
Yup you'r right gonna do that shortly
There was a problem hiding this comment.
Should be good now
| callbacks.signal_dlink_ready = [this](bool value) { publish_dlink_ready(value); }; | ||
|
|
||
| callbacks.signal_state = [this](const std::string& value) { publish_state(value); }; | ||
| callbacks.signal_state = [this](const std::string& value) { publish_state(types::slac::string_to_state(value)); }; |
There was a problem hiding this comment.
My only problem with using string_to_state() that catching an exception is not handled here. As well in EvSlac module.
There was a problem hiding this comment.
I didn't thought of that, now im catching it.
I just have a question here :
try {
publish_state(types::slac::string_to_state(value));
} catch (const std::exception& e) {
EVLOG_error << fmt::format("Tried to publish unknown SLAC state '{}'. Error: {}", value, e.what());
publish_dlink_ready(false);
}
Should i keep publishing dlink false ? I guess it should never happen but just to be sure
2594854 to
830958f
Compare
4afb301 to
99fe7e7
Compare
cburandt
left a comment
There was a problem hiding this comment.
The code in wrapper.[hc]pp looks almost fine. The exception message texts where sort of mixed up, but that was my bad, since the example I pointed you at, had the same confusion. If you apply my suggestions below, this will be fixed.
lib/everest/everest_api_types/src/everest_api_types/slac/wrapper.cpp
Outdated
Show resolved
Hide resolved
lib/everest/everest_api_types/src/everest_api_types/slac/wrapper.cpp
Outdated
Show resolved
Hide resolved
Added types/slac.yaml to fix EVerest#1323 - The SLAC interface uses the unsupported inline enum declaration Updated everything to work with the new types. Signed-off-by: ThatsLucas <lucasmailpro9@gmail.com>
99fe7e7 to
f3fb931
Compare
|
Do i have to do something about Codacy ? |
These checks? No, you cannot fix those, and they do not block the PR (unlike other failing checks). |
|
ok great |
Added types/slac.yaml to fix #1323 - The SLAC interface uses the unsupported inline enum declaration
Updated everything to work with the new types.
Describe your changes
Issue ticket number and link
#1323
Checklist before requesting a review