agri-controller 0.0.0 → 0.0.8

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.
Files changed (182) hide show
  1. checksums.yaml +7 -0
  2. data/ChangeLog.txt +36 -0
  3. data/LICENSE.txt +15 -0
  4. data/agri-controller.gemspec +36 -0
  5. data/gpl-2.0.txt +339 -0
  6. data/lib/agri-controller.rb +11 -33
  7. data/lib/agri-controller/bcc.rb +86 -53
  8. data/lib/agri-controller/bit.rb +158 -143
  9. data/lib/agri-controller/device.rb +7 -0
  10. data/lib/agri-controller/device/dacs.rb +148 -0
  11. data/lib/agri-controller/device/kr.rb +23 -0
  12. data/lib/agri-controller/device/ma.rb +92 -0
  13. data/lib/agri-controller/device/mch383.rb +178 -0
  14. data/lib/agri-controller/device/tr.rb +230 -0
  15. data/lib/agri-controller/device/wr1010.rb +314 -0
  16. data/lib/agri-controller/dt.rb +17 -0
  17. data/lib/agri-controller/error_caption.rb +67 -46
  18. data/lib/agri-controller/gruff.rb +7 -0
  19. data/lib/agri-controller/gruff/base.rb +88 -0
  20. data/lib/agri-controller/gruff/chdata.rb +64 -0
  21. data/lib/agri-controller/gruff/join_csv.rb +62 -0
  22. data/lib/agri-controller/gruff/rename_csv.rb +50 -0
  23. data/lib/agri-controller/{thermo_data_each_day.rb → gruff/thermo_data_each_day.rb} +67 -67
  24. data/lib/agri-controller/{thermo_gruff.rb → gruff/thermo_gruff.rb} +112 -109
  25. data/lib/agri-controller/gruff/thermo_gruff2.rb +161 -0
  26. data/lib/agri-controller/{thermo_gruff_generate.rb → gruff/thermo_gruff_generate.rb} +28 -28
  27. data/lib/agri-controller/gruff/thermo_gruff_loop.rb +42 -0
  28. data/lib/agri-controller/loger.rb +91 -51
  29. data/lib/agri-controller/main.rb +0 -0
  30. data/lib/agri-controller/main_linux.rb +282 -0
  31. data/lib/agri-controller/main_new.rb +401 -401
  32. data/lib/agri-controller/multiple_pulse_timer.rb +190 -169
  33. data/lib/agri-controller/n_dan_thermo.rb +156 -154
  34. data/lib/agri-controller/save_threads.rb +181 -172
  35. data/lib/agri-controller/setting_io.rb +53 -53
  36. data/lib/agri-controller/ttyUSB_watchdog.rb +43 -0
  37. data/lib/agri-controller/value_controller.rb +209 -167
  38. data/lib/agri-controller/version.rb +7 -5
  39. data/lib/agri-controller/web.rb +39 -39
  40. data/lib/agri-controller/webrick_test.rb +51 -46
  41. data/lib/agri-controller/wet_sensor.rb +92 -0
  42. data/test/tc_bit.rb +14 -3
  43. data/test/tc_trigger.rb +27 -0
  44. data/test/ts_agri-controller.rb +10 -10
  45. metadata +62 -202
  46. data/bin/main.bat +0 -2
  47. data/bin/main.bat /202/326/202/314/203V/203/207/201[/203g/203J/203b/203g.lnk +0 -0
  48. data/bin/main.rb +0 -23
  49. data/bin/memo.txt +0 -4
  50. data/bin/server.bat +0 -1
  51. data/bin/server.bat /202/326/202/314/203V/203/207/201[/203g/203J/203b/203g.lnk +0 -0
  52. data/bin/server.rb +0 -4
  53. data/bin/set_config.rb +0 -47
  54. data/bin/usual.rb +0 -3
  55. data/bin//203R/203}/203/223/203h /203v/203/215/203/223/203v/203g.lnk +0 -0
  56. data/lib/agri-controller/dacs.rb +0 -114
  57. data/lib/agri-controller/dircopy.rb +0 -30
  58. data/lib/agri-controller/kr.rb +0 -34
  59. data/lib/agri-controller/kr_2.rb +0 -78
  60. data/lib/agri-controller/serial.rb +0 -114
  61. data/lib/agri-controller/thermo_gruff_loop.rb +0 -35
  62. data/lib/agri-controller/wetsensor.rb +0 -119
  63. data/lib/agri-controller/wr1010.rb +0 -316
  64. data/lib/agri-controller/wr1010_2.rb +0 -0
  65. data/lib/cgi-bin/auto01.cgi +0 -0
  66. data/lib/cgi-bin/auto02.cgi +0 -0
  67. data/lib/cgi-bin/change_step.cgi +0 -42
  68. data/lib/cgi-bin/config/change_step +0 -4
  69. data/lib/cgi-bin/config/house1 +0 -20
  70. data/lib/cgi-bin/config/house2 +0 -8
  71. data/lib/cgi-bin/config/kr01_readable.txt +0 -2
  72. data/lib/cgi-bin/config/kr02_readable.txt +0 -2
  73. data/lib/cgi-bin/config/kr1_bit.txt +0 -2
  74. data/lib/cgi-bin/config/kr2_bit.txt +0 -2
  75. data/lib/cgi-bin/config/last_bit.txt +0 -1
  76. data/lib/cgi-bin/config/last_thermo_data +0 -22
  77. data/lib/cgi-bin/config/last_thermo_time +0 -2
  78. data/lib/cgi-bin/config/manual_bool01.txt +0 -2
  79. data/lib/cgi-bin/config/manual_bool02.txt +0 -2
  80. data/lib/cgi-bin/config/reload_flag +0 -2
  81. data/lib/cgi-bin/config/run_check +0 -2
  82. data/lib/cgi-bin/config/thermo_define.yml +0 -4
  83. data/lib/cgi-bin/config/time_array +0 -10
  84. data/lib/cgi-bin/config/wait_time +0 -2
  85. data/lib/cgi-bin/config/wet0 +0 -3
  86. data/lib/cgi-bin/config/wet0_drain +0 -2
  87. data/lib/cgi-bin/config/wet1 +0 -3
  88. data/lib/cgi-bin/config/wet1_drain +0 -2
  89. data/lib/cgi-bin/config/wet_input.txt +0 -1
  90. data/lib/cgi-bin/curtain_h1.cgi +0 -43
  91. data/lib/cgi-bin/curtain_h1_setting.cgi +0 -43
  92. data/lib/cgi-bin/curtain_h2.cgi +0 -43
  93. data/lib/cgi-bin/curtain_h2_setting.cgi +0 -43
  94. data/lib/cgi-bin/dacs_port.cgi +0 -43
  95. data/lib/cgi-bin/delay_time_0.cgi +0 -43
  96. data/lib/cgi-bin/delay_time_1.cgi +0 -43
  97. data/lib/cgi-bin/error_clear.cgi +0 -0
  98. data/lib/cgi-bin/house1.cgi +0 -42
  99. data/lib/cgi-bin/house1a.cgi +0 -43
  100. data/lib/cgi-bin/house2.cgi +0 -42
  101. data/lib/cgi-bin/house2b.cgi +0 -43
  102. data/lib/cgi-bin/house_n_dan_thermo1.cgi +0 -43
  103. data/lib/cgi-bin/house_n_dan_thermo2.cgi +0 -0
  104. data/lib/cgi-bin/keitai.cgi +0 -25
  105. data/lib/cgi-bin/kr01.cgi +0 -0
  106. data/lib/cgi-bin/kr01_readable.txt.cgi +0 -42
  107. data/lib/cgi-bin/kr02.cgi +0 -0
  108. data/lib/cgi-bin/kr02_readable.txt.cgi +0 -42
  109. data/lib/cgi-bin/kr1_bit.txt.cgi +0 -42
  110. data/lib/cgi-bin/kr2_bit.txt.cgi +0 -42
  111. data/lib/cgi-bin/kr_log.cgi +0 -18
  112. data/lib/cgi-bin/last_bit.txt.cgi +0 -42
  113. data/lib/cgi-bin/last_thermo_data.cgi +0 -42
  114. data/lib/cgi-bin/last_thermo_time.cgi +0 -42
  115. data/lib/cgi-bin/log.cgi +0 -19
  116. data/lib/cgi-bin/log/errors.txt +0 -1
  117. data/lib/cgi-bin/log/errors_.txt +0 -93
  118. data/lib/cgi-bin/log/kr_command_log.txt +0 -240
  119. data/lib/cgi-bin/log/log.txt +0 -441
  120. data/lib/cgi-bin/log/old_log/log_.txt +0 -15
  121. data/lib/cgi-bin/log/thermo/2010-05-22_thermo.csv +0 -1438
  122. data/lib/cgi-bin/log/thermo/2010-06-12_thermo.csv +0 -3
  123. data/lib/cgi-bin/log/thermo/2010-06-13_thermo.csv +0 -2
  124. data/lib/cgi-bin/log/thermo/2010-06-16_thermo.csv +0 -85
  125. data/lib/cgi-bin/log/thermo/2010-06-17_thermo.csv +0 -285
  126. data/lib/cgi-bin/log/thermo_data.csv +0 -643
  127. data/lib/cgi-bin/log/thermo_graph_loop.txt +0 -1
  128. data/lib/cgi-bin/main.cgi +0 -98
  129. data/lib/cgi-bin/manual_bool01.txt.cgi +0 -42
  130. data/lib/cgi-bin/manual_bool02.txt.cgi +0 -42
  131. data/lib/cgi-bin/post_change_step.cgi +0 -44
  132. data/lib/cgi-bin/post_house1.cgi +0 -44
  133. data/lib/cgi-bin/post_house2.cgi +0 -44
  134. data/lib/cgi-bin/post_kr01.cgi +0 -0
  135. data/lib/cgi-bin/post_kr01_readable.txt.cgi +0 -44
  136. data/lib/cgi-bin/post_kr02.cgi +0 -0
  137. data/lib/cgi-bin/post_kr02_readable.txt.cgi +0 -44
  138. data/lib/cgi-bin/post_kr1_bit.txt.cgi +0 -44
  139. data/lib/cgi-bin/post_kr2_bit.txt.cgi +0 -44
  140. data/lib/cgi-bin/post_last_bit.txt.cgi +0 -44
  141. data/lib/cgi-bin/post_last_thermo_data.cgi +0 -44
  142. data/lib/cgi-bin/post_last_thermo_time.cgi +0 -44
  143. data/lib/cgi-bin/post_manual_bool01.txt.cgi +0 -44
  144. data/lib/cgi-bin/post_manual_bool02.txt.cgi +0 -44
  145. data/lib/cgi-bin/post_reload_flag.cgi +0 -44
  146. data/lib/cgi-bin/post_run_check.cgi +0 -44
  147. data/lib/cgi-bin/post_thermo_define.yml.cgi +0 -44
  148. data/lib/cgi-bin/post_time_array.cgi +0 -44
  149. data/lib/cgi-bin/post_wait_time.cgi +0 -44
  150. data/lib/cgi-bin/post_wet0.cgi +0 -44
  151. data/lib/cgi-bin/post_wet0_drain.cgi +0 -44
  152. data/lib/cgi-bin/post_wet1.cgi +0 -44
  153. data/lib/cgi-bin/post_wet1_drain.cgi +0 -44
  154. data/lib/cgi-bin/post_wet_input.txt.cgi +0 -44
  155. data/lib/cgi-bin/reload_flag.cgi +0 -42
  156. data/lib/cgi-bin/reset_.cgi +0 -0
  157. data/lib/cgi-bin/run_check.cgi +0 -42
  158. data/lib/cgi-bin/set.cgi +0 -33
  159. data/lib/cgi-bin/set_post_yml_each.rb +0 -72
  160. data/lib/cgi-bin/set_yml_cgi_each.rb +0 -0
  161. data/lib/cgi-bin/setting.cgi +0 -0
  162. data/lib/cgi-bin/setting.cgi.1 +0 -0
  163. data/lib/cgi-bin/setting_io.rb +0 -53
  164. data/lib/cgi-bin/thermo_data_graphs.cgi +0 -0
  165. data/lib/cgi-bin/thermo_data_list.cgi +0 -0
  166. data/lib/cgi-bin/thermo_define.yml.cgi +0 -42
  167. data/lib/cgi-bin/thermo_graph.cgi +0 -0
  168. data/lib/cgi-bin/time_array.cgi +0 -42
  169. data/lib/cgi-bin/wait_time.cgi +0 -42
  170. data/lib/cgi-bin/web.rb +0 -39
  171. data/lib/cgi-bin/wet0.cgi +0 -42
  172. data/lib/cgi-bin/wet0_drain.cgi +0 -42
  173. data/lib/cgi-bin/wet1.cgi +0 -42
  174. data/lib/cgi-bin/wet1_drain.cgi +0 -42
  175. data/lib/cgi-bin/wet_input.txt.cgi +0 -42
  176. data/lib/htdocs/css/str.css +0 -89
  177. data/lib/htdocs/favicon.ico +0 -0
  178. data/lib/htdocs/thermo/thermo_data.jpg +0 -0
  179. data/lib/htdocs/thermo/thumb/thermo_data.jpg +0 -0
  180. data/test/tc_bit.rb.1 +0 -15
  181. data/test/tc_bit.rb.2 +0 -21
  182. data/test/ts_agri-controller.rb.1 +0 -8
@@ -1,172 +1,181 @@
1
- #!ruby
2
- #coding:utf-8
3
- require "open-uri"
4
- module AgriController
5
- module_function
6
- #ネット上のデータをサーモデータとして利用する
7
- def thermo_read(ref="http://maru.selfip.com/cgi-bin/thermo.rb")
8
- begin
9
- uri=URI(ref)
10
- dat=uri.read("Accept-Language" => "ja")
11
- return dat
12
- rescue
13
- nil
14
- end
15
- end
16
-
17
- #WRの温度データを、logdirにyaml形式でN_secごとに記録する
18
- def thermo_loop_thread(yaml_file,thermo_port,thermo_N,sec=3,logdir="./cgi-bin/config")
19
- Thread.start(yaml_file,thermo_port,thermo_N,sec,logdir) do |name,port,n,s,lo|
20
- #p "start N:"+n.to_s
21
-
22
- loop do
23
- thermo=nil
24
- #load thermo DATA par :sec
25
- x=0
26
-
27
- 10.times do |x|
28
-
29
- begin
30
- #res=thermo_read()
31
- #thermo=eval(res) if res!=nil
32
-
33
- thermo=WR1010::list(port,n,0.3+x*0.1)#import WR1010 data
34
- rescue
35
- thermo=nil
36
- end
37
-
38
- break if (thermo.class==Array && thermo.size>=n)
39
- sleep 1
40
- end
41
-
42
- #read error
43
- if thermo.class==Array && thermo.size>n
44
- thermo=thermo[0..n-1]
45
- end
46
-
47
- yaml_db(name,thermo,lo+"/"+name)#save last data
48
-
49
- #judge right thermo data
50
- if thermo.class==Array && thermo.size==n
51
- #p thermo
52
- yaml_db("last_thermo_time",Time.now,lo+"/last_thermo_time")
53
- else
54
- #p "else"
55
-
56
- #error save and next_try after sleep
57
- dat=Time.now.to_s+" |thermo_thread| "+thermo.inspect+"<br/>"
58
- Loger::loger(lo+"/../log/errors.txt",dat)
59
- Loger::loger(lo+"/../log/errors_.txt",dat)
60
- sleep 600
61
- end
62
- sleep s
63
- end
64
- end
65
- end
66
- require "time"
67
- def thermo_data_logger_thread(thermo_N=3,config="./cgi-bin/config",log="./cgi-bin/log")
68
-
69
- Thread.start(thermo_N,config,log) do |n,c,l|
70
- #thermo number DEFINE
71
-
72
- #begin
73
- #mainloop
74
- before=nil
75
- day_before=Time.now.day
76
- loop do
77
- t=Time.now
78
- min=t.min
79
- if min!=before
80
- before=min
81
-
82
- t2=t.to_a
83
- t2[0]=0
84
- tt=Time.parse(t2[2].to_s+":"+t2[1].to_s+":"+t2[0].to_s)
85
- #p tt
86
- ##
87
- #save DATA LOGGER(default,each o'clock)
88
- thermo=yaml_dbr("last_thermo_data",c+"/last_thermo_data")
89
- word=tt.to_s+","
90
-
91
- if thermo.class==Array && thermo.size >= n
92
- n.times do |a|
93
- word=word+thermo[a][0].to_s+","+thermo[a][1].to_s+","
94
- end
95
-
96
- else
97
- #nil data define ['c,%]=[0,false]
98
- n.times do |a|
99
- word=word+"0"+","+"false"+","
100
- end
101
- end
102
- #seve data each minute.
103
- str=word.chop+"\n"
104
- Loger::loger(l+"/thermo_data.csv",str,"a",150000)
105
- #thermo_gruff
106
- #yesterday = (Date.today-1).to_s
107
- #load yesterday_data
108
- #filename=l+"/"+yesterday+"_thermo.csv"
109
- # if File.exist?(filename)
110
- # yesterday_data=File.read(filename)
111
- # else
112
- # yesterday_data=""
113
- # end
114
- #load today_data
115
- # filename=l+"/thermo_data.csv"
116
- # if File.exist?(filename)
117
- # today_data=File.read(filename)
118
- # else
119
- # today_data=""
120
- # end
121
-
122
- # dat=yesterday_data+today_data
123
- # open(l+"/data.tmp","w"){|io| io.print dat}
124
- end
125
-
126
- sleep 0.3
127
- day=t.day
128
- if day_before!=day
129
- day_before=day
130
- sleep 5
131
- Thread.start(l) do |ll|
132
- last_day=(Date.today-1).to_s
133
- #thermo_gruff(g+'/'+today+'.jpg',l+"/thermo_data.csv",n,"480x420")
134
- #p l+'/thermo/'+last_day+"_thermo.csv"
135
-
136
- #save data every day if needed.
137
- #__HERE!!__
138
-
139
- #
140
- File.rename(ll+"/thermo_data.csv",ll+'/thermo/'+last_day+"_thermo.csv")
141
- open(ll+"/thermo_data.csv","w"){|io| io.print("")}
142
- end
143
- sleep 1
144
- end
145
- #p Time.now
146
- end
147
- sleep 10
148
- end
149
- end
150
- end
151
-
152
- if $0==__FILE__
153
- require "wr1010"
154
- require "serial"
155
- require "setting_io"
156
- require "loger"
157
- require "bit"
158
- include AgriController
159
- Dir_cgi ="./cgi-bin"
160
- Dir_ht ="./htdocs"
161
-
162
- Dir_log =Dir_cgi+"/log"
163
- Dir_config =Dir_cgi+"/config"
164
- Dir_thermo_data =Dir_cgi+"/thermo_data"
165
-
166
- Dir_gruff =Dir_ht+"/thermo"
167
- Dir_gruff_small =Dir_gruff+"/thumb"
168
- t1=thermo_loop_thread(yaml_file="last_thermo_data",thermo_port=8,thermo_N=4,sec=3)
169
- t2=thermo_data_logger_thread
170
- t1.join
171
- t2.join
172
- end
1
+ #!ruby
2
+ #coding:utf-8
3
+ require "open-uri"
4
+ module AgriController
5
+ module_function
6
+ #ネット上のデータをサーモデータとして利用する
7
+ def thermo_read(ref="http://maru.selfip.com/cgi-bin/thermo.rb")
8
+ begin
9
+ uri=URI(ref)
10
+ dat=uri.read("Accept-Language" => "ja")
11
+ return dat
12
+ rescue
13
+ nil
14
+ end
15
+ end
16
+
17
+ #WRの温度データを、logdirにyaml形式でN_secごとに記録する
18
+ def thermo_loop_thread(yaml_file,thermo_port,thermo_N,sec=3,logdir="./cgi-bin/config",baud=57600)
19
+ Thread.start(yaml_file,thermo_port,thermo_N,sec,logdir,baud) do |name,port,n,s,lo,bau|
20
+ #p "start N:"+n.to_s
21
+ unless RUBY_PLATFORM.include?("mswin")
22
+ wr=Serial.new(WR1010::send_sample(n),port,bau,5)
23
+ wr.set
24
+ end
25
+
26
+
27
+ loop do
28
+ thermo=nil
29
+ #load thermo DATA par :sec
30
+ x=0
31
+
32
+ 9.times do |x|
33
+ #p x
34
+ begin
35
+ #res=thermo_read()
36
+ #thermo=eval(res) if res!=nil
37
+ if RUBY_PLATFORM.include?("mswin")
38
+ thermo=WR1010::list(port,n,0.3+x*0.1)#import WR1010 data
39
+ else#linux
40
+ res=wr.serial
41
+ thermo=WR1010::toa(res)
42
+ end
43
+ rescue
44
+ thermo=nil
45
+ end
46
+ Loger::loger(lo+"/../log/errors_.txt",Time.now.inspect+res.inspect+","+x.inspect) if x>2
47
+ break if (thermo.class==Array && thermo.size==n)
48
+ sleep 6
49
+ end
50
+
51
+ #read error
52
+ #if thermo.class==Array && thermo.size>n
53
+ # thermo=thermo[0..n-1]
54
+ #end
55
+
56
+ yaml_db(name,thermo,lo+"/"+name)#save last data
57
+
58
+ #judge right thermo data
59
+ if thermo.class==Array && thermo.size==n
60
+ #p thermo
61
+ yaml_db("last_thermo_time",Time.now,lo+"/last_thermo_time")
62
+ else
63
+ #p "else"
64
+
65
+ #error save and next_try after sleep
66
+ dat=Time.now.iso8601+" |thermo_thread| "+thermo.inspect+"<br/>"
67
+ #Loger::loger(lo+"/../log/errors.txt",dat)
68
+ Loger::loger(lo+"/../log/errors_.txt",dat)
69
+ #sleep 600
70
+ end
71
+ sleep s
72
+ end
73
+ end
74
+ end
75
+ require "time"
76
+ def thermo_data_logger_thread(thermo_N=3,config="./cgi-bin/config",log="./cgi-bin/log")
77
+
78
+ Thread.start(thermo_N,config,log) do |n,c,l|
79
+ #thermo number DEFINE
80
+
81
+ #begin
82
+ #mainloop
83
+ before=nil
84
+ day_before=Time.now.day
85
+ loop do
86
+ t=Time.now
87
+ min=t.min
88
+ if min!=before
89
+ before=min
90
+
91
+ t2=t.to_a
92
+ t2[0]=0
93
+ tt=Time.parse(t2[2].to_s+":"+t2[1].to_s+":"+t2[0].to_s)
94
+ #p tt
95
+ ##
96
+ #save DATA LOGGER(default,each o'clock)
97
+ thermo=yaml_dbr("last_thermo_data",c+"/last_thermo_data")
98
+ word=tt.iso8601+","
99
+
100
+ if thermo.class==Array && thermo.size >= n
101
+ n.times do |a|
102
+ word=word+thermo[a][0].to_s+","+thermo[a][1].to_s+","
103
+ end
104
+
105
+ else
106
+ #nil data define ['c,%]=[0,false]
107
+ n.times do |a|
108
+ word=word+"0"+","+"false"+","
109
+ end
110
+ end
111
+ #seve data each minute.
112
+ str=word.chop+"\n"
113
+ Loger::loger(l+"/thermo_data.csv",str,"a",150000)
114
+ #thermo_gruff
115
+ #yesterday = (Date.today-1).to_s
116
+ #load yesterday_data
117
+ #filename=l+"/"+yesterday+"_thermo.csv"
118
+ # if File.exist?(filename)
119
+ # yesterday_data=File.read(filename)
120
+ # else
121
+ # yesterday_data=""
122
+ # end
123
+ #load today_data
124
+ # filename=l+"/thermo_data.csv"
125
+ # if File.exist?(filename)
126
+ # today_data=File.read(filename)
127
+ # else
128
+ # today_data=""
129
+ # end
130
+
131
+ # dat=yesterday_data+today_data
132
+ # open(l+"/data.tmp","w"){|io| io.print dat}
133
+ end
134
+
135
+ sleep 0.3
136
+ day=t.day
137
+ if day_before!=day
138
+ day_before=day
139
+ sleep 5
140
+ Thread.start(l) do |ll|
141
+ last_day=(Date.today-1).to_s
142
+ #thermo_gruff(g+'/'+today+'.jpg',l+"/thermo_data.csv",n,"480x420")
143
+ #p l+'/thermo/'+last_day+"_thermo.csv"
144
+
145
+ #save data every day if needed.
146
+ #__HERE!!__
147
+
148
+ #
149
+ File.rename(ll+"/thermo_data.csv",ll+'/thermo/'+last_day+"_thermo.csv")
150
+ open(ll+"/thermo_data.csv","w"){|io| io.print("")}
151
+ end
152
+ sleep 1
153
+ end
154
+ #p Time.now
155
+ end
156
+ sleep 10
157
+ end
158
+ end
159
+ end
160
+
161
+ if $0==__FILE__
162
+ require "wr1010"
163
+ require "serial"
164
+ require "setting_io"
165
+ require "loger"
166
+ require "bit"
167
+ include AgriController
168
+ Dir_cgi ="./cgi-bin"
169
+ Dir_ht ="./htdocs"
170
+
171
+ Dir_log =Dir_cgi+"/log"
172
+ Dir_config =Dir_cgi+"/config"
173
+ Dir_thermo_data =Dir_cgi+"/thermo_data"
174
+
175
+ Dir_gruff =Dir_ht+"/thermo"
176
+ Dir_gruff_small =Dir_gruff+"/thumb"
177
+ t1=thermo_loop_thread(yaml_file="last_thermo_data",thermo_port=8,thermo_N=4,sec=3)
178
+ t2=thermo_data_logger_thread
179
+ t1.join
180
+ t2.join
181
+ end
@@ -1,53 +1,53 @@
1
- #!ruby
2
- require "yaml"
3
- require "yaml/store"
4
-
5
- module AgriController
6
- module_function
7
- #module Setting_io
8
- module_function
9
- def yaml_db(name,value,file=name)#"db.yaml")
10
- #p name
11
- db=YAML::Store.new(file)
12
- db.transaction do
13
- db[name.to_s]=value
14
- end
15
- end
16
-
17
- def yaml_dbr(name,file=name)#"db.yaml")
18
- #p file
19
- db=YAML::Store.new(file)
20
- db.transaction(:read_only) do
21
- db[name.to_s]
22
- end
23
- end
24
- def yaml_key(file)
25
- db=YAML::Store.new(file)
26
- db.transaction(:read_only) do
27
- db.roots.sort
28
- end
29
- end
30
-
31
- def yaml_dump(data,filename="setting_io.yml")
32
- yaml_db(name=filename,value=data,"db.yaml")
33
- end
34
-
35
- def yaml_load(filename="setting_io.yml")
36
- res=yaml_dbr(name=filename)#,"db.yaml")
37
- if res == nil
38
- if File.exist?(filename)
39
- a=File.read(filename)
40
- if a
41
- x=YAML.load(a)
42
- yaml_db(name=filename,x,name)
43
- end
44
-
45
- return x
46
- else
47
- return nil
48
- end
49
- else
50
- return res
51
- end
52
- end
53
- end
1
+ #!ruby
2
+ #coding:utf-8
3
+ require "yaml"
4
+ require "yaml/store"
5
+
6
+ module AgriController
7
+ module_function
8
+ module_function
9
+ def yaml_db(name,value,file=name)#"db.yaml")
10
+ #p name
11
+ db=YAML::Store.new(file)
12
+ db.transaction do
13
+ db[name.to_s]=value
14
+ end
15
+ end
16
+
17
+ def yaml_dbr(name,file=name)#"db.yaml")
18
+ #p file
19
+ db=YAML::Store.new(file)
20
+ db.transaction(:read_only) do
21
+ db[name.to_s]
22
+ end
23
+ end
24
+ def yaml_key(file)
25
+ db=YAML::Store.new(file)
26
+ db.transaction(:read_only) do
27
+ db.roots.sort
28
+ end
29
+ end
30
+
31
+ def yaml_dump(data,filename="setting_io.yml")
32
+ yaml_db(name=filename,value=data,"db.yaml")
33
+ end
34
+
35
+ def yaml_load(filename="setting_io.yml")
36
+ res=yaml_dbr(name=filename)#,"db.yaml")
37
+ if res == nil
38
+ if File.exist?(filename)
39
+ a=File.read(filename)
40
+ if a
41
+ x=YAML.load(a)
42
+ yaml_db(name=filename,x,name)
43
+ end
44
+
45
+ return x
46
+ else
47
+ return nil
48
+ end
49
+ else
50
+ return res
51
+ end
52
+ end
53
+ end