Skip to content

Commit 3a58ce3

Browse files
committed
update schemas for ATM usecase
1 parent 11ced7e commit 3a58ce3

File tree

8 files changed

+62
-126
lines changed

8 files changed

+62
-126
lines changed
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# backend/context-service/resources/ATM/schemas.py
22

33
from api.schemas import MetadataSchema
4-
from apiflask.fields import Dict, String
5-
4+
from apiflask.fields import Dict, String, Float, List, Integer
65
class MetadataSchemaATM(MetadataSchema):
7-
topology = String(allow_none=False)
8-
observation = Dict(allow_none=False)
6+
ApDest = Dict()
7+
Current_airspeed = Float()
8+
Latitude = Float()
9+
Longitude = Float()
10+
wpList = List(Dict())
11+
id_plane = Integer()

backend/event-service/resources/ATM/event_manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ def get_unique_fields(self, data):
1515
1616
This method specifies the fields on which InteractiveAI will ensure event uniqueness.
1717
"""
18-
input_line = data["data"].get("line")
19-
return {"line": input_line}
18+
id_plane = data["data"].get("id_plane")
19+
event_type = data["data"].get("event_type")
20+
return {"id_plane": id_plane, "event_type": event_type}

backend/event-service/resources/ATM/schemas.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
from api.schemas import MetadataSchema
66

77
class MetadataSchemaATM(MetadataSchema):
8-
event_type = String(
9-
required=True,
10-
validate=OneOf(["KPI", "anticipation", "agent", "consignation"]),
11-
)
12-
creation_date = String()
13-
zone = String(validate=OneOf(["Est", "Ouest", "Centre"]))
14-
line = String(required=True)
15-
flux = Float()
16-
kpis = Dict(required=True)
17-
event_context = String()
8+
event_type = String(required=True)
9+
system = String(required=True)
10+
id_plane = String(required=True)

backend/recommendation-service/resources/ATM/manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def __init__(self):
88

99
def get_recommendation(self, request_data):
1010
"""
11-
Override to provide recommendations specific to the RTE use case.
11+
Override to provide recommendations specific to the ATM use case.
1212
13-
This method generates and returns recommendations tailored for RTE.
13+
This method generates and returns recommendations tailored for ATM.
1414
"""
15-
action_dict = {}
15+
action_dict = {"action 1": "do something", "action 2": "do nothing"}
1616

1717
output_json = {
1818
"title": "recommendation",

frontend/src/entities/ATM/CAB/Assistant.vue

Lines changed: 41 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
<section class="cab-panel">
33
<Default>
44
<template #title>
5-
<template v-if="appStore.tab.assistant === 1">{{ $t('cab.assistant.procedure') }}</template>
6-
<template v-if="appStore.tab.assistant === 2">
7-
{{ $t('cab.assistant.recommendations') }}
8-
</template>
5+
{{ $t('cab.assistant.recommendations') }}
96
</template>
10-
<Procedure
11-
v-if="appStore.tab.assistant === 1 && procedure && appStore.card('ATM')"
12-
:procedure />
137
<Recommendations
14-
v-if="appStore.tab.assistant === 2 && appStore.card('ATM')"
8+
v-if="appStore.tab.assistant === 1 && appStore.card('ATM')"
159
v-model:recommendations="recommendations"
1610
:buttons="[
1711
$t('recommendations.button1'),
@@ -34,105 +28,66 @@
3428
</Default>
3529
</section>
3630
</template>
31+
3732
<script setup lang="ts">
3833
import { ref, watch } from 'vue'
39-
4034
import { update } from '@/api/cards'
41-
import { getProcedure } from '@/api/services'
42-
import Default from '@/components/organisms/CAB/Assistant.vue'
43-
import Procedure from '@/components/organisms/CAB/Assistant/Procedure.vue'
4435
import Recommendations from '@/components/organisms/CAB/Assistant/Recommendations.vue'
4536
import { useAppStore } from '@/stores/app'
4637
import { useMapStore } from '@/stores/components/map'
4738
import { useServicesStore } from '@/stores/services'
4839
import type { Recommendation } from '@/types/services'
49-
5040
import { applyRecommendation } from '../api'
5141
5242
const servicesStore = useServicesStore()
5343
const mapStore = useMapStore()
5444
const appStore = useAppStore()
5545
56-
const procedure = ref()
5746
const recommendations = ref<Recommendation<'ATM'>[]>([])
5847
59-
watch(
60-
() => appStore._card,
61-
async () => {
62-
if (appStore.card('ATM')?.data.criticality !== 'HIGH') return
63-
appStore.tab.assistant = 1
64-
procedure.value = (
65-
await getProcedure(appStore.card('ATM')!.data.metadata.event_type)
66-
).data.procedure
67-
procedure.value[0].tasks[0].state = 'doing'
68-
}
69-
)
70-
71-
watch(
72-
procedure,
73-
(value) => {
74-
if (value.at(-1)?.tasks.at(-1)?.state === 'done')
75-
update({
76-
title: appStore.card('ATM')?.titleTranslated,
77-
description: appStore.card('ATM')?.summaryTranslated,
78-
data: appStore.card('ATM')?.data.metadata,
79-
use_case: 'ATM',
80-
criticality: 'ND'
81-
})
82-
},
83-
{ deep: true }
84-
)
85-
48+
// Update the assistant tab watcher to handle recommendations with index 1.
8649
watch(
8750
() => appStore.tab.assistant,
8851
async (index) => {
89-
switch (index) {
90-
case 1:
91-
if (!appStore.card('ATM')) break
92-
procedure.value = (
93-
await getProcedure(appStore.card('ATM')!.data.metadata.event_type)
94-
).data.procedure
95-
procedure.value[0].tasks[0].state = 'doing'
96-
break
97-
case 2:
98-
if (!appStore.card('ATM')) break
99-
await servicesStore.getRecommendation(appStore.card('ATM')!)
100-
recommendations.value = servicesStore.recommendations('ATM')
101-
for (const recommendation of recommendations.value)
102-
for (const action of recommendation.actions) {
103-
for (const { wplat, wplon, wpid } of action.waypoints)
104-
mapStore.addWaypoint({
105-
lat: wplat,
106-
lng: wplon,
107-
id: wpid,
108-
category: 'RECOMMENDATION',
109-
options: { color: 'var(--color-primary)' }
110-
})
52+
if (index === 1) {
53+
if (!appStore.card('ATM')) return
54+
await servicesStore.getRecommendation(appStore.card('ATM')!)
55+
recommendations.value = servicesStore.recommendations('ATM')
56+
for (const recommendation of recommendations.value)
57+
for (const action of recommendation.actions) {
58+
for (const { wplat, wplon, wpid } of action.waypoints)
11159
mapStore.addWaypoint({
112-
lat: action.airport_destination.latitude,
113-
lng: action.airport_destination.longitude,
114-
id: action.airport_destination.apname,
60+
lat: wplat,
61+
lng: wplon,
62+
id: wpid,
11563
category: 'RECOMMENDATION',
116-
permanentTooltip: true,
11764
options: { color: 'var(--color-primary)' }
11865
})
119-
mapStore.addPolyline({
120-
id: recommendation.title,
121-
options: { color: 'var(--color-success)' },
122-
waypoints: [
123-
...action.waypoints.map((waypoint: any) => ({
124-
lat: waypoint.wplat,
125-
lng: waypoint.wplon,
126-
id: waypoint.wpid
127-
})),
128-
{
129-
lat: action.airport_destination.latitude,
130-
lng: action.airport_destination.longitude,
131-
id: action.airport_destination.apname
132-
}
133-
]
134-
})
135-
}
66+
mapStore.addWaypoint({
67+
lat: action.airport_destination.latitude,
68+
lng: action.airport_destination.longitude,
69+
id: action.airport_destination.apname,
70+
category: 'RECOMMENDATION',
71+
permanentTooltip: true,
72+
options: { color: 'var(--color-primary)' }
73+
})
74+
mapStore.addPolyline({
75+
id: recommendation.title,
76+
options: { color: 'var(--color-success)' },
77+
waypoints: [
78+
...action.waypoints.map((waypoint: any) => ({
79+
lat: waypoint.wplat,
80+
lng: waypoint.wplon,
81+
id: waypoint.wpid
82+
})),
83+
{
84+
lat: action.airport_destination.latitude,
85+
lng: action.airport_destination.longitude,
86+
id: action.airport_destination.apname
87+
}
88+
]
89+
})
90+
}
13691
}
13792
}
13893
)
@@ -180,9 +135,11 @@ function onSelection(recommendation: Recommendation<'ATM'>) {
180135
applyRecommendation(recommendation.actions[0])
181136
mapStore.resetPolylines()
182137
mapStore.resetWaypoints()
138+
// Optionally, change the tab value to close the assistant.
183139
appStore.tab.assistant = 0
184140
}
185141
</script>
142+
186143
<style lang="scss" scoped>
187144
.cab-assistant main {
188145
scroll-snap-type: y mandatory;

frontend/src/entities/ATM/locales/en.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"assistant.plan": "Recommend new flight plans",
3-
"cab.assistant.procedure": "Checklist",
4-
"cab.notifications.main": "Failures",
5-
"cab.notifications.sub": "Notifications",
3+
"cab.notifications.main": "Alerts",
4+
"cab.notifications.sub": "Information",
65
"map.context": "Plane",
76
"recommendations.button1": "Cockpit maintenance",
87
"recommendations.button2": "Cost",

frontend/src/entities/ATM/locales/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"assistant.plan": "Recommander un nouveau plan de vol",
33
"cab.assistant.procedure": "Checklist",
4-
"cab.notifications.main": "Défaillances",
4+
"cab.notifications.main": "Alertes",
55
"cab.notifications.sub": "Notifications",
66
"map.context": "Avion",
77
"recommendations.button1": "Maintenance cockpit",

frontend/src/entities/ATM/types.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,11 @@ export type ATM = {
3333
wpid: Uppercase<string>
3434
}[]
3535
}
36-
TaskTypes:
37-
| 'task'
38-
| 'monitor'
39-
| 'choice'
40-
| 'caution'
41-
| 'note'
42-
| 'flightpathAction'
43-
| 'operatingProcedure'
44-
| 'noActionRequired'
4536
}
4637

4738
export const SYSTEMS = [
48-
'STAT',
49-
'ENG',
50-
'ELEC',
51-
'FUEL',
52-
'HYD',
53-
'ECS',
54-
'FCS',
55-
'BLD',
56-
'MISC',
57-
'TEST'
39+
'ENGINE',
40+
'ELECTRIC',
5841
] as const
5942
Object.freeze(SYSTEMS)
6043
export type System = (typeof SYSTEMS)[number]

0 commit comments

Comments
 (0)