//计算超限率 int Formamendweight::OverWeightRate(int nTotalWeight,int nAxisNum) { int nWeightLimit; int nOverweightRate; const int nMaxOverweightRate=9999; // NOTE: 编辑计重信息时手工输入限载,此时计算费率的限载不应根据轴数查找 nWeightLimit=getWeightLimit(nAxisNum)/1000; if (nTotalWeight > nWeightLimit) { quint32 nOverweight; nOverweight=nTotalWeight-nWeightLimit; nOverweightRate=round_int32((double)1000*nOverweight/nWeightLimit); } else { nOverweightRate=0; } if (nOverweightRate>nMaxOverweightRate) { nOverweightRate=nMaxOverweightRate; } LogMsg("Weight",tr("超限率:nOverweightRate=1%,nOverweight=%2").arg(nOverweightRate).arg(nOverweightRate)); return nOverweightRate; }
void TDD_VerifyRoundSigned(void) { temp32 = 15349; round_int32(&temp32, 0); check32(temp32, 15350); temp32 = 15346; round_int32(&temp32, 0); check32(temp32, 15350); temp32 = 15345; round_int32(&temp32, 0); check32(temp32, 15350); temp32 = 15344; round_int32(&temp32, 0); check32(temp32, 15340); temp32 = 15341; round_int32(&temp32, 0); check32(temp32, 15340); temp32 = 15340; round_int32(&temp32, 0); check32(temp32, 15340); temp32 = 15349; round_int32(&temp32, 1); check32(temp32, 15300); temp32 = 15350; round_int32(&temp32, 1); check32(temp32, 15400); temp32 = 15351; round_int32(&temp32, 1); check32(temp32, 15400); temp32 = 00001; round_int32(&temp32, 1); check32(temp32, 00000); temp32 = 15501; round_int32(&temp32, 2); check32(temp32, 16000); temp32 = 15499; round_int32(&temp32, 2); check32(temp32, 15000); temp32 = 15999; round_int32(&temp32, 2); check32(temp32, 16000); temp32 = 15123; round_int32(&temp32, 2); check32(temp32, 15000); temp32 = 00001; round_int32(&temp32, 2); check32(temp32, 00000); //------------------------------------// temp32 = -15349; round_int32(&temp32, 0); check32(temp32, -15350); temp32 = -15346; round_int32(&temp32, 0); check32(temp32, -15350); temp32 = -15345; round_int32(&temp32, 0); check32(temp32, -15350); temp32 = -15344; round_int32(&temp32, 0); check32(temp32, -15340); temp32 = -15341; round_int32(&temp32, 0); check32(temp32, -15340); temp32 = -15340; round_int32(&temp32, 0); check32(temp32, -15340); temp32 = -15349; round_int32(&temp32, 1); check32(temp32, -15300); temp32 = -15350; round_int32(&temp32, 1); check32(temp32, -15400); temp32 = -15351; round_int32(&temp32, 1); check32(temp32, -15400); temp32 = -00001; round_int32(&temp32, 1); check32(temp32, 0); temp32 = -15501; round_int32(&temp32, 2); check32(temp32, -16000); temp32 = -15499; round_int32(&temp32, 2); check32(temp32, -15000); temp32 = -15999; round_int32(&temp32, 2); check32(temp32, -16000); temp32 = -15123; round_int32(&temp32, 2); check32(temp32, -15000); temp32 = -00001; round_int32(&temp32, 2); check32(temp32, 0); }