{"id":5224,"date":"2024-06-13T09:49:21","date_gmt":"2024-06-13T07:49:21","guid":{"rendered":"https:\/\/oopm.org\/?page_id=5224"},"modified":"2025-01-14T13:50:23","modified_gmt":"2025-01-14T12:50:23","slug":"5224-2","status":"publish","type":"page","link":"https:\/\/oopm.org\/?page_id=5224","title":{"rendered":"10.2.2 Status of flights"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-page pdfprnt-top-right\"><a href=\"https:\/\/oopm.org\/index.php?rest_route=wpv2pages5224&print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-print\/images\/pdf.png\" alt=\"image_pdf\" title=\"View PDF\" \/><\/a><a href=\"https:\/\/oopm.org\/index.php?rest_route=wpv2pages5224&print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\" id=\"block-77877f77-2c8c-4a6b-9c60-ff2ce4e7f487\">In order to provide status on flights, we extend the first definition of class <code>Flight<\/code> with a couple of data-items, and later by some methods that provide the status:<\/p>\n\n\n\n<pre id=\"block-72f7fdaa-bcf9-4388-8528-8799dd0cb2eb\" class=\"wp-block-code has-custom-color-1-background-color has-background\"><code>   <strong>class<\/strong> FlightRoute(FlightNumber, origin, destination: <strong>var<\/strong> String):   \n      <mark style=\"background-color:rgba(0, 0, 0, 0);color:#454444\" class=\"has-inline-color\">scheduledDepartureTime: <strong>var<\/strong> TimeOfDay \n      scheduledArrivalTime: <strong>var<\/strong> TimeOfDay <\/mark>\n      -\"-\n      <strong>class<\/strong> Flight(<mark style=\"background-color:rgba(0, 0, 0, 0);color:#535151\" class=\"has-inline-color\">departureDate: <strong>var<\/strong> Date<\/mark>): <mark style=\"background-color:rgba(0, 0, 0, 0);color:#5f5e5e\" class=\"has-inline-color\"> <\/mark> \n         departureTime: <strong>var<\/strong> TimeOfDay  \n         arrivalTime: <strong>var<\/strong> TimeOfDay:\n         flightTime: -&gt; ft: <strong>var<\/strong> Time.Hours\n            ft := arrivalTime - departureTime\n         delayed: <strong>var<\/strong> Boolean\n         delayDeparture(newTime: <strong>var<\/strong> TimeOfDay):\n            -- this is called in case the departure is delayed\n            delayed := True\n            departureTime := newTime\n         delay -&gt; period: <strong>var<\/strong> Time.Hours:\n            period := arrivalTime \u2013 scheduledArrivalTime\n\n         cancelled: <strong>var<\/strong> Boolean\n         cancel:\n            cancelled := True\n         hasArrived: <strong>var<\/strong> Boolean\n         hasTakenOff: <strong>var<\/strong> Boolean <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-30ca2847-1b3a-421e-95bb-2357d502a92c\">In the event of cancellation, the method <code>cancel<\/code> is called.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-6be98be0-4c1e-4f2f-b202-c6e3a23dea28\">At take off, <code>departureTime<\/code> is set to the time of take off, <code>hasTakenOff<\/code> is set to <code>True<\/code>, and <code>hasArrived<\/code> is set to <code>False<\/code>. While flying the attribute <code>arrivalTime<\/code> is set based on weather condition and the landing condition of the destination airport. It is therefore assumed that this is set based on real time information from the plane. At arrival, <code>hasArrived<\/code> is set to <code>True<\/code> and <code>hasTakenOff<\/code> to <code>False<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-8f9a9895-ffa7-4170-9a0d-325f416ffba3\">Status of flights are provided in two different ways, either given the origin\/destination airport at a given date, or given the name of the flight route, e.g. SK1926.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-3fddbf42-700a-4145-9076-24a9c3563626\">The method <code>departureStatus<\/code> defined below is called with some interval before take off, to provide the status text that may be displayed:<\/p>\n\n\n\n<pre id=\"block-8d8320b6-c760-4690-bb45-20f7e6a933df\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code><strong>class<\/strong> Flight(<mark style=\"background-color:rgba(0, 0, 0, 0);color:#4e4c4c\" class=\"has-inline-color\">departureDate: <strong>var<\/strong> Date<\/mark>):\n   -\"-\n   departureStatus -&gt; info: <strong>var<\/strong> String:  \n      info := (\"Flight \" + FlightNumber + \" at: \" + departureDate.asString)\n      if cancelled :then\n         info := info + \"is cancelled\"\n      :else\n         if delayed :then\n            info := info + \"Estimated departure time: \"+ \n                    departureTime +\n                    \" expected arrival time: \" + \n                    (departureTime + flightTime)\n         :else\n            info := info + \" On schedule: \" + \n                    scheduledDepartureTime.t.magnitude<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-58c30ba4-eac4-4564-9d28-ec673897e415\">The next method is called after take off:<\/p>\n\n\n\n<pre id=\"block-e0953a1c-dca8-4067-b63f-b3419fbd052e\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code><strong>class<\/strong> Flight(<mark style=\"background-color:rgba(0, 0, 0, 0);color:#555555\" class=\"has-inline-color\">departureDate: <strong>var<\/strong> Date<\/mark>): \n   -\"-\n   arrivalStatus -&gt; info: <strong>var<\/strong> String:  \n      info := (\"Flight \" + name + \" at: \" + departureDate.asString)\n      info := info + \"Departed at: \"+ departureTime\n      if (not hasArrived) :then<code>         info := info + \" expected at: \" + arrivalTime<\/code>      :else<mark>\n<\/mark>         info := info + \" arrived at: \" + ArrivalTime + \n                 \" delayed: \" + delay<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Given the above status methods in <code>Flight<\/code>, we have three ways of selection which flights we want the status: for all flights in all flight routes of a time table, for flights departing or arriving from a given airport at a given date, or flights of a given route at a given airport and date.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Status of flights in the time table<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-2be97152-ea84-424c-8192-841f0046e0b1\">Based upon the entries in the time table, flight status for all flights is provided by the following method:<\/p>\n\n\n\n<pre id=\"block-364c3576-1adc-4cd1-86e7-ab2f40f3bbbe\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code>showFlightStatus:\n   timeTable.scanTimeTable\n      fr: <strong>ref<\/strong> FlightRoute \n      fr := current \n      fr.scan\n         if (not hasTakenOff) :then \n            currentFlight.departureStatus.print\n         :else\n            currentFlight.arrivalStatus.print\n         newline\t<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The method <code>showFlightStatus<\/code> is a submethod of the method <code>scanTimeTable<\/code> in <code>timeTable<\/code>. The method <code>scanTimeTable<\/code> scans the <code>entries<\/code> list of <code>FlightRoute<\/code> objects; for each <code>FlightRoute<\/code>, held by <code>fr,<\/code> a singular method being a submethod of <code>fr.scan<\/code> scans the <code>Flight<\/code> objects of the <code>flights<\/code> list in the <code>FlightRoute<\/code> held by <code>fr<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-33ce3e6e-0e8c-41db-9047-edf011c7ec50\">As described above, the method <code>showFlightStatus<\/code>   is based upon a <code>scanTimeTable<\/code> method in <code>timeTable<\/code>:<\/p>\n\n\n\n<pre id=\"block-a15c5380-3738-4eff-94c7-f950c6af5b7e\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code>timeTable: <strong>obj<\/strong>\n   entries: <strong>obj<\/strong> OrderList(FlightRoute)\n   scanTimeTable:\n      current: <strong>ref<\/strong> FlightRoute\n      entries.scan\n          this(scanTimeTable).current := current\n          inner(scanTimeTable)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As explained before, the <code>inner(scanTimeTable)<\/code> is executed for each element in <code>entries<\/code>, and what is executed is the statements of the <code>showFlightStatus<\/code> submethod of <code>timeTable.scanTimeTable<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-ad5f4280-22ba-4469-af7b-20ee78a2452b\">The above is in turn based upon a <code>scan<\/code> method of <code>FlightRoute<\/code>, scaning all the <code>Flight<\/code> objects of the list <code>flights<\/code>:<\/p>\n\n\n\n<pre id=\"block-c13fcc64-cd0a-49bc-8fb1-8877b360cab2\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code><strong>class<\/strong> FlightRoute(flightNumber, origin, destination: <strong>var<\/strong> String):   \n   -\"-\n   scan:\n       currentFlight: <strong>ref<\/strong> Flight\n       flights.scan\n          currentFlight := current\n          inner(scan)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"block-d25d1ac9-0e35-4355-96bc-a7333dba6b2e\">From\/to a given airport, at a given date<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-85addd8e-5641-4fbc-b837-39d456c5e29c\">The following method delivers the list of flights<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-custom-color-2-color\"> <\/mark>from a given<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-custom-color-2-color\"> <\/mark>airport at a given date:<\/p>\n\n\n\n<pre id=\"block-51ece3f4-a61e-49f6-ba69-757043b78a1d\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code>fromAirport(ap: <strong>var<\/strong> String, d: <strong>var<\/strong> Date) \n   -&gt; flights: <strong>ref<\/strong> OrderedList(Flight):\n\n   timeTable.routesFrom(ap).scan\n      current.flights.scan\n         if (current.date = d) :then \n            flights.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is based upon the method <code>routesFrom<\/code> in <code>timeTable<\/code>, delivering the list of routes departing from a given airport:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timeTable: <strong>obj<\/strong>\n   -\"-\n   routesFrom(ap: <strong>var<\/strong> String) -&gt; routes: OrderedList(FlightRoute):\n      entries.scan\n      if (current.origin = ap :then \n         routes.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-a11d11ed-08e0-4761-abfc-780965cdbe2f\">It is left as a simple exercise to make the method that delivers the list of flights<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-custom-color-2-color\"> <\/mark>to<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-custom-color-2-color\"> <\/mark>a given destination airport at a given date.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-a0eafac4-181c-4df0-810d-3cedfe9f79b0\">Answer:<\/p>\n\n\n\n<pre id=\"block-1f323ea4-69a0-451b-ad06-7ae602e83aa5\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code>toAirport(ap: var String, d: <strong>var<\/strong> Date) \n   -&gt; flights: <strong>ref<\/strong> OrderedList(Flight):\n   timeTable.routesTo(ap).scan\n      current.flights.scan\n         if (current.date = d) :then \n            flights.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">based upon:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timeTable: <strong>obj<\/strong>\n   -\"-\n   routesTo(ap: <strong>var<\/strong> String) -&gt; routes: OrderedList(FlightRoute):\n      entries.scan\n      if (current.destination = ap :then \n         routes.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-64fb2eef-f1df-4561-a14e-2735e20ed4da\">Before the list of <code>Flight<\/code> objects delivered by these two methods are used for producing the status website, the list delivered by <code>fromAirport<\/code> should be sorted according to departure time, while the list of <code>Flight<\/code> objects delivered by <code>toAirport<\/code> should be sorted according to arrival time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-9fcbadc9-144f-45e7-b0d9-0133c6df67cd\">Given these two lists of <code>Flight<\/code> objects, the status website can produce the two strings delivered by the methods <code>departureStatus<\/code> and <code>arrivalStatus<\/code>.<\/p>\n\n\n\n<pre id=\"block-34180e77-934b-4f3a-a4fd-97d9e7141e6f\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code>fromAirport(\"OSL\", Date(6, 6, 2024)).scan\n   current.departureStatus.print \nfromAirport(\"OSL\", Date(6, 6, 2024)).scan\n   current.arrivalStatus.print \n\nfromAirport(\"ARR\", Date(6, 6, 2024)).scan\n   current.departureStatus.print \nfromAirport(\"ARR\", Date(6, 6, 2024)).scan\n   current.arrivalStatus.print <\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"block-a85ecdc2-5070-490d-9cc6-bbcc693d7b19\">Given the flight number, airport, and a given date<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-56aef8a9-d24a-4785-bd11-2e23d973b43f\">The following method produces the list of flights given a certain route, from a given airport at a certain date:<\/p>\n\n\n\n<pre id=\"block-27ab5e99-7c03-4219-b507-ee82caa02b14\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code>onFlightNumberFrom(fn: <strong>var<\/strong> String, from: <strong>var<\/strong> String d: <strong>var<\/strong> Date)\n   -&gt; flights: <strong>ref<\/strong> OrderedList(Flight):\n   theRoute: <strong>ref<\/strong> FlightRoute\n   theRoute := timeTable.lookupRoute(fn)\n   if theRoute.origin = from :then\n      theRoute.flights.scan\n         if (current.date = d) :then flights.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is based on a simple <code>lookupRoute<\/code> in <code>TimeTable<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timeTable: <strong>obj<\/strong>\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#434343\" class=\"has-inline-color\">   entries: <strong>obj<\/strong> OrderList(FlightRoute)\n   scanTimeTable:\n      current: <strong>ref<\/strong> FlightRoute\n      entries.scan\n          this(scanTimeTable).current := current\n          inner(scanTimeTable)<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#4337b9\" class=\"has-inline-color\">   <\/mark>lookupRoute(fn: <strong>var<\/strong> String) -&gt; theRoute: <strong>ref<\/strong> FlightRoute: scanTimeTable\n      if current.flightNumber = fn :then\n         theRoute := current\n         leave(lookupRoute) <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-2ebc6d9b-1383-4237-81bd-a403353401dd\">It is left as a simple exercise to make the method that produces the list of flights given a certain route, to a given airport at a certain date:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Answer:<\/p>\n\n\n\n<pre id=\"block-ac73f14c-ee50-4e4a-a2df-217f15d70065\" class=\"wp-block-code has-custom-color-1-background-color has-background has-tiny-font-size\"><code>onFlightNumberTo(fn: <strong>var<\/strong> String, to: <strong>var<\/strong> String d: <strong>var<\/strong> Date)\n   -&gt; flights: <strong>ref<\/strong> OrderedList(Flight):\n   theRoute: <strong>ref<\/strong> FlightRoute\n   theRoute := timeTable.lookupRoute(fn)\n   if theRoute.destination = to :then\n      theRoute.flights.scan\n         if (current.date = d) :then flights.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"block-16f8dd89-f0f4-4b27-9d60-c5ced03c728f\">Given these two lists of <code>Flight<\/code> objects, the status website can produce the two strings delivered by the methods <code>departureStatus<\/code> and <code>arrivalStatus<\/code>.<\/p>\n\n\n\n<pre id=\"block-936c44cc-41a5-4563-8386-dba9d195cbcc\" class=\"wp-block-code has-custom-color-1-background-color has-background\"><code>onFlightNumberFrom(\"SK1926\", \"ARR\" Date(6, 6, 2024)).scan\n   current.departureStatus.print \nonFlightNumberTo(\"SK1926\", \"OSL\" Date(6, 6, 2024)).scan\n   current.arrivalStatus.print <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<div style=\"display:flex; gap:10px;justify-content:center\" class=\"wps-pgfw-pdf-generate-icon__wrapper-frontend\">\n\t\t<a  href=\"https:\/\/oopm.org?action=genpdf&amp;id=5224\" class=\"pgfw-single-pdf-download-button\" ><img src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-generator-for-wp\/admin\/src\/images\/PDF_Tray.svg\" title=\"Generate PDF\" style=\"width:auto; height:45px;\"><\/a>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>In order to provide status on flights, we extend the first definition of class Flight with a couple of data-items, and later by some methods that provide the status: In the event of cancellation, the method cancel is called. At take off, departureTime is set to the time of take off, hasTakenOff is set to [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":5004,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5224","page","type-page","status-publish","hentry"],"mb":[],"mfb_rest_fields":["title","gutenberg_elementor_mode"],"_links":{"self":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5224"}],"version-history":[{"count":48,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5224\/revisions"}],"predecessor-version":[{"id":11119,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5224\/revisions\/11119"}],"up":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5004"}],"wp:attachment":[{"href":"https:\/\/oopm.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}