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

* added mechanism to make logging easier

* added TestLog for now
* begining work on unit level logger
parent bc8e4511
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ borg.redLoggerInterval = 60 ...@@ -35,6 +35,7 @@ borg.redLoggerInterval = 60
# goal tracker events # goal tracker events
#goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_Event") #goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_Event")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_LogInfo") goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_LogInfo")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_LogMsg")
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
...@@ -86,6 +87,41 @@ LogGenericMsg.logMsg( ...@@ -86,6 +87,41 @@ LogGenericMsg.logMsg(
#printMessage("TEST LOG", True) #printMessage("TEST LOG", True)
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogInfo", [], borg.redLoggerInterval) SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogInfo", [], borg.redLoggerInterval)
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="isGoalTracker_LogMsg" Type="DEFAULT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">if state.getLastTrigger().startswith("doGoalTracker_LogMsg"):
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="logMsg" Type="INTERRUPT">
<Parent>isGoalTracker_LogInfo</Parent>
<Code IsFile="false">import mtry.cxxi.model.MtryLog.LogGenericMsg as LogGenericMsg
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import IsTransmitting
from HTNBehaviors import ConvertJavaToList
# event params
params = state.getLastTriggerParams()[0]
# logger name
logName = params.get(0)
# logger header
logHeader = params.get(1)
# the data is put into a java list so get it back out into a python list
logData = ConvertJavaToList(params.get(2))
# log the message
LogGenericMsg.logMsg(
logName,
logHeader,
info.getMySelf(),
logData)
</Code> </Code>
<Import /> <Import />
</HTNNode> </HTNNode>
......
...@@ -371,6 +371,7 @@ goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ReclaimCo ...@@ -371,6 +371,7 @@ goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ReclaimCo
<Parent>isCreateConvoy</Parent> <Parent>isCreateConvoy</Parent>
<Code IsFile="false">import mtry.cxxi.model.HierarchicalTaskNetwork.PythonUtilities.PythonUnit as PythonUnit <Code IsFile="false">import mtry.cxxi.model.HierarchicalTaskNetwork.PythonUtilities.PythonUnit as PythonUnit
from HTNBehaviors import SendEntityEventDelay from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import ConvertToJavaList
# an index for the convoy # an index for the convoy
convoyIndex = _gt_activeNode.getVar("convoyIndex") convoyIndex = _gt_activeNode.getVar("convoyIndex")
...@@ -410,6 +411,11 @@ _gt_activeNode.putVar("convoyIndex", convoyIndex+1) ...@@ -410,6 +411,11 @@ _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 />
</HTNNode> </HTNNode>
......
...@@ -67,6 +67,12 @@ def GetRandomPoint(): ...@@ -67,6 +67,12 @@ def GetRandomPoint():
return destName return destName
# returns a true or false depending on whether the drawn number is
# less than the probability
def GetRandomChance(probability):
int_num = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0])
return int_num < probability
def _InitBorgInternal(): def _InitBorgInternal():
global borg global borg
......
...@@ -5,6 +5,7 @@ from HTNBehaviors import SendEntityEvent ...@@ -5,6 +5,7 @@ from HTNBehaviors import SendEntityEvent
from HTNBehaviors import ConvertToJavaList from HTNBehaviors import ConvertToJavaList
from HTNBehaviors import ConvertToJavaListRandom from HTNBehaviors import ConvertToJavaListRandom
from HTNBehaviors import GetRandomInt from HTNBehaviors import GetRandomInt
from HTNBehaviors import GetRandomChance
from SATracker import SATracker from SATracker import SATracker
...@@ -26,6 +27,10 @@ printMessage("SA Inited = "+str(borg.saTracker.retrieveData(info.getMyAssignedNa ...@@ -26,6 +27,10 @@ printMessage("SA Inited = "+str(borg.saTracker.retrieveData(info.getMyAssignedNa
borg.goalPath = "HTN/Trees/" borg.goalPath = "HTN/Trees/"
entityName = "RFC" entityName = "RFC"
# get bool value for if we're in attack mode or not
# 0.5 maps to a 50% chance of attack mode being true
borg.attackMode = GetRandomChance(0.5)
randomMoveVeh = ["Entity_303", "Entity_304", "Entity_305", "Entity_306", "Entity_307", randomMoveVeh = ["Entity_303", "Entity_304", "Entity_305", "Entity_306", "Entity_307",
"Entity_308", "Entity_309", "Entity_310", "Entity_311", "Entity_312", "Entity_308", "Entity_309", "Entity_310", "Entity_311", "Entity_312",
"Entity_313", "Entity_314", "Entity_315", "Entity_316", "Entity_317", "Entity_313", "Entity_314", "Entity_315", "Entity_316", "Entity_317",
......
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