Variables
SECS variable types.
- class secsgem.secs.variables.Base(value=None)[source]
Base class for SECS variables.
Due to the python types, wrapper classes for variables are required. If constructor is called with Base or subclass only the value is copied.
- set(value)[source]
Set the internal value to the provided value.
- Parameters:
value (various) – new value
- encode_item_header(length)[source]
Encode item header depending on the number of length bytes required.
- Parameters:
length (integer) – number of bytes in data
- Returns:
encoded item header bytes
- Return type:
string
- decode_item_header(data, text_pos=0)[source]
Encode item header depending on the number of length bytes required.
- Parameters:
data (string) – encoded data
text_pos (integer) – start of item header in data
- Returns:
start position for next item, format code, length item of data
- Return type:
(integer, integer, integer)
- property is_dynamic: bool
Check if this instance is Dynamic or derived.
- property preferred_type
Get the preferred type for this variable.
- class secsgem.secs.variables.Dynamic(types, value=None, count=-1)[source]
Variable with interchangable type.
- property preferred_type
Get the preferred type.
- set(value)[source]
Set the internal value to the provided value.
In doubt provide the variable wrapped in the matching
secsgem.secs.variables.Baseclass, to avoid confusion.Example
>>> import secsgem.secs >>> >>> var = secsgem.secs.variables.Dynamic([secsgem.secs.variables.String, ... secsgem.secs.variables.U1]) >>> var.set(secsgem.secs.variables.U1(10)) >>> var <U1 10 >
If no type is provided the default type is used which might not be the expected type.
- Parameters:
value (various) – new value
- decode(data, start=0)[source]
Decode the secs byte data to the value.
- Parameters:
data (string) – encoded data bytes
start (integer) – start position of value the data
- Returns:
new start position
- Return type:
integer
- property is_dynamic: bool
Check if this instance is Dynamic or derived.
- class secsgem.secs.variables.Array(data_format, value=None, count=-1)[source]
List variable type. List with items of same type.
- static get_format(data_format, showname=False)[source]
Get the format of the variable.
- Returns:
returns the string representation of the function
- Return type:
string
- class secsgem.secs.variables.List(data_format, value=None)[source]
List variable type. List with items of different types.
- static get_format(data_format, showname=False)[source]
Get the format of the variable.
- Returns:
returns the string representation of the function
- Return type:
string
- static get_name_from_format(data_format)[source]
Generate a name for the passed data_format.
- Parameters:
data_format (list/Base based class) – data_format to get name for
- Returns:
name for data_format
- Return type:
str
- class secsgem.secs.variables.Binary(value=None, count=-1)[source]
Secs type for binary data.
- supports_value(value)[source]
Check if the current instance supports the provided value.
- Parameters:
value (any) – value to test
- Return type:
bool
- class secsgem.secs.variables.Boolean(value=None, count=-1)[source]
Secs type for boolean data.
- supports_value(value)[source]
Check if the current instance supports the provided value.
- Parameters:
value (any) – value to test
- Return type:
bool
- class secsgem.secs.variables.String(value='', count=-1)[source]
Secs type for string data.
- Parameters:
value (string) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.JIS8(value='', count=-1)[source]
Secs type for string data.
- Parameters:
value (string) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.F4(value=None, count=-1)[source]
Secs type for 4 byte float data.
- Parameters:
value (list/float) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.F8(value=None, count=-1)[source]
Secs type for 8 byte float data.
- Parameters:
value (list/float) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.I1(value=None, count=-1)[source]
Secs type for 1 byte signed data.
- Parameters:
value (list/integer) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.I2(value=None, count=-1)[source]
Secs type for 2 byte signed data.
- Parameters:
value (list/integer) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.I4(value=None, count=-1)[source]
Secs type for 4 byte signed data.
- Parameters:
value (list/integer) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.I8(value=None, count=-1)[source]
Secs type for 8 byte signed data.
- Parameters:
value (list/integer) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.U1(value=None, count=-1)[source]
Secs type for 1 byte unsigned data.
- Parameters:
value (list/integer) – initial value
count (integer) – number of items this value
- class secsgem.secs.variables.U2(value=None, count=-1)[source]
Secs type for 2 byte unsigned data.
- Parameters:
value (list/integer) – initial value
count (integer) – number of items this value