# Test Set 4: Time-Based Rule Production.
#
# Assume nm_mgr is on ipn:1.1
# Assume nm_agent is on ipn:1.2

###############################################################################
# TC 4.1 Generate Reports to a schedule.
###############################################################################
# This test will cause an AGENT FULL report to be generated
# 5 times at intervals of 5 seconds each.
#
###############################################################################


#------------------------------------------------------------------------------
# Step 4.1.1: Build the TBR to report on the AGENT Full Report.
#------------------------------------------------------------------------------
#
# NOTE: The TBR will be identified as "ari://Tbr.1" which is 0x0b4131
# START: 0
# PERIOD: 5
# COUNT: 5
# Action: {GEN_RPT({FULL_REPORT}, 0)}
# Description: TBR1
#
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:AMP.AGENT/CTRL.ADD_TBR(ari://Tbr.1, 0, 5, 5, [ari:/IANA:amp.agent/Ctrl.gen_rpts([ari:/IANA:amp.agent/Rptt.full_report()],[])], ‘TBR1’)
#
#------------------------------------------------------------------------------
c115410a05062420201625120b413100050581c11541050502252381871819410000682018544252312019
WAIT 1

#------------------------------------------------------------------------------
# Step 4.1.2: Verify that 5 reports are received approximately
# 5 seconds apart (variance up to 1 second between individual reports
# are within tolerance due to the 1Hz rate of the agent autonomy
# engine.
#------------------------------------------------------------------------------

WAIT 30


###############################################################################
# TC 4.2: Manipulate TBRs.
###############################################################################
# Interrupt a running TBR
###############################################################################

#------------------------------------------------------------------------------
# Step 4.2.1: Define a TBR  (TBR 2) that will generate an AGENT FULL REPORT
# every 30 seconds 100 times.
#------------------------------------------------------------------------------
#
# NOTE: The TBR will be identified as "ari://Tbr.2" which is 0x0b4132
# START: 0
# PERIOD: 30
# COUNT: 100
# Action: {GEN_RPT({FULL_REPORT}, 0)}
# Description: TBR2
#
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:AMP.AGENT/CTRL.ADD_TBR(ari://Tbr.2, 0, 30, 100,
#         [ari:/IANA:amp.agent/Ctrl.gen_rpts([ari:/IANA:amp.agent/Rptt.full_report()],[])], ‘TBR2’)
#
#------------------------------------------------------------------------------
c115410a05062420201625120b413200181e186481c11541050502252381871819410000682018544252322019
WAIT 1


#------------------------------------------------------------------------------
# Step 4.2.2: List TBRs on the agent.
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:amp.agent/Ctrl.gen_tbls([ari:/IANA:amp.agent/Tblt.rules()],[])
#
#------------------------------------------------------------------------------
c115410605022523818a181b410400
WAIT 1


#------------------------------------------------------------------------------
# Step 4.2.3: Verify TBR 2 is listed in the reported rules.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Step 4.2.4: Describe TBR 2.
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:amp.agent/Ctrl.desc_rule([ari://Tbr.2])
#
#------------------------------------------------------------------------------
c115410d050125810b4132
WAIT 1

#------------------------------------------------------------------------------
# Step 4.2.5: Verify the description matches the definition.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Step 4.2.6: Delete TBR 2.
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:amp.agent/Ctrl.del_rule([ari://TBR.2])
#
#------------------------------------------------------------------------------
c115410c050125810b4132
WAIT 1


#------------------------------------------------------------------------------
# Step 4.2.7: Verify no reports received after TRL deleted.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Step 4.2.8: List TBRs on the agent.
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:amp.agent/Ctrl.gen_tbls([ari:/IANA:amp.agent/Tblt.rules()],[])
#
#------------------------------------------------------------------------------
c115410605022523818a181b410400
WAIT 1

#------------------------------------------------------------------------------
# Step 4.2.9: Verify TBR2 not shown in list.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Step 4.2.10: Describe TBR 2 from the agent.
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:amp.agent/Ctrl.desc_rule([ari://TBR.2])
#
#------------------------------------------------------------------------------
c115410d050125810b4132
WAIT 1

#------------------------------------------------------------------------------
# Step 4.2.11: Verify TBR not there to be described.
#------------------------------------------------------------------------------


###############################################################################
# TC 4.3: Run macro by TBR
###############################################################################
#
###############################################################################

#------------------------------------------------------------------------------
# Step 4.3.1: Create a Macro that generates a BP full report.
#
# Type: Macro (mac)
# Name: bp_full_rpt_macro
# Macro ARI: ari://Mac.bp_full_rpt_macro
# CBOR Macro ARI: 0x045162705f66756c6c5f7270745f6d6163726f
#
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:amp.agent/Ctrl.add_macro("bp_full_rpt_macro",
#        ari://Mac.bp_full_rpt_macro, [ari:/IANA:amp.agent/Ctrl.gen_rpts(
#         [ari:/IANA:dtn.bp_agent/Rptt.full_report()], [])])
#
#------------------------------------------------------------------------------
c11541070503122425732262705f66756c6c5f7270745f6d6163726f22045162705f66756c6c5f7270745f6d6163726f81c1154105050225238187182d410000
WAIT 1


#------------------------------------------------------------------------------
# Step 4.3.2: Define TBR T7 to run Agent Macro bp_full_rpt_macro 1 time with
#             period 5.
#------------------------------------------------------------------------------
#
# NOTE: The TBR will be identified as "ari://Tbr.7" which is 0x0b4137
# START: 0
# PERIOD: 5
# COUNT: 1
# Action: {bp_full_rpt_macro}
# Description: TBR7
#
#------------------------------------------------------------------------------
#
# ARI: ari:/IANA:AMP.AGENT/CTRL.ADD_TBR(ari://Tbr.7, 0, 5, 1,
#        [ari://Mac.bp_full_rpt_macro], ‘TBR7’)
#
#------------------------------------------------------------------------------
c115410a05062420201625120b413700050181045162705f66756c6c5f7270745f6d6163726f682018544252372019
WAIT 1

#------------------------------------------------------------------------------
# Step 4.3.2: Read the returned report and make sure parms were correct.
#------------------------------------------------------------------------------
