Skip to content
Snippets Groups Projects
Commit 3c1d162e authored by Reeves, David E's avatar Reeves, David E
Browse files

* unit level logging

parent c2c89b69
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
<Import /> <Import />
<HTNNode AllowMsg="true" Name="start" Type="DEFAULT"> <HTNNode AllowMsg="true" Name="start" Type="DEFAULT">
<Parent>addReplanTriggers</Parent> <Parent>addReplanTriggers</Parent>
<Code IsFile="false">#from HTNBehaviors import SendEntityEventDelay <Code IsFile="false">
#from HTNBehaviors import SendEntityEventDelay
# #
#printMessage("Convoy started", True) #printMessage("Convoy started", True)
# #
...@@ -21,6 +22,13 @@ ...@@ -21,6 +22,13 @@
# #
#borg.redUnitStatus[state.getCurrentUnitName()] = 0 #borg.redUnitStatus[state.getCurrentUnitName()] = 0
# #
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "CONVOY_CREATED" "" ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -72,6 +80,7 @@ SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveToPoint", ["ASSE ...@@ -72,6 +80,7 @@ SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveToPoint", ["ASSE
borg.delay=1.0 borg.delay=1.0
borg.redUnitStatus[state.getCurrentUnitName()] = 0 borg.redUnitStatus[state.getCurrentUnitName()] = 0
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -120,6 +129,13 @@ printMessage("Starting move: "+str(wps)+" Spd: "+str(randSpd), True) ...@@ -120,6 +129,13 @@ printMessage("Starting move: "+str(wps)+" Spd: "+str(randSpd), True)
if _gt_activeNode.getVar("moveReason") == "CONVOY": if _gt_activeNode.getVar("moveReason") == "CONVOY":
# borg.redUnitActivity[state.getCurrentUnitName()]="MOVE_TO_DEPLOYMENT_SITE" # borg.redUnitActivity[state.getCurrentUnitName()]="MOVE_TO_DEPLOYMENT_SITE"
SetRedUnitActivity(state.getCurrentUnitName(), "MOVE_TO_DEPLOYMENT_SITE") SetRedUnitActivity(state.getCurrentUnitName(), "MOVE_TO_DEPLOYMENT_SITE")
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "MOVE_TO_POINT", str(wps) ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -166,6 +182,12 @@ if len(borg.redConvoysWaiting[state.getCurrentUnit().getName()])==0: ...@@ -166,6 +182,12 @@ if len(borg.redConvoysWaiting[state.getCurrentUnit().getName()])==0:
cmdName = state.getCurrentCommander().getAssignedName() cmdName = state.getCurrentCommander().getAssignedName()
SendEntityEvent(cmdName, "GoalTracker_ConvoySetup", []) SendEntityEvent(cmdName, "GoalTracker_ConvoySetup", [])
borg.delay=1.0 borg.delay=1.0
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "CONVOY_ARRIVED" "" ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -210,6 +232,13 @@ printMessage("Convoy setup for "+str(borg.formationsByName[formName].size()/2)+" ...@@ -210,6 +232,13 @@ printMessage("Convoy setup for "+str(borg.formationsByName[formName].size()/2)+"
# set activity to log # set activity to log
#borg.redUnitActivity[state.getCurrentUnitName()]="DEPLOY_AT_SITE" #borg.redUnitActivity[state.getCurrentUnitName()]="DEPLOY_AT_SITE"
SetRedUnitActivity(state.getCurrentUnitName(), "DEPLOY_AT_SITE") SetRedUnitActivity(state.getCurrentUnitName(), "DEPLOY_AT_SITE")
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "SETUP_STARTED" "" ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -255,6 +284,13 @@ if borg.redUnitStatus[state.getCurrentUnitName()]==setupNum: ...@@ -255,6 +284,13 @@ if borg.redUnitStatus[state.getCurrentUnitName()]==setupNum:
# set activity to log # set activity to log
#borg.redUnitActivity[state.getCurrentUnitName()]="OPERATE_AT_SITE" #borg.redUnitActivity[state.getCurrentUnitName()]="OPERATE_AT_SITE"
SetRedUnitActivity(state.getCurrentUnitName(), "OPERATE_AT_SITE") SetRedUnitActivity(state.getCurrentUnitName(), "OPERATE_AT_SITE")
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "SETUP_COMPLETE" "" ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -286,6 +322,14 @@ borg.delay=0 ...@@ -286,6 +322,14 @@ borg.delay=0
# set activity to log # set activity to log
#borg.redUnitActivity[state.getCurrentUnitName()]="PACK_UP_AT_SITE" #borg.redUnitActivity[state.getCurrentUnitName()]="PACK_UP_AT_SITE"
SetRedUnitActivity(state.getCurrentUnitName(), "PACK_UP_AT_SITE") SetRedUnitActivity(state.getCurrentUnitName(), "PACK_UP_AT_SITE")
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "PACK_UP_STARTED" "" ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -321,6 +365,12 @@ else: ...@@ -321,6 +365,12 @@ else:
SendUnitEventDelay(state.getCurrentUnit().getName(), "GoalTracker_MoveToPoint", ["CONVOY", randSpd, destName], borg.delay) SendUnitEventDelay(state.getCurrentUnit().getName(), "GoalTracker_MoveToPoint", ["CONVOY", randSpd, destName], borg.delay)
borg.delay=1.0 borg.delay=1.0
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "PACKUP_COMPLETE" "" ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -363,7 +413,15 @@ printMessage("Returning", True) ...@@ -363,7 +413,15 @@ printMessage("Returning", True)
##################################################### #####################################################
# set activity to log # set activity to log
#borg.redUnitActivity[state.getCurrentUnitName()]="RETURN_TO_GARRISON" #borg.redUnitActivity[state.getCurrentUnitName()]="RETURN_TO_GARRISON"
SetRedUnitActivity(state.getCurrentUnitName(), "RETURN_TO_GARRISON")</Code> SetRedUnitActivity(state.getCurrentUnitName(), "RETURN_TO_GARRISON")
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "RETURNING_TO_BASE" "" ])], 0)
</Code>
<Import /> <Import />
</HTNNode> </HTNNode>
</HTNNode> </HTNNode>
...@@ -391,6 +449,13 @@ if borg.redUnitStatus[state.getCurrentUnitName()]==state.getCurrentUnit().getMem ...@@ -391,6 +449,13 @@ if borg.redUnitStatus[state.getCurrentUnitName()]==state.getCurrentUnit().getMem
# set activity to log # set activity to log
#borg.redUnitActivity[state.getCurrentUnitName()] = None #borg.redUnitActivity[state.getCurrentUnitName()] = None
SetRedUnitActivity(state.getCurrentUnitName(), None) SetRedUnitActivity(state.getCurrentUnitName(), None)
# log data
if state.isCommander():
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["UnitLogger", "UNIT_NAME\tACTION\tDATA", ConvertToJavaList([ state.getCurrentUnitName(), "ARRIVED_AT_BASE" "" ])], 0)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
......
...@@ -412,9 +412,6 @@ _gt_activeNode.putVar("convoyIndex", convoyIndex+1) ...@@ -412,9 +412,6 @@ _gt_activeNode.putVar("convoyIndex", convoyIndex+1)
# go to making the convoy move (still in this tree) # go to making the convoy move (still in this tree)
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveConvoy", [tu.getName(), formName], 1) SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveConvoy", [tu.getName(), formName], 1)
# log data
logData = [ info.getMyAssignedName(), state.getCurrentUnitName() ]
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogMsg", ["TestLog", "NAME\tUNIT_NAME", ConvertToJavaList(logData)], 0)
</Code> </Code>
<Import /> <Import />
......
...@@ -16,7 +16,6 @@ __NETWORK_MOVE_PATH__ = "HTN/Trees/NetworkMove.xml" ...@@ -16,7 +16,6 @@ __NETWORK_MOVE_PATH__ = "HTN/Trees/NetworkMove.xml"
borg = None borg = None
def CreateWPAtCurrentLoc(entity): def CreateWPAtCurrentLoc(entity):
wp = HTNUtilities._py_addControlMeasure(entity.getAssignedName(), entity.getPhysicalState().getGroundTruthLocation()) wp = HTNUtilities._py_addControlMeasure(entity.getAssignedName(), entity.getPhysicalState().getGroundTruthLocation())
return wp return wp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment