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

* is transmitting

parent 5ae67298
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,6 @@
#
#borg.redUnitStatus[state.getCurrentUnitName()] = 0
#
</Code>
<Import />
</HTNNode>
......@@ -86,6 +85,7 @@ borg.redUnitStatus[state.getCurrentUnitName()] = 0
<HTNNode AllowMsg="true" Name="moveToPoint" Type="INTERRUPT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">from HTNBehaviors import CreateNetworkMove
from HTNBehaviors import SetRedUnitActivity
params = state.getLastTriggerParams()[0]
......@@ -118,7 +118,8 @@ printMessage("Starting move: "+str(wps)+" Spd: "+str(randSpd), True)
#####################################################
# set activity to log
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")
</Code>
<Import />
</HTNNode>
......@@ -142,6 +143,8 @@ if len(borg.redConvoysWaiting[state.getCurrentUnit().getName()])==0:
moveDestination = _gt_activeNode.getVar("moveDestination")
printMessage("MOVE WAS COMPLETED "+moveReason+" "+moveDestination, True)
if moveReason == "ASSEMBLE":
# let the unit know TODO: THis should probably come from the RFC
......@@ -176,6 +179,7 @@ if len(borg.redConvoysWaiting[state.getCurrentUnit().getName()])==0:
from java.util import ArrayList
from HTNBehaviors import CreateBasicMove
from HTNBehaviors import ConvertToJavaList
from HTNBehaviors import SetRedUnitActivity
printMessage("Starting convoy setup", True)
......@@ -201,7 +205,8 @@ printMessage("Convoy setup for "+str(borg.formationsByName[formName].size()/2)+"
#####################################################
# set activity to log
borg.redUnitActivity[state.getCurrentUnitName()]="DEPLOY_AT_SITE"
#borg.redUnitActivity[state.getCurrentUnitName()]="DEPLOY_AT_SITE"
SetRedUnitActivity(state.getCurrentUnitName(), "DEPLOY_AT_SITE")
</Code>
<Import />
</HTNNode>
......@@ -216,6 +221,7 @@ borg.redUnitActivity[state.getCurrentUnitName()]="DEPLOY_AT_SITE"
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">import cxxi.model.behavior.PythonUtilities as PythonUtilities
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import SetRedUnitActivity
borg.redUnitStatus[state.getCurrentUnitName()] = borg.redUnitStatus[state.getCurrentUnitName()] + 1
setupNum = _gt_activeNode.getVar("setupNum")
......@@ -244,8 +250,8 @@ if borg.redUnitStatus[state.getCurrentUnitName()]==setupNum:
#####################################################
# set activity to log
borg.redUnitActivity[state.getCurrentUnitName()]="OPERATE_AT_SITE"
#borg.redUnitActivity[state.getCurrentUnitName()]="OPERATE_AT_SITE"
SetRedUnitActivity(state.getCurrentUnitName(), "OPERATE_AT_SITE")
</Code>
<Import />
</HTNNode>
......@@ -260,6 +266,7 @@ if borg.redUnitStatus[state.getCurrentUnitName()]==setupNum:
<Parent>isGoalTracker_ConvoyPackUp</Parent>
<Code IsFile="false">import cxxi.model.behavior.PythonUtilities as PythonUtilities
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import SetRedUnitActivity
# commander name
cmdName=""
......@@ -274,7 +281,8 @@ borg.delay=0
#####################################################
# 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")
</Code>
<Import />
</HTNNode>
......@@ -305,7 +313,9 @@ borg.delay=0
<Import />
<HTNNode AllowMsg="true" Name="convoyReturn" Type="INTERRUPT">
<Parent>isGoalTracker_ConvoyReturn</Parent>
<Code IsFile="false">printMessage("Need to return", True)
<Code IsFile="false">from HTNBehaviors import SetRedUnitActivity
printMessage("Need to return", True)
# TODO: This should probably use the moveToPoint methods
......@@ -332,8 +342,8 @@ printMessage("Returning", True)
#####################################################
# set activity to log
borg.redUnitActivity[state.getCurrentUnitName()]="RETURN_TO_GARRISON"
</Code>
#borg.redUnitActivity[state.getCurrentUnitName()]="RETURN_TO_GARRISON"
SetRedUnitActivity(state.getCurrentUnitName(), "RETURN_TO_GARRISON")</Code>
<Import />
</HTNNode>
</HTNNode>
......@@ -347,6 +357,7 @@ borg.redUnitActivity[state.getCurrentUnitName()]="RETURN_TO_GARRISON"
<Parent>New Node</Parent>
<Code IsFile="false">import cxxi.model.behavior.PythonUtilities as PythonUtilities
from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import SetRedUnitActivity
borg.redUnitStatus[state.getCurrentUnitName()] = borg.redUnitStatus[state.getCurrentUnitName()] + 1
#setupNum = _gt_activeNode.getVar("setupNum")
......@@ -358,7 +369,8 @@ if borg.redUnitStatus[state.getCurrentUnitName()]==state.getCurrentUnit().getMem
#####################################################
# set activity to log
borg.redUnitActivity[state.getCurrentUnitName()] = None
#borg.redUnitActivity[state.getCurrentUnitName()] = None
SetRedUnitActivity(state.getCurrentUnitName(), None)
</Code>
<Import />
</HTNNode>
......
......@@ -74,11 +74,14 @@ if currentActivity == None:
loc = state.getCurrentLocation()
heading = state.getCurrentHeading().getHeadingInDegrees()
isTransmitting = IsTransmitting(state.getCurrentUnitName(), state.isCommander())
LogGenericMsg.logMsg(
"EntityActivityLogger",
"ID\tProfile\tLat\tLon\tEle\tSpeed\tHeading\Activity",
"ID\tProfile\tLat\tLon\tEle\tSpeed\tHeading\tActivity\tTransmitting",
info.getMySelf(),
[str(info.getMySelf().getID()), info.getMyProfile().getName(), str(loc.getLatitude()), str(loc.getLongitude()), str(loc.getElevation()), str(state.getCurrentSpeed()), str(heading), currentActivity])
[str(info.getMySelf().getID()), info.getMyProfile().getName(), str(loc.getLatitude()), str(loc.getLongitude()), str(loc.getElevation()), str(state.getCurrentSpeed()), str(heading), currentActivity, str(isTransmitting)])
#printMessage("TEST LOG", True)
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_LogInfo", [], borg.redLoggerInterval)
......
......@@ -12,11 +12,14 @@
<Import />
<HTNNode AllowMsg="true" Name="createData" Type="DEFAULT">
<Parent>addReplanTriggers</Parent>
<Code IsFile="false">profileName = info.getMyProfile().getName()
<Code IsFile="false">from HTNBehaviors import SetRedUnitActivity
profileName = info.getMyProfile().getName()
printMessage("Radar started for "+profileName, True) # desc string, append name True/False
if "NEBO" in profileName:
borg.redUnitActivity[state.getCurrentUnitName()]="EMITTING-EWR"
#borg.redUnitActivity[state.getCurrentUnitName()]="EMITTING-EWR"
SetRedUnitActivity(state.getCurrentUnitName(), "EMITTING-EWR")
</Code>
<Import />
</HTNNode>
......@@ -85,7 +88,9 @@ printMessage("Radar start "+info.getMyProfile().getName()+": "+str(totalTime)+"
<Import />
<HTNNode AllowMsg="false" Name="radarOn" Type="INTERRUPT">
<Parent>New Node</Parent>
<Code IsFile="false">#####################################################
<Code IsFile="false">from HTNBehaviors import SetRedEntityActivityOverride
#####################################################
# set activity to log
profileName = info.getMyProfile().getName()
......@@ -97,7 +102,9 @@ elif profileName == "TARGET_ACQ_RADAR":
else:
suffixName = "EWR"
borg.redEntityActivityOverride[info.getMyAssignedName()]="EMITTING-"+suffixName
#borg.redEntityActivityOverride[info.getMyAssignedName()]="EMITTING-"+suffixName
SetRedEntityActivityOverride(info.getMyAssignedName(), "EMITTING-"+suffixName)
printMessage("Radar on", True) # desc string, append name True/False
</Code>
<Import />
......@@ -111,9 +118,12 @@ printMessage("Radar on", True) # desc string, append name True/False
<Import />
<HTNNode AllowMsg="false" Name="radarOff" Type="INTERRUPT">
<Parent>New Node</Parent>
<Code IsFile="false">#####################################################
<Code IsFile="false">from HTNBehaviors import SetRedEntityActivityOverride
#####################################################
# set activity to log
del borg.redEntityActivityOverride[info.getMyAssignedName()]
#del borg.redEntityActivityOverride[info.getMyAssignedName()]
SetRedEntityActivityOverride(info.getMyAssignedName(), None)
printMessage("Radar off", True) # desc string, append name True/False
</Code>
<Import />
......
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<HTNNode AllowMsg="true" Name="RadioTree" Type="DEFAULT">
<Parent>null</Parent>
<Code IsFile="false" />
<Import />
<HTNNode AllowMsg="true" Name="initInfo" Type="DEFAULT">
<Parent>BasicTree</Parent>
<Code IsFile="false">if _gt_activeNode.getVar("isInited") == None:
_gt_activeNode.putVar("isInited", 1)
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="initTransmittingFlag" Type="DEFAULT">
<Parent>addReplanTriggers</Parent>
<Code IsFile="false"># set the transmission time in seconds
_gt_activeNode.putVar("transmitTime", 10)
# is transmitting flag
_gt_activeNode.putVar("isTransmitting", False)
# is communicating
_gt_activeNode.putVar("isCommunicating", False)
</Code>
<Import />
</HTNNode>
<HTNNode AllowMsg="true" Name="addReplanTriggers" Type="INTERRUPT">
<Parent>initInfo</Parent>
<Code IsFile="false"># model events
#goalContainer.getCurrentExecutingStack().addReplanTrigger("ModelEvent")
# goal tracker events
#goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_Event")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_StartRadioCheckIn")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_StopRadioCheckIn")
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="events" Type="DEFAULT">
<Parent>BasicTree</Parent>
<Code IsFile="false" />
<Import />
<HTNNode AllowMsg="true" Name="isGoalTrackerEvent" Type="DEFAULT">
<Parent>events</Parent>
<Code IsFile="false">if state.getLastTrigger().startswith("doGoalTracker_"):
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="isGoalTracker_StartRadioCheckIn" Type="DEFAULT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">if state.getLastTrigger().startswith("doGoalTracker_StartRadioCheckIn"):
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="setTransmitFlag" Type="INTERRUPT">
<Parent>isGoalTracker_LogInfo</Parent>
<Code IsFile="false">
#isCommunicating = _gt_activeNode.getVar(")
# flip the flag
_gt_activeNode.putVar("isTransmitting", True)
transmitTime = _gt_activeNode.getVar("transmitTime")
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_StopRadioCheckIn", [], transmitTime)
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="isGoalTracker_StopRadioCheckIn" Type="DEFAULT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">if state.getLastTrigger().startswith("doGoalTracker_StopRadioCheckIn"):
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="clearTransmitFlag" Type="INTERRUPT">
<Parent>isGoalTracker_LogInfo</Parent>
<Code IsFile="false"># flip the flag
_gt_activeNode.putVar("isTransmitting", False)
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="printGoalTrackerEvent" Type="INTERRUPT">
<Parent>isGoalTrackerEvent</Parent>
<Code IsFile="false">printMessage("GOAL TRACKER EVENT"+state.getLastTrigger(), True)
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="modelEvents" Type="DEFAULT">
<Parent>events</Parent>
<Code IsFile="false" />
<Import />
<HTNNode AllowMsg="true" Name="printEvent" Type="INTERRUPT">
<Parent>modelEvents</Parent>
<Code IsFile="false">printMessage("EVENT"+state.getLastTrigger(), True)</Code>
<Import />
</HTNNode>
</HTNNode>
</HTNNode>
</HTNNode>
\ No newline at end of file
......@@ -14,6 +14,7 @@
<Parent>initInfo</Parent>
<Code IsFile="false">from HTNBehaviors import SendEntityEventDelay
from HTNBehaviors import GetRandomPoint
from HTNBehaviors import SetRedUnitActivity
import cxxi.model.behavior.PythonUtilities as PythonUtilities
import math
......@@ -33,7 +34,8 @@ printMessage("Create Data for Random Move", True)
#####################################################
# set activity to log
borg.redUnitActivity[state.getCurrentUnitName()]="RANDOM-MOVE"
#borg.redUnitActivity[state.getCurrentUnitName()]="RANDOM-MOVE"
SetRedUnitActivity(state.getCurrentUnitName(), "RANDOM-MOVE")
</Code>
<Import />
</HTNNode>
......
......@@ -20,6 +20,7 @@ borg.redUnitStatus=dict()
# for logging
borg.redUnitActivity=dict()
borg.redUnitActivityTime=dict()
borg.redEntityActivityOverride=dict()
borg.redDestinations=["PATH_DEST1", "PATH_DEST2","PATH_DEST3","PATH_DEST4","PATH_DEST5","PATH_DEST6","PATH_DEST7","PATH_DEST8","PATH_DEST9"]
......
......@@ -6,6 +6,8 @@ import cxxi.model.behavior.OrderUtilities as OrderUtilities
import mtry.cxxi.model.HierarchicalTaskNetwork.GoalContainer as GoalContainer
import cxxi.model.behavior.PythonUtilities as PythonUtilities
import simkit.Schedule as Schedule
#from UtilityFuncsExp import HTNBorg as borg
__HTN_PATH__ = "HTN/Trees/"
......@@ -14,6 +16,36 @@ __NETWORK_MOVE_PATH__ = "HTN/Trees/NetworkMove.xml"
borg = None
def IsTransmitting(unitName, isCommander):
_InitBorgInternal()
# is transmitting
activityName = borg.redUnitActivity[unitName]
activityTime = int(borg.redUnitActivityTime[unitName])
elapsedTime = int(Schedule.getSimTime()) - activityTime
if activityName == "MOVE_TO_DEPLOYMENT_SITE" and not isCommander and (elapsedTime >= 300 and elapsedTime <= 310):
return True
elif activityName == "OPERATE_AT_SITE" and isCommander (elapsedTime >= 3600 and elapsedTime <= 3610):
return True
else
return False
def SetRedUnitActivity(unitName, activityName):
_InitBorgInternal()
borg.redUnitActivity[unitName]=activityName
borg.redUnitActivityTime[unitName]=Schedule.getSimTime()
def SetRedEntityActivityOverride(entityName, activityName):
_InitBorgInternal()
if activityName != None:
borg.redEntityActivityOverride[entityName]=activityName
borg.redEntityActivityOverride[entityName]=Schedule.getSimTime()
else:
del borg.redEntityActivityOverride[entityName]
# Reads from a list of allWPs
def GetRandomPoint():
_InitBorgInternal()
......@@ -35,8 +67,6 @@ def _InitBorgInternal():
exec(impStr)
borg = HTNBorg()
print "Borg created"
else:
print "Borg already created"
def TestBorg():
_InitBorgInternal()
......
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