Skip to content

sift_py.ingestion.channel

CLASS DESCRIPTION
ChannelBitFieldElement
ChannelConfig

A description for a channel

ChannelDataType

Utility enum class to simplify working with channel data-types generated from protobuf

ChannelDataTypeStrRep
ChannelEnumType
ChannelValue

Represents a fully qualified data point for a channel

FUNCTION DESCRIPTION
bit_field_value
bool_value
bytes_value
channel_fqn

Computes the fully qualified channel name.

double_value
empty_value
enum_value
float_value
int32_value
int64_value
is_data_type
string_value
uint32_value
uint64_value

ChannelBitFieldElement

ChannelBitFieldElement(
    name: str, index: int, bit_count: int
)

Bases: AsProtobuf

METHOD DESCRIPTION
as_pb
from_pb
ATTRIBUTE DESCRIPTION
bit_count

TYPE: int

index

TYPE: int

name

TYPE: str

bit_count instance-attribute

bit_count: int = bit_count

index instance-attribute

index: int = index

name instance-attribute

name: str = name

as_pb

as_pb(
    klass: Type[ChannelBitFieldElement],
) -> ChannelBitFieldElement

from_pb classmethod

from_pb(message: ChannelBitFieldElement) -> Self

ChannelConfig

ChannelConfig(
    name: str,
    data_type: ChannelDataType,
    description: Optional[str] = None,
    unit: Optional[str] = None,
    component: Optional[str] = None,
    bit_field_elements: List[ChannelBitFieldElement] = [],
    enum_types: List[ChannelEnumType] = [],
)

Bases: AsProtobuf

A description for a channel

METHOD DESCRIPTION
as_pb
fqn

NOTE: Component field of Channel has been deprecated. Function kept for backwards compatibility.

from_pb
try_value_from

Generate a channel value for this particular channel configuration. This will raise an exception

value_from

Like try_value_from except will return None there is a failure to produce a channel value due to a type mismatch.

ATTRIBUTE DESCRIPTION
bit_field_elements

TYPE: List[ChannelBitFieldElement]

component

TYPE: Optional[str]

data_type

TYPE: ChannelDataType

description

TYPE: Optional[str]

enum_types

TYPE: List[ChannelEnumType]

identifier

TYPE: str

name

TYPE: str

unit

TYPE: Optional[str]

bit_field_elements instance-attribute

bit_field_elements: List[ChannelBitFieldElement] = (
    bit_field_elements
)

component instance-attribute

component: Optional[str] = None

data_type instance-attribute

data_type: ChannelDataType = data_type

description instance-attribute

description: Optional[str] = description

enum_types instance-attribute

enum_types: List[ChannelEnumType] = enum_types

identifier instance-attribute

identifier: str = fqn()

name instance-attribute

name: str = name

unit instance-attribute

unit: Optional[str] = unit

as_pb

as_pb(klass: Type[ChannelConfig]) -> ChannelConfig

fqn

fqn() -> str

NOTE: Component field of Channel has been deprecated. Function kept for backwards compatibility.

The fully-qualified channel name of a channel called 'voltage' is simply voltage. The fully qualified name of a channel called 'temperature' of component 'motor' is a `motor.temperature'.

from_pb classmethod

from_pb(message: ChannelConfig) -> Self

try_value_from

try_value_from(
    value: Optional[Union[int, float, bool, str, bytes]],
) -> IngestWithConfigDataChannelValue

Generate a channel value for this particular channel configuration. This will raise an exception if there is a type match, namely, if value isn't consistent with the channel's data-type. For a version of this function that does not raise an exception and simply ignores type mistmatches, see value_from. If value is None then an empty value will be generated.

value_from

value_from(
    value: Optional[Union[int, float, bool, str, bytes]],
) -> Optional[IngestWithConfigDataChannelValue]

Like try_value_from except will return None there is a failure to produce a channel value due to a type mismatch.

ChannelDataType

Bases: Enum

Utility enum class to simplify working with channel data-types generated from protobuf

METHOD DESCRIPTION
as_human_str
from_pb
from_str
ATTRIBUTE DESCRIPTION
BIT_FIELD

BOOL

BYTES

DOUBLE

ENUM

FLOAT

INT_32

INT_64

STRING

UINT_32

UINT_64

BIT_FIELD class-attribute instance-attribute

BIT_FIELD = CHANNEL_DATA_TYPE_BIT_FIELD

BOOL class-attribute instance-attribute

BOOL = CHANNEL_DATA_TYPE_BOOL

BYTES class-attribute instance-attribute

BYTES = CHANNEL_DATA_TYPE_BYTES

DOUBLE class-attribute instance-attribute

DOUBLE = CHANNEL_DATA_TYPE_DOUBLE

ENUM class-attribute instance-attribute

ENUM = CHANNEL_DATA_TYPE_ENUM

FLOAT class-attribute instance-attribute

FLOAT = CHANNEL_DATA_TYPE_FLOAT

INT_32 class-attribute instance-attribute

INT_32 = CHANNEL_DATA_TYPE_INT_32

INT_64 class-attribute instance-attribute

INT_64 = CHANNEL_DATA_TYPE_INT_64

STRING class-attribute instance-attribute

STRING = CHANNEL_DATA_TYPE_STRING

UINT_32 class-attribute instance-attribute

UINT_32 = CHANNEL_DATA_TYPE_UINT_32

UINT_64 class-attribute instance-attribute

UINT_64 = CHANNEL_DATA_TYPE_UINT_64

as_human_str

as_human_str(api_format: bool = False) -> str

from_pb classmethod

from_pb(val: ValueType) -> 'ChannelDataType'

from_str classmethod

from_str(raw: str) -> Optional['ChannelDataType']

ChannelDataTypeStrRep

Bases: Enum

METHOD DESCRIPTION
from_api_format
ATTRIBUTE DESCRIPTION
BIT_FIELD

BOOL

BYTES

DOUBLE

ENUM

FLOAT

INT_32

INT_64

STRING

UINT_32

UINT_64

BIT_FIELD class-attribute instance-attribute

BIT_FIELD = 'bit_field'

BOOL class-attribute instance-attribute

BOOL = 'bool'

BYTES class-attribute instance-attribute

BYTES = 'bytes'

DOUBLE class-attribute instance-attribute

DOUBLE = 'double'

ENUM class-attribute instance-attribute

ENUM = 'enum'

FLOAT class-attribute instance-attribute

FLOAT = 'float'

INT_32 class-attribute instance-attribute

INT_32 = 'int32'

INT_64 class-attribute instance-attribute

INT_64 = 'int64'

STRING class-attribute instance-attribute

STRING = 'string'

UINT_32 class-attribute instance-attribute

UINT_32 = 'uint32'

UINT_64 class-attribute instance-attribute

UINT_64 = 'uint64'

from_api_format staticmethod

from_api_format(
    val: str,
) -> Optional["ChannelDataTypeStrRep"]

ChannelEnumType

ChannelEnumType(
    name: str, key: int, is_signed: Optional[bool] = None
)

Bases: AsProtobuf

METHOD DESCRIPTION
as_pb
from_pb
ATTRIBUTE DESCRIPTION
is_signed

TYPE: Optional[bool]

key

TYPE: int

name

TYPE: str

is_signed class-attribute instance-attribute

is_signed: Optional[bool] = is_signed

key instance-attribute

key: int = key

name instance-attribute

name: str = name

as_pb

as_pb(klass: Type[ChannelEnumType]) -> ChannelEnumType

from_pb classmethod

from_pb(message: ChannelEnumType) -> Self

ChannelValue

Bases: TypedDict

Represents a fully qualified data point for a channel

ATTRIBUTE DESCRIPTION
channel_name

TYPE: str

component

TYPE: NotRequired[str]

value

TYPE: IngestWithConfigDataChannelValue

channel_name instance-attribute

channel_name: str

component instance-attribute

component: NotRequired[str]

value instance-attribute

value: IngestWithConfigDataChannelValue

bit_field_value

bit_field_value(
    val: bytes,
) -> IngestWithConfigDataChannelValue

bool_value

bool_value(val: bool) -> IngestWithConfigDataChannelValue

bytes_value

bytes_value(val: bytes) -> IngestWithConfigDataChannelValue

channel_fqn

channel_fqn(
    channel: Union[
        ChannelConfig,
        ChannelConfig,
        ChannelValue,
        Channel,
        _AbstractChannel,
    ],
) -> str

Computes the fully qualified channel name.

NOTE: Component field of Channel is deprecated and should not be used. Function is left for code compatibility.

The fully-qualified channel name of a channel called 'voltage' is simply voltage'. The fully qualified name of a channel called 'temperature' of component 'motor' is amotor.temperature'.

double_value

double_value(
    val: float,
) -> IngestWithConfigDataChannelValue

empty_value

empty_value() -> IngestWithConfigDataChannelValue

enum_value

enum_value(val: int) -> IngestWithConfigDataChannelValue

float_value

float_value(val: float) -> IngestWithConfigDataChannelValue

int32_value

int32_value(val: int) -> IngestWithConfigDataChannelValue

int64_value

int64_value(val: int) -> IngestWithConfigDataChannelValue

is_data_type

is_data_type(
    val: IngestWithConfigDataChannelValue,
    target_type: ChannelDataType,
) -> bool

string_value

string_value(val: str) -> IngestWithConfigDataChannelValue

uint32_value

uint32_value(val: int) -> IngestWithConfigDataChannelValue

uint64_value

uint64_value(val: int) -> IngestWithConfigDataChannelValue