Code cleanup
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user