Sending Data to the VMS from A Program

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

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.

And would be willing to pay!!! :lol:

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 =\

Thanks everyone!

I am now planning to release this program publicly so your VA can enjoy it too.

But anyway, time to head back to Visual Studio…

Now that will be impressive!!!

Cant wait for the release.

To say im excited is a understatement. If i can help along the way some how just let me know.

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…)

Maybe this might help

http://www.devx.com/getHelpOn/10MinuteSolution/20356

That link I sent is for sending the data via post.

http://www.c-sharpcorner.com/UploadFile/mahesh/writexmlusingXmlWriter11132005233450PM/writexmlusingXmlWriter.aspx

In that, the writer should have a toString() method or something to pass into the code which sends by POST

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:

Yes, you could save the xml file, in case sending fails, it can be loaded and sent again.

Here’s a few other links:

http://robz.homedns.org:8080/blog/archive/2005/02/25/387.aspx

http://developer.yahoo.com/dotnet/howto-rest_vb.html

http://p2p.wrox.com/vb-net/5447-post-xml-using-xmlhttp-vbulletin-net.html

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

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

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

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

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>

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

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

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

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

I would run a counter for the time, since the start/end times could be in different timezones.