nera 0.2.3 → 0.3.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.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.3.1
2
+ * 1 major enhancement:
3
+ * A new API function is added.
4
+ * 2 bug fixes:
5
+
6
+ == 0.3.0
7
+ * 1 major enhancement:
8
+ * When creating a new parameter set, the parameter values which previously selected are set by default.
9
+ * 2 bug fixes:
10
+
1
11
  == 0.2.3
2
12
  * 1 major enhancement:
3
13
  * 2 bug fixes:
data/lib/nera/nera_cui.rb CHANGED
@@ -146,11 +146,12 @@ HEADER
146
146
  when "return to simulator layer"
147
147
  return :simulator_layer
148
148
  when "create a new parameter set"
149
- plist = plc.list_of_parameters
149
+ plist = plc.list_of_parameters( @parameter_id)
150
150
  new_param_hash = Dialog::set_multiple_values( plist, "Input the new parameter set")
151
151
  f = plc.create_a_new_parameter_set( new_param_hash)
152
152
  if f
153
153
  Dialog::message("A new parameter is successfully added to the table.")
154
+ @parameter_id = f
154
155
  else
155
156
  Dialog::message("This parameter already exists in the database.")
156
157
  end
@@ -63,8 +63,34 @@ module NERA
63
63
  return pstr.split(',').first.to_i
64
64
  end
65
65
 
66
- def list_of_parameters
67
- return @sim_class::Parameters.dup
66
+ def find_ids_by_parameter_hash( param_hash)
67
+ found_ids = []
68
+ @param_records.list_all.each do |rec|
69
+ matched = true
70
+ param_hash.each_pair do |key,value|
71
+ unless rec[key] == value
72
+ matched = false
73
+ break
74
+ end
75
+ end
76
+ if matched
77
+ found_ids << rec[:id]
78
+ end
79
+ end
80
+ found_ids = nil unless found_ids.size > 0
81
+ return found_ids
82
+ end
83
+
84
+ def list_of_parameters( param_id = nil)
85
+ param_list = []
86
+ @sim_class::Parameters.each do |elem| param_list << elem.dup end
87
+ if param_id
88
+ found = @param_records.list_all.find do |rec| rec[:id] == param_id end
89
+ if found # load parameters
90
+ param_list.each do |param| param[2] = found[ param[0] ] end
91
+ end
92
+ end
93
+ return param_list
68
94
  end
69
95
 
70
96
  def path_to_param_layer
data/lib/nera.rb CHANGED
@@ -22,5 +22,5 @@ require 'nera_simulator_records'
22
22
  require 'nera_remote_connector'
23
23
 
24
24
  module NERA
25
- VERSION = '0.2.3'
25
+ VERSION = '0.3.1'
26
26
  end
@@ -78,6 +78,15 @@ class TC_NERA_PARAM_LAYER_CONTROLLER < Test::Unit::TestCase
78
78
  assert_equal( 2, @plc.get_id_from_csv_string( list[1]) )
79
79
  assert_equal( 3, @plc.get_id_from_csv_string( list[2]) )
80
80
  end
81
+
82
+ def test_find_ids_by_parameter_hash
83
+ add_three
84
+ h = {:L => 96, :K => 0.03, :tmax => 3}
85
+ assert_equal( [3], @plc.find_ids_by_parameter_hash(h))
86
+ f = @plc.create_a_new_parameter_set( {:L => 96, :K => 0.03, :tmax => 4} )
87
+ assert_equal( [3,4], @plc.find_ids_by_parameter_hash( {:L => 96}))
88
+ assert_nil( @plc.find_ids_by_parameter_hash( {:L => 999}))
89
+ end
81
90
 
82
91
  def test_list_of_parameters
83
92
  p1 = @plc.list_of_parameters
@@ -86,6 +95,18 @@ class TC_NERA_PARAM_LAYER_CONTROLLER < Test::Unit::TestCase
86
95
  [:tmax, Integer, 512]
87
96
  ]
88
97
  assert_equal( p2, p1)
98
+
99
+ add_three
100
+ p3 = @plc.list_of_parameters(2)
101
+ p4 = [ [:L, Integer, 64],
102
+ [:K, Float, 0.02],
103
+ [:tmax, Integer, 2]
104
+ ]
105
+ assert_equal( p4, p3)
106
+
107
+ p5 = @plc.list_of_parameters(5)
108
+ pp p5
109
+ assert_equal( p2, p5)
89
110
  end
90
111
 
91
112
  def test_path_to_param_layer
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yohsuke Murase
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-07 00:00:00 +09:00
12
+ date: 2009-10-09 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency