summaryrefslogtreecommitdiff
path: root/globals.c
blob: d62b81841231fa914b742de1d27755891cbe5baf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "globals.h"
#include <time.h>
#include <sys/time.h>


GlobalStruct globals = {
	.Flags.do_check_settings = 1,
	.Flags.attenuators_enabled = 1,
	.DefaultFlags.do_check_settings = 1,
	.DefaultFlags.attenuators_enabled = 1,

	.Registers.last_rise_time_relay_setting = 99,

	.Registers.last_relay_driver_settings[0] = -1,
	.Registers.last_relay_driver_settings[1] = -1,
	.Registers.last_relay_driver_settings[2] = -1,
	.Registers.last_relay_driver_settings[3] = -1,
	.Registers.last_relay_driver_settings[4] = -1,

	.Registers.gpib_input_buffer[0] = 0,
	.Registers.pending_output_message = NULL,

	.VxiLocks.locked_network_server = NO_SERVER_LOCKED,

	.MenuStatus.Nonstd_Display = YES
};


PwlStruct pwl_struct[pwl_max_types][max_channels];


long sec_timer (void)
{
	return (long)time(NULL);
}


unsigned long long ms_timer (void)
{
	struct timeval tv;
	gettimeofday(&tv, NULL);

	unsigned long long millisecondsSinceEpoch =
	        (unsigned long long)(tv.tv_sec) * 1000 +
	        (unsigned long long)(tv.tv_usec) / 1000;

	return millisecondsSinceEpoch;
}

const char* param_name[] = { "AMPL", "OS", "PW", "DELAY", "PERIOD", "BURST", "RISE", "SLEW", "DISTORT" };

void debug_new_parameter (int channel, int parameter, float requested)
{
	g_print_debug("chan %d, %s, requested %e, adjusted %e, polarity %d, range %d, word %d, aux %d, atten %d\n", 
		channel, param_name[parameter], requested,
		pwl_struct[parameter][channel].actual_value,
		pwl_struct[parameter][channel].actual_pol,
		pwl_struct[parameter][channel].range,
                pwl_struct[parameter][channel].word_out,
		pwl_struct[parameter][channel].word_out_aux,
		pwl_struct[parameter][channel].atten_range);
}