agri-controller 0.0.10 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 99a49e6fffea6706111ab73523d69f0dae857671
4
- data.tar.gz: 521aa3eb58c5d0cb54de7887d196901b00655572
2
+ SHA256:
3
+ metadata.gz: eb86d25fa1d94427310dd671ce35ab8c93aeaac843c7c3de7d57a30a9963a8f8
4
+ data.tar.gz: 821344fe0ef6e23e6661ff68a61050843ddd38eff41d0b2efd9da11c225da12a
5
5
  SHA512:
6
- metadata.gz: a511d8a69403052fa74f8d477413030df0351123941ab489d73afd57a6dbe737d6cbf56f76abf39e0384f7925f140669575da6642d085ddd390cce5433407f6a
7
- data.tar.gz: a1573d00b1af0e31d4bbd42ef50259c845cfe112842fc548a2aee219863e78dbc5a60aab2a24bea3f520f6f7282f59230be6b82ebbd8319e4edbd8a65e96cee5
6
+ metadata.gz: 36251d3861675ba417cffa0fd0d8fec563267356af1673883e630248fe057dea7e0df09fb00dc79c136a4ea641c48433656a8f381ca4d5e9e234a96e84d85289
7
+ data.tar.gz: 47fe207e6b886186e29e3fcb1c086addf2d44ee2a890098896586a252736310242303872c0bebff67c0a68423e8d60f2b843c65442648645a17a5f6181d36273
@@ -1,5 +1,13 @@
1
+ ==0.0.11
2
+ * housa(degree,rh) add
3
+ * value_controller minorfix
4
+ update2021.1.30
5
+
6
+ ==0.0.10
7
+ some fix for linux update
1
8
  ==0.0.9
2
9
  * Bit::on? fixed
10
+
3
11
  ==0.0.8
4
12
  * Fixed for backward compatibility. Not perfect, but available in a few modifications
5
13
 
@@ -1,6 +1,6 @@
1
1
  'agri-controller' can easy to control greenhouse environment using PC.
2
2
 
3
- Copyright (C) 2009-2014 Takayasu Hayashi (email: joe.ko9ji@gmail.com )
3
+ Copyright (C) 2009-2021 Takayasu Hayashi (email: joe.ko9ji@gmail.com )
4
4
 
5
5
  This program is free software; you can redistribute it and/or modify
6
6
  it under the terms of the GNU General Public License, version 2, as
@@ -3,18 +3,18 @@ require './lib/agri-controller/version'
3
3
  require './license'
4
4
  spec = Gem::Specification.new do |s|
5
5
  s.platform = Gem::Platform::RUBY
6
- s.summary = "AgriController easily controls the greenhouse with a Personal Computer.(win,linux RS232)"
6
+ s.summary = "AgriController easily controls the greenhouse with a Personal Computer,also Raspi.(win,linux RS232)"
7
7
  s.author="Takayasu Hayashi"
8
8
  s.email="joe.ko9ji@gmail.com"
9
9
  s.homepage="http://rubygems.org/gems/agri-controller"
10
10
  s.name = "agri-controller"
11
11
  s.version = AgriController::VERSION
12
- s.licenses="GPLv2"
12
+ s.licenses="GPL-2.0"
13
13
  #s.requirements << 'rmagick'
14
14
  #s.requirements << 'gruff'
15
15
  #s.add_dependency('serialport','>= 1.0.4')
16
16
  s.require_path = 'lib'
17
- s.has_rdoc=true
17
+ #s.has_rdoc=true #deprecated
18
18
  s.test_files=["test/ts_agri-controller.rb"]
19
19
 
20
20
  #s.files = Dir.glob("{test,lib}/**/*.rb")
@@ -0,0 +1,154 @@
1
+ #!ruby -Ku
2
+ #coding:utf-8
3
+ module AgriController
4
+
5
+ module_function
6
+ #return hPa
7
+ #houwa_pressure(Celsius_Degree)
8
+ def houwa_pressure(t)
9
+ eT=6.1078*10**(7.5*t/(t+237.3))
10
+ end
11
+
12
+ #return hPa(Pa * 100)
13
+ def houwa_pressure2(t)
14
+ x=1-(273.15+t)/647.3
15
+ eT2=221200*Math::E**((-7.76451*x+1.45838*(x**1.5)-2.7758*(x**3)-1.23303*(x**6))/(1-x))
16
+ end
17
+
18
+
19
+ #houwa(Celsius_Degree) # =>g/m^3
20
+ def houwa(t)
21
+ eT=houwa_pressure(t)
22
+ #et=houwa_pressure2(t)
23
+ aT=(217*eT)/(t+273.15)
24
+ end
25
+
26
+ def houwa2(t)
27
+ #et=houwa_pressure(t)
28
+ eT=houwa_pressure2(t)
29
+ aT=(217*eT)/(t+273.15)
30
+ end
31
+
32
+ #housa(Celsius_degree,Rh(%)) # =>g/m^3
33
+ def housa(t,rh)
34
+ x=houwa(t)
35
+ x2=x*rh/100.0
36
+ x-x2
37
+ end
38
+
39
+
40
+ def housa2(t,rh)
41
+ x=houwa2(t)
42
+ x2=x*rh/100.0
43
+ x-x2
44
+ end
45
+
46
+ #roten(Celsius_degree,Rh(%)) # =>Celsius_Degree
47
+ def roten(t,rh)
48
+ ps=houwa_pressure(t)*100
49
+ e =ps*rh/100.0
50
+ y=Math.log(e/611.213)
51
+ if y>=0
52
+ p "1"
53
+ td=13.715*y+8.4262*0.1*y**2+1.9048*0.01*y**3+7.8158*0.001*y**4
54
+ elsif y<0
55
+ p "2"
56
+ td2=13.7204*y+7.36631*0.1*y**2+3.32136*0.01*y**3+7.78591*0.001*y**4
57
+ else
58
+ p "3"
59
+ 0
60
+ end
61
+ end
62
+
63
+ #
64
+ def zettai(t,rh)
65
+ x=houwa(t)
66
+ x2=x*rh/100.0
67
+ end
68
+ end
69
+
70
+ if $0==__FILE__
71
+ #require "profile"
72
+ begin
73
+ #p "[t(℃),rh(%)]="+[ARGV[0],ARGV[1]].inspect
74
+ print housa(ARGV[0].to_f,ARGV[1].to_f).to_s+"\n"
75
+ rescue
76
+ #50.times do
77
+ puts "ruby ./housa.rb [Celsius Degree] [rh%]=> g/m^3"
78
+ puts "ruby ./housa.rb 25 60 # =>#{housa(25,60)}"
79
+ puts
80
+ p "25 C 60%"
81
+ p housa(25,60)
82
+ p housa2(25,60)
83
+ p "25 C,70%"
84
+ p housa(25,70)
85
+ p housa2(25,70)
86
+ p "25 C,80%"
87
+ p housa(25,80)
88
+ p housa2(25,80)
89
+ #end
90
+ p roten(25,80)
91
+ p zettai(25,80)
92
+ end
93
+ end
94
+ =begin
95
+ #Difference in the amount of Saturation Water vapor
96
+ 飽和水蒸気量差(ある温度と湿度での、湿度100%と現在の水蒸気量の差)
97
+ 飽差の計算
98
+ t=t [℃]
99
+ rh=rh[%]
100
+
101
+ 飽和水蒸気量(ほうわすいじょうきりょう)a(T)[g/m3] は1m3の空間に存在できる水蒸気の質量をgで表したものである。容積絶対湿度、飽和水蒸気密度ともいう。これは温度T[℃]が小さいと小さくなる。
102
+ 水蒸気を理想気体と見なすとa(T)は以下の式で示される。
103
+
104
+ a(T)={{217 * e(T)} \{T+273.15}}
105
+
106
+ 湿度RH[%]は、その温度の飽和水蒸気量に対して、水蒸気量(絶対湿度)との比であらわす。
107
+ 飽和水蒸気圧曲線、沸点で大気圧になる。
108
+ 空気中の飽和水蒸気圧e(T)は気温できまり、この値を超える分圧を有する水蒸気は安定して存在できない。
109
+ e(T)は近似的にTetens(1930)のパラメータ値によるAugust他の式
110
+
111
+ e(T)=6.1078\times 10^{7.5T\over(T+237.3)}
112
+
113
+ により、指定した温度 T[℃]における飽和水蒸気圧 e(T)[hPa]が求まる。気体の状態方程式により、水蒸気量を計算できる。
114
+
115
+ 臨界圧(=22.12MPa)まで、良い近似で求めるには、ワグナー(Wagner)式を用い、
116
+
117
+ P_{ws} = P_c \times \exp ( \dfrac{A \times x+B \times x^{1.5} + C\times x^3 + D \times x^6}{1-x})
118
+
119
+ ここで、
120
+
121
+ P_{ws}[kPa]ワグナーの厳密水蒸気圧
122
+ P_c = 22120 [kPa]臨界圧
123
+ T_c = 647.3 [K]臨界温度
124
+ T絶対温度[K](T[K] = T[℃]+273.15)
125
+ x = 1 - \dfrac{T}{T_c}
126
+ A = -7.76451
127
+ B = 1.45838
128
+ C = -2.7758
129
+ D = -1.23303
130
+
131
+
132
+ t=20
133
+ => 20
134
+ ruby-1.9.3-head :033 > aT=(217*eT)/(t+273.15)
135
+ => 9.089291190842173
136
+ ruby-1.9.3-head :034 > eT2=221200*Math::E**((-7.76451*x+1.45838*(x**1.5)-2.7758*(x**3)-1.23303*(x**6))/(1-x))
137
+ => 12.289582804524482
138
+ ruby-1.9.3-head :035 >
139
+ ruby-1.9.3-head :036 > x=1-(273.15+t)/647.3 => 0.5471188011741078
140
+ ruby-1.9.3-head :037 > eT=6.1078*10**(7.5*t/(t+237.3))
141
+ => 23.380935143417695
142
+ ruby-1.9.3-head :038 > aT=(217*eT)/(t+273.15) => 17.307395279282414
143
+ ruby-1.9.3-head :039 > x=1-(273.15+t)/647.3
144
+ => 0.5471188011741078
145
+ ruby-1.9.3-head :040 > eT2=221200*Math::E**((-7.76451*x+1.45838*(x**1.5)-2.7758*(x**3)-1.23303*(x**6))/(1-x))
146
+ => 23.406201212631604
147
+ ruby-1.9.3-head :041 > aT=(217*eT2)/(t+273.15)
148
+ => 17.32609811748613
149
+ ==end
150
+
151
+
152
+ =end
153
+
154
+
@@ -5,8 +5,9 @@ module AgriController
5
5
  class Value_controller
6
6
  attr_accessor:steps,:now_step,:up_sec,:down_sec,:acting
7
7
  attr_accessor:set_value,:controll_bool,:reset_time,:emergency
8
+ attr_accessor:first,:dead_bool,:bool
8
9
 
9
- def initialize(steps=5,up_sec=60,down_sec=open_sec,sensitivity=1,set_value=20,dead_time=2,verbose=false)
10
+ def initialize(steps=5,up_sec=60,down_sec=open_sec,sensitivity=1,set_value=20,dead_time=2,verbose=false,first=true)
10
11
  @bit=0
11
12
 
12
13
  @steps =steps #多段制御>=1
@@ -16,22 +17,30 @@ module AgriController
16
17
  @set_value =set_value #設定値
17
18
  @dead_time =dead_time #不感時間
18
19
  @dead_bool =false
19
- @now_step=@steps #現在の段(2010.5.23変更)
20
-
21
- @controll_bool=false #割り込みswitch(0n,0ff)
20
+ if first
21
+ @now_step=@steps #現在の段(2010.5.23変更)
22
+ else
23
+ @now_step=0
24
+ end
25
+ @controll_bool=false #割り込みswitch(0n,0ff)[move:true],[stop:false]
22
26
  @time=Time.now
23
27
  @acting=false
24
28
  @bool=false #true(on) false(off)方向
25
29
  @verbose=verbose
26
30
  @reset_time=Time.now+@up_sec*@steps+3
27
31
  @emergency=false
32
+ @first=first
28
33
  p "Value_controller initialized at #{@reset_time}" if @verbose
29
34
  end
30
-
35
+
31
36
  def switch
32
37
  if @now_step==0 or @now_step==@steps or @emergency==true
33
38
  return true
34
39
  else
40
+ if @dead_bool==true && @acting==true
41
+ @controll_bool=false
42
+ end
43
+
35
44
  return @controll_bool
36
45
  end
37
46
  end
@@ -45,23 +54,23 @@ module AgriController
45
54
  end
46
55
 
47
56
  def before_value_controll(now_value)
48
- if now_value > @set_value+@sensitivity*@steps+1
57
+ if false#now_value > @set_value+@sensitivity*@steps+@sensitivity
49
58
  #too high
50
59
  p "too high!" if $DEBUG
51
60
 
52
61
  @emergency=true
62
+ @now_step=@steps
53
63
  return true
54
64
 
55
- elsif now_value < @set_value-1
65
+ elsif false#now_value < @set_value-@sensitivity
56
66
  #too low
57
67
  p "too low!" if $DEBUG
58
68
 
59
69
  @emergency=true
70
+ @now_step=0
60
71
  return false
61
-
62
- elsif Time.now < @reset_time
63
- return true#open first signal(close:false)
64
-
72
+ elsif Time.now <= @reset_time
73
+ return @first
65
74
  else#normaly
66
75
  @emergency=false
67
76
  return @bool
@@ -69,16 +78,17 @@ module AgriController
69
78
  end
70
79
 
71
80
  def value_controll(now_value)
81
+ if Time.now > @reset_time
72
82
  if @acting==false
73
83
  #now_value:nil or tempareture
74
84
  if now_value != nil
75
- high=(now_value <=> @set_value+@sensitivity*(@now_step+1))
76
- low =(now_value <=> (@set_value+@sensitivity*(@now_step))-2)
85
+ high=(now_value <=> @set_value+@sensitivity*(@now_step)+@sensitivity)
86
+ low =(now_value <=> (@set_value+@sensitivity*(@now_step))-@sensitivity*2)
77
87
  else
78
- high=1#温度を下げる方向へセット
88
+ high=0#そのまま  #1:温度を下げる方向へセット
79
89
  low=0 #そのまま
80
90
  p Time.now.inspect+" :"+now_value.inspect
81
- raise "value_controller.rb:60 error!!"
91
+ #raise "value_controller.rb:60 error!!"
82
92
  end
83
93
 
84
94
  #もし動作中なら、そのときの温度に関係なく動作続行(下記の判定は読みとばす)
@@ -125,9 +135,10 @@ module AgriController
125
135
  if @bool==true
126
136
  x=pulse_timer([@time,@up_sec])
127
137
  y=pulse_timer([@time,@up_sec+@dead_time])
128
- else #@bool==false
138
+ elsif @bool==false
129
139
  x=pulse_timer([@time,@down_sec])
130
140
  y=pulse_timer([@time,@down_sec+@dead_time])
141
+ else
131
142
  end
132
143
  if y==true
133
144
  @acting=true
@@ -136,30 +147,17 @@ module AgriController
136
147
  end
137
148
 
138
149
  if x==true
139
- elsif x==false && y==true
150
+ elsif x!=true && y==true
140
151
  switch_off
141
152
  @dead_bool = true
142
153
  else
143
- @dead_bool = false
154
+ if x!=true && y!=true
155
+ @dead_bool = false
156
+ end
144
157
  end
145
- before_value_controll(now_value)#return
146
-
147
- =begin
148
- if now_value > @set_value+@sensitivity*@steps+1
149
- #too high
150
- p "too high!" if $DEBUG
151
- @emergency=true
152
- return true
153
- elsif now_value < @set_value-1
154
- p "too low!" if $DEBUG
155
- #too low
156
- @emergency=true
157
- return false
158
- else#normaly
159
- @emergency=false
160
- return @bool
161
- end
162
- =end
158
+ else #reset_time
159
+ end
160
+ before_value_controll(now_value)
163
161
  end
164
162
 
165
163
  def step_up
@@ -2,6 +2,6 @@
2
2
  #coding:utf-8
3
3
  module AgriController
4
4
  module_function
5
- VERSION = "0.0.10"
5
+ VERSION = "0.0.11"
6
6
  MINOR_VERSION="0"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agri-controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takayasu Hayashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-03 00:00:00.000000000 Z
11
+ date: 2021-01-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " A few graphic scripts can load below.\n No need \"gruff\".\n
14
14
  \ You can use \"gnuplot\",\"R\",or some useful graphic aplications.)\n \n
@@ -18,53 +18,54 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - lib/agri-controller/device/mch383.rb
21
+ - ChangeLog.txt
22
+ - LICENSE.txt
23
+ - agri-controller.gemspec
24
+ - gpl-2.0.txt
25
+ - lib/agri-controller.rb
26
+ - lib/agri-controller/bcc.rb
27
+ - lib/agri-controller/bit.rb
28
+ - lib/agri-controller/device.rb
29
+ - lib/agri-controller/device/dacs.rb
22
30
  - lib/agri-controller/device/kr.rb
23
31
  - lib/agri-controller/device/ma.rb
24
- - lib/agri-controller/device/dacs.rb
32
+ - lib/agri-controller/device/mch383.rb
25
33
  - lib/agri-controller/device/tr.rb
26
34
  - lib/agri-controller/device/wr1010.rb
27
- - lib/agri-controller/value_controller.rb
28
- - lib/agri-controller/multiple_pulse_timer.rb
29
35
  - lib/agri-controller/dt.rb
30
- - lib/agri-controller/bcc.rb
31
- - lib/agri-controller/gruff/thermo_gruff.rb
36
+ - lib/agri-controller/error_caption.rb
37
+ - lib/agri-controller/gruff.rb
38
+ - lib/agri-controller/gruff/base.rb
39
+ - lib/agri-controller/gruff/chdata.rb
32
40
  - lib/agri-controller/gruff/join_csv.rb
33
- - lib/agri-controller/gruff/thermo_gruff_loop.rb
34
41
  - lib/agri-controller/gruff/rename_csv.rb
35
- - lib/agri-controller/gruff/thermo_gruff_generate.rb
36
42
  - lib/agri-controller/gruff/thermo_data_each_day.rb
37
- - lib/agri-controller/gruff/base.rb
38
- - lib/agri-controller/gruff/chdata.rb
43
+ - lib/agri-controller/gruff/thermo_gruff.rb
39
44
  - lib/agri-controller/gruff/thermo_gruff2.rb
40
- - lib/agri-controller/version.rb
41
- - lib/agri-controller/setting_io.rb
42
- - lib/agri-controller/webrick_test.rb
43
- - lib/agri-controller/wet_sensor.rb
44
- - lib/agri-controller/bit.rb
45
- - lib/agri-controller/main_new.rb
46
- - lib/agri-controller/web.rb
45
+ - lib/agri-controller/gruff/thermo_gruff_generate.rb
46
+ - lib/agri-controller/gruff/thermo_gruff_loop.rb
47
+ - lib/agri-controller/housa.rb
47
48
  - lib/agri-controller/loger.rb
48
- - lib/agri-controller/main_linux.rb
49
49
  - lib/agri-controller/main.rb
50
- - lib/agri-controller/ttyUSB_watchdog.rb
51
- - lib/agri-controller/save_threads.rb
52
- - lib/agri-controller/device.rb
53
- - lib/agri-controller/gruff.rb
54
- - lib/agri-controller/error_caption.rb
50
+ - lib/agri-controller/main_linux.rb
51
+ - lib/agri-controller/main_new.rb
52
+ - lib/agri-controller/multiple_pulse_timer.rb
55
53
  - lib/agri-controller/n_dan_thermo.rb
56
- - lib/agri-controller.rb
57
- - test/ts_agri-controller.rb
58
- - test/tc_trigger.rb
59
- - test/tc_bit.rb
60
- - agri-controller.gemspec
61
- - ChangeLog.txt
62
- - LICENSE.txt
54
+ - lib/agri-controller/save_threads.rb
55
+ - lib/agri-controller/setting_io.rb
56
+ - lib/agri-controller/ttyUSB_watchdog.rb
57
+ - lib/agri-controller/value_controller.rb
58
+ - lib/agri-controller/version.rb
59
+ - lib/agri-controller/web.rb
60
+ - lib/agri-controller/webrick_test.rb
61
+ - lib/agri-controller/wet_sensor.rb
63
62
  - license.rb
64
- - gpl-2.0.txt
63
+ - test/tc_bit.rb
64
+ - test/tc_trigger.rb
65
+ - test/ts_agri-controller.rb
65
66
  homepage: http://rubygems.org/gems/agri-controller
66
67
  licenses:
67
- - GPLv2
68
+ - GPL-2.0
68
69
  metadata: {}
69
70
  post_install_message:
70
71
  rdoc_options: []
@@ -72,20 +73,19 @@ require_paths:
72
73
  - lib
73
74
  required_ruby_version: !ruby/object:Gem::Requirement
74
75
  requirements:
75
- - - '>='
76
+ - - ">="
76
77
  - !ruby/object:Gem::Version
77
78
  version: '0'
78
79
  required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - '>='
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.1.5
85
+ rubygems_version: 3.1.2
86
86
  signing_key:
87
87
  specification_version: 4
88
- summary: AgriController easily controls the greenhouse with a Personal Computer.(win,linux
89
- RS232)
88
+ summary: AgriController easily controls the greenhouse with a Personal Computer,also
89
+ Raspi.(win,linux RS232)
90
90
  test_files:
91
91
  - test/ts_agri-controller.rb