<< 点击显示目录 >> 主页 PVI通信 > PVI帮助信息 > PVI Services > BR.AN.Namespace > BR.AN.PviServices > Variable Class > Variable Properties > Variable.CastMode Property |
This is a combination of the supported cast / conversion modes. Combine the different modes by using the logical OR operator. The cast mode parameter is a bit coded. The adjustable conversion modes are represented by a bit within the bit list: Bit 0 (Value: 1) PG2000 or AS 1.3 - String variable: If the process object data format defines a i8 or u8 array (1 byte array), then the process data is regarded as a single variable of type string (VT=string) during data conversion. When reading the data format (access type TYPE or event "data format change"), "string" is returned as a variable type (i.e. actual data format = "VT=i8 VL=1 VN=24 CM=1" -> returned data format VT=string VL=24 VN=1). The parameter CM=1 must be specified in the process object for this. If CM=1 is only specified in the link object, then the actual data format is returned. Note: This conversion mode is provided for "old" PG2000 or AS 1.3 applications. New applications should not use these conversion parameters; rather, a String variable should also be defined as a String variable in the PLC. Bit 1 (Value: 2) Determines the way numbers appear in the string when converting from variable type String ("VT=string") to variable type Integer ("VT=i8, VT=u32"). Decimal mode is not active (bit=0): A string with leading 0 places is interpreted as octal (i.e. -077, 0012). If the string begins with "0x" or "0X", then the following places are interpreted as hexadecimal (i.e. 0x1f, -0x56a9, 0xA3). In all other cases, the string is interpreted as decimal. Decimal mode is active (bit = 1): The string is always interpreted as decimal. In other words, a string with leading zeroes is interpreted as decimal; "0x123" (hexadecimal) cannot be interpreted. Bit 2 (Value: 4) Determines the behavior of a variable when the value range is violated. A value range violation occurs if a number value cannot be represented in a variable. Example: The value 130 cannot be represented in a variable of type i8 (value range: -128 to 127), but rather in a variable of type u8 (value range: 0 to 255). If link objects and process objects use variable types of different value ranges, then a value range violation can occur in read or write direction (i.e. variable type in the link object i32 and in the process object i16, or variable type in the connection object i8 and in the process object u8). Value range monitoring is not active (bit=0): Group type behavior during data conversion: Group type Integer to a variable type Integer with a smaller value range: The number is truncated binary. Group type Float to a variable type with a smaller value range: In the number is not representable in the value range, then the result is undefined. Group type String to a variable type Float or Integer: If the number is not representable in the value range, then the result is undefined. Group type Float or Integer to variable type String: If the converted String is longer than the length of the string variable (parameter "VL"), then the string is truncated. Value range monitoring is active (bit=1): The behavior during active value range monitoring is the same as the behavior of limit monitoring (see "Scaling and Limiting"). Behavior when a violation of the value range occurs depends on the transfer direction: Writing variable data (PviWrite): Write tasks are halted when an error occurs. Data is not written to the PLC variable. Error code 12014 is returned in the write response. Additionally, the maximum representable value is returned with the write response and is sent to the application in the event data buffer (if specified) for function "PviWrite" or "PviWriteResultResponse". Reading variable data (PviRead or data change event): The maximum representable value is sent instead of the variable data. An error message is not given. In both cases, the respective retVal flags for Cast-overflow or Cast-underflow are set in the response info data (structure T_RESPONSE_INFO). Additional information concerning the response info data can be found in the "PviGetResponseInfo" function or the callback function SET_PVICALLBACK_DATA. Monitoring of limits is also carried out for String variable types ("VT=string"). A limit violation occurs when the string data is longer then the buffer size of the variables. Example: A string "abcdefg"+ terminating null cannot be put completely into a variable with the data format "VT=string VL=4". The retVal flag Cast-Overflow is set when a violation of the string limit or a violation in the positive value range of a numeric variable occurs. Cast-Underflow can only occur in connection with numeric variables with a negative value range (signed Integer, Float). A violation of the negative value range is signaled in this case. In non-interpretable characters are contained in a string which is to be converted to another variable type, this is handled like a string limit violation. Bit 3 (Value: 8) Determines the type of conversion of variable type Float ("VT=f32 ...") to variable type Integer ("VT=i8, VT=u32 ..."). Rounding mode is not active (bit=0): All places behind the decimal point of a Float are truncated. Example: 1.3 -> 1, -15.5 -> -15, 0.9999 -> 0. Rounding mode is active (bit = 1): All places behind the decimal point of a Float are rounded (4/5). Example: 1.3 -> 1, -15.5 -> -16, 0.9999 -> 1. Default / standard conversion = 0.
[Visual Basic]
Public Property CastMode() As CastModes
Public Get
End Get
Public Set
End Set
End Property
[C#]
public CastModes CastMode { public get; public set; }
This is a combination (logical OR) of the supported cast modes.
Variable Class | BR.AN.PviServices Namespace
Generated from assembly BR.AN.PviServices [8.1.0.4]