Difference between revisions of "State Variable Inits"

From T-VEC Wiki
Jump to: navigation, search
 
Line 58: Line 58:
  
 
==Example Model - Double State Delay==
 
==Example Model - Double State Delay==
This rationale for being able to verify code with a single state applies to multiple state depths too, as illustrated by the following example.
+
This rationale for being able to verify code with a single state applies to multiple state depths too, as illustrated by the following example that contains two unit delays that are sequence.
 +
 
 +
[[Image:Double_Time_Delay.png|center|Double Time Delay]]
 +
 
 +
 
 +
===Vectors for State Variable Inits===
 +
 
 +
The following image shows the vectors that are produced based on the T>=0 setting force both state variables  '''_local.IState_Unit_Delay''' and '''_local.IState_Unit_Delay1''' to be converged by the vector generation, and the example further illustrates the sequenced nature of the variable values. This point is key, because the control aspects associated with multi-depth state can be verified without the user defining Test Sequence Vector control mechanisms in the SL2TVEC GUI.
 +
 
 +
[[Image:Double_Time_Delay_vectors.png|center|Doublt Time Delay Vectors for T>=0]]
 +
 
 +
===Test Driver Mapping===
 +
The RTW auto generated code makes these variable ('''test_sequences_DWork.UnitDelay_DSTATE''' and '''test_sequences_DWork.UnitDelay1_DSTATE''') visible. Therefore, the following code illustrates how these variables are mapped to specific test driver inputs.
 +
 
 +
<table>
 +
<pre>
 +
// **** Test 1 ****
 +
// set outputs
 +
  test_sequences_B.Sum_e = 127;
 +
   
 +
  // set inputs
 +
  test_sequences_U.In2 = 127;
 +
  test_sequences_DWork.UnitDelay_DSTATE = 0;
 +
  test_sequences_DWork.UnitDelay1_DSTATE = 0;
 +
   
 +
  // execute the test
 +
  test_se_DoubleTimeDelay();
 +
  test_s_DoubleTimeDelay_Update();
 +
   
 +
  // print vector number and output values to results
 +
  fprintf(ofstream, "%d,", 1);
 +
 
 +
  // __Double_Time_DelayData._output
 +
  fprintf(ofstream, "%d,", test_sequences_B.Sum_e);
 +
  printf("test %d output %d: %d,\n",1, 1, test_sequences_B.Sum_e);
 +
 
 +
  // __Double_Time_DelayData.__local.IState_Unit_Delay
 +
  fprintf(ofstream, "%d,", test_sequences_DWork.UnitDelay_DSTATE);
 +
  printf("test %d output %d: %d,\n",1, 2, test_sequences_DWork.UnitDelay_DSTATE);
 +
 
 +
  // __Double_Time_DelayData.__local.IState_Unit_Delay1
 +
  fprintf(ofstream, "%d,", test_sequences_DWork.UnitDelay1_DSTATE);
 +
  printf("test %d output %d: %d,\n",1, 3, test_sequences_DWork.UnitDelay1_DSTATE);
 +
 
 +
  fprintf(ofstream, "\n");
 +
</pre>
 +
</table>
 +
 
 +
The test driver code again is adequate for testing the control of a code subsystem, because the state variables can be set to key values that demonstrate the compliance of the auto generated code with the specification.

Revision as of 18:49, 27 February 2007