Reafctor app
This commit is contained in:
parent
b8216f6ade
commit
7740be8bb5
36 changed files with 389 additions and 208 deletions
0
app/schemas/__init__.py
Normal file
0
app/schemas/__init__.py
Normal file
31
app/schemas/chargepoint.py
Normal file
31
app/schemas/chargepoint.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.connector import Connector
|
||||
|
||||
class ChargePointBase(BaseModel):
|
||||
friendly_name: str
|
||||
is_active: bool
|
||||
|
||||
class ChargePointUpdate(BaseModel):
|
||||
friendly_name: Optional[str] = None
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
class ChargePointCreate(ChargePointBase):
|
||||
pass
|
||||
|
||||
class ChargePoint(ChargePointBase):
|
||||
id: UUID
|
||||
last_seen: datetime | None
|
||||
connectors: list[Connector] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class ChargePointPassword(BaseModel):
|
||||
password: str
|
||||
|
||||
class ChargePointConnectionInfo(BaseModel):
|
||||
connected: bool
|
19
app/schemas/connector.py
Normal file
19
app/schemas/connector.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import enum
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
class ConnectorStatus(enum.Enum):
|
||||
AVAILABLE = "Available"
|
||||
OCCUPIED = "Occupied"
|
||||
RESERVED = "Reserved"
|
||||
UNAVAILABLE = "Unavailable"
|
||||
FAULTED = "Faulted"
|
||||
|
||||
class Connector(BaseModel):
|
||||
id: UUID
|
||||
evse: int
|
||||
index: int
|
||||
status: ConnectorStatus
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
18
app/schemas/id_token.py
Normal file
18
app/schemas/id_token.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.user import User
|
||||
|
||||
class IdTokenBase(BaseModel):
|
||||
title: str
|
||||
is_active: bool
|
||||
|
||||
class IdTokenCreate(IdTokenBase):
|
||||
pass
|
||||
|
||||
class IdToken(IdTokenBase):
|
||||
id: UUID
|
||||
owner: User
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
55
app/schemas/meter_value.py
Normal file
55
app/schemas/meter_value.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
from datetime import datetime
|
||||
import enum
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
class PhaseType(enum.Enum):
|
||||
L1 = "L1"
|
||||
L2 = "L2"
|
||||
L3 = "L3"
|
||||
N = "N"
|
||||
L1_N = "L1-N"
|
||||
L2_N = "L2-N"
|
||||
L3_N = "L3-N"
|
||||
L1_L2 = "L1-L2"
|
||||
L2_L3 = "L2-L3"
|
||||
L3_L1 = "L3-L1"
|
||||
|
||||
class Measurand(enum.Enum):
|
||||
CURRENT_EXPORT = "Current.Export"
|
||||
CURRENT_IMPORT = "Current.Import"
|
||||
CURRENT_OFFERED = "Current.Offered"
|
||||
ENERGY_ACTIVE_NET = "Energy.Active.Net"
|
||||
ENERGY_ACTIVE_EXPORT_REGISTER = "Energy.Active.Export.Register"
|
||||
ENERGY_ACTIVE_IMPORT_REGISTER = "Energy.Active.Import.Register"
|
||||
ENERGY_ACTIVE_EXPORT_INTERVAL = "Energy.Active.Export.Interval"
|
||||
ENERGY_ACTIVE_IMPORT_INTERVAL = "Energy.Active.Import.Interval"
|
||||
ENERGY_REACTIVE_NET = "Energy.Reactive.Net"
|
||||
ENERGY_REACTIVE_EXPORT_REGISTER = "Energy.Reactive.Export.Register"
|
||||
ENERGY_REACTIVE_IMPORT_REGISTER = "Energy.Reactive.Import.Register"
|
||||
ENERGY_REACTIVE_EXPORT_INTERVAL = "Energy.Reactive.Export.Interval"
|
||||
ENERGY_REACTIVE_IMPORT_INTERVAL = "Energy.Reactive.Import.Interval"
|
||||
ENERGY_APPARENT_NET = "Energy.Apparent.Net"
|
||||
ENERGY_APPARENT_IMPORT = "Energy.Apparent.Import"
|
||||
ENERGY_APPARENT_EXPORT = "Energy.Apparent.Export"
|
||||
FREQUENCY = "Frequency"
|
||||
POWER_ACTIVE_EXPORT = "Power.Active.Export"
|
||||
POWER_ACTIVE_IMPORT = "Power.Active.Import"
|
||||
POWER_FACTOR = "Power.Factor"
|
||||
POWER_OFFERED = "Power.Offered"
|
||||
POWER_REACTIVE_EXPORT = "Power.Reactive.Export"
|
||||
POWER_REACTIVE_IMPORT = "Power.Reactive.Import"
|
||||
SOC = "SoC"
|
||||
VOLTAGE = "Voltage"
|
||||
|
||||
class MeterValue(BaseModel):
|
||||
id: UUID
|
||||
timestamp: datetime
|
||||
measurand: Measurand
|
||||
phase_type: PhaseType
|
||||
unit: str
|
||||
value: float
|
||||
transaction_id: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
45
app/schemas/transaction.py
Normal file
45
app/schemas/transaction.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from datetime import datetime
|
||||
import enum
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
class TransactionStatus(enum.Enum):
|
||||
ONGOING = "ongoing"
|
||||
ENDED = "ended"
|
||||
|
||||
class TransactionEventTriggerReason(enum.Enum):
|
||||
AUTHORIZED = "Authorized"
|
||||
CABLE_PLUGGED_IN = "CablePluggedIn"
|
||||
CHARGING_RATE_CHANGED = "ChargingRateChanged"
|
||||
CHARGING_STATE_CHANGED = "ChargingStateChanged"
|
||||
DEAUTHORIZED = "Deauthorized"
|
||||
ENERGY_LIMIT_REACHED = "EnergyLimitReached"
|
||||
EV_COMMUNICATION_LOST = "EVCommunicationLost"
|
||||
EV_CONNECT_TIMEOUT = "EVConnectTimeout"
|
||||
METER_VALUE_CLOCK = "MeterValueClock"
|
||||
METER_VALUE_PERIODIC = "MeterValuePeriodic"
|
||||
TIME_LIMIT_REACHED = "TimeLimitReached"
|
||||
TRIGGER = "Trigger"
|
||||
UNLOCK_COMMAND = "UnlockCommand"
|
||||
STOP_AUTHORIZED = "StopAuthorized"
|
||||
EV_DEPARTED = "EVDeparted"
|
||||
EV_DETECTED = "EVDetected"
|
||||
REMOTE_STOP = "RemoteStop"
|
||||
REMOTE_START = "RemoteStart"
|
||||
ABNORMAL_CONDITION = "AbnormalCondition"
|
||||
SIGNED_DATA_RECEIVED = "SignedDataReceived"
|
||||
RESET_COMMAND = "ResetCommand"
|
||||
|
||||
class Transaction(BaseModel):
|
||||
id: UUID
|
||||
status: TransactionStatus
|
||||
started_at: datetime
|
||||
ended_at: datetime
|
||||
meter_start: float
|
||||
meter_end: float
|
||||
end_reason: TransactionEventTriggerReason
|
||||
connector_id: str
|
||||
id_token_id: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
18
app/schemas/user.py
Normal file
18
app/schemas/user.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from uuid import UUID
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.id_token import IdToken
|
||||
|
||||
class UserBase(BaseModel):
|
||||
friendly_name: str
|
||||
is_active: bool
|
||||
|
||||
class UserCreate(UserBase):
|
||||
pass
|
||||
|
||||
class User(UserBase):
|
||||
id: UUID
|
||||
id_tokens: list[IdToken] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
Loading…
Add table
Add a link
Reference in a new issue