@startuml cdp_payload_fsm_continuous_mode
' Carto color palette
' light blue       #88CCEE
' light pink/red   #CC6677
' light yellow     #DDCC77
' dark green       #117733
' Dark purple      #332288
' Pink             #AA4499
' Light blue/green #44AA99
' Brown/yellow     #999933
' Dark purple      #882255
' Dark red         #661100
' Medium blue      #6699CC
' Grey             #888888

<style>
title {
  HorizontalAlignment right
  FontSize 40
  'BackGroundColor #F0F0F0
  Margin 1
  Padding 0
}
stateDiagram {
  arrow {
    FontSize 15
    FontStyle bold
  }
}
diamond {
    BackgroundColor #gold
    LineColor black
    LineThickness 0.5
}
</style>
skinparam RoundCorner 20
skinparam State {
  BackgroundColor #44AA99
  FontSize 16
  FontStyle bold
}


Title **CDP payload fsm** (continuous mode)
hide empty description

state after_TDH <<choice>>
state after_TDH_no_data <<choice>>
state after_TDT <<choice>>
state after_Data <<choice>>



[*] -right-----> IHW

IHW -right-> TDH

TDH --> after_TDH

after_TDH --> Data : [no_data == 0]
after_TDH --> after_TDH_no_data : [no_data == 1]

'note left of after_TDH_no_data : Both TDH and DDW0\nare legal next words

after_TDH_no_data --> TDH : [TDH]
after_TDH_no_data --> DDW0 : [DDW0]


Data --> after_Data

'note left of after_Data : Both Data and TDT\nare legal next words

after_Data --> Data : [Data Word]
after_Data --> TDT : [TDT]

TDT --> after_TDT
after_TDT --> TDH : [packet_done == 1\n&& TDH]
after_TDT --> DDW0 : [packet_done == 1\n&& DDW0]
after_TDT --> IHW : [packet_done == 1\n&& IHW]
after_TDT --> Continuation : [packet_done == 0\n&& event page full]
'note right of after_TDT : IHW, TDH and DDW0\nare legal next words\nwhen **packet_done == 1**

state Continuation #6699CC {
  state after_c_Data <<choice>>
    [*] -left---> c_IHW
    c_IHW --> c_TDH : [stop_bit == 0\n&& Page >= 1]


    c_TDH --> c_Data
    c_Data -> after_c_Data

    after_c_Data -left-> c_Data : [Data Word]
    after_c_Data -up-> c_TDT : [TDT]

    c_TDT -down-> after_TDT

    'note top of after_c_Data : Both Data and TDT\nare legal next words\nif event page is not full

}



DDW0 -----right-----> [*]

@enduml
