Skip to content

Commit

Permalink
feature: add new intention at the design level
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-elena committed Jun 4, 2024
1 parent a6db311 commit 1ea56d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/component/event/EventMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import NewBelief from "./design/NewBelief";
import SelectPlan from "./design/SelectPlan";
import BDIBeliefRemoved from "./design/BeliefRemoved";
import BDIGoalCreated from "./design/BDIGoalCreated";
import BDIIntentionCreated from "./design/BDIIntentionCreated";

const EventMapping = {
ExecutedDeed: {implementation: <ExecutedDeed/>, design: <ExecutedAction/>},
Expand All @@ -45,7 +46,7 @@ const EventMapping = {
GoalRemoved: {implementation: <GoalRemoved/>, design: <DesireRemoved/>},
GoalSuspended: {implementation: <GoalSuspended/>, design: <></>},
PlanSelected: {implementation: <PlanSelected/>, design: <></>},
IntentionCreated: {implementation: <IntentionCreated/>, design: <></>}, //todo
IntentionCreated: {implementation: <IntentionCreated/>, design: <BDIIntentionCreated/>},
IntentionRemoved: {implementation: <IntentionRemoved/>, design: <></>},
IntentionSuspended: {implementation: <IntentionSuspended/>, design: <></>},
IntentionWaiting: {implementation: <IntentionWaiting/>, design: <></>},
Expand Down
23 changes: 23 additions & 0 deletions src/component/event/design/BDIIntentionCreated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Event from "../Event";
import {Level} from "../../../model/Level";
import React from "react";

function BDIIntentionCreated(props) {
const event = props.event
const type = "Intention Created"
const intention = event.message.event.intentionInfo
const goal = intention.intendedMeansInfo[0].plan.trigger
const id = "int-" + intention.id + "-" + goal
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === intention.id)
const selectPlan = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "PlanSelected" && e.message.event.goalInfo.goalFunctor === goal)
const description = "I have a new intention " + id

if (selectPlan) {
return (
<Event type={type} description={description} timestamp={props.event.timestamp} filter={props.filter}
log={props.log} level={Level.DESIGN} explanation={explanation}/>
)
}
}

export default BDIIntentionCreated;

0 comments on commit 1ea56d4

Please sign in to comment.