//-------------------------------------------------
// Vehicle Helm config file
// M. Benjamin, MIT

initialize  DEPLOY  = false
initialize  RETURN  = false
initialize  STATION_KEEP = false
initialize  LOITER  = true
initialize  AVOID   = true

set MODE = ACTIVE {
  DEPLOY = true
} INACTIVE

set MODE = STATION-KEEPING {
  MODE = ACTIVE
  STATION_KEEP = true
}                       

set MODE = RETURNING {
  MODE = ACTIVE
  RETURN = true
} 

set MODE = LOITERING {
  MODE = ACTIVE
  LOITER = true
} 


//----------------------------------------------
Behavior = BHV_Loiter
{
  name      = loiter
  pwt       = 100
  condition = MODE==LOITERING
  updates   = UP_LOITER
  runflag   = VEHICLE_UNDERWAY = TRUE
  endflag   = VEHICLE_UNDERWAY = FALSE

  ipf_type = zaic_spd
	
   post_suffix = A
         speed = $(STOCK_SPD:=1.4)
     clockwise = false
        radius = 8.0
     nm_radius = 15.0
       polygon = radial:: $(LOITER_POS), radius=20, pts=8, snap=1, label=$(VNAME)_LOITER
  visual_hints = nextpt_color=white, nextpt_lcolor=khaki
  visual_hints = edge_color=orange, vertex_color=white
  visual_hints = edge_size=1, vertex_size=2
}

//----------------------------------------------
Behavior = BHV_AvdColregsV19
{
  name       = avdcol_
  pwt        = 150
  condition  = AVOID = true 
  condition  = MODE==ACTIVE
  updates    = CONTACT_INFO
  templating = spawn

	spawnxflag = INFO=os=$[OWNSHIP],utc=$[UTC],range=$[RANGE],contact=$[CONTACT],cn_os_rel_bng=$[CN_OS_REL_BNG],os_cn_rel_bng=$[OS_CN_REL_BNG]
             contact = to-be-set
    on_no_contact_ok = true
         extrapolate = true
               decay = 30,60

	       //match_group = alpha
        //  match_type = mokai

	exit_on_filter_group = true
	
	post_per_contact_info = true
	
  use_refinery = true

        pwt_outer_dist = 80
        pwt_inner_dist = 50
        completed_dist = 85
     min_util_cpa_dist = 10
     max_util_cpa_dist = 18
             pwt_grade = linear
   bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0
}

//----------------------------------------------
//Behavior = BHV_AvoidCollision
{
  name         = ac_
  pwt          = 500
  condition    = AVOID = true 
  updates      = CONTACT_INFO

  activeflag   = AVOIDING = active
  inactiveflag = AVOIDING = inactive
  runflag      = AVOIDING = running
  endflag      = AVOIDING = end

  templating   = spawn

             contact = to-be-set
    on_no_contact_ok = true
         extrapolate = true
               decay = 30,60

//	           cnflag = @<20 SAY_MOOS=hello
	           cnflag = @<20 ROC=$[ROC]
	           cnflag = @<20 OS_PORT_OF_CN = $[OS_PORT_OF_CN]
	           cnflag = @<20 OS_STAR_OF_CN = $[OS_STAR_OF_CN]
	           cnflag = @<20 OS_AFT_OF_CN = $[OS_AFT_OF_CN]
	           cnflag = @<20 OS_FORE_OF_CN = $[OS_FORE_OF_CN]
//             cnflag = @>39 SAY_MOOS=bye

        use_refinery = true

        pwt_outer_dist = 75
        pwt_inner_dist = 11
        completed_dist = 80
     min_util_cpa_dist = 8
     max_util_cpa_dist = 15
             pwt_grade = linear
   bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0
}

//----------------------------------------------
Behavior = BHV_Waypoint
{
  name        = waypt_return
  pwt         = 100
  updates     = RETURN_UPDATES
  condition   = MODE==RETURNING
  endflag     = STATION_KEEP = true
  endflag     = AVOID = false
	spawnx_flag = RETURN_UPDATES=point=$[OSX],$[OSY]
	
      speed = 1.3
     radius = 3.0
  nm_radius = 15.0
      point = 0,0
       lead = 8
}

//----------------------------------------------
Behavior = BHV_StationKeep
{
  name         = station-keep
  pwt          = 100
  condition    = MODE==STATION-KEEPING
  inactiveflag = STATIONING = false
  activeflag   = STATIONING = true

     center_activate = true
        inner_radius = 5
        outer_radius = 10 
         outer_speed = 1.0

       transit_speed = 1.3
          swing_time = 7
        visual_hints = vertex_size=0, edge_color=gray50
}