| | |
| | | return (await request<TestLiveStateResponse>(`/system/test/${testId}/live-state`)).data |
| | | } |
| | | |
| | | export interface BtsRecord { |
| | | sequenceId: number |
| | | deviceTime: string |
| | | currentA: number |
| | | voltageV: number |
| | | capacityAh: number |
| | | energyWh: number |
| | | cycleNo: number |
| | | stepNo: number |
| | | stepName: string |
| | | stepType: string |
| | | } |
| | | |
| | | export interface BtsStepRecord { |
| | | cycleNo: number |
| | | stepNo: number |
| | | cyclePosition: number |
| | | stepName: string |
| | | stepType: string |
| | | recordCount: number |
| | | startedAt: string |
| | | endedAt: string |
| | | capacityAh: number |
| | | energyWh: number |
| | | durationSeconds: number |
| | | startVoltageV: number |
| | | endVoltageV: number |
| | | chargePeakVoltageV: number |
| | | dischargeValleyVoltageV: number |
| | | } |
| | | |
| | | export interface BtsCycleRecord { |
| | | recordNo: string |
| | | cycleNo: number |
| | | recordCount: number |
| | | startedAt: string |
| | | endedAt: string |
| | | chargeCapacityAh: number |
| | | dischargeCapacityAh: number |
| | | chargeEnergyWh: number |
| | | dischargeEnergyWh: number |
| | | efficiency: number |
| | | } |
| | | |
| | | async function getSimulatorChannelData<T>(deviceId: number, channelId: number, kind: 'records' | 'steps' | 'cycles'): Promise<T[]> { |
| | | const token = getAuthToken() |
| | | const response = await fetch(`${import.meta.env.VITE_API_BASE_URL || '/dev-api'}/dev/bts-simulator/devices/${deviceId}/channels/${channelId}/${kind}`, { headers: token ? { Authorization: `Bearer ${token}` } : undefined }) |
| | | if (!response.ok) throw new Error(`检测柜${kind}数据加载失败(${response.status})`) |
| | | const result = await response.json() as T[] |
| | | return Array.isArray(result) ? result : [] |
| | | } |
| | | |
| | | export function getBtsRecords(deviceId: number, channelId: number): Promise<BtsRecord[]> { |
| | | return getSimulatorChannelData<BtsRecord>(deviceId, channelId, 'records') |
| | | } |
| | | |
| | | export function getBtsSteps(deviceId: number, channelId: number): Promise<BtsStepRecord[]> { |
| | | return getSimulatorChannelData<BtsStepRecord>(deviceId, channelId, 'steps') |
| | | } |
| | | |
| | | export function getBtsCycles(deviceId: number, channelId: number): Promise<BtsCycleRecord[]> { |
| | | return getSimulatorChannelData<BtsCycleRecord>(deviceId, channelId, 'cycles') |
| | | } |
| | | |
| | | export async function saveTestConsoleDetail(testId: number, detail: TestConsoleDetail): Promise<TestConfigurationDetail> { |
| | | return (await request<TestDetailResponse>(`/system/test/${testId}/console-detail`, { method: 'PUT', body: JSON.stringify(detail) })).data |
| | | } |
| | |
| | | efficiency: number | string | null |
| | | chargeEnergy: number | string | null |
| | | dischargeEnergy: number | string | null |
| | | /** 来源类别:DEVICE 设备提供、AGGREGATED 本系统按工步层聚合、IMPORTED 授权文件导入。 */ |
| | | sourceKind?: string | null |
| | | } |
| | | |
| | | // 三子页和图表查询持久化当前有效数据,不回放实时监控或触发预警判定。 |