#! perl -slw use strict; use IO::Socket; use XML::Simple; $\="\n"; for (;;){ ################################# #Waypoint Functions: print "%%% Waypoint GO %%%"; open TEMP, '<', '/home/uas/Scripts/WP/waytemp' or die "cannot open 'waytemp' $!"; open FINAL, '<', '/home/uas/Scripts/WP/wayfinal' or die "cannot open 'wayfinal' $!"; #check for a new waypoint file my @tstat = stat(TEMP); my @fstat = stat(FINAL); #If waytemp is newer send it to VC if ($tstat[9] >= $fstat[9]) { print "### NEW File ###"; my $xml = new XML::Simple ( RootName => 'Task', XMLDecl => '', ForceArray => [ 'ID' ]); my @temp = ; my @final = ; close TEMP; close FINAL; my @waypoints; my $count = 0; foreach (@temp) { my @point = split(',', $_); push(@waypoints, "{'Longitude' => '$point[0]', 'Latitude' => '$point[1]', 'SequenceNumber' => '$count'}"); $count++; } print "### Create XML ###"; my $waydata= { 'xmlns' => "http://Task.CUIntegration.com", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xsi:schemaLocation' => "http://Task.CUIntegration.com Task.xsd ", 'ID' => 'ID', 'Type' => ['Loop'], 'Destination' => ['Velocity'], 'Waypoint' => [ "@waypoints"], }; print $waydata; my $textdata = $xml->XMLout($waydata); print $textdata; #print "--- SENDING ---"; #send($way_client, $textdata, 0); print "%%% DONE %%%"; } print "SLEEP"; sleep 10; } #### %%% Waypoint GO %%% ### NEW File ### ### Create XML ### HASH(0x97dbeb8) Velocity Loop {'Longitude' => '40.56', 'Latitude' => ' -106.25 ', 'SequenceNumber' => '0'} {'Longitude' => '38.89', 'Latitude' => ' -1 05.44 ', 'SequenceNumber' => '1'} {'Longitude' => '40.31', 'Latitude' => ' -1 03.82', 'SequenceNumber' => '2'} %%% DONE %%% SLEEP #### ID Loop Velocity