Esempio n. 1
0
bool is_cylinder_used(struct dive *dive, int idx)
{
	struct divecomputer *dc;
	bool firstGasExplicit = false;
	if (cylinder_none(&dive->cylinder[idx]))
		return false;

	if ((dive->cylinder[idx].start.mbar - dive->cylinder[idx].end.mbar) > SOME_GAS)
		return true;
	for_each_dc(dive, dc) {
		struct event *event = get_next_event(dc->events, "gaschange");
		while (event) {
			if (dc->sample && (event->time.seconds == 0 ||
					   (dc->samples && dc->sample[0].time.seconds == event->time.seconds)))
				firstGasExplicit = true;
			if (get_cylinder_index(dive, event) == idx)
				return true;
			event = get_next_event(event->next, "gaschange");
		}
		if (dc->divemode == CCR && (idx == dive->diluent_cylinder_index || idx == dive->oxygen_cylinder_index))
			return true;
	}
	if (idx == 0 && !firstGasExplicit)
		return true;
	return false;
}
Esempio n. 2
0
/* get the gas at a certain time during the dive */
void get_gas_at_time(struct dive *dive, struct divecomputer *dc, duration_t time, struct gasmix *gas)
{
	// we always start with the first gas, so that's our gas
	// unless an event tells us otherwise
	struct event *event = dc->events;
	*gas = dive->cylinder[0].gasmix;
	while (event && event->time.seconds <= time.seconds) {
		if (!strcmp(event->name, "gaschange")) {
			int cylinder_idx = get_cylinder_index(dive, event);
			*gas = dive->cylinder[cylinder_idx].gasmix;
		}
		event = event->next;
	}
}
Esempio n. 3
0
static void check_gas_change_events(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
{
	int i = 0, cylinderindex = 0;
	struct event *ev = get_next_event(dc->events, "gaschange");

	// for dive computers that tell us their first gas as an event on the first sample
	// we need to make sure things are setup correctly
	cylinderindex = explicit_first_cylinder(dive, dc);
	set_first_cylinder_index(pi, 0, cylinderindex, ~0u);

	if (!ev)
		return;

	do {
		i = set_cylinder_index(pi, i, cylinderindex, ev->time.seconds);
		cylinderindex = get_cylinder_index(dive, ev);
		ev = get_next_event(ev->next, "gaschange");
	} while (ev);
	set_cylinder_index(pi, i, cylinderindex, ~0u);
}
Esempio n. 4
0
bool is_cylinder_used(struct dive *dive, int idx)
{
	struct divecomputer *dc;
	bool firstGasExplicit = false;
	if (cylinder_none(&dive->cylinder[idx]))
		return false;

	for_each_dc(dive, dc) {
		struct event *event = get_next_event(dc->events, "gaschange");
		while (event) {
			if (event->time.seconds < 30)
				firstGasExplicit = true;
			if (get_cylinder_index(dive, event) == idx)
				return true;
			event = get_next_event(event->next, "gaschange");
		}
	}
	if (idx == 0 && !firstGasExplicit)
		return true;
	return false;
}