Utility functions for LiC processing, file signalling, state strings, CSV logging and system analysis.
The my_tools.py module automatically selects the correct file paths depending on whether it runs under Linux or Windows. All signal files (S, U, R, H, Q, Sreq) are stored in a RAM disk.
# Linux:
"/home/host/FTP/ramdisk/S"
# Windows:
"C:\\home\\host\\FTP\\ramdisk\\S"
The function creates a signal file (S, U, R, H, Q). Steps:
create_file_to_send("S")
Reads voltage values for LiC1β¦LiC7 and stores them into the history deque structures. Values are extracted using a regular expression and then reversed so the newest is first:
LiC7, LiC6, ..., LiC1 # newest at index 0
After processing, the Uresp.txt file is removed.
Reads lines containing:
*1032101#
Resulting in an array:
[1,0,3,2,1,0,1]
Transfers 0/1/2/3 values into GUI radiobuttons.
Creates the R file to trigger a RUN cycle.
Converts radiobutton states into a status string:
*1032101#
The result is written to Sreq.
Saves one full data row into out_array.txt:
ROW;TIME;LiC7..LiC1;Sta7..Sta1
Reconstructs LiC history from the log file.
Example output:
{
"LiC4": 3.6501,
"LiC5": 3.6522,
"LiC6": 3.6488,
"LiC7": 3.6499
}
Returns e.g.:
{
"min": 3.6488,
"max": 3.6522,
"avg": 3.6502,
"over_limit_dolni": 0,
"over_limit_horni": 3,
"LiC_min": 6,
"LiC_max": 5
}
Builds the status string:
*1032101#
Parses a string into an array:
[1,0,3,2,1,0,1]
[4,1,2,3,1,4,1] β [1,0,3,2,1,0,0]
Returns True or False depending on whether arrays match.