[docs]classChannel(Base):# type: ignore""" Represents a channel of a sensor in the database. Attributes: id (int): Unique identifier for the channel. number (int): Channel number of the sensor. type_class (str): Type of sensor. gain (float): Gain of the sensor. sensor_id (int): Foreign key referencing the associated sensor. sensor (Sensor): Relationship to the Sensor object. files (list[File]): List of File objects associated with the channel. samples (list[Sample]): List of Sample objects associated with the channel. events (list[EventChannel]): List of EventChannel objects associated with the channel. """__tablename__="channel"id=Column(Integer,primary_key=True)"""int: Unique identifier for the channel."""number=Column(Integer)"""int: Channel number of the sensor."""type_class=Column(String)"""str: Type or classification of the sensor."""gain=Column(Float)"""float: Gain value of the sensor."""sensor_id=Column(Integer,ForeignKey("sensor.id"))"""int: Foreign key linking to the sensor's ID."""sensor=relationship("sonicdb.database.sensor.Sensor",back_populates="channels",enable_typechecks=False,)"""Sensor: Associated sensor object."""files=relationship("sonicdb.database.file.File",back_populates="channel",enable_typechecks=False)"""list[File]: List of files associated with the channel."""samples=relationship("sonicdb.database.sample.Sample",back_populates="channel",enable_typechecks=False,)"""list[Sample]: List of samples associated with the channel."""events=relationship("sonicdb.database.event.EventChannel",back_populates="channel",enable_typechecks=False,)"""list[EventChannel]: List of events associated with the channel."""__mapper_args__={"polymorphic_identity":"channel"}def__repr__(self)->str:# pragma: no cover"""Return a string representation of the channel. Returns: str: String representation of the channel. """returnf"Channel: {self.number} of Sensor"
[docs]defget_start(self:"Channel")->datetime:# pragma: no cover"""Get the earliest datetime from the channel's files. Returns: datetime: The earliest recording datetime. """returnmin([f.startforfinself.filesifisinstance(f.start,datetime)])
[docs]defget_end(self:"Channel")->datetime:# pragma: no cover"""Get the latest datetime from the channel's files. Returns: datetime: The latest recording datetime. """returnmax([f.endforfinself.filesifisinstance(f.end,datetime)])
[docs]defdict(self:"Channel")->dict[str,int]:# pragma: no cover"""Convert the channel's attributes to a dictionary. Returns: dict[str, int]: Dictionary of channel attributes. """return{k.title():vfork,vinself.__dict__.items()}