Code cleanup

This commit is contained in:
2023-01-28 09:01:02 -05:00
parent eeb1d04f9b
commit 74b6a23045
24 changed files with 1548 additions and 1442 deletions
+41
View File
@@ -0,0 +1,41 @@
#include "CANSignal.h"
#include "defines.h"
CCANSignal::CCANSignal()
{
mEncoding = CAN_SIGNAL_ENCODING_INVALID;
}
int CCANSignal::ComputeNewSignalValue(quint64 NewValue, quint16 MessageSize)
{
if(mEncoding == CAN_SIGNAL_ENCODING_INTEL)
{
//TODO: trouver un device qui crache du intel??
mRawValue = NewValue;
}
else if(mEncoding == CAN_SIGNAL_ENCODING_MOTOROLA)
{
//mRawValue = MotorolaValue;
mRawValue = NewValue;
int StartIndex = mStartBit - (mStartBit % 8) + 7 - (mStartBit % 8);
int shift = ((MessageSize * 8) - StartIndex -1);
mRawValue >>= shift;
quint64 mask = 1;
mask <<= mSignalSize;
mask -= 1;
mRawValue &= mask;
}
else
{
//TODO: À faire!!!
return RET_GENERAL_ERROR;
}
mPhysicalValue = ((signed) mRawValue * mValueFactor) + mValueOffset;
return RET_OK;
}