package spc

import (
	"time"
)

type AsuStats struct {
	Total IoMeter `json:"total"`
	Read  IoMeter `json:"read"`
	Write IoMeter `json:"write"`
}

func NewAsuStats() *AsuStats {
	return &AsuStats{}
}

func (a *AsuStats) Collect(iostat *IoStats) {
	a.Total.Collect(iostat)
	if iostat.Io.Isread {
		a.Read.Collect(iostat)
	} else {
		a.Write.Collect(iostat)
	}
}

func (a *AsuStats) Csv(delta time.Duration) string {
	return a.Read.Csv(delta) +
		a.Write.Csv(delta) +
		a.Total.Csv(delta)
}

func (a *AsuStats) CsvDelta(prev *AsuStats, delta time.Duration) string {
	return a.Read.CsvDelta(&prev.Read, delta) +
		a.Write.CsvDelta(&prev.Write, delta) +
		a.Total.CsvDelta(&prev.Total, delta)
}
