loom
1import "solvers.s-script" : solvers
2import "support.s-script" : s
3
4def float :
5t = 0.0,
6tk = 0.0,
7dt = 0.0
8
9def int :
10iteration_step = 1
11
12def auto :
13objects = []
14
15def auto :
16callback = fn [] ()
17{
18},
19solver = solvers.Euler
20
21fn add (object : obj)
22{
23if obj["__equetions__"] == null && obj["__rights__"] == null
24print "*** scene.add : Объект не является моделью ode"
25else
26objects ++ obj
27}
28
29fn start ()
30{
31if tk == t {
32print "*** scene.start : Не задано значение tk"
33return
34}
35
36if dt == 0.0 {
37print "*** scene.start : Не задано значение dt"
38return
39}
40
41def int :
42n = 0,
43callback_count = iteration_step
44
45s.sendTimeToShellStatusBar(t)
46callback()
47
48while t < tk {
49t = dt * n
50
51for auto : obj in objects {
52if obj["__equetions__"] != null
53obj["__equetions__"]()
54
55if obj["__rights__"] != null {
56solver(obj, t, dt)
57}
58}
59
60callback_count -= 1
61
62if callback_count == 0 {
63s.sendTimeToShellStatusBar(t)
64callback()
65callback_count = iteration_step
66}
67
68n += 1
69}
70
71if callback_count != iteration_step {
72s.sendTimeToShellStatusBar(t)
73callback()
74}
75}
76