Variables

SECS variable types

class secsgem.secs.variables.SecsVar[source]

Bases: object

Base class for SECS variables. Due to the python types, wrapper classes for variables are required. If constructor is called with SecsVar or subclass only the value is copied.

formatCode = -1
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)

class secsgem.secs.variables.SecsVarDynamic(types, length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Variable with interchangable type.

Parameters:
  • types (list of secsgem.secs.variables.SecsVar classes) – list of supported types, default first. empty list means all types are support, SecsVarString default
  • length (integer) – max number of items in type
  • value (various) – initial value
set(value)[source]

Set the internal value to the provided value

In doubt provide the variable wrapped in the matching secsgem.secs.variables.SecsVar class, to avoid confusion.

Example:

>>> import secsgem
>>>
>>> var = secsgem.SecsVarDynamic([secsgem.SecsVarString, secsgem.SecsVarU1])
>>> var.set(10)
>>> var
A '10'
>>> var.set(secsgem.SecsVarU1(value=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
get()[source]

Return the internal value

Returns:internal value
Return type:various
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarDynamic
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
formatCode = -1
class secsgem.secs.variables.SecsVarList(data, field_count=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

List variable type. List with items of different types

Parameters:
  • data (OrderedDict) – internal data values
  • field_count (integer) – number of fields in the list
  • value (dict/list) – initial value
formatCode = 0
set(value)[source]

Set the internal value to the provided value

Parameters:value (dict/list) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarList
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarArray(data, field_count=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

List variable type. List with items of same type

Parameters:
  • data (secsgem.secs.variables.SecsVar) – internal data definition/sample
  • field_count (integer) – number of fields in the list
  • value (list) – initial value
formatCode = 0
append(data)[source]

Append data to the internal list

Parameters:value (various) – new value
set(value)[source]

Set the internal value to the provided value

Parameters:value (list) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarArray
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarBinary(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for binary data

Parameters:
  • length (integer) – number of items this value
  • value (string/integer) – initial value
formatCode = 8
set(value)[source]

Set the internal value to the provided value

Parameters:value (string/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarBinary
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarBoolean(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for boolean data

Parameters:
  • length (integer) – number of items this value
  • value (list/boolean) – initial value
formatCode = 9
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/boolean) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/boolean
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarBoolean
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarString(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for string data

Parameters:
  • length (integer) – number of items this value
  • value (string) – initial value
formatCode = 16
set(value)[source]

Set the internal value to the provided value

Parameters:value (string) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:string
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarString
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarI8(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 8 byte signed data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 24
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarI8
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarI1(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 1 byte signed data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 25
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarI1
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarI2(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 2 byte signed data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 26
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarI2
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarI4(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 4 byte signed data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 28
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarI4
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarF8(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 8 byte float data

Parameters:
  • length (integer) – number of items this value
  • value (list/float) – initial value
formatCode = 32
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/float) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/float
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarF8
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarF4(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 4 byte float data

Parameters:
  • length (integer) – number of items this value
  • value (list/float) – initial value
formatCode = 36
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/float) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/float
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarF4
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarU8(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 8 byte unsigned data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 40
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarU8
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarU1(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 1 byte unsigned data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 41
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarU1
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarU2(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 2 byte unsigned data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 42
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarU2
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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
class secsgem.secs.variables.SecsVarU4(length=-1, value=None)[source]

Bases: secsgem.secs.variables.SecsVar

Secs type for 4 byte unsigned data

Parameters:
  • length (integer) – number of items this value
  • value (list/integer) – initial value
formatCode = 44
set(value)[source]

Set the internal value to the provided value

Parameters:value (list/integer) – new value
get()[source]

Return the internal value

Returns:internal value
Return type:list/integer
encode()[source]

Encode the value to secs data

Returns:encoded data bytes
Return type:string
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

clone()[source]

Returns copy of the object

Returns:copy
Return type:secsgem.secs.variables.SecsVarU4
decode_item_header(data, text_pos=0)

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)

encode_item_header(length)

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