|
@@ -1,5 +1,5 @@
|
|
|
// // ******************************************************************
|
|
|
-// // /\ /| @File USBDecodeModel.cpp
|
|
|
+// // /\ /| @File USBDecode.cpp
|
|
|
// // \ V/ @Brief
|
|
|
// // | "") @Author lijinwen, ghz005@uni-trend.com.cn
|
|
|
// // / | @Creation 2024-1-4
|
|
@@ -7,11 +7,11 @@
|
|
|
// // *(__\_\
|
|
|
// // ******************************************************************
|
|
|
|
|
|
-#include "USBDecodeModel.h"
|
|
|
+#include "USBDecode.h"
|
|
|
|
|
|
namespace Protocol
|
|
|
{
|
|
|
- double USBDecodeModel::GetBitRateByPs() const
|
|
|
+ double USBDecode::GetBitRateByPs() const
|
|
|
{
|
|
|
double result = 1.0;
|
|
|
switch (signalRate)
|
|
@@ -30,42 +30,42 @@ namespace Protocol
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- std::vector<std::string> USBDecodeModel::EventInfoTitles() const
|
|
|
+ std::vector<std::string> USBDecode::EventInfoTitles() const
|
|
|
{
|
|
|
return {"Index", "Start Time", "Sync", "PID", "Data", "Addr", "FNUM", "CRC5", "CRC16", "EOP", "Error"};
|
|
|
}
|
|
|
|
|
|
- Enums::SignalRate USBDecodeModel::SignalRate() const
|
|
|
+ Enums::SignalRate USBDecode::SignalRate() const
|
|
|
{
|
|
|
return signalRate;
|
|
|
}
|
|
|
|
|
|
- void USBDecodeModel::SetSignalRate(Enums::SignalRate value)
|
|
|
+ void USBDecode::SetSignalRate(Enums::SignalRate value)
|
|
|
{
|
|
|
signalRate = value;
|
|
|
}
|
|
|
|
|
|
- uint16_t USBDecodeModel::ByteCount() const
|
|
|
+ uint16_t USBDecode::ByteCount() const
|
|
|
{
|
|
|
return byteCount;
|
|
|
}
|
|
|
|
|
|
- void USBDecodeModel::SetByteCount(uint16_t value)
|
|
|
+ void USBDecode::SetByteCount(uint16_t value)
|
|
|
{
|
|
|
byteCount = value;
|
|
|
}
|
|
|
|
|
|
- uint16_t USBDecodeModel::MaxByteCount()
|
|
|
+ uint16_t USBDecode::MaxByteCount()
|
|
|
{
|
|
|
return 1023;
|
|
|
}
|
|
|
|
|
|
- uint16_t USBDecodeModel::MinByteCount()
|
|
|
+ uint16_t USBDecode::MinByteCount()
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- bool USBDecodeModel::ParseData(std::vector<Protocol::TwoLevelEdgePulse> edgePluses,
|
|
|
+ bool USBDecode::ParseData(std::vector<Protocol::TwoLevelEdgePulse> edgePluses,
|
|
|
std::promise<void>& cancellationSignal)
|
|
|
{
|
|
|
if (edgePluses.empty()) return false;
|
|
@@ -97,7 +97,7 @@ namespace Protocol
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- bool USBDecodeModel::CheckDifferenceWithinThreshold(double* array, int32_t size, double threshold)
|
|
|
+ bool USBDecode::CheckDifferenceWithinThreshold(double* array, int32_t size, double threshold)
|
|
|
{
|
|
|
//threshold = 0.15;
|
|
|
for (int i = 1; i < size; i++)
|
|
@@ -117,7 +117,7 @@ namespace Protocol
|
|
|
return true; // 所有元素之间的差异都小于阈值
|
|
|
}
|
|
|
|
|
|
- void USBDecodeModel::ClearEdgeArray(Protocol::Edge* edges, int32_t size)
|
|
|
+ void USBDecode::ClearEdgeArray(Protocol::Edge* edges, int32_t size)
|
|
|
{
|
|
|
for (int i = 0; i < size; ++i)
|
|
|
{
|
|
@@ -125,12 +125,12 @@ namespace Protocol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- bool USBDecodeModel::CheckSyncEdges(Protocol::Edge startEdge, Protocol::Edge* edges)
|
|
|
+ bool USBDecode::CheckSyncEdges(Protocol::Edge startEdge, Protocol::Edge* edges)
|
|
|
{
|
|
|
return edges[0] == edges[1] && edges[0] == startEdge && edges[0] == edges[6];
|
|
|
}
|
|
|
|
|
|
- bool USBDecodeModel::CheckSyncSpans(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize
|
|
|
+ bool USBDecode::CheckSyncSpans(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize
|
|
|
, const int32_t count, int32_t& avgSpans)
|
|
|
{
|
|
|
if (count < 1)
|
|
@@ -156,7 +156,7 @@ namespace Protocol
|
|
|
return CheckSyncSpansByArrary(startIndexs, count, avgSpans);
|
|
|
}
|
|
|
|
|
|
- bool USBDecodeModel::CheckSyncSpansByArrary(int32_t* startIndexs, const int32_t count,
|
|
|
+ bool USBDecode::CheckSyncSpansByArrary(int32_t* startIndexs, const int32_t count,
|
|
|
int32_t& avgSpans)
|
|
|
{
|
|
|
if (count < 1)
|
|
@@ -177,7 +177,7 @@ namespace Protocol
|
|
|
return CheckDifferenceWithinThreshold(tmpSpans, count - 1);
|
|
|
}
|
|
|
|
|
|
- bool USBDecodeModel::FindAllSyncs(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize,
|
|
|
+ bool USBDecode::FindAllSyncs(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize,
|
|
|
std::vector<SYNC>& allSYNC, std::promise<void>& cancellationSignal,
|
|
|
bool polarity)
|
|
|
{
|
|
@@ -263,7 +263,7 @@ namespace Protocol
|
|
|
return !allSYNC.empty();
|
|
|
}
|
|
|
|
|
|
- bool USBDecodeModel::FindPackets(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize,
|
|
|
+ bool USBDecode::FindPackets(Protocol::TwoLevelEdgePulse* node, int32_t& leftOverSize,
|
|
|
std::vector<USBPacket>& allPacket, std::promise<void>& cancellationSignal,
|
|
|
bool polarity)
|
|
|
{
|