Translations for our friends around the world.

Click on banner for Tacview website

Author Topic: Linking DCS to a virtual airline software.  (Read 662 times)

0 Members and 1 Guest are viewing this topic.

Offline neon

  • New member
  • *
  • Posts: 8
Linking DCS to a virtual airline software.
« on: August 19, 2019, 03:55:49 AM »
Ok so I am attempting to start using a virtual airline website to track flight hours, fuel, ect. On other flight sims you use a set of software called ACARS and normally after you are done flying it reports to the website and submits a PIREP. Now from what I understand the flight sim community used the real airline lingo because what they do and what they do in the real world are two different things.

So what I am trying to figure out is how I can get dcs or some other software to take the info and report it to the site. In other sims (P3D, FSX, Xplane 11) they have to use software called UIPC to get the information from the sim live.

So someone pointed out that tacview does this already and should talk to you guys to get help. If I can find some way to pull the needed info from the ACMI and then push it to the site I would be set. From what I can tel if I can figure out how to convert the info I can write a script to pull the info out, convert it to the format that is needed, and then push the info to the website.


Anyone wanna help?

Offline BuzyBee

  • Tacview
  • *
  • Posts: 15
    • Tacview
Re: Linking DCS to a virtual airline software.
« Reply #1 on: August 19, 2019, 04:39:13 PM »
Hi neon,

You should be able to write a Lua add-on either for DCS or for Tacview which will send the information you need to your website using sockets.

If you wrote a DCS add-on you wouldn't need Tacview at all. Everything would happen in the Export.lua file found in the Saved Games folder under DCS.

The advantage of Tacview is that your add-on would work with all simulators that work with Tacview. If you choose to go this route we can help you. Check out the add-on we wrote for HSR Sim Racing: https://github.com/RaiaSoftwareInc/tacview.add-ons.lua


Offline neon

  • New member
  • *
  • Posts: 8
Re: Linking DCS to a virtual airline software.
« Reply #2 on: August 19, 2019, 08:02:58 PM »
I would prefer to just use Tacview since my entire unit uses it. I do know some lua but overall I am still trying to dig up what format the system wants the data submitted in. From what I can tell what it needs for into is flight number (we could use callsign for this), date of flight, Departing ICAO, Arrival ICAO, Aircraft, Distance, fuel used (in pounds), number in people in the plane (I would assume we would just use a table for this to pull the number of pilots for a given plane), depart time, arrival time, and flight duration. There is also an area for putting comments about the flight and route. If we do anything with comments I think it would just be a kind of flight log (fired guns at this time ect.). As far as the route I dont think there is any way of even recording a route.

Offline BuzyBee

  • Tacview
  • *
  • Posts: 15
    • Tacview
Re: Linking DCS to a virtual airline software.
« Reply #3 on: August 21, 2019, 05:55:11 PM »
We can definitely send callsign, date of flight, actual departing and arriving ICAO if it exists, Aircraft, Distance. depart time, arrival time and flight duration.

Fuel info is only available for some planes. Number of people in the plane could be pulled from a table as you suggest. 

Route information is not currently available (from DCS) and I don't know how to enter comments but we can look at that later.

When you find out what format you need, let me know! HTTP REST request would be best in my opinion because of its simplicity to implement on both ends.

Offline neon

  • New member
  • *
  • Posts: 8
Re: Linking DCS to a virtual airline software.
« Reply #4 on: August 22, 2019, 08:56:41 PM »
I am pretty sure this won't help but this is the software that is used for fsx/p3d/xplane to report the flight. But I am putting it up here just in case.

http://acars.vabase.com/setup.exe

This system normally uses a plugin called FSUIPC or XUIPC (depending on the sim).


Offline neon

  • New member
  • *
  • Posts: 8
Re: Linking DCS to a virtual airline software.
« Reply #5 on: August 27, 2019, 11:10:27 PM »
Alright, I finally have the info. Can we write something that connects to a mysql database?

Offline neon

  • New member
  • *
  • Posts: 8
Re: Linking DCS to a virtual airline software.
« Reply #6 on: August 28, 2019, 02:43:33 AM »
I dont know if you can read PHP but this is the main chunk of code that is updated for the majority of the pirep.

Code: [Select]
date_default_timezone_set('UTC');
$today = date("Y-m-d");
$time = date("Y-m-d H:i:s");
$filled = false;

if(isset($_POST['btnpirep']))
{

$date_filled = addslashes(trim($_POST['date_filled']));
$date = addslashes(trim($_POST['date']));
$depicao = strtoupper(addslashes(trim($_POST['depicao'])));
$arricao = strtoupper(addslashes(trim($_POST['arricao'])));
$route = strtoupper(addslashes(trim($_POST['route'])));
$aircraft = strtoupper(addslashes(trim($_POST['aircraft'])));
$fuel = addslashes(trim(preg_replace("/[^0-9,.]/", "", $_POST['fuel'])));
$miles = addslashes(trim(preg_replace("/[^0-9,.]/", "", $_POST['miles'])));
$pax = addslashes(trim(preg_replace("/[^0-9,.]/", "", $_POST['pax'])));
$dh = addslashes(trim($_POST['dh']));
$dm = addslashes(trim($_POST['dm']));
$ds = "00";
$ah = addslashes(trim($_POST['ah']));
$am = addslashes(trim($_POST['am']));
$as = "00";
$th = addslashes(trim($_POST['th']));
$tm = addslashes(trim($_POST['tm']));
$ts = "00";
$comments = addslashes(trim($_POST['comments']));
$pilot = addslashes(trim($_POST['pilot']));
$flight_number = strtoupper(addslashes(trim($_POST['flight_number'])));

if ((((( empty($date) ) || ( empty($depicao) ) || ( strlen($depicao) <> 4 ) || ( empty($arricao) ) || ( empty($pax) ) || ( strlen($arricao) <> 4 ) || ( empty($route) ) || ( empty($flight_number) ) || ( empty($aircraft) || ( empty($miles) ||  ( empty($pilot) ))))))) {
echo '<script>alert("Some fields are not fully filled in correctly.");</script>';
echo '<script>history.back(1);</script>';
exit;
}

$paym = getClientPay($cCode, $conn);
$pay = $miles * $paym;
$pilotid = $_SESSION['pilotid'];

$query_in = "CALL spdInsPIREP('$date_filled', '$date', '$depicao', '$arricao', '$route', '$aircraft', '$miles', '$pax', '$dh:$dm:$ds', '$ah:$am:$as', '$th:$tm:$ts', '$pay', '$comments', '$pilotid', '$flight_number', '$cCode', '$pilot', '$fuel')";
$in = mysqli_query($conn, $query_in) or die(mysqli_error($conn));

$filled = true;

This section is what info is being used for live update (basicly live tracking of flights to the website where it shows up on a map.

Code: [Select]
$flights_coordinates = array();
$jsonarray = array();
$index = 0;
$query_dep = "CALL spdGetAirport('$cCode','$depicao')";
$dep = mysqli_query($conn, $query_dep, MYSQLI_STORE_RESULT) or die(mysqli_error($conn));
$row_dep = mysqli_fetch_assoc($dep);
clearStoredResults($conn);
$query_arr = "CALL spdGetAirport('$cCode','$arricao')";
$arr = mysqli_query($conn, $query_arr, MYSQLI_STORE_RESULT) or die(mysqli_error($conn));
$row_arr = mysqli_fetch_assoc($arr);
clearStoredResults($conn);
$last_lat = floatval($row_dep["latitude_deg"]);
$last_long = floatval($row_dep["longitude_deg"]);
$flights_coordinates ["lat"] = floatval($row_dep["latitude_deg"]);
$flights_coordinates ["lng"] = floatval($row_dep["longitude_deg"]);
$flights_coordinates ["name"] = $depicao;
$jsonarray [0][$index] = $flights_coordinates;
$index ++;
$flights_coordinates ["lat"] = floatval($row_arr["latitude_deg"]);
$flights_coordinates ["lng"] = floatval($row_arr["longitude_deg"]);
$flights_coordinates ["name"] = $arricao;
$jsonarray [0][$index] = $flights_coordinates;

The live stuff gets pushed to a MySQL DB about every 30 sec or so (rough guess) and then the rest of the info is submitted once the flight is over. Ideally, we could connect DCS to the ACARS program that the site comes built-in with but the dev is not being very helpful on that part and I don't feel like digging through his compile dlls to try and mod something.

Offline BuzyBee

  • Tacview
  • *
  • Posts: 15
    • Tacview
Re: Linking DCS to a virtual airline software.
« Reply #7 on: August 28, 2019, 04:10:30 PM »
Thanks for all this info. This looks do-able.

I'll work on it and try to get a prototype working. This prototype will be a Tacview add-on which can be used to send the info to your server after the flight is over.

Offline neon

  • New member
  • *
  • Posts: 8
Re: Linking DCS to a virtual airline software.
« Reply #8 on: October 06, 2019, 01:34:51 AM »
Hey just wanted to check if you made any progress.

Offline BuzyBee

  • Tacview
  • *
  • Posts: 15
    • Tacview
Re: Linking DCS to a virtual airline software.
« Reply #9 on: October 08, 2019, 03:47:26 PM »
Hey! Here is a skeleton prototype I made called virtual-flight-report: https://github.com/RaiaSoftwareInc/tacview.add-ons.lua

From Tacview, the user has to select Add-Ons -> Virtual Flight Report to send their flight report manually

Can you please provide a detailed explanation of each variable and I'll try to get them programmed one by one.

Please note all dates will be UTC ISO YYYY-MM-DD and all measurements will be in metric. And for now there can be no user-entered values; everything has to be detected automatically by Tacview. Later we will try to implement dialogue boxes.