redshift 1.3.19 → 1.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -2,12 +2,14 @@
2
2
 
3
3
  A framework for simulation of networks of hybrid automata, similar to SHIFT and Lambda-SHIFT. Includes ruby-based DSL for defining simulation components, and ruby/C code generation and runtime.
4
4
 
5
- There's no documentation yet. Start with the examples.
5
+ There's no documentation yet, but it will be at http://redshift.sourceforge.net and http://redshift.rubyforge.org. For now, start with the examples.
6
6
 
7
7
  == Requirements
8
8
 
9
9
  RedShift needs ruby 1.8.x and a compatible C compiler. If you can build native gems, you're all set.
10
10
 
11
+ Some of the examples also use Ruby/Tk and the tkar gem.
12
+
11
13
  == Env vars
12
14
 
13
15
  If you have a multicore system and are using the gnu toolchain, set
data/RELEASE-NOTES CHANGED
@@ -1,3 +1,11 @@
1
+ redshift 1.3.20
2
+
3
+ - added hook_remove_comp
4
+
5
+ - added tkar as dependency
6
+
7
+ - added orbit example
8
+
1
9
  redshift 1.3.19
2
10
 
3
11
  - prevent bones from including compiled files
data/examples/orbit.rb ADDED
@@ -0,0 +1,130 @@
1
+ # A very simple simulation of orbital mechanics. Planets orbit sun, but do
2
+ # not interact with each other.
3
+
4
+ require 'redshift'
5
+ require 'redshift/util/tkar-driver'
6
+
7
+ include RedShift
8
+
9
+ module OrbitWorld
10
+ def next_id
11
+ @next_id ||= 1
12
+ @next_id += 1
13
+ end
14
+
15
+ def tkar
16
+ @tkar ||= TkarDriver.new do |pipe|
17
+ pipe.puts <<-END
18
+ title Orbit example
19
+ background black
20
+ height 600
21
+ width 600
22
+ view_at -50 -50
23
+ zoom_to 4
24
+
25
+ shape planet oval*0,*0,*1,*1,oc:*2,fc:*2 \
26
+ text0,3,anchor:c,justify:center,width:100,text:*3,fc:white
27
+ END
28
+ ## the view_at seems to be needed to overcome a little
29
+ ## centering bug in tkar
30
+
31
+ # Add the Sun, but never move it.
32
+ pipe.puts "add planet 0 - 5 0 0 0"
33
+ pipe.puts "param 0 0 4"
34
+ pipe.puts "param 0 1 -10"
35
+ pipe.puts "param 0 2 yellow"
36
+ pipe.puts "param 0 3 ."
37
+
38
+ grep(Planet) do |pl|
39
+ pipe.puts pl.tk_add
40
+ pipe.puts pl.tk_update
41
+ end
42
+ end
43
+ end
44
+
45
+ def tk_update
46
+ tkar.update do |pipe|
47
+ grep(Planet) do |pl|
48
+ pipe.puts pl.tk_update
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ class Planet < Component
55
+ attr_accessor :name, :id, :color
56
+ constant :size, :mass
57
+
58
+ constant :g => 1.0
59
+ constant :mass_sun => 1000.0
60
+
61
+ default do
62
+ @id = world.next_id
63
+ @name = id
64
+ @color = "white"
65
+ self.mass = 1
66
+ self.size = 1
67
+ end
68
+
69
+ flow do
70
+ diff " x' = vx "
71
+ diff " y' = vy "
72
+
73
+ diff " vx' = ax "
74
+ diff " vy' = ay "
75
+
76
+ alg " r = hypot(x, y) "
77
+ alg " w = -g * (mass_sun + mass) / pow(r, 3) "
78
+ alg " ax = w * x "
79
+ alg " ay = w * y "
80
+ end
81
+
82
+ # return string that adds an instance of the shape with label t.name,
83
+ # position based on (x, y), and
84
+ # rotation based on (x', y')
85
+ def tk_add
86
+ "add planet #{id} - 10 #{x} #{y} 0\n" +
87
+ "param #{id} 0 #{size}\n" +
88
+ "param #{id} 1 #{-size}\n" +
89
+ "param #{id} 2 #{color}\n" +
90
+ "param #{id} 3 #{name}"
91
+ end
92
+
93
+ # emit string representing current state
94
+ def tk_update
95
+ "moveto #{id} #{x} #{y}"
96
+ end
97
+ end
98
+
99
+ w = World.new
100
+ w.extend OrbitWorld
101
+
102
+ w.time_step = 0.1
103
+
104
+ earth = w.create Planet do |pl|
105
+ pl.name = "Earth"
106
+ pl.color = "blue"
107
+ pl.size = 2
108
+ pl.mass = 100
109
+ pl.x = 40
110
+ pl.y = 0
111
+ pl.vx = 0
112
+ pl.vy = 5
113
+ end
114
+
115
+ ellipto = w.create Planet do |pl|
116
+ pl.name = "Ellipto"
117
+ pl.color = "bisque2"
118
+ pl.size = 2
119
+ pl.mass = 100
120
+ pl.x = 80
121
+ pl.y = 0
122
+ pl.vx = 0
123
+ pl.vy = 2
124
+ end
125
+
126
+ w.evolve 1000 do
127
+ #p [earth.x, earth.y]
128
+ w.tk_update
129
+ #sleep 0.01
130
+ end
@@ -33,7 +33,7 @@ end
33
33
  module RedShift
34
34
  include Math
35
35
 
36
- VERSION = '1.3.19'
36
+ VERSION = '1.3.20'
37
37
 
38
38
  Infinity = Math::Infinity
39
39
 
@@ -384,6 +384,7 @@ class World
384
384
  assert(comp_shdw->world == shadow);
385
385
  comp_shdw->world = 0;
386
386
  --RARRAY(list)->len;
387
+ //%% hook_remove_comp(comp_shdw->self);
387
388
  }
388
389
  inline static double eval_expr(VALUE comp, VALUE expr)
389
390
  {
@@ -6,7 +6,7 @@
6
6
  class TkarDriver
7
7
  # +dragger+ is a callable object that takes (id, x, y) and should
8
8
  # move object id to (x,y)
9
- def initialize dragger
9
+ def initialize dragger = nil
10
10
  @dragger = dragger
11
11
  cmd =
12
12
  case RUBY_PLATFORM
data/rakefile CHANGED
@@ -22,6 +22,7 @@ A framework for simulation of networks of hybrid automata, similar to SHIFT and
22
22
  END
23
23
 
24
24
  depend_on 'cgen'
25
+ depend_on 'tkar'
25
26
 
26
27
  history_file 'RELEASE-NOTES'
27
28
  changes File.read(history_file)[/^\w.*?(?=^\w)/m]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redshift
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 19
10
- version: 1.3.19
9
+ - 20
10
+ version: 1.3.20
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joel VanderWerf
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-26 00:00:00 -07:00
18
+ date: 2010-06-27 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,9 +35,23 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: bones
38
+ name: tkar
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: bones
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
41
55
  none: false
42
56
  requirements:
43
57
  - - ">="
@@ -49,7 +63,7 @@ dependencies:
49
63
  - 7
50
64
  version: 3.4.7
51
65
  type: :development
52
- version_requirements: *id002
66
+ version_requirements: *id003
53
67
  description: |
54
68
  A framework for simulation of networks of hybrid automata, similar to SHIFT and Lambda-SHIFT. Includes ruby-based DSL for defining simulation components, and ruby/C code generation and runtime.
55
69
 
@@ -95,6 +109,7 @@ files:
95
109
  - examples/guard-debugger.rb
96
110
  - examples/lotka-volterra.rb
97
111
  - examples/modular-component-def.rb
112
+ - examples/orbit.rb
98
113
  - examples/pid.rb
99
114
  - examples/ports.rb
100
115
  - examples/queue.rb