import sys
from importlib import reload
sys.path.append('./')
import asotr_kdi
import asotr
reload(asotr_kdi)
reload(asotr)

fname = '/home/danila/Danila/work/MVN/Soft/PID/rust/uart_server/log_experim/cmd_data_asotr/asotr01/cmd_data_20250314_asotr.log'

# fname = '/home/danila/Danila/work/MVN/Soft/PID/rust/uart_server/log_experim/cmd_data_asotr/asotr01/cmd_data_20250324_asotr_step_var_cond.log'

# fname = '/home/danila/Danila/work/MVN/Soft/PID/rust/uart_server/log_experim/cmd_data_asotr/asotr01/cmd_data_20250325_asotrPD_thermostat.log'

# fname_save = '../data/experiments/noize_20250325_12.csv'
# begin_time = '25.03.2025 11:55:00'
# end_time = '25.03.2025 12:10:00'

fname_save = '../data/experiments/noize_20250314_14.csv'
begin_time = '14.03.2025 14:20:00'
end_time = '14.03.2025 14:35:00'

cmd_list, temp, power = asotr_kdi.get_cmd_data(fname)

begin = asotr.find_best_time_idx(temp.timestamp, begin_time, accuracy='seconds')
end = asotr.find_best_time_idx(temp.timestamp, end_time, accuracy='seconds')

temp1 = temp[begin:end]

print(temp1)
temp1.to_csv(fname_save, date_format='%d.%m.%Y %H:%M:%S.%f', index=False, sep=';', columns=['timestamp', 'ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6'])

