Commit c78bbfc2 authored by Andrey Filippov's avatar Andrey Filippov

added named camog.disk copies for navigation

parent 01b565e2
......@@ -112,7 +112,8 @@ pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
*/
typedef enum {
RAW_PATH,
FILE_PATH
FILE_PATH,
RAW_STATE
} path_type;
enum sysfs_path_type {
......@@ -355,8 +356,16 @@ int camogm_start(camogm_state *state)
D0(fprintf(debug_file, "Raw device write initiated, but file format is not JPEG. Will not start\n"));
return CAMOGM_FRAME_OTHER;
}
if (state->rawdev_op){
copy_state_file(state); // copy camogm.disk to named state file, fill be used when downloading data as file_start parameter
D1(fprintf(debug_file, "Starting raw data recording, marked %s, state->path='%s'\n", get_state_path(state), state->path));
D1(syslog (LOG_INFO, "Starting raw data recording, marked %s", get_state_path(state)));
next_state_path(state); // increment path so next time will use different one.
} else {
D1(fprintf(debug_file, "Starting file system recording to %s\n", state->path));
D1(syslog (LOG_INFO, "Starting file system recording to %s", state->path));
D1(fprintf(debug_file, "Starting recording\n"));
}
double dtime_stamp;
state->frameno = 0;
......@@ -890,6 +899,7 @@ int camogm_stop(camogm_state *state)
pthread_mutex_lock(&state->mutex);
state->prog_state = STATE_STOPPED;
pthread_mutex_unlock(&state->mutex);
D1(fprintf(debug_file, "Ended recording\n"));
DFLUSH;
return 0;
}
......@@ -1006,11 +1016,25 @@ void camogm_set_dummy_read(camogm_state *state, int d)
* the file name as is.
* @param[in] type the type of prefix, can be one of #path_type
*/
void camogm_set_prefix(camogm_state *state, const char * p, path_type type)
void camogm_set_prefix(camogm_state *state, const char * p, path_type type) // may use cookies to remember file
{
if (type == FILE_PATH) {
strncpy(state->path_prefix, p, sizeof(state->path_prefix) - 1);
state->path_prefix[sizeof(state->path_prefix) - 1] = '\0';
D1(fprintf(debug_file, "Set prefix: '%s', mode=%d\n", p, (int) type));
D1(syslog (LOG_INFO, "Set prefix: '%s', mode=%d", p, (int) type)); // RAW_STATE
if (type == RAW_STATE) { // path to state files for raw recording
if (state->rawdev_op) { // only for raw mode
// 07.02.2023 - use the same name as a template for camogm.disk copy
set_state_file_from_prefix(state, p); // will also set state->path_prefix as an absolute path
}
} else if (type == FILE_PATH) {
// if (state->rawdev_op) {
// // 07.02.2023 - use the same name as a template for camogm.disk copy
// set_state_file_from_prefix(state, p); // will also set state->path_prefix as an absolute path
// } else {
strncpy(state->path_prefix, p, sizeof(state->path_prefix) - 1); // cut off trailing "/"?
state->path_prefix[sizeof(state->path_prefix) - 1] = '\0';
// }
//int set_state_file_from_prefix(rawdev_buffer *rawdev, const char * prefix){
} else if (type == RAW_PATH && (strncmp(p, "/dev/", 5) == 0)) {
strncpy(state->rawdev.rawdev_path, p, sizeof(state->rawdev.rawdev_path) - 1);
state->rawdev.rawdev_path[sizeof(state->rawdev.rawdev_path) - 1] = '\0';
......@@ -1539,8 +1563,11 @@ int parse_cmd(camogm_state *state, FILE* npipe)
camogm_set_segment_length(state, d);
return 5;
} else if (strcmp(cmd, "prefix") == 0) {
if (args) camogm_set_prefix(state, args, FILE_PATH);
if (args) camogm_set_prefix(state, args, FILE_PATH); //RAW_STATE
return 6;
} else if (strcmp(cmd, "prefix_raw") == 0) {
if (args) camogm_set_prefix(state, args, RAW_STATE);
return 31;
} else if (strcmp(cmd, "status") == 0) {
camogm_status(state, args, 0);
return 7;
......@@ -1680,6 +1707,8 @@ int parse_cmd(camogm_state *state, FILE* npipe)
return -1;
}
/**
* @brief This function closes open files, terminates reading thread and deletes allocated memory.
* @param[in] state pointer to #camogm_state structure for a particular sensor channel
......@@ -2423,9 +2452,12 @@ int main(int argc, char *argv[])
if (str_len > 0) {
strncpy(sstate.rawdev.state_path, (const char *)state_name_str, str_len + 1);
}
ret = get_state_directory(&sstate);
D2(syslog (LOG_INFO, "%s:line %d : get_state_directory() -> %d @ %07d\n", \
__FILE__, __LINE__, ret, get_fpga_usec(sstate.fd_fparmsall[0], 0)));
ret = listener_loop(&sstate);
return ret;
......
......@@ -228,6 +228,11 @@ typedef struct {
unsigned char *disk_mmap;
int sysfs_fd;
char state_path[ELPHEL_PATH_MAX];
// char state_directory[ELPHEL_PATH_MAX];
// copy state file (camogm.disk) to the same directory when starting record. Can be used
// "<last_state_prefix>_<last_state_index>
char state_prefix[ELPHEL_PATH_MAX]; // absolute
int state_index;
} rawdev_buffer;
/**
......
This diff is collapsed.
......@@ -31,7 +31,18 @@ ssize_t emul_writev (int fd, const struct iovec *iovec, int count);
int get_write_page(struct writer_params *wparams);
int get_num_empty(struct writer_params *wparams);
int get_num_busy(struct writer_params *wparams);
int get_state_directory(camogm_state *state); // rawdev_buffer *rawdev);
int set_state_file_from_prefix(camogm_state *state, const char * prefix);
char * get_state_path(camogm_state *state);
void next_state_path(camogm_state *state);
int copy_state_file(camogm_state *state);
int copy_file(const char *from, const char *to);
#define STATE_EXT ".disk"
//#define STATE_FMT "%s_%04d"STATE_EXT
#define STATE_FMT "%s_%04d.disk"
#define STATE_SFMT "%s %d"
#define STATE_PREF_DFLT "test"
#endif /* _CAMOGM_JPEG_H */
......@@ -638,7 +638,11 @@ else
fprintf($fcmd, "prefix=%s;\n", $prefix);
// setcookie("directory", $prefix);
break;
case "set_prefix_raw": // path to camogm.disk for raw recording. Does not use cookies
$prefix_raw = $_GET['prefix'];
fprintf($fcmd, "prefix_raw=%s;\n", $prefix_raw);
break;
case "set_debuglev":
$debuglev = $_GET['debuglev'];
fprintf($fcmd, "debuglev=%s;\n", $debuglev);
......
......@@ -430,6 +430,9 @@ function process_recording(xmldoc) {
clearTimeout(update_intvl);
update_intvl = setTimeout(update_state, frame_period);
}
// this variable is injected into web page from camogmgui.php
var sensor_ports = parseInt(document.getElementById('sensor_ports').textContent, 10);
file_duration /= sensor_ports; // 07/01/2023: It was combined duration of all channels, so wrong data rate
//Update HTML
document.getElementById('ajax_state').innerHTML = state.substring(1, state.length-1);
document.getElementById('ajax_file_duration').innerHTML = Math.round(file_duration*100)/100 + " seconds / " + frame_number + " frames";
......@@ -447,7 +450,7 @@ function process_recording(xmldoc) {
var buffers_used = xmldoc.getElementsByTagName('buffer_used');
var buffer_size;
// this variable is injected into web page from camogmgui.php
var sensor_ports = parseInt(document.getElementById('sensor_ports').textContent, 10);
// var sensor_ports = parseInt(document.getElementById('sensor_ports').textContent, 10);
var max_bar_len = 370;
for (var i = 0; i < sensor_ports; i++) {
free_sz = buffers_free[i].firstChild.data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment