rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
log_select.h File Reference

Which of a card's entries a bounded list keeps, and the order it draws them in. More...

#include <stdint.h>
#include "fm_select.h"
#include "log_name.h"
#include "log_viewer_screen.h"

Go to the source code of this file.

Data Structures

struct  log_select_page_t
 One page being chosen while a directory is read. Filled by log_select_page_begin(); the fields are the walk's, not the caller's. Not copied while a walk runs: its page keeping points at its own key. More...

Functions

int log_select_keep (log_viewer_file_t *set, int count, int capacity, const log_viewer_file_t *cand)
 Offer cand to a set in log_name_rank() order.
void log_select_page_begin (log_select_page_t *sel, log_viewer_file_t *set, int capacity, const log_viewer_page_t *page)
 Start choosing page into set.
void log_select_page_offer (log_select_page_t *sel, const log_viewer_file_t *cand)
 Offer one directory entry; it is copied if it is kept.
int log_select_page_end (log_select_page_t *sel, log_viewer_page_t *page)
 End the walk: put the set into the order the browse list draws (log_select_sort()) and write page's ahead and held.
void log_select_sort (log_viewer_file_t *set, int count)
 Put count entries into the order the browse list draws them in: directories first, then log_name_rank() order – runs newest first, then the other names, case-insensitively.
bool log_select_lists (const char *name)
 Whether the list holds a file of this name: a CSV file, or a report.

Detailed Description

Which of a card's entries a bounded list keeps, and the order it draws them in.

The browse list holds a page of LOG_VIEWER_MAX_FILES entries and a card takes up to LOG_RUN_LAST runs, so a listing of a full card is a choice. Making that choice by where the directory read stopped hides every run written after the card passed that many files – usually the newest experiments.

Entries are offered one at a time, in whatever order the volume hands them over. log_select_keep() holds the LOG_VIEWER_MAX_FILES that log_name_rank() puts first; log_select_page_*() hold one page of that order, the one a log_viewer_page_t names, and count where it starts. Memory is the page and nothing more: one walk of the directory per page, whatever the card holds. Ordering for display is a separate pass, run once the directory has been read to its end: directories first, then log_name_rank() order, so the rows of a page run the same way as the pages, newest run at the top.

The page keeping is the file manager's (fm_select.h) with log_name_rank() as its order; the file manager's panes keep theirs in name order.

Paging needs log_name_rank() to be a strict order: zero only for the same file. Two names that tie fall on the key's side of every page edge, and one of them is shown on no page.

Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).

SPDX-License-Identifier: MIT

Function Documentation

◆ log_select_keep()

int log_select_keep ( log_viewer_file_t * set,
int count,
int capacity,
const log_viewer_file_t * cand )

Offer cand to a set in log_name_rank() order.

The count is the same one that came back from the last call, so a set never drifts past its capacity. A candidate that ranks below a full set is dropped and the count does not move.

Parameters
setthe entries, in log_name_rank() order
countentries in set
capacityroom in set
candthe entry offered; copied when it is kept
Returns
the count after the offer

◆ log_select_lists()

bool log_select_lists ( const char * name)

Whether the list holds a file of this name: a CSV file, or a report.

A report is a name log_report_number() takes, the same rule FILES labels a report by (fm_kind_of()): ATESTnnn.TXT beside its ATESTnnn.CSV or without it, LIMITnnn.TXT, which a LIMIT RUN writes with no CSV, and the SERVOnnn.TXT of firmware 0.21.0 and older. A run and its report are two rows, the run first (log_name_rank()); OPEN reads the CSV into the import and the report as text, and DELETE on the run takes its report along. Any other ".TXT" is not listed. One walk of a folder decides it name by name.

Parameters
namea file's name in the folder; NULL is none
Returns
true for a name ending in ".csv", any case, after a base name, and for a report; false for every other name and for NULL

◆ log_select_page_begin()

void log_select_page_begin ( log_select_page_t * sel,
log_viewer_file_t * set,
int capacity,
const log_viewer_page_t * page )

Start choosing page into set.

The key is copied, so page may change while the walk runs.

Parameters
selthe walk's state
setroom for capacity entries
capacityentries set takes
pagewhich page; NULL for the first

◆ log_select_page_end()

int log_select_page_end ( log_select_page_t * sel,
log_viewer_page_t * page )

End the walk: put the set into the order the browse list draws (log_select_sort()) and write page's ahead and held.

Parameters
selthe walk's state
pagetakes ahead and held; may be NULL
Returns
the entries held

◆ log_select_page_offer()

void log_select_page_offer ( log_select_page_t * sel,
const log_viewer_file_t * cand )

Offer one directory entry; it is copied if it is kept.

Parameters
selthe walk's state
candthe entry

◆ log_select_sort()

void log_select_sort ( log_viewer_file_t * set,
int count )

Put count entries into the order the browse list draws them in: directories first, then log_name_rank() order – runs newest first, then the other names, case-insensitively.

Parameters
setthe entries
counthow many