machine_setup 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -2
- data/VERSION +1 -1
- data/{setup.rb → bin/setup_analyze_dat} +2 -0
- data/bin/setup_init_dsl +27 -0
- data/examples/underleaver/underleaver.setup.param +4 -0
- data/examples/underleaver/underleaver.setup.param.de.yml +33 -2
- data/examples/underleaver/underleaver.setup.param.en.yml +31 -1
- data/lib/setup_configuration/legacy/category.rb +22 -0
- data/lib/setup_configuration/legacy/importer.rb +255 -0
- data/lib/setup_configuration/legacy/language_context.rb +39 -0
- data/lib/setup_configuration/legacy/legacy.rb +7 -0
- data/lib/setup_configuration/legacy/parameter.rb +26 -0
- data/lib/setup_configuration/legacy/templates/setup.param.erb +32 -0
- data/lib/setup_configuration/legacy/templates/setup.param.language.yml.erb +13 -0
- data/lib/setup_configuration/setup_config.rb +4 -3
- data/lib/setup_configuration/suite_generator.rb +23 -22
- data/lib/setup_configuration/templates/deutsch.lng.erb +7 -2
- data/lib/setup_configuration/templates/english.lng.erb +7 -2
- data/lib/setup_configuration/templates/logcodesetup.exp.erb +2 -1
- data/lib/setup_configuration/templates/mps3.ini.erb +13 -6
- data/lib/setup_configuration/translation.rb +4 -0
- data/lib/setup_configuration.rb +3 -1
- metadata +59 -10
data/Rakefile
CHANGED
@@ -5,13 +5,16 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "machine_setup"
|
8
|
-
gem.executables =
|
8
|
+
gem.executables = %W{setup_config_gen setup_init_dsl setup_analyze_dat}
|
9
|
+
gem.default_executable = gem.executables.first
|
9
10
|
gem.summary = %Q{Generating configuration for machine setup parameters.}
|
10
11
|
gem.description = %Q{Helps generating configuration files for machine setup parameters.}
|
11
12
|
gem.email = "robi-wan@suyu.de"
|
12
13
|
gem.homepage = "http://github.com/robi-wan/machine_setup"
|
13
14
|
gem.authors = ["robi-wan"]
|
14
|
-
gem.add_runtime_dependency "i18n", ">= 0.3.
|
15
|
+
gem.add_runtime_dependency "i18n", ">= 0.3.3"
|
16
|
+
gem.add_runtime_dependency "ini", ">= 0.1.1"
|
17
|
+
gem.add_runtime_dependency "erubis", ">= 2.6.5"
|
15
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
19
|
end
|
17
20
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/bin/setup_init_dsl
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
legacy_data_folder=ARGV[0]
|
5
|
+
machine_name=ARGV[1]
|
6
|
+
machine_abbreviation=ARGV[2]
|
7
|
+
|
8
|
+
raise RuntimeError.new("Missing argument: directory with legacy definition") if legacy_data_folder.nil?
|
9
|
+
raise RuntimeError.new("Wrong argument: directory '#{legacy_data_folder}' with legacy definition not found") unless File.directory?(legacy_data_folder)
|
10
|
+
|
11
|
+
raise RuntimeError.new("Missing argument: machine name") unless machine_name
|
12
|
+
|
13
|
+
|
14
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
15
|
+
require 'setup_configuration'
|
16
|
+
|
17
|
+
importer=SetupConfiguration::Legacy::Importer.new(legacy_data_folder, machine_name, machine_abbreviation)
|
18
|
+
importer.output
|
19
|
+
|
20
|
+
puts("#{File.basename(__FILE__)} completed.")
|
21
|
+
rescue Exception => e
|
22
|
+
#puts("Error, program will exit => #{e}!")
|
23
|
+
puts(e.message)
|
24
|
+
#puts(e.backtrace().join("\n"))
|
25
|
+
exit(1)
|
26
|
+
|
27
|
+
end
|
@@ -13,6 +13,7 @@ SetupConfiguration :underleaver, :ul do
|
|
13
13
|
|
14
14
|
category :common do
|
15
15
|
param :underleaver_config, 1
|
16
|
+
param :distance_photo_sensor_from_start, 9
|
16
17
|
param :distance_photo_sensor, 2
|
17
18
|
param :distance_blade_to_sheet_drive, 3
|
18
19
|
param :distance_sheet_drive_to_sheet_exit, 4
|
@@ -42,6 +43,9 @@ SetupConfiguration :underleaver, :ul do
|
|
42
43
|
param :factor_activation_point_roll_bracket, 23 do
|
43
44
|
depends_on :roll_bracket_active
|
44
45
|
end
|
46
|
+
|
47
|
+
param :decrease_simulated_portions, 24
|
48
|
+
param :length_correction_first_sheet_after_insert_sheet, 25
|
45
49
|
end
|
46
50
|
|
47
51
|
category :drives do
|
@@ -25,7 +25,11 @@ de:
|
|
25
25
|
|
26
26
|
distance_photo_sensor:
|
27
27
|
name: "Weg Lichtschranke bis Blattaustritt"
|
28
|
-
comment: "Abstand der Lichtschranke vom Blattaustritt."
|
28
|
+
comment: "Abstand der Lichtschranke vom Blattaustritt. [mm]"
|
29
|
+
|
30
|
+
distance_photo_sensor_from_start:
|
31
|
+
name: "Weg Bandbeginn bis Lichtschranke"
|
32
|
+
comment: "Abstand der Lichtschranke vom Bandbeginn. [mm]"
|
29
33
|
|
30
34
|
distance_blade_to_sheet_drive:
|
31
35
|
name: "Weg Schneide bis Blattantrieb"
|
@@ -135,7 +139,34 @@ de:
|
|
135
139
|
|
136
140
|
|
137
141
|
Standardm��ig wird die Rollenbremse unterhalb des unteren Teachpunktes des T�nzers aktiviert. Sollte ein h�herer Aktivierungspunkt notwendig sein, kann �ber diesen Parameter ein Prozentwert angegeben werden, um den der Aktivierungspunkt in Richtung des oberen Teachpunktes des T�nzers verschoben wird. Der Prozentwert bezieht sich auf den Abstand zwischen unteren und oberen Teachpunkt.
|
138
|
-
|
142
|
+
|
143
|
+
|
144
|
+
decrease_simulated_portions:
|
145
|
+
name: "Faktor f�r Verringerung der simulierten Portionen"
|
146
|
+
comment: |
|
147
|
+
Faktor, der die Anzahl der simulierten Portionen in der Betriebsart Simulation verringert.
|
148
|
+
Dieser Faktor wird verwendet bei der Berechnung des Abstandes zwischen zwei Portionen.
|
149
|
+
Da die Berechnung der simulierten Portionen von der eingestellten Blattl�nge und der Bandgeschwindigkeit abh�ngt,
|
150
|
+
wirkt sich der Faktor unterschiedlich aus.
|
151
|
+
|
152
|
+
|
153
|
+
Mit einem Wert von 0 wird die maximale Anzahl von Portionen simuliert.
|
154
|
+
Der eingegebene Wert wird als Zahl mit einer Nachkommastelle vom Programm verarbeitet:
|
155
|
+
aus der Eingabe 25 wird programmintern 2,5.
|
156
|
+
Eine Erh�hung des Wertes um 10 kann (in Abh�ngigkeit von Blattl�nge und Bandgeschwindigkeit)
|
157
|
+
zu einer Reduktion der simulierten Portionen zwischen 10 und 20 Prozent f�hren.
|
158
|
+
|
159
|
+
length_correction_first_sheet_after_insert_sheet:
|
160
|
+
name: "L�ngenkorrektur f�r erstes Blatt nach 'Papier einlegen' [mm]"
|
161
|
+
comment: |
|
162
|
+
Korrekturwert f�r die L�nge des ersten Blattes nach dem Papier einlegen.
|
163
|
+
Wenn die L�nge des ersten Blattes nach dem Papier einlegen um einen
|
164
|
+
konstanten Wert abweichen sollte, kann �ber diesen Parameter die fehlende L�nge
|
165
|
+
eingegeben werden - anschlie�end wird dieser Korrekturwert beim Positionieren
|
166
|
+
der Folie nach dem Papier einlegen verwendet.
|
167
|
+
|
168
|
+
Der Wert wird in Millimeter angegeben.
|
169
|
+
|
139
170
|
paper_roll_drive_selection:
|
140
171
|
name: "Bahnantrieb abgew�hlt=0/Servo=1/FU=2"
|
141
172
|
comment: &COMMON_DRIVE_CONFIG |
|
@@ -22,11 +22,17 @@ en:
|
|
22
22
|
1xx: The controller simulates all drives."
|
23
23
|
|
24
24
|
distance_photo_sensor:
|
25
|
-
name: "Distance of photo sensor"
|
25
|
+
name: "Distance of photo sensor to paper exit"
|
26
26
|
comment: "Configuration of photo sensor.\n
|
27
27
|
\n
|
28
28
|
X: Describes the distance [mm] from photo sensor to the paper exit."
|
29
29
|
|
30
|
+
distance_photo_sensor_from_start:
|
31
|
+
name: "Distance of photo sensor from start"
|
32
|
+
comment: "Configuration of photo sensor.\n
|
33
|
+
\n
|
34
|
+
X: Describes the distance [mm] to photo sensor from start of transport conveyor."
|
35
|
+
|
30
36
|
distance_blade_to_sheet_drive:
|
31
37
|
name: "Distance of blade"
|
32
38
|
comment: "Configuration of Blade\n
|
@@ -139,6 +145,30 @@ en:
|
|
139
145
|
|
140
146
|
If active, roll brake will be activated beneath lower loop position. This parameter allows to move this activation point towards the upper loop position. Movement is given in percent and relates to the distance between lower and upper loop position.
|
141
147
|
|
148
|
+
decrease_simulated_portions:
|
149
|
+
name: "Factor for reduction of simulated portions"
|
150
|
+
comment: |
|
151
|
+
This parameter configures a factor which can decrease simulated portions.
|
152
|
+
This factor is used for calculation the distance between two simulated portions.
|
153
|
+
This factor differently influences the count of simulated portions because
|
154
|
+
the calculation of simulated portions depends on sheet length and conveyor velocity.
|
155
|
+
|
156
|
+
|
157
|
+
With a value of 0 the maximum number of portions will be simulated.
|
158
|
+
The given value will be interpreted as decimal with one decimal place:
|
159
|
+
value 25 will be interpreted as 2.5.
|
160
|
+
Increasing this parameter by 10 can (depending on sheet length and conveyor velocity)
|
161
|
+
reduce the number of simulated portions between 10 and 20 percent.
|
162
|
+
|
163
|
+
length_correction_first_sheet_after_insert_sheet:
|
164
|
+
name: "Length correction for first sheet after 'Insert Paper' [mm]"
|
165
|
+
comment: |
|
166
|
+
Correction for length of first sheet after insert paper.
|
167
|
+
A constant length difference of first sheet after insert paper can be compensated with this value.
|
168
|
+
Subsequent 'insert paper' operations will use this correction value for sheet positioning.
|
169
|
+
|
170
|
+
Value is given in millimeter.
|
171
|
+
|
142
172
|
paper_roll_drive_selection:
|
143
173
|
name: "Paper roll drive - Select/Deselect"
|
144
174
|
comment: &COMMON_DRIVE_CONFIG "Unit�s Place: 'Select/Deselect drive'\n
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SetupConfiguration
|
2
|
+
|
3
|
+
module Legacy
|
4
|
+
|
5
|
+
class Category
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
attr_accessor :number
|
9
|
+
attr_accessor :name
|
10
|
+
attr_accessor :parameter
|
11
|
+
|
12
|
+
def initialize()
|
13
|
+
@parameter = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def <=>(parameter)
|
17
|
+
self.number <=> parameter.number
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
|
2
|
+
module SetupConfiguration
|
3
|
+
|
4
|
+
module Legacy
|
5
|
+
|
6
|
+
class Importer
|
7
|
+
|
8
|
+
INI_LINE_SPLIT_PATTERN=','
|
9
|
+
|
10
|
+
attr_reader :categories
|
11
|
+
|
12
|
+
def initialize(folder, name, abbreviation)
|
13
|
+
@folder=folder
|
14
|
+
@name=name
|
15
|
+
@abbreviation=abbreviation
|
16
|
+
@mps3 = ::IniFile.load( File.join(@folder, 'mps3.ini'))
|
17
|
+
@settings = SetupConfiguration::Setting.new
|
18
|
+
@categories=[]
|
19
|
+
@languages=[]
|
20
|
+
@ini_files=Hash.new { |hash, key| hash[key] = ::IniFile.load( File.join(@folder, key), :comment => ';//') }
|
21
|
+
init_settings()
|
22
|
+
init_params()
|
23
|
+
end
|
24
|
+
|
25
|
+
def output(output_path=@folder)
|
26
|
+
output_param(output_path)
|
27
|
+
@languages.each() {|lang| output_language(output_path, lang)}
|
28
|
+
end
|
29
|
+
|
30
|
+
def output_language(output_path, lang)
|
31
|
+
context = LanguageContext.new(@name, lang, self)
|
32
|
+
|
33
|
+
template=File.join(File.dirname(__FILE__), "templates", "setup.param.language.yml.erb")
|
34
|
+
input = File.read(template)
|
35
|
+
eruby = Erubis::Eruby.new(input)
|
36
|
+
|
37
|
+
File.open(File.join(output_path, context.output ), "w") do |f|
|
38
|
+
f << eruby.evaluate(context)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def output_param(output_path)
|
44
|
+
template=File.join(File.dirname(__FILE__), "templates", "setup.param.erb")
|
45
|
+
input = File.read(template)
|
46
|
+
eruby = Erubis::Eruby.new(input)
|
47
|
+
|
48
|
+
File.open(File.join(output_path, "#{@name}.#{SetupConfiguration::Translation::FILE_EXTENSION}" ), "w") do |f|
|
49
|
+
f << eruby.result(binding())
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def compute_machine_types(binary)
|
55
|
+
# 60.to_s(2).chars.to_a.reverse.each_with_index { |s,i| puts s; puts i}
|
56
|
+
result=[]
|
57
|
+
if binary.eql?(0) then
|
58
|
+
result << machine_type_by_number(binary).name
|
59
|
+
else
|
60
|
+
Fixnum.induced_from(binary).to_s(2).chars.to_a.reverse.each_with_index do |value, index|
|
61
|
+
if value.eql?("1")
|
62
|
+
result << machine_type_by_number(index+1).name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
result.join(" + ")
|
67
|
+
end
|
68
|
+
|
69
|
+
def machine_type_by_number(number)
|
70
|
+
@settings.machine_types.select() {|mt| mt.sequence_number.eql?(number)}.first
|
71
|
+
end
|
72
|
+
|
73
|
+
def init_settings()
|
74
|
+
@settings.min(Range.new(sv('BEGIN_MIN'), sv('END_MIN')))
|
75
|
+
@settings.max(Range.new(sv('BEGIN_MAX'), sv('END_MAX')))
|
76
|
+
@settings.balance_min(Range.new(sv('BEGIN_WAAG_MIN'), sv('END_WAAG_MIN')))
|
77
|
+
@settings.balance_max(Range.new(sv('BEGIN_WAAG_MAX'), sv('END_WAAG_MAX')))
|
78
|
+
|
79
|
+
#machine types
|
80
|
+
machine_types = @mps3['MASCHINENTYP']
|
81
|
+
machine_type_regexp=/BEGIN_TYP(\d\d?)/
|
82
|
+
machine_types.each do |k,v|
|
83
|
+
number=k.scan(machine_type_regexp).flatten.first.to_i
|
84
|
+
@settings.machine_type("machine_type_#{number}".to_sym, number, v.to_i)
|
85
|
+
end
|
86
|
+
|
87
|
+
@settings.machine_types.each_with_index do |mt, index|
|
88
|
+
ending=mt.range + 999
|
89
|
+
if @settings.machine_types[index + 1]
|
90
|
+
ending = @settings.machine_types[index + 1].range - 1
|
91
|
+
end
|
92
|
+
#mt.range=Range.new(mt.range, ending)
|
93
|
+
# this is really ugly
|
94
|
+
mt.instance_variable_set( :@range, Range.new(mt.range, ending))
|
95
|
+
end
|
96
|
+
|
97
|
+
# languages
|
98
|
+
lang = @mps3['SPRACHE']
|
99
|
+
lang.each() do |k,v|
|
100
|
+
if k =~ /SPRACHE\d\d?/
|
101
|
+
@languages << v
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
def setting_value(key)
|
108
|
+
minmax = @mps3['MINMAXWERTE']
|
109
|
+
minmax[key].to_i
|
110
|
+
end
|
111
|
+
alias :sv :setting_value
|
112
|
+
|
113
|
+
|
114
|
+
#todo preserve original parameter order
|
115
|
+
def init_params()
|
116
|
+
params = @mps3['PARAMANZEIGE']
|
117
|
+
params.each do |key, value|
|
118
|
+
cat_regexp = /TAB((\d\d?)([abc]))/
|
119
|
+
if key =~ cat_regexp then
|
120
|
+
unless value.empty?
|
121
|
+
cat_level=key.scan(cat_regexp).flatten[0]
|
122
|
+
cat_number=key.scan(cat_regexp).flatten[1].to_i
|
123
|
+
|
124
|
+
deps = param_dependencies(params, "#{cat_level}")
|
125
|
+
types = machine_types(params, "#{cat_level}")
|
126
|
+
|
127
|
+
cat = category_by_number(cat_number)
|
128
|
+
value.split(INI_LINE_SPLIT_PATTERN).each_with_index do |param_number, index|
|
129
|
+
|
130
|
+
#check for multiple defined parameters (in different categories)
|
131
|
+
#warn and skip
|
132
|
+
if param_by_number(param_number) then
|
133
|
+
puts("WARNING: parameter '#{ param_key(param_number)}' with number '#{param_number}' multiple defined. Duplicate found in category '#{category_name(cat_number)}' will be skipped.")
|
134
|
+
else
|
135
|
+
parameter = Parameter.new(param_number)
|
136
|
+
parameter.depends_on(deps[index])
|
137
|
+
parameter.for_machine_type(types[index].to_i)
|
138
|
+
parameter.key = param_key(param_number)
|
139
|
+
cat.parameter << parameter
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# replace parameter numbers with parameter keys
|
148
|
+
parameters.each() do |param|
|
149
|
+
p = param_by_number(param.dependency)
|
150
|
+
param.depends_on(p ? p.key : :none)
|
151
|
+
end
|
152
|
+
|
153
|
+
#get categorie names
|
154
|
+
self.categories.each do |cat|
|
155
|
+
cat.name = category_name(cat.number)
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
# TODO extract into module
|
161
|
+
def category_name_raw(lang, cat_number)
|
162
|
+
ini= @ini_files["#{lang.downcase}.lng"]
|
163
|
+
ini[lang.downcase]["TAB#{cat_number}"]
|
164
|
+
end
|
165
|
+
|
166
|
+
# TODO extract into module
|
167
|
+
# Get the name of the category with the given number. Name is escaped and ready to use as a symbol
|
168
|
+
# Language defaults to 'deutsch'.
|
169
|
+
def category_name(number)
|
170
|
+
key=category_name_raw('deutsch', number)
|
171
|
+
# ensure uniqueness of category names so that they do not clash with parameter names
|
172
|
+
# otherwise comments for parameters get lost (categories have no comments)
|
173
|
+
"cat_#{escape(key)}"
|
174
|
+
end
|
175
|
+
|
176
|
+
def escape(key)
|
177
|
+
key=key.gsub(/[^a-z���A-Z���0-9\s]/, '')
|
178
|
+
key=key.gsub('�', 'ae')
|
179
|
+
key=key.gsub('�', 'oe')
|
180
|
+
key=key.gsub('�', 'ue')
|
181
|
+
key=key.gsub('�', 'Ae')
|
182
|
+
key=key.gsub('�', 'Oe')
|
183
|
+
key=key.gsub('�', 'Ue')
|
184
|
+
key=key.gsub('�', 'ss')
|
185
|
+
key=key.split(' ').collect(){|splitter| splitter.downcase }
|
186
|
+
#remove leading numbers
|
187
|
+
#TODO this just works if first element is a number - extend for all leading elements...
|
188
|
+
if key.first.to_i.to_s.eql?(key.first) then
|
189
|
+
key.shift
|
190
|
+
end
|
191
|
+
|
192
|
+
key.join('_').to_sym
|
193
|
+
end
|
194
|
+
|
195
|
+
def param_name(lang, param_number)
|
196
|
+
filename = "#{lang.downcase}.lng"
|
197
|
+
key_ini= @ini_files[filename]
|
198
|
+
key_ini[lang.downcase]["PARAM#{param_number}"]
|
199
|
+
end
|
200
|
+
|
201
|
+
def param_key(param_number)
|
202
|
+
key=param_name('deutsch', param_number)
|
203
|
+
#delete unwanted characters
|
204
|
+
escape(key)
|
205
|
+
end
|
206
|
+
|
207
|
+
def parameter_description(lang, param_number)
|
208
|
+
#determine number in description file name
|
209
|
+
file_number=1
|
210
|
+
SetupConfiguration.description_ranges().each_with_index() do |range, index|
|
211
|
+
file_number= index + 1 if range.include?(param_number.to_i)
|
212
|
+
end
|
213
|
+
|
214
|
+
filename = lang.downcase << file_number.to_s << ".lng"
|
215
|
+
key_ini= @ini_files[filename]
|
216
|
+
desc=key_ini[lang.upcase]["HILFEPARAM#{param_number}"]
|
217
|
+
escape_param_description(desc)
|
218
|
+
end
|
219
|
+
|
220
|
+
def escape_param_description(description)
|
221
|
+
description unless description.eql?("not used")
|
222
|
+
end
|
223
|
+
|
224
|
+
def parameters
|
225
|
+
@categories.collect(){|cat| cat.parameter }.flatten
|
226
|
+
end
|
227
|
+
|
228
|
+
def param_by_number(number)
|
229
|
+
self.parameters().select(){|p| p.number.eql?(number)}.first
|
230
|
+
end
|
231
|
+
|
232
|
+
def category_by_number(number)
|
233
|
+
cat = self.categories.select(){|cat| cat.number.eql?(number)}.first
|
234
|
+
unless cat then
|
235
|
+
cat = Category.new
|
236
|
+
cat.number = number
|
237
|
+
self.categories << cat
|
238
|
+
end
|
239
|
+
cat
|
240
|
+
end
|
241
|
+
|
242
|
+
# key = 2CF#{level}
|
243
|
+
def param_dependencies(params, level)
|
244
|
+
params["2CF#{level}"].split(INI_LINE_SPLIT_PATTERN)
|
245
|
+
end
|
246
|
+
|
247
|
+
# key = 1CF#{level}
|
248
|
+
def machine_types(params, level)
|
249
|
+
params["1CF#{level}"].split(INI_LINE_SPLIT_PATTERN)
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module SetupConfiguration
|
2
|
+
|
3
|
+
module Legacy
|
4
|
+
|
5
|
+
class LanguageContext
|
6
|
+
|
7
|
+
attr_reader :lang_abbr
|
8
|
+
attr_reader :output
|
9
|
+
|
10
|
+
def initialize(name, lang, helper)
|
11
|
+
@lang=lang
|
12
|
+
@helper=helper
|
13
|
+
@lang_abbr= SetupConfiguration::Translation.language_abbreviation(lang)
|
14
|
+
@output = SetupConfiguration::Translation.translation_files(name).select(){|file| file.include?(@lang_abbr.to_s)}.first
|
15
|
+
end
|
16
|
+
|
17
|
+
def category_name(cat)
|
18
|
+
@helper.category_name_raw(@lang, cat)
|
19
|
+
end
|
20
|
+
|
21
|
+
def parameter_name(param)
|
22
|
+
@helper.param_name(@lang, param)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def parameter_description(param)
|
27
|
+
#TODO escape ($$ into \n)
|
28
|
+
@helper.parameter_description(@lang, param.to_i)
|
29
|
+
end
|
30
|
+
|
31
|
+
def categories
|
32
|
+
@helper.categories.sort
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
require 'inifile'
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/parameter')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/category')
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + '/language_context')
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + '/importer')
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SetupConfiguration
|
2
|
+
|
3
|
+
module Legacy
|
4
|
+
|
5
|
+
class Parameter < SetupConfiguration::Parameter
|
6
|
+
def initialize(number)
|
7
|
+
@number=number
|
8
|
+
end
|
9
|
+
|
10
|
+
def extended?
|
11
|
+
dep? || type?
|
12
|
+
end
|
13
|
+
|
14
|
+
def dep?
|
15
|
+
@dependency != :none
|
16
|
+
end
|
17
|
+
|
18
|
+
def type?
|
19
|
+
@machine_type != 0
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
SetupConfiguration :<%= @name.to_sym %>, :<%= @abbreviation.to_sym %> do
|
2
|
+
|
3
|
+
setting do
|
4
|
+
min <%= @settings.minimum %>
|
5
|
+
max <%= @settings.maximum %>
|
6
|
+
balance_min <%= @settings.balance_minimum %>
|
7
|
+
balance_max <%= @settings.balance_maximum %>
|
8
|
+
<% for type in @settings.machine_types %>
|
9
|
+
machine_type :<%= type.name.to_sym %>, <%= type.sequence_number %>, <%= type.range %>
|
10
|
+
<% end %>
|
11
|
+
end
|
12
|
+
|
13
|
+
<% for cat in @categories.sort %>
|
14
|
+
category :<%= cat.name %> do
|
15
|
+
<% for param in cat.parameter %>
|
16
|
+
param :<%= param.key %>, <%= param.number %><% if param.extended? %> do
|
17
|
+
<% if param.dep? %>
|
18
|
+
depends_on :<%= param.dependency %>
|
19
|
+
<% end %>
|
20
|
+
<% if param.type? %>
|
21
|
+
for_machine_type <%= compute_machine_types(param.machine_type) %>
|
22
|
+
<% end %>
|
23
|
+
end
|
24
|
+
<% else %>
|
25
|
+
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
end
|
29
|
+
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= lang_abbr %>:
|
2
|
+
|
3
|
+
<% for cat in categories %>
|
4
|
+
<%= cat.name %>:
|
5
|
+
name: "<%= category_name(cat.number) %>"
|
6
|
+
|
7
|
+
<% for param in cat.parameter %>
|
8
|
+
<%= param.key %>:
|
9
|
+
name: "<%= parameter_name(param.number) %>"
|
10
|
+
comment: "<%= parameter_description(param.number) %>"
|
11
|
+
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -50,7 +50,8 @@ class SetupConfiguration::Suite
|
|
50
50
|
|
51
51
|
# Gets all known parameters.
|
52
52
|
def parameters()
|
53
|
-
|
53
|
+
# cache parameters so sorting is necessary only once - this saves a lot of time...
|
54
|
+
@parameters ||= categories.values.flatten.sort
|
54
55
|
end
|
55
56
|
|
56
57
|
#
|
@@ -88,8 +89,8 @@ class SetupConfiguration::Suite
|
|
88
89
|
|
89
90
|
keys=[]
|
90
91
|
numbers=[]
|
91
|
-
#valid parameter numbers
|
92
|
-
valid_param_numbers=
|
92
|
+
# slicer contains parameter with number 0... therefore valid parameter numbers starts at 0
|
93
|
+
valid_param_numbers=SetupConfiguration.parameter_range()
|
93
94
|
|
94
95
|
self.parameters().each() do |p|
|
95
96
|
|
@@ -35,14 +35,16 @@ module SetupConfiguration::Generator
|
|
35
35
|
@lang=lang
|
36
36
|
@parameter_range=range
|
37
37
|
@output=output
|
38
|
+
@translator = SetupConfiguration::Translation::Translator.new()
|
38
39
|
end
|
39
40
|
|
40
41
|
def lang_name
|
41
42
|
SetupConfiguration::Translation.language_name(lang)
|
42
43
|
end
|
43
44
|
|
45
|
+
|
44
46
|
def cat_name(key)
|
45
|
-
name, desc
|
47
|
+
name, desc=@translator.translate(key, @lang)
|
46
48
|
name
|
47
49
|
end
|
48
50
|
|
@@ -61,7 +63,7 @@ module SetupConfiguration::Generator
|
|
61
63
|
p=self.suite.find_param_by_number(number)
|
62
64
|
if p
|
63
65
|
key=p.key
|
64
|
-
translation =
|
66
|
+
translation = @translator.translate(key, @lang)
|
65
67
|
if extractor
|
66
68
|
extractor.call( *translation )
|
67
69
|
else
|
@@ -85,7 +87,6 @@ module SetupConfiguration::Generator
|
|
85
87
|
|
86
88
|
class MPSTemplateBinding < TemplateBinding
|
87
89
|
|
88
|
-
|
89
90
|
def languages
|
90
91
|
SetupConfiguration::Translation.language_names.values
|
91
92
|
end
|
@@ -104,7 +105,7 @@ module SetupConfiguration::Generator
|
|
104
105
|
end
|
105
106
|
#TODO compute value for max_number_parameters_per_tab of value maximum_numbers_per_category
|
106
107
|
max_number_parameters_per_tab=50
|
107
|
-
[depends, machine_type, number].collect(){ |arr| (arr%(max_number_parameters_per_tab))
|
108
|
+
[depends, machine_type, number].collect(){ |arr| (arr%(max_number_parameters_per_tab)).collect(){|a| prepare(a)}}
|
108
109
|
end
|
109
110
|
|
110
111
|
:private
|
@@ -194,37 +195,37 @@ end
|
|
194
195
|
|
195
196
|
|
196
197
|
class SetupConfiguration::SetupCodeBinding < SetupConfiguration::Generator::TemplateBinding
|
197
|
-
|
198
|
+
|
198
199
|
def initialize
|
199
200
|
super
|
200
201
|
end
|
201
|
-
|
202
|
+
|
202
203
|
def parameters
|
203
204
|
suite.parameters
|
204
205
|
end
|
205
|
-
|
206
|
+
|
206
207
|
#
|
207
208
|
# Offset for setup parameter numbers. This offset is added to a parameter number when evaluated in controller.
|
208
209
|
#
|
209
210
|
def parameter_offset
|
210
211
|
1300
|
211
212
|
end
|
212
|
-
|
213
|
+
|
213
214
|
def key(symbol)
|
214
215
|
s=symbol.to_s
|
215
216
|
delimiter='_'
|
216
217
|
s.split(delimiter).collect(){|splitter| splitter.capitalize}.join(delimiter).ljust(longest_key_length)
|
217
218
|
end
|
218
|
-
|
219
|
+
|
219
220
|
:private
|
220
221
|
|
221
222
|
def longest_key_length
|
222
223
|
# find the length of the longest word
|
223
224
|
unless @longest
|
224
|
-
|
225
|
+
longest = parameters.inject(0) do |memo, param|
|
225
226
|
memo >= param.key.to_s.length ? memo : param.key.to_s.length
|
226
|
-
|
227
|
-
|
227
|
+
end
|
228
|
+
@longest=longest + 5
|
228
229
|
end
|
229
230
|
@longest
|
230
231
|
end
|
@@ -236,9 +237,9 @@ class SetupConfiguration::SetupCodeGenerator
|
|
236
237
|
setup_code=SetupConfiguration::SetupCodeBinding.new
|
237
238
|
setup_code.output="LOGCODE#{suite.name.to_s.upcase}SETUP.EXP"
|
238
239
|
setup_code.suite=suite
|
239
|
-
|
240
|
+
|
240
241
|
if template then
|
241
|
-
rhtml =
|
242
|
+
rhtml = Erubis::Eruby.new( template )
|
242
243
|
|
243
244
|
File.open(File.join(output_path, setup_code.output), "w") do |f|
|
244
245
|
f << rhtml.result(setup_code.get_binding)
|
@@ -246,11 +247,12 @@ class SetupConfiguration::SetupCodeGenerator
|
|
246
247
|
else
|
247
248
|
puts "WARNING: No template found. Generation of #{setup_code.output} aborted."
|
248
249
|
end
|
249
|
-
|
250
|
-
|
250
|
+
|
251
|
+
|
251
252
|
end
|
252
|
-
|
253
|
+
|
253
254
|
:private
|
255
|
+
|
254
256
|
def template
|
255
257
|
template=File.join(File.dirname(__FILE__), "templates", "logcodesetup.exp.erb")
|
256
258
|
if File.file?(template)
|
@@ -259,7 +261,7 @@ class SetupConfiguration::SetupCodeGenerator
|
|
259
261
|
puts "WARNING: Template file #{template} expected but not found"
|
260
262
|
end
|
261
263
|
end
|
262
|
-
|
264
|
+
|
263
265
|
end
|
264
266
|
|
265
267
|
|
@@ -283,7 +285,7 @@ class SetupConfiguration::SuiteGenerator
|
|
283
285
|
|
284
286
|
description_bindings().each() do |bind|
|
285
287
|
bind.suite=self.suite
|
286
|
-
rhtml =
|
288
|
+
rhtml = Erubis::Eruby.new(description_template)
|
287
289
|
|
288
290
|
File.open(File.join(output_path, bind.output), "w") do |f|
|
289
291
|
f << rhtml.result(bind.get_binding)
|
@@ -298,7 +300,7 @@ class SetupConfiguration::SuiteGenerator
|
|
298
300
|
bind.suite=self.suite
|
299
301
|
template = parameter_template(bind.lang_name())
|
300
302
|
if template then
|
301
|
-
rhtml =
|
303
|
+
rhtml = Erubis::Eruby.new(template)
|
302
304
|
|
303
305
|
File.open(File.join(output_path, bind.output), "w") do |f|
|
304
306
|
f << rhtml.result(bind.get_binding)
|
@@ -312,7 +314,7 @@ class SetupConfiguration::SuiteGenerator
|
|
312
314
|
bind.suite=self.suite
|
313
315
|
mps_template=mps_template()
|
314
316
|
if mps_template then
|
315
|
-
rhtml =
|
317
|
+
rhtml = Erubis::Eruby.new(mps_template)
|
316
318
|
|
317
319
|
File.open(File.join(output_path, bind.output), "w") do |f|
|
318
320
|
f << rhtml.result(bind.get_binding)
|
@@ -322,7 +324,6 @@ class SetupConfiguration::SuiteGenerator
|
|
322
324
|
end
|
323
325
|
|
324
326
|
SetupConfiguration::SetupCodeGenerator.new.generate(self.suite, output_path)
|
325
|
-
|
326
327
|
end
|
327
328
|
end
|
328
329
|
|
@@ -1,8 +1,13 @@
|
|
1
1
|
[<%= lang_name %>]
|
2
2
|
//Parametertexte
|
3
|
-
<% parameter_range.each do |number| %>
|
3
|
+
<% parameter_range.each do |number| %>
|
4
|
+
PARAM<%= number%>=<%= name(number)%>
|
5
|
+
<% end %>
|
6
|
+
|
4
7
|
//Texte Tabelle/Registerkarte
|
5
|
-
<% categories.each_with_index do |category, index| %>
|
8
|
+
<% categories.each_with_index do |category, index| %>
|
9
|
+
TAB<%= index%>=<%= cat_name(category)%>
|
10
|
+
<% end %>
|
6
11
|
|
7
12
|
//�berschriften Spalten
|
8
13
|
COL0=Parameter
|
@@ -1,8 +1,13 @@
|
|
1
1
|
[<%= lang_name %>]
|
2
2
|
//Parametertexte
|
3
|
-
<% parameter_range.each do |number| %>
|
3
|
+
<% parameter_range.each do |number| %>
|
4
|
+
PARAM<%= number%>=<%= name(number)%>
|
5
|
+
<% end %>
|
6
|
+
|
4
7
|
//Texte Tabelle/Registerkarte
|
5
|
-
<% categories.each_with_index do |category, index| %>
|
8
|
+
<% categories.each_with_index do |category, index| %>
|
9
|
+
TAB<%= index%>=<%= cat_name(category)%>
|
10
|
+
<% end %>
|
6
11
|
|
7
12
|
//�berschriften Spalten
|
8
13
|
COL0=Parameter
|
@@ -7,7 +7,8 @@ TYPE LogCode<%= suite.name.to_s.capitalize %>Setup :
|
|
7
7
|
Edit instead the machine setup parameter description. *)
|
8
8
|
|
9
9
|
<% parameters.each do | parameter | %>
|
10
|
-
SUP_<%= suite.abbreviation.to_s.upcase %>_<%= key(parameter.key) %>:= <%= parameter.number + parameter_offset %><% unless parameters.last.eql?(parameter) then %><%= "," %><% end
|
10
|
+
SUP_<%= suite.abbreviation.to_s.upcase %>_<%= key(parameter.key) %>:= <%= parameter.number + parameter_offset %><% unless parameters.last.eql?(parameter) then %><%= "," %><% end %>
|
11
|
+
<% end %>
|
11
12
|
|
12
13
|
);
|
13
14
|
END_TYPE
|
@@ -4,8 +4,10 @@ DRUCK=0
|
|
4
4
|
DATKONVERT=0
|
5
5
|
|
6
6
|
[SPRACHE]
|
7
|
-
AKTUELL=0
|
8
|
-
|
7
|
+
AKTUELL=0
|
8
|
+
<% languages.each_with_index do | language_name, index| %>
|
9
|
+
SPRACHE<%= index %>=<%= language_name.upcase %>
|
10
|
+
<% end %>
|
9
11
|
|
10
12
|
[MINMAXWERTE]
|
11
13
|
BEGIN_MIN=<%= settings.minimum.first %>
|
@@ -17,12 +19,16 @@ END_WAAG_MIN=<%= settings.balance_minimum.last %>
|
|
17
19
|
BEGIN_WAAG_MAX=<%= settings.balance_maximum.first %>
|
18
20
|
END_WAAG_MAX=<%= settings.balance_maximum.last %>
|
19
21
|
|
20
|
-
[MASCHINENTYP]
|
21
|
-
|
22
|
+
[MASCHINENTYP]
|
23
|
+
<% settings.machine_types.each do |machine_type| %>
|
24
|
+
BEGIN_TYP<%= machine_type.sequence_number %>=<%= machine_type.range.first %>
|
25
|
+
<% end %>
|
22
26
|
|
23
27
|
;(0..16)
|
24
28
|
;generate param names as comment
|
25
|
-
[PARAMANZEIGE]
|
29
|
+
[PARAMANZEIGE]
|
30
|
+
<% categories.each_with_index do |category, index| %>
|
31
|
+
<% dependencies, machine_types, parameters = param_infos(category) %>
|
26
32
|
2CF<%= index%>a=<%= dependencies[0] %>
|
27
33
|
1CF<%= index%>a=<%= machine_types[0] %>
|
28
34
|
TAB<%= index%>a=<%= parameters[0] %>
|
@@ -31,4 +37,5 @@ TAB<%= index%>a=<%= parameters[0] %>
|
|
31
37
|
TAB<%= index%>b=<%= parameters[1] %>
|
32
38
|
2CF<%= index%>c=<%= dependencies[2] %>
|
33
39
|
1CF<%= index%>c=<%= machine_types[2] %>
|
34
|
-
TAB<%= index%>c=<%= parameters[2]
|
40
|
+
TAB<%= index%>c=<%= parameters[2] %>
|
41
|
+
<% end %>
|
data/lib/setup_configuration.rb
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
require 'pp'
|
17
17
|
require 'singleton'
|
18
|
-
require '
|
18
|
+
require 'erubis'
|
19
19
|
require 'fileutils'
|
20
20
|
require 'i18n'
|
21
21
|
require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/array')
|
@@ -23,3 +23,5 @@ require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/paramete
|
|
23
23
|
require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/setup_config')
|
24
24
|
require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/suite_generator')
|
25
25
|
require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/translation')
|
26
|
+
|
27
|
+
require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/legacy/legacy')
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: machine_setup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- robi-wan
|
@@ -9,23 +14,57 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-03-29 00:00:00 +02:00
|
13
18
|
default_executable: setup_config_gen
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: i18n
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 3
|
30
|
+
- 3
|
31
|
+
version: 0.3.3
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: ini
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 1
|
44
|
+
- 1
|
45
|
+
version: 0.1.1
|
17
46
|
type: :runtime
|
18
|
-
|
19
|
-
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: erubis
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
20
52
|
requirements:
|
21
53
|
- - ">="
|
22
54
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
55
|
+
segments:
|
56
|
+
- 2
|
57
|
+
- 6
|
58
|
+
- 5
|
59
|
+
version: 2.6.5
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
25
62
|
description: Helps generating configuration files for machine setup parameters.
|
26
63
|
email: robi-wan@suyu.de
|
27
64
|
executables:
|
28
65
|
- setup_config_gen
|
66
|
+
- setup_init_dsl
|
67
|
+
- setup_analyze_dat
|
29
68
|
extensions: []
|
30
69
|
|
31
70
|
extra_rdoc_files:
|
@@ -39,12 +78,21 @@ files:
|
|
39
78
|
- Rakefile
|
40
79
|
- TODO
|
41
80
|
- VERSION
|
81
|
+
- bin/setup_analyze_dat
|
42
82
|
- bin/setup_config_gen
|
83
|
+
- bin/setup_init_dsl
|
43
84
|
- examples/underleaver/underleaver.setup.param
|
44
85
|
- examples/underleaver/underleaver.setup.param.de.yml
|
45
86
|
- examples/underleaver/underleaver.setup.param.en.yml
|
46
87
|
- lib/setup_configuration.rb
|
47
88
|
- lib/setup_configuration/array.rb
|
89
|
+
- lib/setup_configuration/legacy/category.rb
|
90
|
+
- lib/setup_configuration/legacy/importer.rb
|
91
|
+
- lib/setup_configuration/legacy/language_context.rb
|
92
|
+
- lib/setup_configuration/legacy/legacy.rb
|
93
|
+
- lib/setup_configuration/legacy/parameter.rb
|
94
|
+
- lib/setup_configuration/legacy/templates/setup.param.erb
|
95
|
+
- lib/setup_configuration/legacy/templates/setup.param.language.yml.erb
|
48
96
|
- lib/setup_configuration/parameter_machinetype_bridge.rb
|
49
97
|
- lib/setup_configuration/setup_config.rb
|
50
98
|
- lib/setup_configuration/suite_generator.rb
|
@@ -53,7 +101,6 @@ files:
|
|
53
101
|
- lib/setup_configuration/templates/logcodesetup.exp.erb
|
54
102
|
- lib/setup_configuration/templates/mps3.ini.erb
|
55
103
|
- lib/setup_configuration/translation.rb
|
56
|
-
- setup.rb
|
57
104
|
- test/setup_configuration/machine_type_test.rb
|
58
105
|
- test/setup_configuration/parameter_test.rb
|
59
106
|
- test/setup_configuration/setup_configuration_test.rb
|
@@ -71,18 +118,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
118
|
requirements:
|
72
119
|
- - ">="
|
73
120
|
- !ruby/object:Gem::Version
|
121
|
+
segments:
|
122
|
+
- 0
|
74
123
|
version: "0"
|
75
|
-
version:
|
76
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
125
|
requirements:
|
78
126
|
- - ">="
|
79
127
|
- !ruby/object:Gem::Version
|
128
|
+
segments:
|
129
|
+
- 0
|
80
130
|
version: "0"
|
81
|
-
version:
|
82
131
|
requirements: []
|
83
132
|
|
84
133
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.3.
|
134
|
+
rubygems_version: 1.3.6
|
86
135
|
signing_key:
|
87
136
|
specification_version: 3
|
88
137
|
summary: Generating configuration for machine setup parameters.
|