Hi Cyuan
I'm a bit confused by the wording "change to a different state at fixed timings".
Did you mean that during the first (fixed?) interval, you want to capture a behavior event, and when the interval is over you want to go into one of several different delay states depending on which event you captured?
If so, You can use the following example:
sma = NewStateMachine;
sma = SetGlobalTimer(sma, 'TimerID', 1, 'Duration', 3);
sma = AddState(sma, 'Name', 'PreviousTimeInterval', ...
'Timer', 0,...
'StateChangeConditions', {'Port1In', 'Port1Chosen', 'Port2In', 'Port2Chosen', 'GlobalTimer1_End', 'MassiveDelay'},...
'OutputActions', {'GlobalTimerTrig', 1});
sma = AddState(sma, 'Name', 'Port1Chosen', ...
'Timer', 0,...
'StateChangeConditions', {'GlobalTimer1_End', 'ShortDelay'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'Port2Chosen', ...
'Timer', 0,...
'StateChangeConditions', {'GlobalTimer1_End', 'LongDelay'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'ShortDelay', ...
'Timer', 1,...
'StateChangeConditions', {'Tup', 'exit'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'LongDelay', ...
'Timer', 2,...
'StateChangeConditions', {'Tup', 'exit'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'MassiveDelay', ...
'Timer', 5,...
'StateChangeConditions', {'Tup', 'exit'},...
'OutputActions', {});
Please let me know if you meant something else and I'll try to help.
-Josh