Code Search for Developers
 
 
  

emview_i.h from EmStar at Krugle


Show emview_i.h syntax highlighted

/*
 *
 * Copyright (c) 2003 The Regents of the University of California.  All 
 * rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * - Neither the name of the University nor the names of its
 *   contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

/*
 *  emview_i.h
 *
 *  Author: girod
 *
 */

#include <gtk/gtk.h>
#include <emview.h>
#include <libdev/status_dev.h>
#include <libdev/frame_processor.h>
#include "emview_source.h"
#include "emview_component.h"
#include "emview_node.h"
#include "emview_device.h"
#include "emview_gui.h"
#include "emview_config.h"
#include "emview_analysis.h"

#ifndef __EMVIEW_I_H__ 
#define __EMVIEW_I_H__ 

struct emview_module {  
  emview_module_opts_t opts;  
  GPtrArray *instances;
  int instance_count;
  QUEUE_ELEMENT_DECL(ptrs, struct emview_module);
};


typedef struct emview_core {
  /* modules */
  QUEUE_DECL(modules, emview_module_t);

  /* devices */
  emview_device_list_t device_list;

  /* data sources */
  emview_source_list_t source_list;

  /* current node set */
  emview_node_list_t node_list;

  /* current default configuration */
  slot_list_t default_slots;                 /* the current set of default slot mappings */

  /* registered component list */
  component_list_t components;          /* ordered list of registered components */

  /* gui stuff */
  gui_t gui;
  int nogui;
  char *gui_title;

  /* location file */
  char *location_file_path;

  /* the current options tree */
  config_info_t config;

  /* analysis info */
  analysis_info_t analysis;

  /* trace file state */

  /* output */
  int trace_fd;
  char *trace_path;

  /* input */
  char *input_trace_path;
  frame_context_t *de_frame;
  emproxy_reply_hdr_t *on_deck;
} core_t;


extern core_t _core;

/*
 *  timing constants
 */

#define EMVIEW_NODE_INACTIVITY_TIMEOUT      10  /*sec*/
#define EMVIEW_NODE_INACTIVITY_CHECK      1000  /*ms*/

/* updates after config changes occur are delayed */
#define EMVIEW_NODE_CONFIG_UPDATE         1000  /*ms*/
#define EMVIEW_DEVICE_RECOMPUTE_DELAY     1000  /*ms*/

/* justification options */
#define EMVIEW_CENTER      0
#define EMVIEW_TOP_JUST    1
#define EMVIEW_LEFT_JUST   1
#define EMVIEW_BOT_JUST    2
#define EMVIEW_RIGHT_JUST  2


/*
 *  Function Prototypes
 */

/* emview_node.c */
void emview_node_list_init();
node_t *emview_node_lookup_nocreate(node_id_t id);
node_t *emview_node_lookup(node_id_t id);
void emview_node_heard(node_id_t node_id, int direct);
void emview_node_global_relink_display();
void emview_node_relink_display(node_t *n);
void emview_nodes_compute_extent();
int emview_draw_nodes(GTimer *timer);
void emview_draw_nodes_reset();
void emview_repos_nodes();
void emview_node_handle_simconfig(emproxy_reply_hdr_t *reply);
void emview_node_ref(node_id_t id, GQuark component);
int emview_node_get_center(node_id_t id, GQuark component, int *x, int *y);
int emview_source_in_defaults(source_t *s);
void emview_module_config_defaults(emview_module_t *mod);
void emview_node_clear_refs(node_t *n);
component_list_t *emview_node_get_component_list(node_id_t target);
QUEUE_INLINE_INSTANTIATIONS(emview_node, ptrs, nodes, node_t, emview_node_list_t);

/* emview_slots.c */
void emview_slot_list_assign_low(slot_list_t *slots, component_t *c, node_id_t id);
void emview_slots_list_status_printable(slot_list_t *slots, buf_t *buf, GQuark option_q);

/* emview_source.c */
void emview_sources_init();
source_t *emview_source_lookup(const char *name);
source_t *emview_source_lookup_q(GQuark name);
source_data_t *emview_source_data_lookup_safe_q(GQuark source, node_id_t id);
source_data_t *emview_source_data_lookup_safe(char *source_name, node_id_t id);
void emview_source_reset_node(node_id_t id);
void emview_source_activate_deps(source_t *src);
int emview_source_data_valid(source_data_t *data);
void emview_build_layout_menu();
void emview_build_link_menu();
void emview_source_links_track_refs(link_source_t *ls);
void emview_source_links_draw(link_source_t *ls, node_t *n, emview_color_t default_color,
			      GQuark default_component, int annotations);
void emview_link_set_check(link_source_t *ls);
char *emview_source_data_string_value(source_data_t *data);
emview_color_t emview_source_data_bg_color(source_data_t *data);
emview_color_t emview_source_data_fg_color(source_data_t *data);
void emview_print_source_data(char *field, source_data_t *d, buf_t *buf);

/* emview_device.c */
void emview_devices_init(emproxy_client_opts_t *opts);
void emview_device_update_command();
void emview_device_clear_active_flags();
void emview_device_note_timeout(node_id_t id);
void emview_device_activate(emview_device_t *dev);

void emview_trace_log(emproxy_reply_hdr_t *reply);

/* emview_component.c */
void emview_components_init();
void emview_component_list_append_copy(component_list_t *dst, component_list_t *src);
component_t *emview_component_lookup(component_list_t *cl, char *c_name);
component_t *emview_component_lookup_q(component_list_t *cl, GQuark component);
int emview_component_is_exclusive_q(component_list_t *cl, GQuark component, int field);
void emview_component_relink(component_list_t *cl, node_id_t id, slot_list_t *slots);
void emview_component_note_config_change(node_id_t target);
void emview_component_assign_low(component_t *c, int field, source_data_t *d);
void component_nonexcl_append(GPtrArray **arr, source_data_t *d);
void component_nonexcl_clear(GPtrArray **arr, source_data_t *d);
void component_nonexcl_check_referenced(component_t *c, GPtrArray *ne);
void component_check_referenced(component_t *c, source_data_t *data);
void emview_build_component_menu();
void emview_component_extend_upper_right(component_t *c, int width, int height);
void emview_component_list_clear_refs(component_list_t *cl);
int emview_component_layout_type(node_t *n, emview_component_type_t type);
void emview_components_draw(component_list_t *cl);
void emview_reconfig();
int emview_component_list_status_printable(component_list_t *cl, buf_t *buf);
void emview_component_clear_refs(component_list_t *cl);
void emview_component_list_set_active(component_list_t *cl, int active);
void emview_component_list_mark(component_list_t *cl);
void emview_component_list_prune_marked(component_list_t *cl);

/* emview_*_component.c */
void emview_node_component_init();
void emview_box_component_init();

/* emview_gui_menu.c */
GtkWidget *emview_toplevel_menu(char *label, GtkWidget **item);
GtkWidget *emview_menu_item(GtkWidget *menu, GtkWidget *menuitem,
			    GtkFunction callback, void *data);
GtkWidget *emview_check_menu_item(GtkWidget *menu, char *label, int *var);
GtkWidget *emview_sub_menu(GtkWidget *super_menu, char *label);

/* emview_gui.c */
int emview_gui_init(int *argc, char **argv);
float emview_p2m_y(int y_pixels);
float emview_p2m_x(int x_pixels);
int emview_m2p_y(float y_coord_meters);
int emview_m2p_x(float x_coord_meters);
void emview_recalc_zoom();
int emview_set_fg_color(GdkGC *gc, emview_color_t color, int light);
void emview_next_redraw_full();

/* returns number of pixels high */
int emview_put_label_in_comp(component_t *c, char *buf, 
			     emview_color_t bg_color, emview_color_t fg_color,
			     emview_color_t box_color,
			     int v_just, int h_just, int pad,
			     int bold, int italics, int p_size, int light);
int emview_put_label(int x1, int y1, int width, int height, char *buf, 
		     emview_color_t bg_color, emview_color_t fg_color,
		     emview_color_t box_color,
		     int v_just, int h_just, int pad,
		     int bold, int italics, int p_size, int light);

/* emview_main.c */
emview_module_t *emvew_module_lookup(char *name);
emview_module_inst_t *emview_mod_inst_lookup_or_create(emview_module_t *mod, char *nick, int *created);
void emview_init(emproxy_client_opts_t *opts);
void mod_init(int *argc, char **argv);
int emview_exit(void *data);
QUEUE_INLINE_INSTANTIATIONS(emview_module, ptrs, modules, emview_module_t, core_t);

/* emview_config.c */
int config_main(int *argc, char **argv);
char *emview_config_unparse_enable(int enable);
int emview_option_tree_update(char *option_name, int enable_bit);
void emview_build_options_menu();
void emview_config_test(node_t *n, buf_t *buf);
void emview_config_dump(emview_module_t *module, node_t *n, buf_t *buf);
char *emview_unparse_source_type(emview_source_type_t type);
char *emview_unparse_component_field(int field);
char *emview_unparse_color(emview_color_t color);
int emview_config_global_now(void *data, int interval, g_event_t *ev);

/* emview_analysis.c */
void emview_analysis_runcommands(sim_config_t *cf);
void emview_analysis_restart(analysis_info_t *a);


/*
 *  semantics options
 */

/*
 * 'Referenced' bits are used to determine which parts of the system
 * to display at a given time.  For instance, there may be a potential
 * for 3 radio boxes, but if only two of them actually have data
 * associated with them you don't want to see the third one.  There
 * are two options here.
 *
 * One will clear reference bits before each draw operation, meaning
 * that if data is timed out, or the assignment is changed so that
 * there is no data source assigned to a given component, that
 * component will no longer be displayed.  This is called 
 * "CLEAR_REFS_ON_EVERY_DRAW"
 *
 * The other will clear reference bits only on "reactivation", which
 * happens when a node has been inactive for a while and then is
 * reactivated by new data associated to it.  The latter option is
 * selected by setting the define below.  This is called
 * "CLEAR_REFS_ON_RESET"
 */

#define  CLEAR_REFS_ON_EVERY_DRAW
//#define  CLEAR_REFS_ON_RESET

#endif




See more files for this project here

EmStar

EmStar is a software system for developing and deploying wireless sensor networks involving Linux-based platforms. As the wireless sensor network community has attempted to deploy more complex designs---large-scale, long-lived systems that need self-organization and adaptivity---a number of difficult software design issues have arisen. Advances in software design have not kept pace with the capabilities of hardware. This is because designing for an adaptive, efficient, and useful sensor network has turned out to be surprisingly complex and difficult. EmStar is a Linux-based software framework, whose goal is to dramatically reduce this complexity, enabling work to be shared and reused, and simplifying and speeding the design of new sensor network applications.

Project homepage: http://cvs.cens.ucla.edu/emstar/
Programming language(s): C,Shell Script
License: other

  emview_analysis.c
  emview_analysis.h
  emview_box_component.c
  emview_component.c
  emview_component.h
  emview_config.c
  emview_config.h
  emview_device.c
  emview_device.h
  emview_gui.c
  emview_gui.h
  emview_gui_menu.c
  emview_i.h
  emview_main.c
  emview_node.c
  emview_node.h
  emview_node_component.c
  emview_slots.c
  emview_source.c
  emview_source.h