import {InstrumentState} from "../components/administrationSection/sensors/SensorsPageTypes";
import {ErrorType} from "../common/errorHandling/ErrorMapper";

export type ErrorDto = {
    exceptionType: ErrorType,
    statusCode: number,
    message?: string,
    detail?: any
}

export type LoginRequest = {
    username: string,
    password: string
}

export type SignUpRequest = {
    username: string,
    email: string,
    password: string,
    firstName: string,
    lastName: string
}


export type UserSummary = {
    id: number,
    username: string,
    name: string
}

export type JwtAuthenticationResponse = {
    accessToken: string,
    tokenType: string
}

export type InstrumentDto = {
    id: number,
    state: InstrumentState
    guid: string,
    gpsCoordinates: string,
    altitude: number,
    tilt: number,
    direction: number,
    calibrationValue: number,
    monitoredAreas: InsInvMonitoredAreaDto[]
}

export type InsInvMonitoredAreaDto = {
    id: number,
    description: string
}

export type InverterDto = {
    id: number,
    manufacturer: string,
    efficiency: number,
    monitoredAreas: InsInvMonitoredAreaDto[],
}

export type MonitoredAreaDto = {
    id: number,
    instrumentId?: number,
    inverterId?: number,
    description: string,
    pvAreas: PvAreaDto[]
}

export type PvAreaDto = {
    id: number,
    area: number,
    altitude: number,
    tilt: number,
    direction: number,
    pvPanel?: PvPanelDto
}

export type PvPanelDto = {
    id: number,
    code: string,
    efficiency: number,
    manufacturer: string,
    material: string
}

export type InstrumentListDto = {
    instruments: InstrumentDto[],
    availableMonitoredAreas: InsInvMonitoredAreaDto[]
}

export type InverterListDto = {
    inverters: InverterDto[],
    availableMonitoredAreas: InsInvMonitoredAreaDto[]
}

export type MonitoredAreaListDto = {
    monitoredAreas: MonitoredAreaDto[],
    availablePvPanels: PvPanelDto[]
}

export type ApiResponse = {
    success: boolean,
    message: string
}

export type MeasurementPickerDto = {
    withInverter?: InverterConnectedInstrumentsDto[],
    withoutInverter?: MeasurementInstrumentDto[]
}

export type InverterConnectedInstrumentsDto = {
    inverterId: number,
    instruments: MeasurementInstrumentDto[]
}

export type MeasurementInstrumentDto = {
    id: number,
    monitoredAreas: MeasurementMonitoredAreaDto[]
}

export type MeasurementMonitoredAreaDto = {
    id: number,
    description: string
}

export type PickedMeasurementsDto = {
    pickedInverterId?: number,
    pickedInstrumentIds?: number[]
}

export type MeasurementDataDto = {
    instrumentEnergyAndIrradiance?: EnergyAndIrradianceDataDto[],
    sumEnergy?: SumEnergyDataDto,
    performanceRatio?: PerformanceRatioDataDto
}

export type EnergyAndIrradianceDataDto={
    instrumentId: number,
    minT: number,
    maxT: number,
    irradiance: DataPointDto[],
    monitoredAreaEnergy?: MonitoredAreaEnergyDto[]
}

export type MonitoredAreaEnergyDto={
    monitoredAreaId: number,
    graphData: DataPointDto[]
}

export type SumEnergyDataDto={
    minT: number,
    maxT: number,
    realEnergy?: InverterEnergyDto,
    theoreticalEnergy: InstrumentEnergyDto[]
}

export type InstrumentEnergyDto={
    instrumentId: number,
    graphData: DataPointDto[]
}

export type InverterEnergyDto={
    inverterId: number,
    graphData: DataPointDto[]
}

export type PerformanceRatioDataDto = {
    minT: number,
    maxT: number,
    inverterId: number,
    instrumentIds: number[],
    monitoredAreas: MeasurementMonitoredAreaDto[],
    graphData: DataPointDto[]
}

export type DataPointDto = {
    time: number,
    value: number
}