<< 点击显示目录 >> 主页 PVI通信 > PVI帮助信息 > PVI Services > BR.AN.Namespace > BR.AN.PviServices > CastModes Enumeration |
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 status 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 CB 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 status 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.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
[Visual Basic]
<Flags> _
Public Enum CastModes
[C#]
[Flags]
public enum CastModes
Member Name |
Description |
Value |
DEFAULT |
Default CAST- mode. |
0 |
PG2000String |
Bit 0 (Value: 1) String variable for PG2000 or AS 1.3. If the variable 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 type conversion. When reading the data format (access type POBJ_ACC_TYPE or event POBJ_EVENT_DATAFORM), "String" is returned as the variable type (e.g. actual data format = "VT=i8 VL=1 VN=24" -> returned data format "VT=string VL=24 VN=1"). Setting CM=1 should take place in the process object. If CM=1 is only specified in the link object, the corresponding type conversion is carried out, but the actual data format is returned when the data format is read. This conversion mode is intended for "old" PG2000 or AS 1.3 applications. New applications should not use this mode. Instead, a string variable should also be defined as a string variable in the PLC. |
1 |
DecimalConversion |
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. |
2 |
RangeCheck |
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 status 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 CB 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 status 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. |
4 |
FloatConversion |
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. |
8 |
StringTermination |
Always terminating string variables with a binary 0 (zero): A string variable with a data format of "VT=string VL=4" can contain a maximum of 4 characters. If string data "abcd" is assigned, then there is no more room for zero-termination. If "zero-termination" mode is enabled, then the string variable will always be terminated with a binary 0 during type conversion. In the example above, the string variable would contain "abc" and a binary 0 would hold the fourth position. |
16 |
Namespace: BR.AN.PviServices
Assembly: BR.AN.PviServices (in BR.AN.PviServices.dll)
Generated from assembly BR.AN.PviServices [8.1.0.4]