topas-tools 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/bin/toparunGUI +19 -20
- data/lib/topas-tools.rb +1 -0
- data/lib/topas-tools/Metarefine.rb +36 -0
- data/lib/topas-tools/TopasEngine.rb +36 -59
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebd3b0096d76533b4ad2b3b29d13e9c0fb440ec2
|
4
|
+
data.tar.gz: 3f9822ab33d2135dda7593b0d7fcea801feef74f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 391701df3da48ef07f27893af04a5aa73deaad6bfc4782b5691d9e2991e861fb1da4b153ecdab7d5be71448f7f61a1eb8976ab29b7d94ba691277dc89b35fdd1
|
7
|
+
data.tar.gz: 2175813c9d94dcd5593b8796d4229607a63aedb09bc3e5adf280e0256651b80dedb7d820e6b9bf2bebc6d2d1a8db2209cb0b8ba69190700354f672931e5937fb
|
data/bin/toparunGUI
CHANGED
@@ -18,7 +18,7 @@ Shoes.app :width => 400, :height => 800 do
|
|
18
18
|
#big stack
|
19
19
|
stack do
|
20
20
|
caption 'Your system:'
|
21
|
-
@systemlist = list_box items:['wine','windows','dummy'], choose:'
|
21
|
+
@systemlist = list_box items:['wine','windows','dummy'], choose:'windows'
|
22
22
|
|
23
23
|
caption 'Your Topas4-2 directory:'
|
24
24
|
|
@@ -39,7 +39,7 @@ Shoes.app :width => 400, :height => 800 do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
flow do
|
42
|
-
para "
|
42
|
+
para "Stepss:"
|
43
43
|
@stepsline = edit_line
|
44
44
|
@stepsline.text = "4,1"
|
45
45
|
end
|
@@ -51,26 +51,25 @@ Shoes.app :width => 400, :height => 800 do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
@
|
69
|
-
|
70
|
-
@clear.clear
|
71
|
-
end
|
54
|
+
button 'Go!' do
|
55
|
+
begin
|
56
|
+
points = @pointline.text.split(/[,\s]+/).map(&:to_f)
|
57
|
+
steps = @stepsline.text.split(/[,\s]+/).map(&:to_f)
|
58
|
+
rescue alert("Some issues with steps'n'points!")
|
59
|
+
end
|
60
|
+
|
61
|
+
Thread.new(points, steps, @log ) do |points, steps|
|
62
|
+
inp = @inpline.text
|
63
|
+
engine = TopasEngine.create @systemlist.text.to_sym, @topasdir.text
|
64
|
+
input = TopasInput.new IO.read(inp, :encoding => "UTF-8"), inp
|
65
|
+
runner = Metarefine.new engine, input, File.dirname(inp), Steps.new(points, steps)
|
66
|
+
runner.toparun BaseAnalyzer.new(@log)
|
67
|
+
@clear = button 'Clear' do
|
68
|
+
@log = StringIO.new
|
69
|
+
@clear.clear
|
72
70
|
end
|
73
71
|
end
|
72
|
+
end
|
74
73
|
|
75
74
|
para self
|
76
75
|
caption "Log:"
|
data/lib/topas-tools.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
class Steps
|
2
|
+
def initialize ps, ss
|
3
|
+
ss.empty? && raise("Empty steps!")
|
4
|
+
(ps.size == (ss.size + 1) ) || raise("Inconsistent points and steps: #{ps}, #{ss}")
|
5
|
+
@k1s = get_k1s ps, ss
|
6
|
+
end
|
7
|
+
attr_reader :k1s
|
8
|
+
def get_k1s points, stepsizes
|
9
|
+
stepsizes.reduce([]){|result, stepsize|
|
10
|
+
a = result +
|
11
|
+
points[0].step(points[1] ,-stepsize.to_f).to_a +
|
12
|
+
[points[1].to_f]
|
13
|
+
points.shift
|
14
|
+
a}.uniq
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Metarefine
|
19
|
+
def initialize engine, input, basedir, steps
|
20
|
+
@engine = engine
|
21
|
+
@input = input
|
22
|
+
@basedir = basedir
|
23
|
+
@steps = steps
|
24
|
+
Dir.chdir @basedir
|
25
|
+
end
|
26
|
+
|
27
|
+
def toparun analyzer, work_dir = File.expand_path(@input.base_name)
|
28
|
+
Dir.mkdir(work_dir) unless Dir.exists? work_dir
|
29
|
+
@steps.k1s.reduce(@input) do |inp, k1|
|
30
|
+
out = @engine.tc work_dir inp.set_k1(k1)
|
31
|
+
analyzer.analyze(out) ? out : break
|
32
|
+
end
|
33
|
+
Dir.chdir @base_dir
|
34
|
+
analyzer.report
|
35
|
+
end
|
36
|
+
end
|
@@ -1,79 +1,56 @@
|
|
1
1
|
class TopasEngine
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if Systems.any?{|sys| sys = system}
|
11
|
-
@@system = system
|
2
|
+
def self.create system, topasdir
|
3
|
+
case system
|
4
|
+
when :wine
|
5
|
+
WineTopasEngine.new topasdir
|
6
|
+
when :windows
|
7
|
+
WindowsTopasEngine.new topasdir
|
8
|
+
when :dummy
|
9
|
+
TopasEngine.new topasdir
|
12
10
|
else
|
13
|
-
raise "
|
11
|
+
raise "Bad system: #{system}"
|
14
12
|
end
|
15
13
|
end
|
16
|
-
|
17
|
-
def
|
14
|
+
|
15
|
+
def initialize topasdir
|
16
|
+
@enc = 'UTF-8'
|
18
17
|
Dir.exists?(topasdir) || raise("Non-existing directory!")
|
19
18
|
Dir.entries(topasdir).any?{|f| f == 'tc.exe'} || raise("Where is my tc.exe?!")
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
def initialize dir = Dir.getwd
|
25
|
-
@base_dir = dir
|
26
|
-
Dir.chdir @base_dir
|
27
|
-
@enc = "UTF-8"
|
19
|
+
@topasdir = topasdir
|
28
20
|
end
|
29
21
|
|
30
|
-
def tc input
|
22
|
+
def tc dir, input
|
31
23
|
infile = "#{input.name}.inp"
|
24
|
+
Dir.chdir dir
|
32
25
|
File.open(infile, mode:'w'){|f| f.write input.text}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
go_n_do command
|
38
|
-
when :windows
|
39
|
-
command = "tc.exe #{File.expand_path(infile)}"
|
40
|
-
go_n_do command
|
41
|
-
when :dummy
|
42
|
-
outfile = "#{input.name}.out"
|
43
|
-
p "Say hello to #{outfile} with k1 = #{input.k1}"
|
44
|
-
File.open(outfile , mode:'w'){|f| f.write input.text}
|
45
|
-
end
|
26
|
+
cmd = command infile
|
27
|
+
Dir.chdir @topasdir
|
28
|
+
system(cmd)
|
29
|
+
Dir.chdir dir
|
46
30
|
TopasInput.new IO.read("#{input.name}.out", :encoding => @enc)
|
47
31
|
end
|
48
|
-
|
49
32
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
out = tc inp.set_k1(k1)
|
58
|
-
analyzer.analyze(out) ? out : break
|
59
|
-
end
|
60
|
-
Dir.chdir @base_dir
|
61
|
-
analyzer.report
|
33
|
+
private
|
34
|
+
|
35
|
+
def command filename
|
36
|
+
filepath = File.expand_path filename
|
37
|
+
dirpath = File.dirname filepath
|
38
|
+
outfile = File.join dirpath, filename.sub(/\..{2,3}$/ , '.out')
|
39
|
+
"cp #{filepath} #{outfile}"
|
62
40
|
end
|
41
|
+
end
|
63
42
|
|
43
|
+
class WindowsTopasEngine < TopasEngine
|
64
44
|
private
|
65
|
-
|
66
|
-
|
67
|
-
Dir.chdir @@topasdir
|
68
|
-
system(command)
|
69
|
-
Dir.chdir @work_dir
|
45
|
+
def command infile
|
46
|
+
"tc.exe #{File.expand_path(infile)}"
|
70
47
|
end
|
48
|
+
end
|
71
49
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
50
|
+
class WineTopasEngine < TopasEngine
|
51
|
+
private
|
52
|
+
def command infile
|
53
|
+
path = `winepath -w #{infile}`.gsub('\\', '\\\\\\').gsub("\n", "")
|
54
|
+
"wine tc.exe #{path}"
|
77
55
|
end
|
78
|
-
|
79
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: topas-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Dmitrienko
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- bin/toparunGUI
|
43
43
|
- lib/topas-tools.rb
|
44
44
|
- lib/topas-tools/Analyzers.rb
|
45
|
+
- lib/topas-tools/Metarefine.rb
|
45
46
|
- lib/topas-tools/TopasEngine.rb
|
46
47
|
- lib/topas-tools/TopasInput.rb
|
47
48
|
homepage: https://github.com/dmitrienka/topas-tools
|