Homework 3

Washing Machine

Step of washing

  1. Get the input of the human.
  2. Add the water.
  3. Begin to wash
  4. Drain the water
  5. Add the water.
  6. Begin to wash
  7. Drain the water
  8. Halt

Pseudocode of washing

Water_in_switch(open)
Water_out_switch(close)
If(get_water_volume()!=Target_volume and time_counter() > set_time)
    {
Water_in_switch(close)
Water_out_switch(open)
halt(failure)
}
Water_in_switch(close)
While(washing_time_counter>0)
 {
    while(time_counter()<loop_time){
    Motor_run(left);
    While(time_counter()<next_step_time)
    {
}
Motor_run(right)
While(time_counter()<next_step_time)
    {
}}
While(get_water_volumn()!=0)
Water_out_switch(open)
}
Halt(success)

Module:
Wait(time)
{
    Previous=time_counter()
    While(time_counter()<=previous+time)
    {
    }
}
注水(volume,timeout)
{
    If(get_water_volume()!=volume and time_counter() > timeout)
    {
Water_in_switch(close)
Water_out_switch(open)
halt(failure)
}
}
排水()
{
While(get_water_volumn()!=0)
Water_out_switch(open)
}

The difference between Normal washing and Quick washing

The difference is the repeat time of whole washing step and washing time. Normal washing will repeat for 2 or 3 times, and quick washing will just repeat 1 or 2 times. And the time it cost will be different.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章