[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/tinysql
TextLogger.java, NONE, 1.1 expdecay.mt, NONE, 1.1 tinysql, NONE, 1.1
David Gay
idgay at users.sourceforge.net
Sat Oct 29 10:24:25 PDT 2005
Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/tinysql
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31004
Added Files:
TextLogger.java expdecay.mt tinysql
Log Message:
tinysql stuff
--- NEW FILE: TextLogger.java ---
// $Id: TextLogger.java,v 1.1 2005/10/29 17:24:23 idgay Exp $
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2005 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
import java.util.*;
import net.tinyos.packet.*;
public class TextLogger implements PacketListenerIF
{
static String[] fields;
public void addResult(Object[] results) {
System.out.print(System.currentTimeMillis());
for (int i = 0; i < results.length; i++) {
System.out.print(", ");
System.out.print(results[i]);
}
System.out.println();
}
public void packetReceived(byte[] packet) {
int offset;
if (packet[2] == 0x2b || packet[2] == 0x2c)
offset = 12;
else if (packet[2] == 0x2a)
offset = 5;
else
return;
if (packet[4] - (offset - 5) != 2 * fields.length) {
System.err.println("invalid packet length\n");
return;
}
Object[] result = new Object[fields.length];
for (int i = 0; i < fields.length; i++) {
int val = ((packet[offset + 2 * i]) & 0xff) |
((packet[offset + 2 * i + 1]) & 0xff) << 8;
result[i] = new Integer(val);
}
addResult(result);
}
public static void main(String[] args) {
fields = args;
TextLogger logger = new TextLogger();
PhoenixSource source = BuildSource.makePhoenix(null);
source.setResurrection();
source.registerPacketListener(logger);
source.run();
}
}
--- NEW FILE: expdecay.mt ---
any expdecay_make(bits) vector(bits, 0);
any expdecay_get(s, val)
s[1] = s[1] - (s[1] >> s[0]) + (val >> s[0]);
--- NEW FILE: tinysql ---
#!/usr/bin/perl
for ($i = 0; $i <= $#ARGV; $i++) {
$_ = $ARGV[$i];
if (/^-/) {
if (/^-h$/ || /^--help$/) {
&usage();
exit 0;
}
}
else {
if (!defined($action)) {
$action = $_;
}
elsif (!defined($query)) {
$query = $_;
}
else {
print "Ignoring extra argument $_\n";
}
}
}
$tmpf = "xxx";
$qfile = "$ENV{HOME}/.tinysql_query";
if ($action eq "start") {
$install = 1;
$log = 1;
}
if ($action eq "compile") {
system("echo \"$query\" | sqlgen | tee $tmpf");
system("mload -c $tmpf");
exit 0;
}
if ($action eq "install" || $install) {
system("echo \"$query\" | sqlgen > $qfile");
system("mload $qfile");
}
if ($action eq "log" || $log) {
open QUERY, $qfile or die;
while (<>) {
if (m!^// SCHEMA: (.*)!) {
#@schema = split / /, $1;
$schema = $1;
}
}
close QUERY;
die if !defined(@schema);
system("java TextLogger $schema");
}
More information about the Tinyos-commits
mailing list