Skip to content

Commit

Permalink
refactor: send message event
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-elena committed Jun 2, 2024
1 parent db680f7 commit 6d8b82c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/component/event/EventMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const EventMapping = {
MailBoxMessages: {implementation: <MailBoxMessages/>, design: <></>},
NewSpeechActMessage: {implementation: <NewSpeechActMessage/>, design: <NewSpeechActMessage/>},
SelectedMessage: {implementation: <SelectedMessage/>, design: <></>},
SendMessage: {implementation: <SendMessage/>, design: <SendMessage/>}
SendMessage: {implementation: <SendMessage/>, design: <ExecutedAction/>}
};

export default EventMapping;
87 changes: 47 additions & 40 deletions src/component/event/design/ExecutedAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,57 @@ import Event from "../Event";
import {Level} from "../../../model/Level";

function ExecutedAction(props) {

const type = "Executed action"
const deed = props.event.message.event.deedInfo
let description
let info = "Type: "
const intentionInfo = props.event.message.event.intentionInfo.value ? props.event.message.event.intentionInfo.value : props.log.slice(0, props.log.indexOf(props.event)).find(e => e.message.type === "IntentionCreated" && e.message.event.intentionInfo.intendedMeansInfo[0].plan.body.includes(deed.term)).message.event.intentionInfo
const intentionId = intentionInfo.id
const intentionTrigger = intentionInfo.intendedMeansInfo[0]
if (props.event.message.type === "SendMessage") {
const message = props.event.message.event.messageInfo
const description = "I sent a " + message.type + " message to " + message.receiver + ": " + message.message
return (
<Event type={"Executed action"} description={description} info={""} timestamp={props.event.timestamp}
filter={props.filter} log={props.log} level={Level.DESIGN}/>
)
} else {
const deed = props.event.message.event.deedInfo
let description
let info = "Type: "
const intentionInfo = props.event.message.event.intentionInfo.value ? props.event.message.event.intentionInfo.value : props.log.slice(0, props.log.indexOf(props.event)).find(e => e.message.type === "IntentionCreated" && e.message.event.intentionInfo.intendedMeansInfo[0].plan.body.includes(deed.term)).message.event.intentionInfo
const intentionId = intentionInfo.id
const intentionTrigger = intentionInfo.intendedMeansInfo[0]
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 === intentionId)

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 === intentionId)
switch (deed.type) {
case "addBel":
description = "I believe "
break;
case "delBel":
description = "I no longer believe in "
break;
case "delAddBel":
description = "I updated belief "
break;
case "test":
description = "I executed test goal "
break;
case "internalAction":
description = "I executed internal action "
break;
case "constraint":
description = "I evaluated expression "
break;
default:
description = "I executed action "
break;
}

switch (deed.type) {
case "addBel":
description = "I believe "
break;
case "delBel":
description = "I no longer believe in "
break;
case "delAddBel":
description = "I updated belief "
break;
case "test":
description = "I executed test goal "
break;
case "internalAction":
description = "I executed internal action "
break;
case "constraint":
description = "I evaluated expression "
break;
default:
description = "I executed action "
break;
}
const intention = "intention int-" + intentionId + "-" + intentionTrigger.plan.trigger
description = description + deed.term + " because of " + intention
info = info + deed.type

const intention = "intention int-" + intentionId + "-" + intentionTrigger.plan.trigger
description = description + deed.term + " because of " + intention
info = info + deed.type

if (deed.type !== "achieve" && !deed.type.includes("Bel")) {
return (
<Event type={type} description={description} info={info} timestamp={props.event.timestamp}
filter={props.filter} log={props.log} level={Level.DESIGN} explanation={explanation}/>
)
if (deed.type !== "achieve" && !deed.type.includes("Bel")) {
return (
<Event type={type} description={description} info={info} timestamp={props.event.timestamp}
filter={props.filter} log={props.log} level={Level.DESIGN} explanation={explanation}/>
)
}
}
}

Expand Down

0 comments on commit 6d8b82c

Please sign in to comment.