I'll have to get onto this again tonight.
I think I used your set of transitions from post
149
I didn't have time to go through your walk-throughs after writing it or I may have noticed I had done the other line!
It does sound like you're using the software correctly, Although you really need to hit step on every panel (and possibly keep pressing them until nothing else changes if you want to be certain of the final result of some input).
What you can do is verify I have all the states defined correctly in terms of their outputs. Especially important is the definition of the output signals.
Start from the initial condition where everything is in reset and use the drop down list to confirm that the states produce the correct output. This is the first of three fundamental tests. If I have this wrong, then it is pointless going further.
What I'd expect is a list like this:
Foo Panel
1) When in state foo_init, the foo_o_bar_ready should be on
2) When in state foo_baring, the foo_o_bar_ready should be off
3) The output signal foo_o_widget_bar should be changed to foo_o_gadget_bar
4) The output indication bar_o_bar_mode looks like a typo, it should be foo_o_bar_mode
All other outputs are correct as currently encoded.
So I currently note that:
CFY_UD panel
1) When in state CFY_UD_S_SDIC output Signal CFY_UD_ERM_O_STRD is ON but should be OFF
What I also now know is that there is a state (or states) where that signal needs to be ON, but I don't know what they are. I hope you will lest another state where this output signal is off but should be on.
Note that it is not correct to say that an input has a correct state because an input only takes you to a state. If a change to that input should take you to another state, we need a transition which includes that. And testing the transitions is the next task
It may be helpful to look at this part of the code (which is different to what you will write on the arduino, but you should be able to see the corresponding meaning:
Code:
procedure TfrmCFY_UD.SetState(iState: integer);
begin
case iState of
S_CFY_UD_S_INIT:
Begin
chkCFY_UD_O_TRD.Checked := false;
chkCFY_UD_O_TA.Checked := false;
chkCFY_UD_O_ANS.Checked := false;
chkCFY_UD_O_FSRD.Checked := false;
chkCFY_UD_O_FRS.Checked := false;
chkCFY_UD_O_UFA.Checked := false;
chkCFY_UD_O_ERM_STRD.Checked := false;
chkCFY_UD_O_ERM_FSRD.Checked := false;
chkCFY_UD_O_LFY_FSRD.Checked := false;
end;
S_CFY_UD_S_RSIE:
Begin
chkCFY_UD_O_TRD.Checked := false;
chkCFY_UD_O_TA.Checked := false;
chkCFY_UD_O_ANS.Checked := true;
chkCFY_UD_O_FSRD.Checked := false;
chkCFY_UD_O_FRS.Checked := false;
chkCFY_UD_O_UFA.Checked := false;
chkCFY_UD_O_ERM_STRD.Checked := true;
chkCFY_UD_O_ERM_FSRD.Checked := false;
chkCFY_UD_O_LFY_FSRD.Checked := false;
end;
S_CFY_UD_S_SDIC:
Begin
chkCFY_UD_O_TRD.Checked := true;
chkCFY_UD_O_TA.Checked := false;
chkCFY_UD_O_ANS.Checked := false;
chkCFY_UD_O_FSRD.Checked := false;
chkCFY_UD_O_FRS.Checked := false;
chkCFY_UD_O_UFA.Checked := false;
chkCFY_UD_O_ERM_STRD.Checked := false;
chkCFY_UD_O_ERM_FSRD.Checked := false;
chkCFY_UD_O_LFY_FSRD.Checked := false;
end;
S_CFY_UD_S_SAIE:
Begin
chkCFY_UD_O_TRD.Checked := false;
chkCFY_UD_O_TA.Checked := true;
chkCFY_UD_O_ANS.Checked := false;
chkCFY_UD_O_FSRD.Checked := false;
chkCFY_UD_O_FRS.Checked := false;
chkCFY_UD_O_UFA.Checked := false;
chkCFY_UD_O_ERM_STRD.Checked := false;
chkCFY_UD_O_ERM_FSRD.Checked := false;
chkCFY_UD_O_LFY_FSRD.Checked := false;
end;
S_CFY_UD_S_FDIC:
Begin
chkCFY_UD_O_TRD.Checked := false;
chkCFY_UD_O_TA.Checked := false;
chkCFY_UD_O_ANS.Checked := false;
chkCFY_UD_O_FSRD.Checked := true;
chkCFY_UD_O_FRS.Checked := false;
chkCFY_UD_O_UFA.Checked := false;
chkCFY_UD_O_ERM_STRD.Checked := false;
chkCFY_UD_O_ERM_FSRD.Checked := false;
chkCFY_UD_O_LFY_FSRD.Checked := false;
end;
S_CFY_UD_S_FRSE:
Begin
chkCFY_UD_O_TRD.Checked := false;
chkCFY_UD_O_TA.Checked := false;
chkCFY_UD_O_ANS.Checked := false;
chkCFY_UD_O_FSRD.Checked := false;
chkCFY_UD_O_FRS.Checked := true;
chkCFY_UD_O_UFA.Checked := false;
chkCFY_UD_O_ERM_STRD.Checked := false;
chkCFY_UD_O_ERM_FSRD.Checked := true;
chkCFY_UD_O_LFY_FSRD.Checked := true;
end;
S_CFY_UD_S_FAIL:
Begin
chkCFY_UD_O_TRD.Checked := false;
chkCFY_UD_O_TA.Checked := false;
chkCFY_UD_O_ANS.Checked := false;
chkCFY_UD_O_FSRD.Checked := false;
chkCFY_UD_O_FRS.Checked := false;
chkCFY_UD_O_UFA.Checked := true;
chkCFY_UD_O_ERM_STRD.Checked := false;
chkCFY_UD_O_ERM_FSRD.Checked := false;
chkCFY_UD_O_LFY_FSRD.Checked := false;
end;
else
begin
Showmessage('Illegal State');
end;
end;
// pass on the output states
frmERM_UA.chkERM_UA_I_TWA.Checked := chkCFY_UD_O_ERM_STRD.Checked;
frmERM_UA.chkERM_UA_I_UFRD.Checked := chkCFY_UD_O_ERM_FSRD.Checked;
frmLFY_UA.chkLFY_UA_I_FSRD.Checked := chkCFY_UD_O_LFY_FSRD.Checked;
//frmLFY_UA.chkLFY_UA_I_FRSD.Checked := chkCFY_UD_O_LFY_FSRD.Checked;
end;
All you really need to know is that this:
is the start of the equivalent of a switch statement. I'm looking at what to do in each state.
This is the state we're looking for. The next block happens if iState (the state we're switching to) is equal to S_CFY_UD_S_INIT. I added the S_ at the beginning to tell me it is a state, so this state is CFY_UD_S_INIT.
Code:
Begin
chkCFY_UD_O_TRD.Checked := false;
chkCFY_UD_O_TA.Checked := false;
chkCFY_UD_O_ANS.Checked := false;
chkCFY_UD_O_FSRD.Checked := false;
chkCFY_UD_O_FRS.Checked := false;
chkCFY_UD_O_UFA.Checked := false;
chkCFY_UD_O_ERM_STRD.Checked := false;
chkCFY_UD_O_ERM_FSRD.Checked := false;
chkCFY_UD_O_LFY_FSRD.Checked := false;
end;
and this is what happens in that case.
Code:
chkCFY_UD_O_TRD.Checked := false;
The input and output signals and indications are all represented as checkboxes on the form. The prefix "chk" is standard for this. So this is the output indication CFY_UD_O_TRD.
I am determining if the box is checked or not.
A checkbox has a property "checked" that I can refer to with the name of the checkbox followed by a dot and then the keyword "checked".
The assignment operator is :=, this means the variable on the left takes the value on the right.
The value on the right is "false", which means unchecked (or OFF). You would be unlikely to be surprised that the other value is "true", representing a checked box (or ON).
Finally the statement ends in a semicolon.
So the whole line
Code:
chkCFY_UD_O_TRD.Checked := false;
means turn the output indication CFY_UD_O_TRD off. When we are in the init state this output indication is off.
As you have seen, when you start up the program, this panel is in the init state, and this indication is unchecked.
Going through the states, you will see that I have tried to copy exactly what you have said for the output indications. I needed to figure out the output signals because they were not specified. I expect them to be wrong.