Jump to content

Recommended Posts

Posted

Hello all,

I am coding an private ACARS program for our VA. I need to know what format phpVMS can receive pilot reports. The program is all in Visual Basic with the log stored in a Rich Text box. Maybe convert that to XML or something?

Thanks,

Mitch

  • Administrators
Posted

Nabeel has built it to recieve xml the easiest. It also seems to be the cleanest way to do it. I think I can speak for most in saying we would love to see a dedicated ACARS system built to phpVMS standards.

  • Administrators
Posted

Yes, I would say XML. You'd create a module, and send your XML as POST data to that url. Like:

http://support.microsoft.com/kb/311294

<myacars>
<pilotid>XXX</pilotid>
<date>XXX</date>
<pirepdetails>
<flightnum>XXXYYYY</flightnum>
<depicao>KJFK</depicao>
... etc
</pirepdetails>
</myacars>

So that string would get sent as POST data (?pirepxml=THE_XML_STRING) to this URL:

index.php/myacars/pirep

Which we create a module for, with all the functions we need

class MyACARS extends CodonModule
{

/**
* Receieves PIREP
* index.php/myacars/pirep
*/
public function pirep()
{
$pirep_xml = $this->post->pirepxml;
$xml = simplexml_load_string($pirep);


// Then you'd fill in the data array and submit
$pirep_data = array(
	 'pilotid' => $xml->pilotid,
	 'flightnum' => $xml->pirepdetails->flightnum,
	 'depicao' => $xml->pirepdetails->depicao,
	 // ... fill in everything else
);

// This submits the PIREP
$submit = ACARSData::filePIREP($pirepdata):
}
}

It'll be the same thing for status messages. I can write the basic class for you if you want, but it's basically the same as the FSFK module which is there. The data structures are there. FSFK doesn't do status messages in XML, but if I were you, I'd do EVERYTHING in XML, it makes life 100000% easier. No string parsing, just PHP handles all the parsing work, you just get the references.

But check out the FSFK module, it has the code to translate the aircraft registration into the ID (which is how the PIREP data structure needs it),

And I think VB can easily read an INI file (I know in C# it's pretty simple), for settings,

so you'd create a template, I can help you out when you get to here too, so then a pilot

can download their config file

[settings]
pilotid=VMS0001
baseurl=http://dev.phpvms.net/
pirepurl=index.php/myacars/pirep
statusurl=index.php/myacars/status

I've been looking into developing something as well, but I haven't had the time =\

Posted

Anybody happen to have any VB knowledge?

I am getting really confused when it comes to: Creating the XML, Reading data from the rich text log and flight plan page, Sending to Server, Receiving at server

Thanks,

Mitch

(tried to read that link Nabeel sent me though it confused the hell out of me...)

Posted

I wonder if this works:

The log is written in XML format, when the user ends then sends the log the program saves it as a temporary XML then sends it to the website.

I think that will probably be the simplest way...

What the log looks like pre-flight:

1268064026.jpg

Posted

Anyone know the VB code to simply save a .xml file using data from a rich text box. Once thats done i can move onto the sending part :o

And also would help ALOT if someone could provide code for the XML post function...cause all the links i go to always confuse me.

Sorry if im asking for too much,

Mitch

  • Administrators
Posted

You should be tracking things internally, not in some text field. Like, you'd build the data at the end and send i tout.

I could build the phpVMS side for you if you'd like. Let me know what you have for your XML so far, I can shape it up into what I'd need - for status updates and also for PIREPs

Guest lorathon
Posted

I have been reading this and it has interested me.

I have already developed a custom ACARS system but am using a bit different method to post.

It is still a webrequest but the string is sent to "http::/mysite.com/action.php/pirep/update"

With the string formatted as such "var1=xxxx&var2=yyyy&var3=zzzzz". For simple items I use this method.

For more data I am sending it delimited with "/" then spilt and assigned to the correct variables in the module. On some I even split twice, First into rows and then into fields. "|" first split and then "/" second split.

Is the advantage of using XML that you not not have to split and assign? And I am thinking that if I change to XML I need to have the same variable names sent from the application as are used in the module, is this correct? This ACARS is developed using C#.

  • Administrators
Posted

I have been reading this and it has interested me.

I have already developed a custom ACARS system but am using a bit different method to post.

It is still a webrequest but the string is sent to "http::/mysite.com/action.php/pirep/update"

With the string formatted as such "var1=xxxx&var2=yyyy&var3=zzzzz". For simple items I use this method.

For more data I am sending it delimited with "/" then spilt and assigned to the correct variables in the module. On some I even split twice, First into rows and then into fields. "|" first split and then "/" second split.

Is the advantage of using XML that you not not have to split and assign? And I am thinking that if I change to XML I need to have the same variable names sent from the application as are used in the module, is this correct? This ACARS is developed using C#.

Exactly, there's no splitting or anything involved. Especially for something like a route, but you can split it down into any depth. Something like:

<flightinfo>
<pilotid>VMS0001</pilotid>
<depicao>KJFK</depicao>
<arricao>KBOS</arricao>
<route>
	<segment timereached="10:25am">XYZ</segment>
	<segment timereached="10:32am">ABC</segment>
</route>
</flight>

Is simply:

$xml = simplexml_load_string($xml_string);
$xml->flightinfo->depicao;

Or:
foreach($xml->routeinfo->route->segment as $segment)
{ 
echo $segment['timereached']; // echos the time
echo $segment; // echos ABC or XYZ
}

Instead of parsing the ugly ugly mess of explode()ing pipes and carrets and fields.

Also, keep in mind that $_GET requests (the query string) have a character limit, which is why FSACARS has to send multiple requests with all the data - which is also why it breaks alot, because many times those multiple requests don't go through. Always do a post request as &xml=..., and you can load that easil.

The variable names can be anything you want, as long as it's mapped to that data structure which is passed to filePIREP(). But with XML you can order it any way you want, whatever works for you, without having to worry about breaking the mess of splits and explodes

Guest lorathon
Posted

So I have been messing with this and can get the XML to send but it does not seem to be being recognized.

XML sent

<verify>
 <pilotid>id</pilotid>
 <password>pw</password>
</verify>

php sent to

public function verify()
{
	$rec_xml = $this->post->RECxml;
	$xml = simplexml_load_string($rec_xml);

	echo $xml->verify->pilotId;
	echo $xml->verify->password;
	echo "Made it";
}

the only return I get is the "Made it". Does the post need to be named the same? 1st element in the XML? And what about returns? Can a XML return be coded to my application? I also send the XML directly to my text box and it seems to be formatted correctly.

I am converting the XML to a string and then use WebRequest to send it. Is that my problem? Converting it to a string?

FYI - Using C#

  • Administrators
Posted

Can you try print_r($xml) and print_r($this->post) to see what they're outputting?

Also, it should be:

<?xml version="1.0" encoding='UTF-8'?>
<verify>
<pilotid>id</pilotid>
<password>pw</password>
</verify>

Guest lorathon
Posted

I am not getting anything in the post.

I have tried many different ways. Right now I am writing the info into an xml file. I can see that it looks correct. Then reading the file into a string and sending as post using WebRequest.

File Contents.

<?xml version="1.0" encoding="utf-8"?>
<!--kACARS-->
<verify>
 <pilotid>xcvxcvxcvx</pilotid>
 <password>xcvcvxcvx</password>
</verify>

PHP code

public function verify()
{

	echo "start";
	print_r ($this->post->RECxml);
	$rec_xml = $this->post->RECxml;
	$xml = simplexml_load_string($rec_xml);		

	echo $xml->verify->pilotId;
	eecho $xml->verify->password;
	echo "end";
}

The only return I get is the start/end. Does it matter what this is? $this->post->RECxml or is what ever posted going to file it no matter what it is called?

Guest lorathon
Posted

So I have messed around with the php side to see if anything is coming through.

Changed it to

public function verify()
{
	if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
	{ 
   	    $postText = file_get_contents('php://input');		

		echo "start";
		echo $postText;
		$rec_xml = $postText;
		$xml = simplexml_load_string($rec_xml);		

		echo $xml->verify->pilotid;
		echo $xml->verify->password;
		echo "end";
	}
}

The echo $postText; returns the following

<?xml version="1.0" encoding="utf-8"?>
<!--kACARS-->
<verify>
 <pilotid>vnvn</pilotid>
 <password>vnvbn</password>
</verify>

But nothing still coming from other echos (besides the Start/End). Is the XML coming through correctly? What am I doing wrong?

Guest lorathon
Posted

FYI -

I could not get this to work

$rec_xml = $this->post->RECxml;
$xml = simplexml_load_string($rec_xml);

But this works just fine

if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
               { 
           $postText = file_get_contents('php://input');
           $rec_xml = $postText;
           $xml = simplexml_load_string($rec_xml);       

  • Administrators
Posted

Yup, you'd have to use the php://input. But it depends how you're sending it. If you're assigning it to a variable and sending it, then it will use the $this->post->variable_name.

Glad it's working though. Much easier to parse :)

Posted

The php code so far:

class WACARS extends CodonModule
{

// Receive the XML
public function pirep()
{
$pirep_xml = $this->post->pirepxml;
$xml = simplexml_load_string($pirep);


// Process the data
$pirep_data = array(
        'pilotid' => $xml->pilotid,
        'flightnum' => $xml->flightnum,
        'depicao' => $xml->depicao,
        'arricao' => $xml->arricao,
        'aircraft' => $xml->reg,
);

// Submit the data to the SQL
$submit = ACARSData::filePIREP($pirepdata);
}
}

That code above is just the basics of what I am working on.

I have the basic XML being generated, just need to code the sending off part and finish the php stuff and then release it!

Thanks,

Mitch

  • Administrators
Posted

Yup, you're on your way Mitchell... that $pirepdata array is this:

$data = array(
'pilotid' => $pilotid,
'code' => $code,
'flightnum' => $flightnum,
'depicao' => $_GET['origin'],
'arricao' => $_GET['dest'],
'aircraft' => $ac->id,
'flighttime' => $flighttime,
'landingrate' => $landingrate,
'submitdate' => 'NOW()',
'comment' => $comment,
'fuelused' => $_GET['fuel'],
'source' => 'fsacars',
'load' => $load,
'rawdata' => $log,
'log'=> $_GET['log']
);

The pilotid is the numeric ID. The aircraft is the numeric ID. the Comment is optional

Posted

Thanks nabeel, will have a play around to change stuff.

Plus, anyone know how to subtract times in VB?

e.g

12:30 - 12:20 = :20 (20 minutes total time)

The way i use it is the when the log starts i capture the FS time and when the log ends it captures the time again. They are stored in blocka.Text and blockb.Text

Once caculated it will move the answer to totalhours.text then when you hit send log it will read the data, convert it to XML then send it off.

Thanks in advance,

Mitch

Guest lorathon
Posted

I use a counter for flight time. Much easier and more accurate. Relying on FS time is not a good idea.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...