mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-07 17:49:49 +08:00
*** empty log message ***
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package Paparazzi::Configuration;
|
||||
|
||||
use strict;
|
||||
use XML::Parser;
|
||||
use XML::DOM;
|
||||
|
||||
use Paparazzi::Environment;
|
||||
|
||||
|
||||
sub read_current {
|
||||
my $filename = Paparazzi::Environment::paparazzi_home()."/conf/conf.xml";
|
||||
my $parser = XML::DOM::Parser->new();
|
||||
my $doc = $parser->parsefile($filename);
|
||||
my $conf = $doc->getElementsByTagName('conf')->[0];
|
||||
return parse($conf);
|
||||
}
|
||||
|
||||
sub parse {
|
||||
my ($conf) = @_;
|
||||
my @ret = ();
|
||||
my @aircrafts = $conf->getElementsByTagName('aircraft');
|
||||
foreach my $aircraft (@aircrafts) {
|
||||
push @ret, parse_aircraft($aircraft);
|
||||
}
|
||||
my $xml_ground = $conf->getElementsByTagName('ground')->[0];
|
||||
my $ground = parse_ground($xml_ground);
|
||||
return { ground => $ground, aircrafts => \@ret};
|
||||
}
|
||||
|
||||
sub parse_aircraft {
|
||||
my ($aircraft) = @_;
|
||||
return {
|
||||
ac_id => $aircraft->getAttribute('ac_id'),
|
||||
name => $aircraft->getAttribute('name'),
|
||||
airframe => $aircraft->getAttribute('airframe'),
|
||||
radio => $aircraft->getAttribute('radio'),
|
||||
flight_plan => $aircraft->getAttribute('flight_plan'),
|
||||
};
|
||||
}
|
||||
|
||||
sub parse_ground {
|
||||
my ($ground) = @_;
|
||||
return {
|
||||
name => $ground->getAttribute('name'),
|
||||
ivy_bus => $ground->getAttribute('ivy_bus')
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,28 @@
|
||||
package Paparazzi::Ploter;
|
||||
|
||||
use Paparazzi::Environment;
|
||||
|
||||
use Expect;
|
||||
|
||||
sub gen_plot {
|
||||
my ($terminal, $filename, $plot_cmd ) = @_;
|
||||
|
||||
my $set_terminal_cmd = "set terminal $terminal";
|
||||
my $set_output_cmd = "set output \"".Paparazzi::Environment::paparazzi_home()."/var/plot/$filename\"";
|
||||
my $print_cmd = "$set_terminal_cmd; $set_output_cmd; $plot_cmd";
|
||||
my $exp = new Expect();
|
||||
$exp->raw_pty(1);
|
||||
$Expect::Debug = 10;
|
||||
my $pid = $exp->spawn("/usr/bin/gnuplot", ("-geometry", "1x1+0+0")) or printf "Don't find gnuplot";
|
||||
$pid->log_stdout(0);
|
||||
# print("Printing $print_cmd <br>\n");
|
||||
$exp->send($print_cmd."\n");
|
||||
my $timeout = 1;
|
||||
my $foo = $exp->expect($timeout);
|
||||
$exp->hard_close();
|
||||
return "http://ornette:8889/var/plot/".$filename;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user