• R/O
  • HTTP
  • SSH
  • HTTPS

tutorial: Commit

This repository is for tutorials of Eos.


Commit MetaInfo

Revision259a6356c62c4944afb1536fb14bfe72ccd4fae1 (tree)
Time2015-01-07 19:02:52
Authorkinoshita-eos <kinoshita@yasu...>
Commiterkinoshita-eos

Log Message

Add: PIONE tutorial to create ref2d file.
new file: SampleCode/PIONE/Advanced3/Annotation.pione
new file: SampleCode/PIONE/Advanced3/Interaction.pione
new file: SampleCode/PIONE/Advanced3/Main.pione
new file: SampleCode/PIONE/Advanced3/Ref3DtoRef2D.pione
new file: SampleCode/PIONE/Advanced3/Result.pione
new file: SampleCode/PIONE/Advanced3/bin/Finish.cgi
new file: SampleCode/PIONE/Advanced3/bin/Ref3DtoRef2D.cgi
new file: SampleCode/PIONE/Advanced3/bin/Retry.cgi
new file: SampleCode/PIONE/Advanced3/etc/Ref3DtoRef2D.html
new file: SampleCode/PIONE/Advanced3/etc/index.html
new file: SampleCode/PIONE/Advanced3/etc/index2.html

Change Summary

Incremental Difference

--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/Annotation.pione
@@ -0,0 +1,3 @@
1+.@ PackageName :: "Ref3DtoRef2D"
2+.@ Editor :: "Kinoshita"
3+.@ Tag :: "v0.1.0"
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/Interaction.pione
@@ -0,0 +1,19 @@
1+Rule Interaction
2+ input 'Start{$val}!Flag'
3+ output '*.*'.all
4+ param $val
5+Action
6+ # build public directory for pione-interactive
7+ mkdir public
8+ cp etc/* public
9+ cp bin/* public
10+
11+ # start interactive operation
12+ pione-interactive browser --public public
13+
14+ cp public/* .
15+ for file in $(ls *Mode *Rot1 *Rot2 *Rot3 *.ref3d) ;
16+ do
17+ mv "$file" "$file-{$val}";
18+ done
19+End
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/Main.pione
@@ -0,0 +1,33 @@
1+Rule Main
2+ output '*.ref3d'
3+ output '*.ref2d'
4+ output '*.mon'
5+ output '*.gif'
6+Flow
7+ rule Start
8+ rule SubMain
9+ rule Result
10+ rule Finish
11+End
12+
13+Rule Start
14+ output 'Start0!Flag'
15+Action
16+ touch {$O[1]}
17+End
18+
19+Rule SubMain
20+ input 'Start*!Flag'
21+ output '*.*'.all
22+Flow
23+ rule Interaction {val : '{$I[1][1]}'.str().i()}
24+ rule Ref3DtoRef2D {val : '{$I[1][1]}'.str().i()}
25+End
26+
27+Rule Finish
28+ input 'Finish*!Flag'
29+ input '*.*-{$I[1][1]}'
30+ output '{$I[2][1]}.{$I[2][2]}'
31+Action
32+ cp {$I[2]} {$O[1]}
33+End
\ No newline at end of file
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/Ref3DtoRef2D.pione
@@ -0,0 +1,117 @@
1+Rule Ref3DtoRef2D
2+ input '*.!*-{$val}'.all
3+ input '*.ref3d-{$val}'
4+ output '*.ref2d-{$val}'.all
5+ output 'Ref3DtoRef2D.info-{$val}'
6+ param $val
7+Flow
8+ rule FlowLoop3Dto2D1 {val : $val}
9+ rule Info3Dto2D {val : $val}
10+End
11+
12+Rule Info3Dto2D
13+ input '*.ref2d-{$val}'.all
14+ output 'Ref3DtoRef2D.info-{$val}'
15+ param $val
16+Action
17+ for file in $(ls *.ref2d-{$val})
18+ do
19+ echo "./$file" >> {$O[1]}
20+ done
21+End
22+
23+Rule FlowLoop3Dto2D1
24+ input '*!*!*.!Rot1-{$val}'
25+ input '*!*!*.!Rot2-{$val}'
26+ input '*!*!*.!Rot3-{$val}'
27+ input '*.!Mode-{$val}'
28+ input '*.ref3d-{$val}'
29+ output '*.ref2d-{$val}'.all
30+ $min1 := '{$I[1][1]}'.str().f()
31+ $max1 := '{$I[1][2]}'.str().f()
32+ $delta1 := '{$I[1][3]}'.str().f()
33+ $loop1 := ($max1 - $min1) / $delta1
34+ param $val1 := 0.0
35+ param $val
36+Flow
37+ rule FlowLoop3Dto2D2 {val1 : $val1, val :$val}
38+
39+ if $val1 + 1.0 <= $loop1
40+ rule FlowLoop3Dto2D1 {val1 : $val1 + 1.0, val :$val}
41+ end
42+End
43+
44+Rule FlowLoop3Dto2D2
45+ input '*!*!*.!Rot1-{$val}'
46+ input '*!*!*.!Rot2-{$val}'
47+ input '*!*!*.!Rot3-{$val}'
48+ input '*.!Mode-{$val}'
49+ input '*.ref3d-{$val}'
50+ output '*.ref2d-{$val}'.all
51+ $min2 := '{$I[2][1]}'.str().f()
52+ $max2 := '{$I[2][2]}'.str().f()
53+ $delta2 := '{$I[2][3]}'.str().f()
54+ $loop2 := ($max2 - $min2) / $delta2
55+ param $val1
56+ param $val2 := 0.0
57+ param $val
58+Flow
59+ rule FlowLoop3Dto2D3 {val1 : $val1, val2 : $val2, val :$val}
60+
61+ if $val2 + 1.0 <= $loop2
62+ rule FlowLoop3Dto2D2 {val1 : $val1, val2 : $val2 + 1.0, val :$val}
63+ end
64+End
65+
66+Rule FlowLoop3Dto2D3
67+ input '*!*!*.!Rot1-{$val}'
68+ input '*!*!*.!Rot2-{$val}'
69+ input '*!*!*.!Rot3-{$val}'
70+ input '*.!Mode-{$val}'
71+ input '*.ref3d-{$val}'
72+ output '*.ref2d-{$val}'.all
73+ $min3 := '{$I[3][1]}'.str().f()
74+ $max3 := '{$I[3][2]}'.str().f()
75+ $delta3 := '{$I[3][3]}'.str().f()
76+ $loop3 := ($max3 - $min3) / $delta3
77+ param $val1
78+ param $val2
79+ param $val3 := 0.0
80+ param $val
81+Flow
82+ rule One3Dto2D {val1 : $val1, val2 : $val2, val3 : $val3, val :$val}
83+
84+ if $val3 + 1.0 <= $loop3
85+ rule FlowLoop3Dto2D3 {val1 : $val1, val2 : $val2, val3 : $val3 + 1.0, val :$val}
86+ end
87+End
88+
89+Rule One3Dto2D
90+ input '*!*!*.!Rot1-{$val}'
91+ input '*!*!*.!Rot2-{$val}'
92+ input '*!*!*.!Rot3-{$val}'
93+ input '*.!Mode-{$val}'
94+ input '*.ref3d-{$val}'
95+ output '*.ref2d-{$val}'.all
96+ param $val1
97+ param $val2
98+ param $val3
99+ param $val
100+Action
101+ min1={$I[1][1]}
102+ min2={$I[2][1]}
103+ min3={$I[3][1]}
104+ delta1={$I[1][3]}
105+ delta2={$I[2][3]}
106+ delta3={$I[3][3]}
107+ mode={$I[4][1]}
108+ rot1=$(echo "scale=5; {$val1} * $delta1 + $min1" | bc)
109+ rot2=$(echo "scale=5; {$val2} * $delta2 + $min2" | bc)
110+ rot3=$(echo "scale=5; {$val3} * $delta3 + $min3" | bc)
111+ output="{$I[5][1]}-$mode-$rot1-$rot2-$rot3.ref2d-{$val}"
112+ mrc3Dto2D -i {$I[5]} -o $output \
113+ -Rot1 $rot1 $rot1 1 \
114+ -Rot2 $rot2 $rot2 1 \
115+ -Rot3 $rot3 $rot3 1 \
116+ -EulerMode $mode;
117+End
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/Result.pione
@@ -0,0 +1,43 @@
1+Rule Result
2+ input 'Ref3DtoRef2D.info-*'
3+ input '*.ref2d-{$I[1][1]}'.all
4+ output '*!Flag'
5+ output 'Ref3DtoRef2D.mon-{$I[1][1]}'
6+ output 'Ref3DtoRef2D.gif-{$I[1][1]}'
7+Flow
8+ rule Ref2DtoGIF {val : '{$I[1][1]}'.str().i()}
9+ rule ResultCheck {val : '{$I[1][1]}'.str().i()}
10+End
11+
12+Rule Ref2DtoGIF
13+ input 'Ref3DtoRef2D.info-{$val}'
14+ input '*.ref2d-{$val}'.all
15+ output 'Ref3DtoRef2D.mon-{$val}'
16+ output 'Ref3DtoRef2D.gif-{$val}'
17+ param $val
18+Action
19+ mrcImageMontageCreate -i {$I[1]} -o {$O[1]}
20+ mrc2gif -i {$O[1]} -o {$O[2]}
21+End
22+
23+Rule ResultCheck
24+ input 'Ref3DtoRef2D.gif-{$val}'
25+ output '*!Flag'
26+ param $val
27+Action
28+ # build public directory for pione-interactive
29+ mkdir public
30+ cp etc/index2.html public/index.html
31+ cp bin/* public
32+ cp {$I[1]} public/Ref3DtoRef2D.gif
33+
34+ # start interactive operation
35+ pione-interactive browser --public public
36+
37+ cp public/* .
38+ if [ -e "Finish!Flag" ]; then
39+ mv "Finish!Flag" "Finish{$val}!Flag";
40+ elif [ -e "Start!Flag" ]; then
41+ mv "Start!Flag" "Start{$val + 1}!Flag";
42+ fi
43+End
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/bin/Finish.cgi
@@ -0,0 +1,26 @@
1+#!/usr/bin/env ruby
2+
3+require 'cgi'
4+
5+cgi = CGI.new
6+
7+### Header
8+strHTML = ""
9+strHTML += "<!DOCTYPE html>"
10+strHTML += "<html>"
11+strHTML += "<head>"
12+strHTML += "<title>Finish</title>"
13+### Auto Close
14+strHTML += '<meta http-equiv="REFRESH" content="0;URL=?pione-action=finish">'
15+
16+# Main Process
17+command = "touch Finish!Flag"
18+system(command)
19+
20+strHTML += "</head>"
21+strHTML += "</html>"
22+
23+# Output as html
24+cgi.out(type: "text/html") do
25+ strHTML
26+end
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/bin/Ref3DtoRef2D.cgi
@@ -0,0 +1,65 @@
1+#!/usr/bin/env ruby
2+
3+require 'cgi'
4+
5+cgi = CGI.new
6+
7+### Header
8+strHTML = ""
9+strHTML += "<!DOCTYPE html>"
10+strHTML += "<html>"
11+strHTML += "<head>"
12+strHTML += "<title>Ref3DtoRef2D</title>"
13+### Auto Close
14+strHTML += '<meta http-equiv="REFRESH" content="0;URL=?pione-action=finish">'
15+
16+# Main Process
17+
18+## Query to Parameters
19+
20+### Copy InputFile
21+fpQueryInputFile = cgi.params['InputFile'][0]
22+strInputFile = fpQueryInputFile.original_filename
23+fpInputFile = open(strInputFile, "wb")
24+fpInputFile.write(fpQueryInputFile.read)
25+fpInputFile.close
26+
27+### Other Query
28+strMode = cgi['Mode1'] + cgi['Mode2'] + cgi['Mode3'] + cgi['Mode4']
29+strRotMin1 = cgi['RotMin1']
30+strRotMax1 = cgi['RotMax1']
31+strRotDelta1 = cgi['RotDelta1']
32+strRotMin2 = cgi['RotMin2']
33+strRotMax2 = cgi['RotMax2']
34+strRotDelta2 = cgi['RotDelta2']
35+strRotMin3 = cgi['RotMin3']
36+strRotMax3 = cgi['RotMax3']
37+strRotDelta3 = cgi['RotDelta3']
38+
39+### Set Parameter to FileNames
40+strParamFile = strMode + ".!Mode"
41+command = "touch " + strParamFile
42+system(command)
43+
44+strParamFile = strRotMin1 + "!" + strRotMax1 + "!" + strRotDelta1 + ".!Rot1"
45+command = "touch " + strParamFile
46+system(command)
47+
48+strParamFile = strRotMin2 + "!" + strRotMax2 + "!" + strRotDelta2 + ".!Rot2"
49+command = "touch " + strParamFile
50+system(command)
51+
52+strParamFile = strRotMin3 + "!" + strRotMax3 + "!" + strRotDelta3 + ".!Rot3"
53+command = "touch " + strParamFile
54+system(command)
55+
56+command = "cp " + strInputFile + " Refer.ref3d"
57+system(command)
58+
59+strHTML += "</head>"
60+strHTML += "</html>"
61+
62+# Output as html
63+cgi.out(type: "text/html") do
64+ strHTML
65+end
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/bin/Retry.cgi
@@ -0,0 +1,26 @@
1+#!/usr/bin/env ruby
2+
3+require 'cgi'
4+
5+cgi = CGI.new
6+
7+### Header
8+strHTML = ""
9+strHTML += "<!DOCTYPE html>"
10+strHTML += "<html>"
11+strHTML += "<head>"
12+strHTML += "<title>Retry</title>"
13+### Auto Close
14+strHTML += '<meta http-equiv="REFRESH" content="0;URL=?pione-action=finish">'
15+
16+# Main Process
17+command = "touch Start!Flag"
18+system(command)
19+
20+strHTML += "</head>"
21+strHTML += "</html>"
22+
23+# Output as html
24+cgi.out(type: "text/html") do
25+ strHTML
26+end
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/etc/Ref3DtoRef2D.html
@@ -0,0 +1,109 @@
1+<!DOCTYPE html>
2+<html>
3+ <head>
4+ <meta charset="utf-8">
5+ <title>Ref3DtoRef2D</title>
6+ </head>
7+ <body>
8+ <form action="Ref3DtoRef2D.cgi" method="post" enctype="multipart/form-data">
9+ <button type="submit">開始</button>
10+ <br>
11+ <table>
12+ <tr>
13+ <td>
14+ <input type="file" name="InputFile"/>
15+ </td>
16+ <td>
17+ 入力ファイル名(.ref3d)
18+ </td>
19+ </tr>
20+ <tr>
21+ <td>
22+ <select name="Mode1">
23+ <option value="X">X</option>
24+ <option value="Y">Y</option>
25+ <option value="Z">Z</option>
26+ </select>
27+ <select name="Mode2">
28+ <option value="O">O</option>
29+ <option value="E">E</option>
30+ </select>
31+ <select name="Mode3">
32+ <option value="Y">Y</option>
33+ <option value="N">N</option>
34+ </select>
35+ <select name="Mode4">
36+ <option value="S">S</option>
37+ <option value="R">R</option>
38+ </select>
39+ </td>
40+ <td>
41+ 回転モード
42+ </td>
43+ </tr>
44+ </table>
45+ <table>
46+ <tr>
47+ <td>
48+
49+ </td>
50+ <td>
51+ 最小値
52+ </td>
53+ <td>
54+ 最大値
55+ </td>
56+ <td>
57+ 加算値
58+ </td>
59+ </tr>
60+ <tr>
61+ <td>
62+ 角度1
63+ </td>
64+ <td>
65+ <input type="text" name="RotMin1" value="0"/>
66+ </td>
67+ <td>
68+ <input type="text" name="RotMax1" value="359"/>
69+ </td>
70+ <td>
71+ <input type="text" name="RotDelta1" value="30"/>
72+ </td>
73+ </tr>
74+ <tr>
75+ <td>
76+ 角度2
77+ </td>
78+ <td>
79+ <input type="text" name="RotMin2" value="0"/>
80+ </td>
81+ <td>
82+ <input type="text" name="RotMax2" value="359"/>
83+ </td>
84+ <td>
85+ <input type="text" name="RotDelta2" value="30"/>
86+ </td>
87+ </tr>
88+ <tr>
89+ <td>
90+ 角度3
91+ </td>
92+ <td>
93+ <input type="text" name="RotMin3" value="0"/>
94+ </td>
95+ <td>
96+ <input type="text" name="RotMax3" value="0"/>
97+ </td>
98+ <td>
99+ <input type="text" name="RotDelta3" value="30"/>
100+ </td>
101+ </tr>
102+ </table>
103+ </form>
104+ <br>
105+ <br>
106+ <a href="index.html">戻る</a><br>
107+ <a href="?pione-action=finish">終了</a><br>
108+ </body>
109+</html>
\ No newline at end of file
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/etc/index.html
@@ -0,0 +1,12 @@
1+<!DOCTYPE html>
2+<html>
3+ <head>
4+ <meta charset="utf-8">
5+ <title>InteractiveCommand Index Page</title>
6+ </head>
7+ <body>
8+ <a href="Ref3DtoRef2D.html">Ref3DtoRef2D</a><br>
9+ <br>
10+ <a href="?pione-action=finish">終了</a>
11+ </body>
12+</html>
\ No newline at end of file
--- /dev/null
+++ b/SampleCode/PIONE/Advanced3/etc/index2.html
@@ -0,0 +1,13 @@
1+<!DOCTYPE html>
2+<html>
3+ <head>
4+ <meta charset="utf-8">
5+ <title>InteractiveCommand Index Page</title>
6+ </head>
7+ <body>
8+ <img src="Ref3DtoRef2D.gif"><br>
9+ <br>
10+ <a href="Finish.cgi">決定</a><br>
11+ <a href="Retry.cgi">やり直し</a>
12+ </body>
13+</html>
\ No newline at end of file
Show on old repository browser