summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbothorel2002-12-16 17:22:00 +0000
committerbothorel2002-12-16 17:22:00 +0000
commit535f0402adcb3ac3102725c4828f56819241fca7 (patch)
tree5a1c93298299778c3095a8ca1be3a6bb583ac660
parent23abb4b87c7e40ed259dd02f653516f60e55ade4 (diff)
downloadtransduct-535f0402adcb3ac3102725c4828f56819241fca7.zip
transduct-535f0402adcb3ac3102725c4828f56819241fca7.tar.gz
transduct-535f0402adcb3ac3102725c4828f56819241fca7.tar.bz2
transduct-535f0402adcb3ac3102725c4828f56819241fca7.tar.xz
Initial revision
-rw-r--r--data/transduct_exemple.xml25
-rw-r--r--debian/README.debian6
-rw-r--r--debian/changelog0
-rw-r--r--debian/control10
-rw-r--r--debian/copyright8
-rw-r--r--debian/dirs1
-rw-r--r--debian/files1
-rwxr-xr-xdebian/rules53
-rwxr-xr-xsrc/transduct177
9 files changed, 281 insertions, 0 deletions
diff --git a/data/transduct_exemple.xml b/data/transduct_exemple.xml
new file mode 100644
index 0000000..a63aa31
--- /dev/null
+++ b/data/transduct_exemple.xml
@@ -0,0 +1,25 @@
+<?xml version='1.0' ?>
+<!DOCTYPE transduct SYSTEM "transduct.dtd">
+
+<transduct>
+ <message>
+ <input name="^.* Down control=RCATV1 button=volume up" />
+ <output>
+ <item msg="RAISE program1" />
+ <item msg="HIDE program2" />
+ </output>
+ </message>
+ <message>
+ <input name="^.* Down control=RCATV1 button=channel up" />
+ <output>
+ <item msg="RAISE program2" />
+ <item msg="HIDE program1" />
+ </output>
+ </message>
+ <message>
+ <input name="ProcessItems item1=(.*) item2=(.*) item3=(.*)" />
+ <output>
+ <item msg="NewOrder item2=$2 item3=$3 item1=$1" />
+ </output>
+ </message>
+</transduct>
diff --git a/debian/README.debian b/debian/README.debian
new file mode 100644
index 0000000..ba64366
--- /dev/null
+++ b/debian/README.debian
@@ -0,0 +1,6 @@
+voiceplugin for DEBIAN
+----------------------
+
+Comments regarding the Package
+
+Gwenael Bothorel <bothorel@cena.dgac.fr>, Fri, 23 Apr 1999 16:25:58 +0200
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debian/changelog
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..425ef19
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,10 @@
+Source: transduct
+Section: toccata
+Priority: extra
+Maintainer: Gwenael Bothorel <bothorel@cena.fr>
+Standards-Version: 0.0.0.0
+
+Package: transduct
+Architecture: all
+Depends:
+Description: transduct, a transductor for Ivy messages
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..ae67089
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,8 @@
+This package was debianized by Gwenael Bothorel bothorel@cena.fr on
+Fri, 23 Apr 1999 16:25:58 +0200.
+
+It was downloaded from <fill in ftp site>
+
+Copyright:
+
+C.E.N.A (Centre d'Etudes de la Navigation Aérienne)
diff --git a/debian/dirs b/debian/dirs
new file mode 100644
index 0000000..e772481
--- /dev/null
+++ b/debian/dirs
@@ -0,0 +1 @@
+usr/bin
diff --git a/debian/files b/debian/files
new file mode 100644
index 0000000..ee6fda0
--- /dev/null
+++ b/debian/files
@@ -0,0 +1 @@
+transduct_0.0.0_all.deb toccata extra
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..88c103f
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,53 @@
+#!/usr/bin/make -f
+# Made with the aid of debmake, by Christoph Lameter,
+# based on the sample debian/rules file for GNU hello by Ian Jackson.
+
+package=transduct
+
+build:
+ $(checkdir)
+ touch build
+
+clean:
+ $(checkdir)
+ -rm -f build
+ -rm -f `find . -name "*~"`
+ -rm -rf debian/tmp debian/files* core debian/substvars
+
+binary-indep: checkroot build
+ $(checkdir)
+# There are no architecture-independent files to be uploaded
+# generated by this package. If there were any they would be
+# made here.
+
+binary-arch: checkroot build
+ $(checkdir)
+ -rm -rf debian/tmp
+ install -d debian/tmp
+ cd debian/tmp && install -d `cat ../dirs`
+ install -d debian/tmp/usr/lib/$(package)
+ install -m755 src/transduct debian/tmp/usr/bin/$(package)
+ install -m644 src/*.pm data/*.gif debian/tmp/usr/lib/$(package)
+ install -d debian/tmp/usr/share/man/man1
+ pod2man src/$(package) > debian/tmp/usr/share/man/man1/$(package).1
+# Must have debmake installed for this to work. Otherwise please copy
+# /usr/bin/debstd into the debian directory and change debstd to debian/debstd
+ debstd -c -d
+ dpkg-gencontrol
+ chown -R root.root debian/tmp
+ chmod -R go=rX debian/tmp
+ dpkg --build debian/tmp ..
+
+define checkdir
+ test -f debian/rules
+endef
+
+# Below here is fairly generic really
+
+binary: binary-indep binary-arch
+
+checkroot:
+ $(checkdir)
+ test root = "`whoami`"
+
+.PHONY: binary binary-arch binary-indep clean checkroot
diff --git a/src/transduct b/src/transduct
new file mode 100755
index 0000000..38561ae
--- /dev/null
+++ b/src/transduct
@@ -0,0 +1,177 @@
+#!/usr/bin/perl -w
+#
+# transduct, an Ivy transductor
+#
+# Copyright (C) 2002
+# Centre d'Études de la Navigation Aérienne
+#
+# Main
+#
+# Authors: Gwenael Bothorel <bothorel@cena.dgac.fr>
+#
+# $Id$
+#
+
+use Ivy;
+use strict;
+use Getopt::Long;
+use XML::Parser;
+require File::Basename;
+
+my $bus = ":2010";
+my $verbose = undef;
+my $filename = undef;
+my $help = undef;
+my $app_name = "TRANSDUCT";
+my $num_message = 0;
+my @outputs;
+my @outputtoggles;
+my $max_nb_parameters = 10;
+my %toggled_message;
+my $output_type = undef;
+
+my %options = ('bus=s', \$bus,
+ 'verbose', \$verbose,
+ 'file=s', \$filename,
+ 'help', \$help);
+GetOptions (%options);
+
+if ($help) {
+ Usage ();
+ exit;
+}
+
+if (! $filename) {
+ print "Transductor file is mandatory\n";
+ Usage (),
+ exit;
+}
+
+# Niveau de verbosité :
+# 0 : très verbeux
+# 1 : moins verbeux
+#
+if (defined $verbose) {
+ $verbose = 0;
+ Verbose (__LINE__, 0, "Verbose=yes");
+} else {
+ $verbose = 1;
+ Verbose (__LINE__, 0, "Verbose=no");
+}
+
+Ivy->init (-loopMode => 'LOCAL', -appName => $app_name, -ivyBus => $bus);
+my $ivy = Ivy->new (-ivyBus => $bus, -appName => $app_name);
+$ivy->start;
+
+my $p = XML::Parser->new(Style => 'Subs');
+$p->parsefile ($filename);
+
+$ivy->mainLoop;
+
+###############################################################################
+
+sub Verbose {
+ my ($line, $value, $msg) = @_;
+
+ if ($value >= $verbose) {
+ my $FILE = File::Basename::basename (__FILE__);
+ print "$FILE:$line: $msg\n";
+ }
+}
+
+sub Usage {
+ print "Usage : transduct --file transductor_file [--bus my_bus] [--verbose] [--help]\n";
+ print "Options :\n";
+ print " --file : transductor file\n";
+ print " --bus : Ivy bus\n";
+ print " --verbose : verbose mode\n";
+ print " --help : help\n";
+}
+
+sub message {
+ $num_message++;
+ Verbose (__LINE__, 0, "A new message");
+}
+
+sub input {
+ Verbose (__LINE__, 0, "A new input");
+ my ($parser, $elementname, %attrs) = @_;
+ (my $name) = $attrs{name};
+ Verbose (__LINE__, 0, "input <$name>");
+ $ivy->bindRegexp ("$name", [\&CB_Callback, $num_message]);
+ if ($attrs{type}) {
+ my $type = $attrs{type};
+ if ($type eq "toggle") {
+ $toggled_message{$num_message} = 0;
+ }
+ }
+}
+
+sub output {
+ Verbose (__LINE__, 0, "A new output");
+ $output_type="normal";
+}
+
+sub outputtoggle {
+ Verbose (__LINE__, 0, "A new outputtoggle");
+ $output_type="toggled";
+}
+
+sub item {
+ Verbose (__LINE__, 0, "A new item");
+ my ($parser, $elementname, %attrs) = @_;
+ (my $msg) = $attrs{msg};
+ Verbose (__LINE__, 0, "output item <$msg>");
+
+ if($output_type eq "normal") {
+ if (! $outputs[$num_message]) {
+ $outputs[$num_message] = $msg;
+ } else {
+ $outputs[$num_message] .= " , $msg";
+ }
+ } else {
+ if (! $outputtoggles[$num_message]) {
+ $outputtoggles[$num_message] = $msg;
+ } else {
+ $outputtoggles[$num_message] .= " , $msg";
+ }
+ }
+}
+
+sub CB_Callback {
+ my ($who, $num, @tab) = @_;
+ my $toggled = undef;
+ Verbose (__LINE__, 0, "Message num = $num");
+# for (my $i = 0; $i < $max_nb_parameters; $i++) {
+# if ($tab[$i]) {
+# print " <$tab[$i]>";
+# }
+# }
+# print "\n";
+
+ if (defined $toggled_message{$num}) {
+ if ($toggled_message{$num} == 0) {
+ Verbose (__LINE__, 0, "The toggle button was off");
+ $toggled_message{$num} = 1;
+ } else {
+ Verbose (__LINE__, 0, "The toggle button was on");
+ $toggled_message{$num} = 0;
+ my @tab_msgs = split (/ , /, $outputtoggles[$num]);
+ foreach my $item (@tab_msgs) {
+ for (my $i = 0; $i < $max_nb_parameters; $i++) {
+ $item =~ s/\$$i/$tab[$i-1]/;
+ }
+ $ivy->sendMsgs ($item);
+ }
+ return;
+ }
+ }
+
+ my @tab_msgs = split (/ , /, $outputs[$num]);
+ foreach my $item (@tab_msgs) {
+ for (my $i = 0; $i < $max_nb_parameters; $i++) {
+ $item =~ s/\$$i/$tab[$i-1]/;
+ }
+ $ivy->sendMsgs ($item);
+ }
+}