/test/language/gc/aux_agent_gc2.e

http://github.com/tybor/Liberty · Specman e · 110 lines · 75 code · 14 blank · 21 comment · 7 complexity · 0653c8982b7c03789d92ccac4e6d1194 MD5 · raw file

  1. -- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2. -- See the Copyright notice at the end of this file.
  3. --
  4. class AUX_AGENT_GC2
  5. create {ANY}
  6. make
  7. feature {ANY}
  8. alea: AUX_AGENT_GC4
  9. discharged: AUX_AGENT_GC5
  10. is_main: BOOLEAN
  11. staff: INTEGER
  12. triage, examination, treatment, transfers: AUX_AGENT_GC6
  13. make (staf, seed: INTEGER; main: BOOLEAN)
  14. do
  15. alea.set_seed(seed)
  16. staff := staf
  17. is_main := main
  18. end
  19. triage_examination
  20. do
  21. transfers.clear
  22. treatment.for_each(agent discharge_one_patient(?))
  23. examination.for_each(agent treat_or_transfert_one_patient(?))
  24. triage.for_each(agent triage_one_patient(?))
  25. if alea.test(0.7) then
  26. new_arrival(create {AUX_AGENT_GC3})
  27. end
  28. end
  29. new_arrival (p: AUX_AGENT_GC3)
  30. do
  31. p.enter_hospital
  32. if staff <= 0 then
  33. triage.add(p)
  34. else
  35. staff := staff - 1
  36. examination.add(p)
  37. p.wait(3)
  38. end
  39. end
  40. discharge_one_patient (p: AUX_AGENT_GC3)
  41. do
  42. p.next_time
  43. if p.finished then
  44. staff := staff + 1
  45. treatment.remove(p)
  46. discharged.add(p)
  47. end
  48. end
  49. treat_or_transfert_one_patient (p: AUX_AGENT_GC3)
  50. do
  51. p.next_time
  52. if p.finished then
  53. examination.remove(p)
  54. if alea.test(0.1) or else is_main then
  55. treatment.add(p)
  56. p.wait(10)
  57. else
  58. staff := staff + 1
  59. transfers.add(p)
  60. end
  61. end
  62. end
  63. triage_one_patient (p: AUX_AGENT_GC3)
  64. do
  65. if staff <= 0 then
  66. p.incr_hospital_time
  67. else
  68. staff := staff - 1
  69. triage.remove(p)
  70. examination.add(p)
  71. p.wait(3)
  72. end
  73. end
  74. accumulate_totals: AUX_AGENT_GC5
  75. do
  76. Result := discharged + triage.accumulate_totals + examination.accumulate_totals + treatment.accumulate_totals
  77. end
  78. end -- class AUX_AGENT_GC2
  79. --
  80. -- ------------------------------------------------------------------------------------------------------------------------------
  81. -- Copyright notice below. Please read.
  82. --
  83. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  84. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  85. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  86. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  87. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  88. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  89. --
  90. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  91. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  92. --
  93. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  94. --
  95. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  96. -- ------------------------------------------------------------------------------------------------------------------------------