//-*-c++-*-
#ifndef INCLUDED_ParallelBehavior_h_
#define INCLUDED_ParallelBehavior_h_
 
#include "Behaviors/StateMachine.h"

#include "Events/EventRouter.h"
class ParallelBehavior : public StateNode {
public:
  ParallelBehavior() : StateNode("ParallelBehavior") {}

  virtual void setup() {
    std::cout << getName() << " is setting up the state machine." << std::endl;

#statemachine

//States
launch: StateNode =N=> {red1, barklow1}

//--Led cycle
red1: LedNode [getMC()->flash(RobotInfo::RedLEDMask, 1000);]

yellow1: LedNode [getMC()->flash(RobotInfo::YellowLEDMask, 1000);]

blue1: LedNode [getMC()->flash(RobotInfo::BlueLEDMask, 1000);] 

green1: LedNode [getMC()->flash(RobotInfo::GreenLEDMask, 1000);] 

//--Led inverse cycle
red2: LedNode [getMC()->flash(RobotInfo::RedLEDMask, 1000);]

yellow2: LedNode [getMC()->flash(RobotInfo::YellowLEDMask, 1000);]

blue2: LedNode [getMC()->flash(RobotInfo::BlueLEDMask, 1000);] 

green2: LedNode [getMC()->flash(RobotInfo::GreenLEDMask, 1000);] 

//-- Bark cycle
barklow1: SoundNode($, "barklow.wav") 

barkmed1: SoundNode($, "barkmed.wav")

barkhigh1: SoundNode($, "barkhigh.wav")

//--Bark inverse cycle
barklow2: SoundNode($, "barklow.wav") 

barkmed2: SoundNode($, "barkmed.wav")

barkhigh2: SoundNode($, "barkhigh.wav")

//Transistions

//--Led cycle
red1 =C=> yellow1

yellow1 =C=> green1

green1 =C=> blue1

blue1 =C=> red1

//--Led inverse cycle
red2 =C=> blue2

blue2 =C=> green2

green2 =C=> yellow2

yellow2 =C=> red2

//--Led button press
red1 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>blue2

blue1 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>green2

green1=E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>yellow2

yellow1=E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>red2

red2=E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>yellow1

yellow2 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>green1

green2 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>blue1

blue2=E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>red1

//--Bark cycle
barklow1 =C=> barkmed1

barkmed1 =C=> barkhigh1

barkhigh1 =C=> barklow1

//--Bark inverse cycle
barklow2 =C=> barkhigh2

barkmed2 =C=> barklow2

barkhigh2 =C=> barkmed2

//--Bark button press
barklow1 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>barkhigh2

barkmed1 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>barklow2

barkhigh1 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>barkmed2

barklow2 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>barkmed1

barkmed2 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>barkhigh1

barkhigh2 =E(buttonEGID, RobotInfo::GreenButOffset, activateETID)=>barklow1

#endstatemachine

    startnode = launch;
  }

virtual void DoStart() {
    std::cout << getName() << " is starting up." << std::endl;
  }
  
  virtual void DoStop() {
    std::cout << getName() << " is shutting down." << std::endl;
  }
  
 private:  // Dummy methods to satisfy the compiler
  ParallelBehavior(const ParallelBehavior&);
  ParallelBehavior& operator=(const ParallelBehavior&);
  
};

#endif
