|
|
/home/brennan/Software/sensix/tools/sim/platform.pc/nido.hGo to the documentation of this file.00001 // $Id: nido.h,v 1.2 2009/07/23 02:45:49 sean_m_brennan Exp $ 00002 00003 /* tab:4 00004 * "Copyright (c) 2000-2003 The Regents of the University of California. 00005 * All rights reserved. 00006 * 00007 * Permission to use, copy, modify, and distribute this software and its 00008 * documentation for any purpose, without fee, and without written agreement is 00009 * hereby granted, provided that the above copyright notice, the following 00010 * two paragraphs and the author appear in all copies of this software. 00011 * 00012 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR 00013 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00014 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF 00015 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00016 * 00017 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00018 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00019 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00020 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO 00021 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00022 * 00023 * Copyright (c) 2002-2003 Intel Corporation 00024 * All rights reserved. 00025 * 00026 * This file is distributed under the terms in the attached INTEL-LICENSE 00027 * file. If you do not find these files, copies can be found by writing to 00028 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 00029 * 94704. Attention: Intel License Inquiry. 00030 */ 00031 /* 00032 * 00033 * Authors: Philip Levis 00034 * 00035 */ 00036 00037 /* 00038 * FILE: nido.h 00039 * AUTHOR: pal 00040 * DESC: Core simulation data. 00041 * 00042 * This file declares the core structures used by NIDO, including 00043 * the global simulation state (time, etc.) and individual node state. 00044 * 00045 * This file also defines a few macros for simulation state abstraction. 00046 * 00047 */ 00048 00055 #ifndef NIDO_H_INCLUDED 00056 #define NIDO_H_INCLUDED 00057 00058 00059 /* in nesc/nesc-cpp.c, the TOSH_NUM_NODES macro is defined, so that 00060 TOSNODES is set to the value specified to the nesc compiler by the flag 00061 "-fnesc-nido-tosnodes=___" */ 00062 enum { 00063 TOSNODES = TOSH_NUM_NODES, 00064 }; 00065 00066 #ifndef DEFAULT_EEPROM_SIZE 00067 #define DEFAULT_EEPROM_SIZE (512 * 1024) // 512 KB 00068 #endif 00069 00070 enum { 00071 TOSSIM_RADIO_MODEL_SIMPLE = 0, 00072 TOSSIM_RADIO_MODEL_LOSSY = 1, 00073 TOSSIM_RADIO_MODEL_PACKET = 2 00074 }; 00075 00076 00077 #include <event_queue.h> 00078 #include <adjacency_list.h> 00079 #include <rfm_model.h> 00080 #include <adc_model.h> 00081 #include <spatial_model.h> 00082 #include <nido_eeprom.h> 00083 #include <events.h> 00084 #include <packet_sim.h> 00085 #include <sys/time.h> 00086 00087 typedef struct TOS_node_state{ 00088 long long time; // Time at which mote booted 00089 int pot_setting; 00090 } TOS_node_state_t; 00091 00092 typedef struct TOS_state { 00093 long long tos_time; 00094 int radio_kb_rate; 00095 short first_node; 00096 short num_nodes; 00097 short current_node; 00098 TOS_node_state_t node_state[TOSNODES]; 00099 event_queue_t queue; 00100 uint8_t radioModel; // Simple, lossy (bit), or packet, from above enum 00101 rfm_model* rfm; // The actual functions that implement the model 00102 adc_model* adc; 00103 spatial_model* space; 00104 bool moteOn[TOSNODES]; 00105 bool cancelBoot[TOSNODES]; 00106 00107 /* Synchronization */ 00108 bool paused; 00109 pthread_mutex_t pause_lock; 00110 pthread_cond_t pause_cond; 00111 pthread_cond_t pause_ack_cond; 00112 } TOS_state_t; 00113 00114 #define NODE_START (tos_state.first_node) 00115 #define NODE_END (tos_state.first_node + tos_state.num_nodes) 00116 00117 #define NODE_NUM (tos_state.current_node) 00118 #define THIS_NODE (tos_state.node_state[tos_state.current_node]) 00119 #define TOS_queue_insert_event(event) \ 00120 queue_insert_event(&(tos_state.queue), event); 00121 00122 extern TOS_state_t tos_state; 00123 00124 int notifyTaskPosted(char* name); 00125 int notifyEventSignaled(char* name); 00126 int notifyCommandCalled(char* name); 00127 void set_sim_rate(uint32_t); 00128 uint32_t get_sim_rate(); 00129 static void __nesc_nido_initialise(int mote); 00130 00131 #include <dbg_modes.h> 00132 00133 /* This function is here because it uses function pointers */ 00134 void tos_state_model_init(void) 00135 { 00136 tos_state.space->init(); 00137 tos_state.rfm->init(); 00138 tos_state.adc->init(); 00139 } 00140 00141 #endif 00142 |