Technical Reference > CtAPI Functions > Function Reference > ctEngToRaw


Converts the engineering scale variable into raw I/O Device scale. This is not necessary for the Tag functions as CitectSCADA will do the scaling. Scaling is not necessary for digitals, strings or if no scaling occurs between the values in the I/O Device and the Engineering values. You need to know the scaling for each variables as specified in the CitectSCADA Variable Tags table.


ctEngToRaw(pResult, dValue, pScale, dwMode)


Type: Double
Input/output: Output
Description: The resulting raw scaled variable.


Type: Double
Input/output: Input
Description: The engineering value to scale.


Input/output: Input
Description: The scaling properties of the variable.


Type: Dword
Input/output: Input
Description: The mode of the scaling:

CT_SCALE_RANGE_CHECK: Range check the result. If the variable is out of range then generate an error. The pResult still contains the raw scaled value.

CT_SCALE_CLAMP_LIMIT: Clamp limit to maximum or minimum scales. If the result is out of scale then set result to minimum or maximum scale (which ever is closest). No error is generated if the scale is clamped. Cannot be used with CT_SCALE_RANGE_CHECK or CT_SCALE_NOISE_FACTOR options.

CT_SCALE_NOISE_FACTOR: Allow noise factor for range check on limits. If the variable is our of range by less than 0.1 % then a range error is not generated.

Return Value

TRUE if successful, otherwise FALSE. Use GetLastError() to get extended error information.

Related Functions

ctOpen, ctRawToEng, ctTagRead


CTSCALE		Scale	= { 0.0, 32000.0, 0.0, 100.0};
double dSetPoint = 42.23;
double dRawValue;
ctEngToRaw(&dRawValue, dSetPoint, &Scale, CT_SCALE_RANGE_CHECK);