Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Solved bug #16
  • Loading branch information
mikyll committed Dec 20, 2022
1 parent e9e0ba9 commit 03d3a92
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class Test_wasteservice ( name: String, scope: CoroutineScope ) : ActorBasicFsm
return { //this:ActionBasciFsm
state("state_init") { //this:State
action { //it:State

var CurrentPlastic = 0.0f
var CurrentGlass = 0.0f
println("$name in ${currentState.stateName} | $currentMsg")
println("[WasteService] Reset:")
println(" Plastic: $CurrentPlastic")
println(" Glass: $CurrentGlass")
//genTimer( actor, state )
}
//After Lenzi Aug2002
Expand All @@ -32,43 +39,36 @@ class Test_wasteservice ( name: String, scope: CoroutineScope ) : ActorBasicFsm
}
state("state_idle") { //this:State
action { //it:State
println("[Test_WasteService] Waiting for messages...")
//genTimer( actor, state )
}
//After Lenzi Aug2002
sysaction { //it:State
}
transition(edgeName="t10",targetState="state_handle_store",cond=whenRequest("storerequest"))
transition(edgeName="t00",targetState="state_handle_store",cond=whenRequest("storerequest"))
}
state("state_handle_store") { //this:State
action { //it:State
println(" dioporco")
println("$name in ${currentState.stateName} | $currentMsg")
if( checkMsgContent( Term.createTerm("storerequest(TYPE,TRUCKLOAD)"), Term.createTerm("storerequest(TYPE,TRUCKLOAD)"),
currentMsg.msgContent()) ) { //set msgArgList
println(" dioporco2")

Type = wasteservice.WasteType.valueOf(payloadArg(0))
TruckLoad = payloadArg(1).toFloat()
if(
// enough space
(Type == wasteservice.WasteType.PLASTIC && CurrentPlastic + TruckLoad <= wasteservice.Constants.MAXPB) ||
(Type == wasteservice.WasteType.GLASS && CurrentGlass + TruckLoad <= wasteservice.Constants.MAXGB)
){
if (Type == wasteservice.WasteType.PLASTIC) {
CurrentPlastic += TruckLoad
}
else {
CurrentGlass += TruckLoad
}
println("[Test_WasteService] Load accepted ($TruckLoad KG of $Type).")
){println(" OK")
answer("storerequest", "loadaccepted", "loadaccepted(_)" )
}
else
{println("[Test_WasteService] Load rejected")
{println(" NO")
answer("storerequest", "loadrejected", "loadaccepted(_)" )
}
println("[Test_WasteService] State:")
println(" Plastic: ${CurrentPlastic}/ ${wasteservice.Constants.MAXPB} KG, Glass: ${CurrentGlass} / ${wasteservice.Constants.MAXPB} KG")
}
delay(1000)
//genTimer( actor, state )
}
//After Lenzi Aug2002
Expand Down
2 changes: 1 addition & 1 deletion Sprint0/Sprint0_RequirementAnalysis/test_storerequest.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%====================================================================================
% test_storerequest description
%====================================================================================
context(ctx_test_storerequest, "localhost", "TCP", "11820").
context(ctx_test_storerequest, "localhost", "TCP", "9003").
qactor( test_wasteservice, ctx_test_storerequest, "it.unibo.test_wasteservice.Test_wasteservice").

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ private void clearMapConfig() {
this.settings.saveSettings(SETTINGS_FILENAME);

this.vboxDisplayControls.setVisible(false);
this.hboxFileControls.setDisable(false);
this.buttonSave.setDisable(true);
this.buttonSaveAs.setDisable(true);
this.hboxActionControls.setDisable(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<?import javafx.scene.paint.Color?>
<?import javafx.scene.text.Font?>

<AnchorPane fx:id="anchorPaneRoot" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane fx:id="anchorPaneRoot" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane fx:id="anchorPaneBase" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<?import javafx.scene.paint.Color?>
<?import javafx.scene.text.Font?>

<AnchorPane fx:id="anchorPaneRoot" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane fx:id="anchorPaneRoot" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane fx:id="anchorPaneBase" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
Expand Down
2 changes: 1 addition & 1 deletion unibo.mapperQak22/build2022.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ eclipse {

application {
// Define the main class for the application.
mainClass = 'it.unibo.ctxmapemptyroom22.MainCtxmapemptyroom22Kt'
mainClass = 'it.unibo.ctxmapperqak22.MainCtxmapperqak22Kt'
}

jar {
Expand Down
2 changes: 1 addition & 1 deletion unibo.mapperQak22/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "unibo.mapemptyroom22"
rootProject.name = "unibo.mapperqak22"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
QakContext.createContexts(
"127.0.0.1", this, "mapemptyroom22.pl", "sysRules.pl","ctxbasicrobot"
"127.0.0.1", this, "mapperqak22.pl", "sysRules.pl","ctxbasicrobot"
)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Generated by AN DISI Unibo */
package it.unibo.ctxmapperqak22
import it.unibo.kactor.QakContext
import it.unibo.kactor.sysUtil
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
QakContext.createContexts(
"localhost", this, "mapperqak22.pl", "sysRules.pl","ctxmapperqak22"
)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Generated by AN DISI Unibo */
package it.unibo.ctxmapwithobstqak22
import it.unibo.kactor.QakContext
import it.unibo.kactor.sysUtil
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
QakContext.createContexts(
"localhost", this, "mapwithobstqak22.pl", "sysRules.pl","ctxmapwithobstqak22"
)
}

83 changes: 83 additions & 0 deletions unibo.mapperQak22/src/it/unibo/mapperqak22/Mapperqak22.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* Generated by AN DISI Unibo */
package it.unibo.mapperqak22

import it.unibo.kactor.*
import alice.tuprolog.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

class Mapperqak22 ( name: String, scope: CoroutineScope ) : ActorBasicFsm( name, scope ){

override fun getInitialState() : String{
return "s0"
}
override fun getBody() : (ActorBasicFsm.() -> Unit){
val interruptedStateTransitions = mutableListOf<Transition>()
var NumStep = 0
return { //this:ActionBasciFsm
state("s0") { //this:State
action { //it:State
println("mapperbuilder starts")
unibo.kotlin.planner22Util.initAI()
//genTimer( actor, state )
}
//After Lenzi Aug2002
sysaction { //it:State
}
transition( edgeName="goto",targetState="doAheadMove", cond=doswitch() )
}
state("doAheadMove") { //this:State
action { //it:State
delay(300)
request("step", "step(350)" ,"basicrobot" )
//genTimer( actor, state )
}
//After Lenzi Aug2002
sysaction { //it:State
}
transition(edgeName="t00",targetState="continue",cond=whenReply("stepdone"))
transition(edgeName="t01",targetState="turn",cond=whenReply("stepfail"))
}
state("continue") { //this:State
action { //it:State
unibo.kotlin.planner22Util.updateMap( "w", "" )
//genTimer( actor, state )
}
//After Lenzi Aug2002
sysaction { //it:State
}
transition( edgeName="goto",targetState="doAheadMove", cond=doswitch() )
}
state("turn") { //this:State
action { //it:State
NumStep = NumStep + 1
forward("cmd", "cmd(l)" ,"basicrobot" )
unibo.kotlin.planner22Util.updateMap( "l", "" )
unibo.kotlin.planner22Util.showMap()
//genTimer( actor, state )
}
//After Lenzi Aug2002
sysaction { //it:State
}
transition( edgeName="goto",targetState="doAheadMove", cond=doswitchGuarded({ NumStep < 4
}) )
transition( edgeName="goto",targetState="endwork", cond=doswitchGuarded({! ( NumStep < 4
) }) )
}
state("endwork") { //this:State
action { //it:State
unibo.kotlin.planner22Util.showMap();
unibo.kotlin.planner22Util.saveRoomMap("mapRoomEmpty");
println("mapperbuilder BYE")
terminate(1)
//genTimer( actor, state )
}
//After Lenzi Aug2002
sysaction { //it:State
}
}
}
}
}
Loading

0 comments on commit 03d3a92

Please sign in to comment.