fixed issue on udpstreamer trigger logic

This commit is contained in:
Martino Ferrari
2026-08-28 16:53:17 +02:00
parent 1c61e814c0
commit 044ce57ba3
170 changed files with 16958 additions and 24036 deletions
+6 -17
View File
@@ -842,10 +842,7 @@ func (hf *histFile) readAfter(after, t0, t1 float64, max int) ([]byte, float64,
// The run wraps at most once, so it costs at most two reads.
buf := make([]byte, n*histPairSize)
start := (oldest + lo) % capacity
head := int(capacity-start) * histPairSize
if head > len(buf) {
head = len(buf)
}
head := min(int(capacity-start)*histPairSize, len(buf))
if _, err := hf.f.ReadAt(buf[:head], int64(histHeaderSize)+int64(start)*histPairSize); err != nil {
return nil, 0, err
}
@@ -898,10 +895,8 @@ func (hf *histFile) writePairs(t, v []float64) error {
binary.LittleEndian.PutUint64(buf[i*histPairSize+8:], math.Float64bits(v[i]))
}
first := int(hf.capacity - hf.head)
if first > n {
first = n
}
first := min(int(hf.capacity-hf.head), n)
off := int64(histHeaderSize) + int64(hf.head)*histPairSize
if _, err := hf.f.WriteAt(buf[:first*histPairSize], off); err != nil {
return err
@@ -1089,10 +1084,7 @@ func (hw *historyWriter) readRange(key string, t0, t1 float64, maxOut int) ([]fl
// Read in contiguous runs: the range wraps at most once.
buf := make([]byte, n*histPairSize)
start := (oldest + lo) % capacity
first := int(capacity - start)
if first > n {
first = n
}
first := min(int(capacity-start), n)
if _, err := hf.f.ReadAt(buf[:first*histPairSize],
int64(histHeaderSize)+int64(start)*histPairSize); err != nil {
return nil, nil
@@ -1265,7 +1257,7 @@ func (h *Hub) handleSetHistoryBudget(env map[string]interface{}) {
// handleHistoryZoom answers a historyZoom request from disk. Same request and
// reply shape as "zoom", so clients can fall back to it transparently when a
// window reaches further back than the in-memory rings hold.
func (h *Hub) handleHistoryZoom(c *wsClient, env map[string]interface{}) {
func (h *Hub) handleHistoryZoom(c *wsClient, env map[string]any) {
if !h.hist.enabled() {
msg, _ := json.Marshal(map[string]any{
"type": "historyZoom", "reqId": env["reqId"],
@@ -1287,10 +1279,7 @@ func (h *Hub) handleHistoryZoom(c *wsClient, env map[string]interface{}) {
// oversampled relative to the plot's point budget and thinned afterwards.
// The cap keeps a request for "no decimation" over a multi-hour window from
// pulling the whole file into memory.
readCap := n * histReadOversample
if readCap > histMaxReadPoints {
readCap = histMaxReadPoints
}
readCap := min(n*histReadOversample, histDefaultMaxPoints)
signals := make(map[string]sigData)
for _, k := range strings.Split(sigCSV, ",") {