Add Camera, LOTS project temporal devices

This commit is contained in:
Xavier Bustamante Talavera 2019-07-01 20:39:32 +02:00
parent c92d6b3282
commit f40f7187de
5 changed files with 141 additions and 2 deletions

View File

@ -166,6 +166,11 @@ class BatteryDef(ComponentDef):
SCHEMA = schemas.Battery
class CameraDef(ComponentDef):
VIEW = None
SCHEMA = schemas.Camera
class ComputerAccessoryDef(DeviceDef):
VIEW = None
SCHEMA = schemas.ComputerAccessory
@ -297,6 +302,36 @@ class Mixer(CookingDef):
SCHEMA = schemas.Mixer
class DrillDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Drill
class PackOfScrewdriversDef(DeviceDef):
VIEW = None
SCHEMA = schemas.PackOfScrewdrivers
class DehumidifierDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Dehumidifier
class StairsDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Stairs
class BikeDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Bike
class RacketDef(DeviceDef):
VIEW = None
SCHEMA = schemas.Racket
class ManufacturerDef(Resource):
VIEW = ManufacturerView
SCHEMA = schemas.Manufacturer

View File

@ -24,7 +24,7 @@ from teal.marshmallow import ValidationError
from teal.resource import url_for_resource
from ereuse_devicehub.db import db
from ereuse_devicehub.resources.enums import BatteryTechnology, ComputerChassis, \
from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \
DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface, Severity
from ereuse_devicehub.resources.models import STR_SM_SIZE, Thing
@ -686,6 +686,18 @@ class Battery(JoinedComponentTableMixin, Component):
return real_size / self.size if real_size and self.size else None
class Camera(Component):
"""The camera of a device."""
focal_length = db.Column(db.SmallInteger)
video_height = db.Column(db.SmallInteger)
video_width = db.Column(db.Integer)
horizontal_view_angle = db.Column(db.Integer)
facing = db.Column(db.Enum(CameraFacing))
vertical_view_angle = db.Column(db.SmallInteger)
video_stabilization = db.Column(db.Boolean)
flash = db.Column(db.Boolean)
class ComputerAccessory(Device):
"""Computer peripherals and similar accessories."""
id = Column(BigInteger, ForeignKey(Device.id), primary_key=True)
@ -775,6 +787,32 @@ class Mixer(Cooking):
pass
class Drill(Device):
max_drill_bit_size = db.Column(db.SmallInteger)
class PackOfScrewdrivers(Device):
pass
class Dehumidifier(Device):
size = db.Column(db.SmallInteger)
size.comment = """The capacity in Liters."""
class Stairs(Device):
max_allowed_weight = db.Column(db.Integer)
class Bike(Device):
wheel_size = db.Column(db.SmallInteger)
gears = db.Column(db.SmallInteger)
class Racket(Device):
pass
class Manufacturer(db.Model):
"""The normalized information about a manufacturer.

View File

@ -14,7 +14,7 @@ from teal.enums import Layouts
from ereuse_devicehub.resources.action import models as e
from ereuse_devicehub.resources.agent.models import Agent
from ereuse_devicehub.resources.device import states
from ereuse_devicehub.resources.enums import BatteryTechnology, ComputerChassis, \
from ereuse_devicehub.resources.enums import BatteryTechnology, CameraFacing, ComputerChassis, \
DataStorageInterface, DisplayTech, PrinterTechnology, RamFormat, RamInterface
from ereuse_devicehub.resources.lot.models import Lot
from ereuse_devicehub.resources.models import Thing
@ -356,6 +356,28 @@ class Battery(Component):
self.size = ... # type: bool
class Camera(Component):
focal_length = ... # type: Column
video_height = ... # type: Column
video_width = ... # type: Column
horizontal_view_angle = ... # type: Column
facing = ... # type: Column
vertical_view_angle = ... # type: Column
video_stabilization = ... # type: Column
flash = ... # type: Column
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
focal_length = ... # type: Optional[int]
video_height = ... # type: Optional[int]
video_width = ... # type: Optional[int]
horizontal_view_angle = ... # type: Optional[int]
facing = ... # type: Optional[CameraFacing]
vertical_view_angle = ... # type: Optional[int]
video_stabilization = ... # type: Optional[bool]
flash = ... # type: Optional[bool]
class ComputerAccessory(Device):
pass

View File

@ -307,6 +307,19 @@ class Battery(Component):
size = Integer(required=True, description=m.Battery.size.comment)
class Camera(Component):
__doc__ = m.Camera
focal_length = Integer(data_key='focalLength')
video_height = Integer(data_key='videoHeight')
video_width = Integer(data_key='videoWidth')
horizontal_view_angle = Integer(data_key='horizontalViewAngle')
facing = Integer()
vertical_view_angle = Integer(data_key='verticalViewAngle')
video_stabilization = Integer(data_key='videoStabilization')
flash = Integer()
class Manufacturer(Schema):
__doc__ = m.Manufacturer.__doc__
@ -398,3 +411,28 @@ class Cooking(Device):
class Mixer(Cooking):
__doc__ = m.Mixer.__doc__
class Drill(Device):
max_drill_bit_size = Integer(data_key='maxDrillBitSize')
class PackOfScrewdrivers(Device):
size = Integer()
class Dehumidifier(Device):
size = Integer()
class Stairs(Device):
max_allowed_weight = Integer(data_key='maxAllowedWeight')
class Bike(Device):
wheel_size = Integer(data_key='wheelSize')
gears = Integer()
class Racket(Device):
pass

View File

@ -249,6 +249,12 @@ class PrinterTechnology(Enum):
Thermal = 'Thermal'
@unique
class CameraFacing(Enum):
Front = 'Front'
Back = 'Back'
@unique
class BatteryHealth(Enum):
"""The battery health status as in Android."""