예제 #1
0
/*
 * Search the outlets of a breaker for the receptacles having id of receptacle_id.
 *
 * Returns:
 *  Not Found: NULL
 *  Found: VA receptacle_t
 */
static receptacle_t *get_receptacle_by_id_from_breaker_id(uint32_t breaker_id, uint32_t receptacle_id) {
	receptacle_t *r = NULL;
	list_t *outlet_list = get_outlet_list_on_breaker(breaker_id);
	node_t *outlet_node_ptr = get_first_node(outlet_list);
	while (get_list_tail(outlet_list) != outlet_node_ptr) {
		r = search_outlet_for_receptacle_id((outlet_t *)outlet_node_ptr->data, receptacle_id);
		if (NULL != r) break;
		outlet_node_ptr = outlet_node_ptr->next;
	}	

	return r;
}
예제 #2
0
/*
 * Calculate the total amp load on a breaker having id of breaker_id.
 *
 * Returns:
 *  Success: amp_load >= 0.0
 *  Failure: ERR_INVALID_BREAKER_ID
 */
float get_total_amp_load_on_breaker_by_breaker_id(uint32_t breaker_id) {
	if (FALSE == breaker_id_is_installed(breaker_id)) {
		return ERR_INVALID_BREAKER_ID;
	}

	// sum amp loads of installed breakers
	float total_amp_load = 0.0;
	list_t *outlet_list =  get_outlet_list_on_breaker(breaker_id);
	node_t * outlet_node_ptr = get_first_node(outlet_list);
	while (get_list_tail(outlet_list) != outlet_node_ptr) {
		total_amp_load += get_total_amp_load_on_outlet_by_outlet_va((outlet_t *)outlet_node_ptr->data);
		outlet_node_ptr = outlet_node_ptr->next;
	}

	return total_amp_load;
}
예제 #3
0
double fp_item::get_density()
{
	fp_node* node = get_first_node();

	double freq = node->get_freq();

	while(node->get_next_item_neighbor())
	{
		node = node->get_next_item_neighbor();
		freq += node->get_freq();
	}

	//	std::cout << "##" << this << " freq: " << freq
	//			<< " diff:  "<< fabs(get_min() - get_max())
	//			<< " dens: " << freq / fabs(get_min() - get_max()) << std::endl;

	return ( freq / fabs(get_min() - get_max()) );
}
예제 #4
0
/*
 * Search the e_model for the breaker having id of breaker_id.
 *
 * Returns:
 *  Not Found: NULL
 *  Found: VA breaker_t
 */
static breaker_t *get_breaker_by_id(uint32_t breaker_id) {
#ifdef PATCHED
	if ((FALSE == load_center_is_created()) || 
		(0 == e_model->breakers_installed_cnt) ||
		(breaker_id >= e_model->breakers_installed_cnt)) {
#else
	if ((FALSE == load_center_is_created()) || (0 == e_model->breakers_installed_cnt)) {
#endif
		return NULL;
	}

	return &(e_model->breakers[breaker_id]);
}

/*
 * Search the e_model for the outlet having id of outlet_id.
 *
 * Returns:
 *  Not Found: NULL
 *  Found: VA outlet_t
 */
static outlet_t *get_outlet_by_id(uint32_t outlet_id) {
	outlet_t *o = NULL;
	int8_t breakers_installed_cnt = get_number_of_breakers_installed_in_load_center();
	if (0 > breakers_installed_cnt) {
		return NULL;
	}
	for (uint32_t breaker_id = 0; breaker_id < breakers_installed_cnt; breaker_id++) {

		list_t *outlet_list = get_outlet_list_on_breaker(breaker_id);
		node_t *outlet_node_ptr = get_first_node(outlet_list);
		while (get_list_tail(outlet_list) != outlet_node_ptr) {
			o = (outlet_t *)outlet_node_ptr->data;
			if (outlet_id == o->id) {
				break;
			} else {
				o = NULL;
			}
			outlet_node_ptr = outlet_node_ptr->next;
		}
	}
	return o;
}
예제 #5
0
/*
 * Search the e_model for light string having id of light_string_id.
 *
 * Returns:
 *  Not Found: NULL
 *  Found: VA light_string_t
 */
static light_string_t *get_light_string_by_id(uint32_t light_string_id) {
	light_string_t *ls = NULL;

	int8_t breakers_installed_cnt = get_number_of_breakers_installed_in_load_center();
	if (0 > breakers_installed_cnt) {
		return NULL;
	}
	for (uint32_t breaker_id = 0; breaker_id < breakers_installed_cnt; breaker_id++) {

		list_t *outlet_list = get_outlet_list_on_breaker(breaker_id);
		node_t *outlet_node_ptr = get_first_node(outlet_list);
		while (get_list_tail(outlet_list) != outlet_node_ptr) {
			outlet_t *o = (outlet_t *)outlet_node_ptr->data;
			ls = search_outlet_for_light_string_id(o, light_string_id);
			if (NULL != ls) {
				break;
			}
			outlet_node_ptr = outlet_node_ptr->next;
		}
	}
	return ls;	
}
예제 #6
0
/*
 * Search the e_model for splitter having id of splitter_id.
 *
 * Returns:
 *  Not Found: NULL
 *  Found: VA n_way_splitter_t
 */
static n_way_splitter_t *get_splitter_by_id(uint32_t splitter_id) {
	n_way_splitter_t *s = NULL;

	int8_t breakers_installed_cnt = get_number_of_breakers_installed_in_load_center();
	if (0 > breakers_installed_cnt) {
		return NULL;
	}
	for (uint32_t breaker_id = 0; breaker_id < breakers_installed_cnt; breaker_id++) {

		list_t *outlet_list = get_outlet_list_on_breaker(breaker_id);
		node_t *outlet_node_ptr = get_first_node(outlet_list);
		while (get_list_tail(outlet_list) != outlet_node_ptr) {
			outlet_t *o = (outlet_t *)outlet_node_ptr->data;
			s = search_outlet_for_splitter_id(o, splitter_id);
			if (NULL != s) {
				break;
			}
			outlet_node_ptr = outlet_node_ptr->next;
		}
	}
	return s;
}