mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-07-01 21:25:11 +00:00
update parser (#5)
This commit is contained in:
@@ -40,14 +40,24 @@ namespace asc
|
||||
enum class EState {header, body, footer} eState = EState::header;
|
||||
while (std::getline(fstream, ssLine))
|
||||
{
|
||||
// Compare two characters and two strings case insensitive
|
||||
auto ichar_equals = [](char a, char b)
|
||||
{
|
||||
return std::tolower(static_cast<unsigned char>(a)) == std::tolower(static_cast<unsigned char>(b));
|
||||
};
|
||||
auto iequals = [&](const std::string& a, const std::string& b)
|
||||
{
|
||||
return std::equal(a.begin(), a.end(), b.begin(), b.end(), ichar_equals);
|
||||
};
|
||||
|
||||
switch (eState)
|
||||
{
|
||||
case EState::header:
|
||||
if (ssLine.compare(0, 18, "Begin TriggerBlock") == 0)
|
||||
if (iequals(ssLine.substr(0, 18), "Begin TriggerBlock"))
|
||||
eState = EState::body;
|
||||
break;
|
||||
case EState::body:
|
||||
if (ssLine.compare(0, 16, "End TriggerBlock") == 0)
|
||||
if (iequals(ssLine.substr(0, 16), "End TriggerBlock"))
|
||||
eState = EState::footer;
|
||||
else
|
||||
ProcessSample(ssLine);
|
||||
@@ -74,7 +84,7 @@ namespace asc
|
||||
|
||||
uint32_t CAscReader::GetMessageCount() const
|
||||
{
|
||||
return m_lstMessages.size();
|
||||
return static_cast<uint32_t>(m_lstMessages.size());
|
||||
}
|
||||
|
||||
uint32_t CAscReader::GetLoopCount() const
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <functional>
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
namespace asc
|
||||
{
|
||||
@@ -159,8 +160,8 @@ namespace asc
|
||||
std::list<SCanMessage> m_lstMessages; ///< Vector with messages
|
||||
std::list<SCanMessage>::iterator m_itCurrent; ///< Current iterator position
|
||||
std::thread m_threadPlayback; ///< Playback thread.
|
||||
bool m_bPlaybackThread = false; ///< Set when running playback thread
|
||||
bool m_bPlayback = false; ///< Set when running playback
|
||||
std::atomic_bool m_bPlaybackThread = false; ///< Set when running playback thread
|
||||
std::atomic_bool m_bPlayback = false; ///< Set when running playback
|
||||
std::atomic<uint32_t> m_uiLoopCount{ 0 }; ///< Counter how often the data set was sent
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user