Creating delay loop in C++

@physicboy @RDunn
After your comment, let compare our understanding

  1. time (t) in Trunc() is next timestep (no happened yet)
  2. This time (t) is sent into main function to get its output and store into tmp.
  3. if (tmp != *inst) is equivalent to compare next step output (tmp.) and current output (inst->), this compare should be discrete, if they are different, a state change is confirmed, and should reduce timestep
    ** can use any kind of logic to detect a change event, not limit to if(tmp != *inst)
  4. if condition trigger, set *timestep = ttol to reduce timestep temporary
  5. ** Remark : time (t) in #1 may or may not be used for an actual next step. If no *timestep changes, this time (t) and its output data is next time step data. But if *timestep changes, simulator goes back in time and reduce timestep at this region to calculate the result (if not go back in time, I cannot explain why timestep can reduce before state change).

1 Like