Skip to content

sift_py.ingestion.channel

CLASS DESCRIPTION
ChannelValue

Represents a fully qualified data point for a channel

ChannelConfig

A description for a channel

ChannelBitFieldElement
ChannelEnumType
ChannelDataTypeStrRep
ChannelDataType

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

FUNCTION DESCRIPTION
channel_fqn

Computes the fully qualified channel name.

string_value
double_value
float_value
bool_value
int32_value
uint32_value
int64_value
uint64_value
bit_field_value
enum_value
empty_value
bytes_value
is_data_type

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

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
value_from

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

try_value_from

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

as_pb
from_pb
fqn

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

ATTRIBUTE DESCRIPTION
name

TYPE: str

data_type

TYPE: ChannelDataType

description

TYPE: Optional[str]

unit

TYPE: Optional[str]

component

TYPE: Optional[str]

bit_field_elements

TYPE: List[ChannelBitFieldElement]

enum_types

TYPE: List[ChannelEnumType]

identifier

TYPE: str

name instance-attribute

name: str = name

data_type instance-attribute

data_type: ChannelDataType = data_type

description instance-attribute

description: Optional[str] = description

unit instance-attribute

unit: Optional[str] = unit

component instance-attribute

component: Optional[str] = None

bit_field_elements instance-attribute

bit_field_elements: List[ChannelBitFieldElement] = (
    bit_field_elements
)

enum_types instance-attribute

enum_types: List[ChannelEnumType] = enum_types

identifier instance-attribute

identifier: str = self.fqn()

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.

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.

as_pb

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

from_pb classmethod

from_pb(message: ChannelConfig) -> Self

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'.

ChannelBitFieldElement

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

Bases: AsProtobuf

METHOD DESCRIPTION
as_pb
from_pb
ATTRIBUTE DESCRIPTION
name

TYPE: str

index

TYPE: int

bit_count

TYPE: int

name pydantic-field

name: str = name

index pydantic-field

index: int = index

bit_count pydantic-field

bit_count: int = bit_count

as_pb

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

from_pb classmethod

from_pb(message: ChannelBitFieldElement) -> Self

ChannelEnumType

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

Bases: AsProtobuf

METHOD DESCRIPTION
as_pb
from_pb
ATTRIBUTE DESCRIPTION
name

TYPE: str

key

TYPE: int

is_signed

TYPE: Optional[bool]

name pydantic-field

name: str = name

key pydantic-field

key: int = key

is_signed pydantic-field

is_signed: Optional[bool] = is_signed

as_pb

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

from_pb classmethod

from_pb(message: ChannelEnumType) -> Self

ChannelDataTypeStrRep

Bases: Enum

METHOD DESCRIPTION
from_api_format
ATTRIBUTE DESCRIPTION
DOUBLE

STRING

ENUM

BIT_FIELD

BOOL

FLOAT

INT_32

INT_64

UINT_32

UINT_64

BYTES

DOUBLE class-attribute instance-attribute

DOUBLE = 'double'

STRING class-attribute instance-attribute

STRING = 'string'

ENUM class-attribute instance-attribute

ENUM = 'enum'

BIT_FIELD class-attribute instance-attribute

BIT_FIELD = 'bit_field'

BOOL class-attribute instance-attribute

BOOL = 'bool'

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'

UINT_32 class-attribute instance-attribute

UINT_32 = 'uint32'

UINT_64 class-attribute instance-attribute

UINT_64 = 'uint64'

BYTES class-attribute instance-attribute

BYTES = 'bytes'

from_api_format staticmethod

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

ChannelDataType

Bases: Enum

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

METHOD DESCRIPTION
from_pb
from_str
as_human_str
ATTRIBUTE DESCRIPTION
DOUBLE

STRING

ENUM

BIT_FIELD

BOOL

FLOAT

INT_32

INT_64

UINT_32

UINT_64

BYTES

DOUBLE class-attribute instance-attribute

DOUBLE = channel_pb.CHANNEL_DATA_TYPE_DOUBLE

STRING class-attribute instance-attribute

STRING = channel_pb.CHANNEL_DATA_TYPE_STRING

ENUM class-attribute instance-attribute

ENUM = channel_pb.CHANNEL_DATA_TYPE_ENUM

BIT_FIELD class-attribute instance-attribute

BIT_FIELD = channel_pb.CHANNEL_DATA_TYPE_BIT_FIELD

BOOL class-attribute instance-attribute

BOOL = channel_pb.CHANNEL_DATA_TYPE_BOOL

FLOAT class-attribute instance-attribute

FLOAT = channel_pb.CHANNEL_DATA_TYPE_FLOAT

INT_32 class-attribute instance-attribute

INT_32 = channel_pb.CHANNEL_DATA_TYPE_INT_32

INT_64 class-attribute instance-attribute

INT_64 = channel_pb.CHANNEL_DATA_TYPE_INT_64

UINT_32 class-attribute instance-attribute

UINT_32 = channel_pb.CHANNEL_DATA_TYPE_UINT_32

UINT_64 class-attribute instance-attribute

UINT_64 = channel_pb.CHANNEL_DATA_TYPE_UINT_64

BYTES class-attribute instance-attribute

BYTES = channel_pb.CHANNEL_DATA_TYPE_BYTES

from_pb classmethod

from_pb(val: ValueType) -> 'ChannelDataType'

from_str classmethod

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

as_human_str

as_human_str(api_format: bool = False) -> str

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'.

string_value

string_value(val: str) -> IngestWithConfigDataChannelValue

double_value

double_value(
    val: float,
) -> IngestWithConfigDataChannelValue

float_value

float_value(val: float) -> IngestWithConfigDataChannelValue

bool_value

bool_value(val: bool) -> IngestWithConfigDataChannelValue

int32_value

int32_value(val: int) -> IngestWithConfigDataChannelValue

uint32_value

uint32_value(val: int) -> IngestWithConfigDataChannelValue

int64_value

int64_value(val: int) -> IngestWithConfigDataChannelValue

uint64_value

uint64_value(val: int) -> IngestWithConfigDataChannelValue

bit_field_value

bit_field_value(
    val: bytes,
) -> IngestWithConfigDataChannelValue

enum_value

enum_value(val: int) -> IngestWithConfigDataChannelValue

empty_value

empty_value() -> IngestWithConfigDataChannelValue

bytes_value

bytes_value(val: bytes) -> IngestWithConfigDataChannelValue

is_data_type

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