#include "Behaviors/StateMachine.h"

$nodeclass ParallelMachine : StateNode {
  $setupmachine{

    launch: StateNode =N=> {noblink, flash_power, low_bark}

    noblink: LedNode [setPriority(MotionManager::kBackgroundPriority);
	                  getMC()->set(RobotInfo::AllLEDMask,0.0)]

    flash_power: LedNode [getMC()->set(RobotInfo::PowerRedLEDMask,1.0)] =B(RobotInfo::BumpLeftButOffset)=> flash_advance_r
    flash_play: LedNode [getMC()->set(RobotInfo::PlayLEDMask,1.0)] =B(RobotInfo::BumpLeftButOffset)=> flash_power_r
    flash_advance: LedNode [getMC()->set(RobotInfo::AdvanceLEDMask,1.0)] =B(RobotInfo::BumpLeftButOffset)=> flash_play_r

    flash_power =T(1000)=> flash_play =T(1000)=> flash_advance =T(1000)=> flash_power

    flash_power_r: LedNode [getMC()->set(RobotInfo::PowerRedLEDMask,1.0)] =B(RobotInfo::BumpLeftButOffset)=> flash_play
    flash_play_r: LedNode [getMC()->set(RobotInfo::PlayLEDMask,1.0)] =B(RobotInfo::BumpLeftButOffset)=> flash_advance
    flash_advance_r: LedNode [getMC()->set(RobotInfo::AdvanceLEDMask,1.0)] =B(RobotInfo::BumpLeftButOffset)=> flash_power

    flash_power_r =T(1000)=> flash_advance_r =T(1000)=> flash_play_r =T(1000)=> flash_power_r

    low_bark: SoundNode("barklow.wav") =B(RobotInfo::BumpLeftButOffset)=> yipper_r
    med_bark: SoundNode("barkmed.wav") =B(RobotInfo::BumpLeftButOffset)=> low_bark_r
    yipper: SoundNode("yipper.wav") =B(RobotInfo::BumpLeftButOffset)=> med_bark_r

    low_bark =T(1000)=> med_bark =T(1000)=> yipper =T(1000)=> low_bark

    low_bark_r: SoundNode("barklow.wav") =B(RobotInfo::BumpLeftButOffset)=> med_bark
    med_bark_r: SoundNode("barkmed.wav") =B(RobotInfo::BumpLeftButOffset)=> yipper
    yipper_r: SoundNode("yipper.wav") =B(RobotInfo::BumpLeftButOffset)=> low_bark

    low_bark_r =T(1000)=> yipper_r =T(1000)=> med_bark_r =T(1000)=> low_bark_r
  }

}

REGISTER_BEHAVIOR(ParallelMachine);
