package collector

import (
	"context"
	"time"

	"git.mchus.pro/mchus/logpile/internal/models"
)

type IPMIMockConnector struct{}

func NewIPMIMockConnector() *IPMIMockConnector {
	return &IPMIMockConnector{}
}

func (c *IPMIMockConnector) Protocol() string {
	return "ipmi"
}

func (c *IPMIMockConnector) Collect(ctx context.Context, req Request, emit ProgressFn) (*models.AnalysisResult, error) {
	steps := []Progress{
		{Status: "running", Progress: 20, Message: "IPMI: подключение к BMC..."},
		{Status: "running", Progress: 55, Message: "IPMI: чтение инвентаря..."},
		{Status: "running", Progress: 85, Message: "IPMI: нормализация данных..."},
	}

	for _, step := range steps {
		if !sleepWithContext(ctx, 150*time.Millisecond) {
			return nil, ctx.Err()
		}
		if emit != nil {
			emit(step)
		}
	}

	return &models.AnalysisResult{
		Events:   make([]models.Event, 0),
		FRU:      make([]models.FRUInfo, 0),
		Sensors:  make([]models.SensorReading, 0),
		Hardware: &models.HardwareConfig{},
	}, nil
}
