stateDiagram

%% Initial state name as "." so that it fits in black circle shape.
%% See https://github.com/StateSmith/StateSmith/issues/404
state "." as ROOT.(InitialState)

STANDBY

STANDBY : STANDBY

STANDBY : enter / #123; ResetRXIQCalBand()#59; #125;

state FIND_MINIMUM {

        WAIT

        WAIT : WAIT

        WAIT : enter / #123; count_ms = 0#59; #125;

        WAIT : 1. do / #123; count_ms++#59;\nUpdateRXDeltaVal()#59; #125;

        ADJUST

        ADJUST : ADJUST

        ADJUST : enter / #123; AdjustRXIQCalSetting()#59; #125;

        READ

        READ : READ

        READ : enter / #123; ReadRXIQDelta()#59; #125;

        %% Initial state name as "." so that it fits in black circle shape.
        %% See https://github.com/StateSmith/StateSmith/issues/404
        state "." as FIND_MINIMUM.(InitialState)

        state "$exit_pt.done" as FIND_MINIMUM.(ExitPoint)(done)

}

BAND_ADJUST

BAND_ADJUST : BAND_ADJUST

BAND_ADJUST : enter / #123; AdjustRXIQBand()#59; #125;

ROOT.(InitialState) --> STANDBY

STANDBY --> BAND_ADJUST : AUTO

WAIT --> READ : do [count_ms >= acquisitionDuration_ms]

ADJUST --> FIND_MINIMUM.(ExitPoint)(done) : MIN_EXIT

ADJUST --> WAIT : READ_DELTA

READ --> ADJUST : NEXT_POINT

READ --> FIND_MINIMUM.(ExitPoint)(done) : MIN_EXIT

FIND_MINIMUM.(InitialState) --> ADJUST

FIND_MINIMUM.(ExitPoint)(done) --> BAND_ADJUST

BAND_ADJUST --> FIND_MINIMUM : FIND_MINIMUM

BAND_ADJUST --> STANDBY : AUTO_COMPLETE