MST线性值计算器_V1.3.exe
MST模拟量线性计算工具,个人制作。 BYTE usrNonLinearCalculate(NonLinearCurveType NoLinear,BYTE AdjustValue) { //dual direction BYTE rValue,ucXVStart,ucXVEnd,ucXStar,ucXEnd,ucStartPoint; WORD wDistance; BYTE temData = AdjustValue; if (AdjustValue < NON_LINEAR_POINT_X1) { ucXVStart = NoLinear.X0; ucXVEnd = NoLinear.X1; ucXStar = NON_LINEAR_POINT_X0; ucXEnd = NON_LINEAR_POINT_X1; } else if (AdjustValue < NON_LINEAR_POINT_X2) { ucXVStart = NoLinear.X1 ; ucXVEnd = NoLinear.X2; ucXStar = NON_LINEAR_POINT_X1; ucXEnd = NON_LINEAR_POINT_X2; } else if (AdjustValue < NON_LINEAR_POINT_X3) { ucXVStart = NoLinear.X2; ucXVEnd = NoLinear.X3; ucXStar = NON_LINEAR_POINT_X2; ucXEnd = NON_LINEAR_POINT_X3; } else { ucXVStart = NoLinear.X3; ucXVEnd = NoLinear.X4; ucXStar = NON_LINEAR_POINT_X3; ucXEnd = NON_LINEAR_POINT_X4; } if (ucXVEnd > ucXVStart) { wDistance = ucXVEnd - ucXVStart; ucStartPoint = ucXVStart; temData = AdjustValue - ucXStar; } else { wDistance = ucXVStart - ucXVEnd; ucStartPoint = ucXVEnd; temData = ucXEnd - AdjustValue; } rValue = ((WORD)wDistance*temData/(ucXEnd - ucXStar)) + ucStartPoint; return rValue; } ; ucXVEnd = NoLinear.X2; ucXStar = NON_LINEAR_POINT_X1; ucXEnd = NON_LINEAR_POINT_X2; } else if (AdjustValue < NON_LINEAR_POINT_X3) { ucXVStart = NoLinear.X2; ucXVEnd = NoLinear.X3; ucXStar = NON_LINEAR_POINT_X2; ucXEnd = NON_LINEAR_POINT_X3; } else { ucXVStart = NoLinear.X3; ucXVEnd = NoLinear.X4; ucXStar = NON_LINEAR_POINT_X3; ucXEnd = NON_LINEAR_POINT_X4; } if (ucXVEnd > ucXVStart) { wDistance = ucXVEnd - ucXVStart; ucStartPoint = ucXVStart; temData = AdjustValue - ucXStar; } else { wDistance = ucXVStart - ucXVEnd; ucStartPoint = ucXVEnd; temData = ucXEnd - AdjustValue; } rValue = ((WORD)wDistance*temData/(ucXEnd - ucXStar)) + ucStartPoint; return rValue; }
用户评论