• R/O
  • HTTP
  • SSH
  • HTTPS

tutorial: Commit

This repository is for tutorials of Eos.


Commit MetaInfo

Revision5ecfb1486d9e9a8f5cdcbe6c6d34399acaba48a8 (tree)
Time2014-12-03 09:00:11
Authorkinoshita-eos <kinoshita@yasu...>
Commiterkinoshita-eos

Log Message

Modify: Bug Fixed
modified: SampleCode/PIONE-PNML/Basic5/Serial5.md

Add: tutorial for PIONE about Interaction
new file: SampleCode/PIONE/Basic8/Annotation1.0.pione
new file: SampleCode/PIONE/Basic8/InteractiveCalc.pione
new file: SampleCode/PIONE/Basic8/InteractiveCalcInput/test1.in
new file: SampleCode/PIONE/Basic8/InteractiveCalcInput/test2.in
new file: SampleCode/PIONE/Basic8/InteractiveCalcInput/test3.in
new file: SampleCode/PIONE/Basic8/InteractiveCalcInput/test4.in
new file: SampleCode/PIONE/Basic8/InteractiveCalcInput/test5.in
new file: SampleCode/PIONE/Basic8/bin/FileCalc.cgi
new file: SampleCode/PIONE/Basic8/etc/index.html
new file: SampleCode/PIONE/Packages/InteractiveCalc(Kinoshita)+v0.1.0.ppg

Change Summary

Incremental Difference

--- a/SampleCode/PIONE-PNML/Basic5/Serial5.md
+++ b/SampleCode/PIONE-PNML/Basic5/Serial5.md
@@ -1,4 +1,4 @@
1-# Serial2.pione
1+# Serial5.pione
22
33 ## First
44 Multiply 2 to all input data.
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/Annotation1.0.pione
@@ -0,0 +1,3 @@
1+.@ PackageName :: "InteractiveCalc"
2+.@ Editor :: "Kinoshita"
3+.@ Tag :: "v0.1.0"
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/InteractiveCalc.pione
@@ -0,0 +1,22 @@
1+Rule Main
2+ output '*.out'.all
3+Flow
4+ rule Interaction
5+End
6+
7+Rule Interaction
8+ output '*.out'.all
9+Action
10+ # build public directory for pione-interactive
11+ mkdir public
12+ cp etc/* public
13+ cp bin/* public
14+
15+ echo "Interruption!" > result.log.out
16+
17+ # start interactive operation
18+ pione-interactive browser --public public
19+
20+ cp public/* .
21+ echo "finish!" > result.log.out
22+End
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/InteractiveCalcInput/test1.in
@@ -0,0 +1,2 @@
1+3
2+5
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/InteractiveCalcInput/test2.in
@@ -0,0 +1,2 @@
1+2
2+4
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/InteractiveCalcInput/test3.in
@@ -0,0 +1,2 @@
1+7
2+1
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/InteractiveCalcInput/test4.in
@@ -0,0 +1,3 @@
1+8
2+9
3+6
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/InteractiveCalcInput/test5.in
@@ -0,0 +1,9 @@
1+1
2+2
3+3
4+4
5+5
6+6
7+7
8+8
9+9
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/bin/FileCalc.cgi
@@ -0,0 +1,51 @@
1+#!/usr/bin/env ruby
2+
3+require 'cgi'
4+
5+cgi = CGI.new
6+
7+HTMLstr=""
8+
9+# Main Process
10+
11+## Query to Parameters
12+input_file=cgi.params['inputfile'][0]
13+output_path=cgi['outputfile']
14+operator=cgi['operator']
15+value=cgi['value'].to_i
16+
17+## Calc input to output
18+output_file = open(output_path, "w")
19+
20+HTMLstr += "<table>"
21+HTMLstr += "<tr>"
22+HTMLstr += "<td>" + input_file.original_filename.to_s + "</td>"
23+HTMLstr += "<td>" + output_path + "</td>"
24+HTMLstr += "</tr>"
25+
26+input_file.each do |input_line|
27+ HTMLstr += "<tr>"
28+ HTMLstr += "<td>" + input_line + "</td>"
29+
30+ work_value = input_line.to_i
31+
32+ case operator
33+ when "add"
34+ work_value += value
35+ when "mul"
36+ work_value *= value
37+ end
38+
39+ output_line = work_value.to_s
40+ output_file.write(output_line + "\n")
41+ HTMLstr += "<td>" + output_line + "</td>"
42+ HTMLstr += "</tr>"
43+end
44+
45+HTMLstr += "</table>"
46+output_file.close
47+
48+# Output as html
49+cgi.out(type: "text/html") do
50+ HTMLstr
51+end
--- /dev/null
+++ b/SampleCode/PIONE/Basic8/etc/index.html
@@ -0,0 +1,29 @@
1+<!DOCTYPE html>
2+<html>
3+ <head>
4+ <meta charset="utf-8">
5+ <title>InteractiveCalc Index Page</title>
6+ </head>
7+ <body>
8+ <form action="FileCalc.cgi" method="post" enctype="multipart/form-data">
9+ 入力ファイル名
10+ <input type="file" name="inputfile"/>
11+ <br>
12+ 演算子
13+ <select name="operator">
14+ <option value="add">+</option>
15+ <option value="mul">*</option>
16+ </select>
17+ 数値
18+ <input type="text" name="value"/>
19+ <br>
20+ 出力ファイル名
21+ <input type="text" name="outputfile"/>
22+ <br>
23+ <button type="submit">計算開始</button>
24+ </form>
25+ <br>
26+ <br>
27+ <a href="?pione-action=finish">終了</a>
28+ </body>
29+</html>
\ No newline at end of file
Binary files /dev/null and b/SampleCode/PIONE/Packages/InteractiveCalc(Kinoshita)+v0.1.0.ppg differ
Show on old repository browser