⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tinydb.tex

📁 tinyos中文手册,是根据tinyos系统自带手册翻译过来的,虽然质量不好,但是对英文不强的人还是有用的
💻 TEX
📖 第 1 页 / 共 5 页
字号:
Event-based queries must be input in the text panel of the TinyDB GUI.  Thesyntax of these queries is as follows:\sqlquery{ON event: \\SELECT ... }Where {\tt event} is the name of the firing event.  TinyDB ships witha single event, called {\tt evtTest}, defined for demonstrationpurposes.  This event can be fired using the ``Fire Test Event''\index{Fire Test Event Command}button on the Command Window (see Figure \ref{fig:command}).  For example,the query:\sqlquery{ON evtTest: \\SELECT nodeid,light \\SAMPLE PERIOD 1024}Should cause the network to begin reporting sensor ids light values onceper second when the ``Fire Test Event'' button is clicked.\subsection{Queries Over Flash}\index{flash,buffer,in-network storage}\label{sec:flash}TinyDB includes to ability to run queries that log into the Flashmemory of the motes.  To enable this feature, you need to turn on the{\tt kMATCHBOX} option in the {\tt CompileDefines.h} header file --see Section \ref{sec:compile-defines} below for more information.Queries over flash are accessible only through the text interface ofthe TinyDB GUI.  TinyDB includes commands for creating tables thatreside in flash, for running queries that insert into these tables,for running queries the retrieve from these tables, and for deletingthese tables.  The syntax for creating a table is much like the syntaxfor creating a table in traditional SQL:\sqlquery{  CREATE BUFFER name \\  SIZE x \\  ( field1 type, \\    field2 type, \\    ... )}This creates a table named {\tt name}, with space for {\tt x} rows, where each row hasthe fields listed at the end of the query.  Field and table names may be up to 8 characterslong, and field types must be one of {\tt uint8, uint16, uint16, int8, int16} or {\tt int32},where the {\tt u} indicates unsigned fields and the number at the end of the type indicatesthe number of bits in the field.To add data to a specific table, run a query like:\sqlquery {  SELECT field1, field2, ... \\  FROM sensors \\  SAMPLE PERIOD x  \\  INTO name}The number and types of the fields appear in this query must match the number and typesof fields in the {\tt CREATE BUFFER} statement above.  The fastest rate available for loggingqueries is current 1 sample per 64 ms (values less than 64 will not work.)  Note that only onequery can log to a buffer at a time, and that new logging queries will overwrite data thatwas previously logged to a table.Finally, to select from a table, you run a query like:\sqlquery{  SELECT field1, field2, ... \\  SAMPLE PERIOD y \\  FROM name}Where the field names are the same as field names specified in the{\tt CREATE BUFFER} statement. This will fetch the logged results fromthe named buffer, starting at the beginning of the table and scanningforward.Currently, in TinyDB, you may not run a query that selects from aFlash table at the same time that a query which writes into the sametable is running.  You must stop the logging query first, using the``Stop Query'' button on the query window, or using the Stop Querycommand line tool (see Section \ref{sec:cmd-line-tools}).Finally, you can delete all tables from Flash and reset the internal state associatedwith them by running the query:\sqlquery{DROP ALL}Future versions of TinyDB will include improved ability to delete individual tables andwill support higher data rates.\subsection{Understanding Power Management and Time Synchronization}\label{sec:time-sync}When running queries longer than 4 seconds (by default), TinyDBenables power-management and time-synchronization.  This means thateach sensor is ``on'' for exactly the same four seconds of everysample period.  Results from every sensor for a particular queryshould arrive at the basestation within four seconds of each other.This time-synchronization and power management enables long runningdeployments of sensors.  To compute the expected lifetime in hours ofyour deployment, use the following calculation, assuming that thesensor draws 100 $\mu$A of current when sleeping and 12 mA ofcurrent in active mode, and you are using a pair of AA batteries thatprovide 2400 mAh of capacity, and the sample period you have selectedis $d$ seconds:$life = 2400/((4/d) * 12 + ((d-4)/d) * .1)$\noindent For example, using a sample period of 30 seconds, this results in a lifetimeof about 60 days.  A sample period of 120 seconds extends thislifetime to 200 days.There are a few caveats with power management to bear in mind:\begin{itemize}\item The basestation (mote id 0) does not sleep.  You need to provide  an always-on power source for this mote if you want to avoid  replacing its batteries every few days.\item Power management does not work on original Mica or Rene motes --  it is only supported on Mica2 and Mica2Dots.\item You can change the ``waking period'' of 4 seconds by changing the value  of the {\tt kWAKING\_CLOCKS} defined at the beginning of the file   {\tt \docroot/tos/lib/TinyDB/TupleRouterM.nc}.  Using a value less than 4 seconds  is not recommended;  increasing this value may result in an increase in the  percentage of messages that are successfully collected from the network.\end{itemize}\subsection{The Config File}\index{configuration file}\label{sec:configfile}TinyDB uses a configuration file\index{configuration} to configuresome of its settings; this file is called``tinydb.conf''\index{tinydb.conf} in the {\tt \java/tinyos/tinydb}directory.  This file consists of colon (``:'') delimited pairs ofsettings and values.  Blank lines and comments beginning with ``\%''are also allowed.  Table \ref{tab:config} summarizes the majorconfiguration file options.  The configuration file is read once whenthe TinyDB application starts.Settings in the configuration file are available to TinyDB java components via staticmethods in the {\tt Config.java} class.  {\tt Config.init(...)} is called when {\tt TinyDBMain}is instantiated.  Components can call {\tt Config.getParam(...)} to retrieve the valueof a setting;  if the setting has no value, {\tt null} is returned.\begin{table*}[tb]\noindent\tiny\begin{tabular}{|c|l|l|l|}\hlineOption & Description & Possible Values & Default \\\hline\hlineshow-command-window & Should the command window (see Figure \ref{fig:command}) be shown? & true, false & true \\default-query & The default query to show in the TinyDB text command window & Any string & none \\postgres-user & The name of the Postgres user (see Section \ref{postgres} below) & Any string & none \\postgres-passwd & The password (if any) for the specified user  & Any string & none \\postgres-db & The name of database where TinyDB results should be logged  & Any string & none \\postgres-host & The IP-address or hostname of a TCP-enabled Postgres server & A valid IP address & none \\comm-string & A communication string that specifies how & See {\tt \docroot/doc/serialcomm} & serial@COM1:57600 \\            &  TinyDB should talk to the network        &                                              &        \\  catalog-file & The XML-based catalog file that TinyDB should use & Any file & {\tt net/tinyos/tinydb/catalog.xml} \\\hline\end{tabular}\caption{Config file options and default values}\label{tab:config}\normalsize\end{table*}\subsection{Text Mode}\label{sec:textmode}TinyDB provides a very simple text mode \index{text mode} for running queries (when using the {\tt -run} command line option.)Query results are printed out to the console \index{console};  motes are reset each time a new query is posed (no interfaceto stop a currently running query or run multiple queries is currently available via this interface.)\noindent For example, posing the command (in a single mote network):\\\\{\tt java net.tinyos.tinydb.TinyDBMain -run ``select nodeid,light epoch duration 1024''}\\\\produces output resembling:\\\noindent\begin{verbatim}|    Epoch   |  nodeid  |    light  |-------------------------------------      3      |    12    |    860    |      4      |    12    |    860    |      5      |    12    |    861    |      8      |    12    |    860    |      9      |    12    |    879    |      11     |    12    |    860    |      12     |    12    |    860    |...\end{verbatim}\subsection{The LEDS}\index{LEDS}The LEDS\index{LEDS} on TinyDB motes are used to indicate the current status of the device;  each LED is usedto communicate one of several pieces of information, depending on the current status of themote.  A simple selection query should cause the mote to blink its yellow LED once per epoch, and itsred LED once per data value forwarded up the tree. The following table summarizes otherLED actions by mote status:\vspace{.1in}\tiny\noindent\begin{tabular}{|l|l|l|}\hlineMote Status & LED Response & Notes \\\hline\hlineSent Message & Red Toggle & \\Received Aggregate From Child & Green Toggle & \\End of Epoch & Yellow Toggle & Once per query \\Aborted Query & All LEDS On & \\Reset Mote & All LEDS Flash & \\\hline\end{tabular}\normalsize\\\subsection{Debugging and Status Tools}\index{sec:debugging}TinyDB includes several debugging and status tools that can be enabledto help understand the status of running devices.The most important new tool that is available is the TinyOS simulator(TOSSIM) -- to learn how use TinyDB in TOSSIM, see Section\ref{sec:tossim} of this document.Three other tools for debugging running motes are available.  The first is the status panel and status command.  The status panel now appears when the TinyDBGUI is started, as shown in Figure \ref{fig:status-panel}.  It provides a listof queries currently running on the basestation mote and can be used to tellif a particular query was successfully injected into the network.\begin{figure}\centering\includegraphics[width=3in]{status}\caption{The TinyDB Status Window.}\label{fig:status-panel}\end{figure}The second tool is the {\tt UARTDebuggerM.nc}, which is a component for driving anexternal serial display.  To enable support for this component, you must enablethe {\tt kUART\_DEBUGGER} option in {\tt CompileDefines} -- see Section \ref{sec:compiledefines}for more information.  A serial display can be used to print status messages as the mote is running.  The {\tt \docroot/tos/lib/Util/UartDebuggerM.nc} fileincludes information about purchasing such a display and interfacing it to amote.Finally, if you have access to an AVR JTAG debugger, you can debug your mote usinggdb.  See the documentation with the TinyOS release in {\tt \docroot/doc/nesc/debugging.html}.\section{Configuring The TinyDB Sensor Application}Although the basic version of TinyDB will run without modification on the basic Moteplatforms, there are some advanced options and configuration files for the TinyDBAppnesC application that advanced users may wish to configure.  Changes made in this sectionwill require you to recompile the mode-side software and reinstall it on your motes.\subsection{Support for Different Hardware Platforms and Sensor Boards}\label{sec:sb-config}This section describes the steps involving in configuring TinyDB touse a different sensor board or adding support for a new sensor boardto TinyDB.  The components used to support the different sensorboardhardware are stored in individual directories in the {\tt  \docroot/tos/sensorboards} directory.  Each of these directoriescontains a {\tt sensorboard.h} file that defines the ADC ports used by

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -