AFVA | Mitchell Posted March 7, 2010 Report Posted March 7, 2010 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 Quote
Administrators simpilot Posted March 7, 2010 Administrators Report Posted March 7, 2010 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. Quote
Moderators mark1million Posted March 7, 2010 Moderators Report Posted March 7, 2010 And would be willing to pay!!!!!! :lol: Quote
Administrators Nabeel Posted March 7, 2010 Administrators Report Posted March 7, 2010 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 =\ Quote
AFVA | Mitchell Posted March 7, 2010 Author Report Posted March 7, 2010 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... Quote
Moderators mark1million Posted March 7, 2010 Moderators Report Posted March 7, 2010 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. Quote
AFVA | Mitchell Posted March 7, 2010 Author Report Posted March 7, 2010 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...) Quote
Moderators mark1million Posted March 7, 2010 Moderators Report Posted March 7, 2010 Maybe this might help http://www.devx.com/getHelpOn/10MinuteSolution/20356 Quote
Administrators Nabeel Posted March 7, 2010 Administrators Report Posted March 7, 2010 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 Quote
AFVA | Mitchell Posted March 8, 2010 Author Report Posted March 8, 2010 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: Quote
Administrators Nabeel Posted March 8, 2010 Administrators Report Posted March 8, 2010 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 Quote
AFVA | Mitchell Posted March 8, 2010 Author Report Posted March 8, 2010 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 Quote
Administrators Nabeel Posted March 8, 2010 Administrators Report Posted March 8, 2010 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 Quote
Guest lorathon Posted March 9, 2010 Report Posted March 9, 2010 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#. Quote
Administrators Nabeel Posted March 9, 2010 Administrators Report Posted March 9, 2010 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 Quote
Guest lorathon Posted March 12, 2010 Report Posted March 12, 2010 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# Quote
Administrators Nabeel Posted March 12, 2010 Administrators Report Posted March 12, 2010 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> Quote
Guest lorathon Posted March 12, 2010 Report Posted March 12, 2010 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? Quote
Guest lorathon Posted March 12, 2010 Report Posted March 12, 2010 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? Quote
Guest lorathon Posted March 12, 2010 Report Posted March 12, 2010 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); Quote
Administrators Nabeel Posted March 12, 2010 Administrators Report Posted March 12, 2010 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 Quote
AFVA | Mitchell Posted March 12, 2010 Author Report Posted March 12, 2010 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 Quote
Administrators Nabeel Posted March 13, 2010 Administrators Report Posted March 13, 2010 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 Quote
AFVA | Mitchell Posted March 13, 2010 Author Report Posted March 13, 2010 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 Quote
Administrators Nabeel Posted March 13, 2010 Administrators Report Posted March 13, 2010 I would run a counter for the time, since the start/end times could be in different timezones. Quote
AFVA | Mitchell Posted March 13, 2010 Author Report Posted March 13, 2010 FSUIPC reads the UTC time so it wouldn't make difference, plus i cant find the code to time stuff. Quote
Administrators Nabeel Posted March 13, 2010 Administrators Report Posted March 13, 2010 http://www.google.com/#hl=en&source=hp&q=visual+basic+subtract+times&aq=f&aqi=&aql=&oq=&fp=93b6e195ecf679eb There's a datediff function, but see Quote
Moderators mark1million Posted March 13, 2010 Moderators Report Posted March 13, 2010 This is where the times get difficult, get it to read server time and make sure server time is set to utc. Quote
Guest lorathon Posted March 13, 2010 Report Posted March 13, 2010 I use a counter for flight time. Much easier and more accurate. Relying on FS time is not a good idea. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.