Table Of Contents

Strip ChartSupport ► Decoding Backup

Usually you will probably want to Export collected data or simply save the document the strip chart is on. There are plenty of facilities to export and save data and documents. This section deals with a much more efficient real-time exporting of data which operates while a Strip Chart is acquiring data.

If enabled (see Managing Backup), Strip Chart writes real-time backup files. You can use another program to decode those files. The next section explains this process using conventional unix and C-language constructs, but you can also use any other system available for this purpose.

Decoding Backup Files

Backup files are encoded in binary format within the document. First save the document before using a backup. The backup files are located within the document file structure in the overlay of the strip chart. For example, here is a directory listing within the Terminal application of a backup:

fred2:~ ed$ cd /Users/ed/example.vvibook/page1.page/overlay1.layer
fred2:overlay1.layer ed$ ls -l
total 384
-rw-r--r-- 1 ed staff 0 Aug 9 10:16 backup_1533823886_774772_1.vvidaq_index
-rw-r--r-- 1 ed staff 4 Aug 9 10:16 backup_1533823886_774772_1.vvidaq_state
-rw-r--r-- 1 ed staff 8192 Aug 9 10:17 backup_1533823886_774772_1_1.vvidaq
-rw-r--r-- 1 ed staff 36 Aug 9 10:12 format
-rw-r--r-- 1 ed staff 326057 Aug 9 10:12 main_layer.vvidefinition

The linear backup can be decoded using this code:

#import <stdio.h>
#import <string.h>

{
FILE *a_stream;

int desired_read_byte_length;
int actual_read_byte_length;
char *read_buffer;
char *read_buffer_location;
double *sample_value_location;
double *sample_value_end;
unsigned sample_state;
unsigned number_of_amplitudes;
double current_sample_value_c_array[16];
double current_second;

a_path = "/Users/ed/example.vvibook/page1.page/overlay1.layer/backup_1533823886_774772_1_1.vvidaq";

a_stream = fopen(a_path, "r");

if(a_stream == NULL)
{
printf("No backup file\n");
return;
}

number_of_amplitudes = 16;

desired_read_byte_length = (number_of_amplitudes + 1) * sizeof(double) + sizeof(unsigned);
sample_value_end = current_sample_value_c_array + number_of_amplitudes;

read_buffer = malloc(desired_read_byte_length);

actual_read_byte_length = desired_read_byte_length;

while(1)
{

/*
Poll read with a throttle
*/

actual_read_byte_length = 0;
while(actual_read_byte_length != desired_read_byte_length)
{
read_buffer_location = read_buffer + actual_read_byte_length;
actual_read_byte_length += fread(read_buffer, 1, desired_read_byte_length, a_stream);

if(actual_read_byte_length = 0) usleep(1);
}

/*
Decode a single-time-sample amount of 16 channel data
*/

read_buffer_location = read_buffer;
sample_value_location = current_sample_value_c_array;

memcpy(&sample_state, read_buffer_location, sizeof(unsigned));
read_buffer_location += sizeof(unsigned);

memcpy(&current_second, read_buffer_location, sizeof(double));
read_buffer_location += sizeof(double);

for(; sample_value_location < sample_value_end; sample_value_location++)
{
memcpy(sample_value_location, read_buffer_location, sizeof(double));
read_buffer_location += sizeof(double);
}

/*
Got some data, so now process it here using your own code.
current_sample_value_c_array : 16 element double array with channel data.
current_second: The second since 1970 of the samples.
sample_state: not documented
*/

}

free(read_buffer);

fclose(a_stream);
}


© Copyright 1993-2021 by VVimaging, Inc. (VVI); All Rights Reserved (Legal). Please email support@vvi.com with any comments you have concerning this documentation.