machine_setup 0.0.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.
@@ -0,0 +1,218 @@
1
+ en:
2
+
3
+ #Tabs aka categories
4
+ common:
5
+ name: "Common"
6
+
7
+ drives:
8
+ name: "Drives Underleaver"
9
+
10
+ #parameter
11
+ underleaver_config:
12
+ name: "Underleaver virtual=1 / real=0"
13
+ comment: "Unit�s Place:\n
14
+ x0: Controller with real drives and covers\n
15
+ x1: Controller simulates all selected drives and covers\n
16
+ \n
17
+ Ten�s Place:\n
18
+ 0x: CanBus on\n
19
+ 1x: CanBus off\n
20
+ \n
21
+ Hundred�s Place:\n
22
+ 1xx: The controller simulates all drives."
23
+
24
+ distance_photo_sensor:
25
+ name: "Distance of photo sensor"
26
+ comment: "Configuration of photo sensor.\n
27
+ \n
28
+ X: Describes the distance [mm] from photo sensor to the paper exit."
29
+
30
+ distance_blade_to_sheet_drive:
31
+ name: "Distance of blade"
32
+ comment: "Configuration of Blade\n
33
+ \n
34
+ X: Describes the distance [mm] from blade to the paper feed drive."
35
+
36
+ distance_sheet_drive_to_sheet_exit:
37
+ name: "Distance of sheet drive"
38
+ comment: "Configuration of foil drive\n
39
+ \n
40
+ X: Describes the distance [mm] from the paper feed drive to paper exit."
41
+
42
+ time_for_cutting_unit:
43
+ name: "Time of cutting unit"
44
+ comment: "Configuration of cutting unit.\n
45
+ \n
46
+ X: Describes the time [ms] to lift up the cutting unit."
47
+
48
+ paper_jam_detection_active:
49
+ name: "Paper jam monitoring"
50
+ comment: "Configuration of paper jam sensor\n
51
+ \n
52
+ 0: Deselect the paper jam monitoring.\n
53
+ 1: Select the paper jam monitoring."
54
+
55
+ paper_jam_detection_signal_length:
56
+ name: "Paper jam signal duration"
57
+ comment: "Configuration of paper jam sensor\n
58
+ \n
59
+ X: Describes the signal duration [ms] that defines a paper jam.\n
60
+ 0: The signal duration will be defined by an internal value.\n
61
+ \n
62
+ Value is given in milliseconds."
63
+
64
+ paper_jam_detection_check_time:
65
+ name: "Paper jam check time after 'last' product"
66
+ comment: "Configuration of paper jam sensor\n
67
+ \n
68
+ Paper jam checks for the current product are executed at the beginning of the next product.\n
69
+ But when there is no product following the current product this parameter allows you to define a timer.\n
70
+ Started after finishing the current product after the expiration of this time the paper jam checks are executed.\n
71
+ A value of 3000 means that 3 seconds after the last product a paper jam check is executed.\n
72
+ \n
73
+ The value is given in milliseconds."
74
+
75
+ ext_enabling_following_unit:
76
+ name: "External behavior to downstream unit"
77
+ comment: "Configuration of external behavior (downstream)\n
78
+ \n
79
+ Select/Deselect the enable signal from the downstream unit.\n
80
+ \n
81
+ 0: The underleaver works standalone or has no downstream unit.\n
82
+ 1: The underleaver has a downstream unit and react to enable signal."
83
+
84
+ ext_enabling_following_unit_method:
85
+ name: "Configuration of enable signal"
86
+ comment: "Configuration of external behavior (downstream)\n
87
+ \n
88
+ 0: Impulse - Switch the enabling signal at any impulse (on->off oder off->on)\n
89
+ 1: Negative continuously signal - enables by 0V\n
90
+ 2: Positiv continuously signal - enables by 12V"
91
+
92
+ ext_enabling_following_unit_delay:
93
+ name: "Configuration of enable delay"
94
+ comment: "Configuration of external behavior (downstream)\n
95
+ \n
96
+ X: Describes the time [ms] to wait for reacting to the enabling signal. Not till then the underleaver continuous conveyance."
97
+
98
+ ext_enabling_previous_unit:
99
+ name: "External behavior to upstream unit"
100
+ comment: "Configuration of external behavior (upstream)\n
101
+ \n
102
+ 0: Impulse - Switch the enabling signal at any impulse (on->off oder off->on)\n
103
+ 1: Negative continuously signal - enables by 0V\n
104
+ 2: Positiv continuously signal - enables by 12V"
105
+
106
+ paper_roll_drive_config:
107
+ name: "Paper roll drive - Select/Deselect"
108
+ comment: &COMMON_DRIVE_CONFIG "Unit�s Place: 'Select/Deselect drive'\n
109
+ \n
110
+ XXX0: Drive doesn't exist.\n
111
+ XXX1: Drive exists as a servo.\n
112
+ XXX2: Drive exists as a frequency converter.\n
113
+ \n
114
+ Ten�s and Hundred�s Place: 'Typ of Drive'\n
115
+ \n
116
+ X00X = NORD_MOTOR_037\n
117
+ X01X = NORD_MOTOR_075\n
118
+ X02X = LENZE_063C32\n
119
+ X03X = LENZE_047C22\n
120
+ X04X = LENZE_063C22\n
121
+ X05X = INTERROLL_TM111_037_2_081\n
122
+ X06X = INTERROLL_TM082_012_2_056\n
123
+ X07X = LENZE_063C22_GEBER\n
124
+ X08X = LENZE_063C22_POSI\n
125
+ X17X = INTERROLL_111_2P_037_133V\n
126
+ X18X = INTERROLL_111_2P_037_133V_GEBER\n
127
+ X19X = INTERROLL_111_2P_037_133V_POSI\n
128
+ X20X = INTERROLL_111_2P_037_133V_GEBER_AUF_C400\n
129
+ X21X = HARMONIC_DRIVE_FHA_11C_D200_GEBER\n
130
+ \n
131
+ Thousend�s Place:\n
132
+ \n
133
+ 0XXX = without PTC\n
134
+ 1XXX = with PTC"
135
+
136
+ paper_roll_drive_distance_revolution:
137
+ name: "Paper roll drive - Distance per revolution [mm]"
138
+ comment: &COMMON_DISTANCE_REVOLUTION "X= Distance X per revolution [in mm]"
139
+
140
+ paper_roll_drive_gear_in:
141
+ name: "Paper roll drive - Gear IN"
142
+ comment: &COMMON_GEAR_IN "Number of teeth motor sided."
143
+
144
+ paper_roll_drive_gear_out:
145
+ name: "Paper roll drive - Gear OUT"
146
+ comment: &COMMON_GEAR_OUT "Number of teeth - drive shaft sided."
147
+
148
+ blade_drive_config:
149
+ name: "Blade drive - Select/Deselect"
150
+ comment: *COMMON_DRIVE_CONFIG
151
+
152
+ blade_drive_diameter:
153
+ name: "Blade drive - Diameter [mm]"
154
+ comment: "X= Diameter X of blade drive [in mm]"
155
+
156
+ blade_drive_gear_in:
157
+ name: "Blade drive - Gear IN"
158
+ comment: *COMMON_GEAR_IN
159
+
160
+ blade_drive_gear_out:
161
+ name: "Blade drive - Gear OUT"
162
+ comment: *COMMON_GEAR_OUT
163
+
164
+ paper_feed_drive_config:
165
+ name: "Paper feed drive - Select/Deselect"
166
+ comment: *COMMON_DRIVE_CONFIG
167
+
168
+ paper_feed_drive_distance_revolution:
169
+ name: "Paper feed drive - Distance per revolution [mm]"
170
+ comment: *COMMON_DISTANCE_REVOLUTION
171
+
172
+ paper_feed_drive_gear_in:
173
+ name: "Paper feed drive - Gear IN"
174
+ comment: *COMMON_GEAR_IN
175
+
176
+ paper_feed_drive_gear_out:
177
+ name: "Paper feed drive - Gear OUT"
178
+ comment: *COMMON_GEAR_OUT
179
+
180
+ transport_drive_config:
181
+ name: "Transport drive - Select/Deselect"
182
+ comment: *COMMON_DRIVE_CONFIG
183
+
184
+ transport_drive_distance_revolution:
185
+ name: "Transport drive - Distance per revolution [mm]"
186
+ comment: *COMMON_DISTANCE_REVOLUTION
187
+
188
+ transport_drive_gear_in:
189
+ name: "Transport drive - Gear IN"
190
+ comment: *COMMON_GEAR_IN
191
+
192
+ transport_drive_gear_out:
193
+ name: "Transport drive - Gear OUT"
194
+ comment: *COMMON_GEAR_OUT
195
+
196
+ transport_drive_belt_length:
197
+ name: "Transport drive - Length of belt [mm]"
198
+ comment: "Specify the length of the transport conveyor [in mm]"
199
+
200
+ infeed_drive_config:
201
+ name: "Infeed drive - Select/Deselect"
202
+ comment: *COMMON_DRIVE_CONFIG
203
+
204
+ infeed_drive_distance_revolution:
205
+ name: "Infeed drive - Distance per revolution [mm]"
206
+ comment: *COMMON_DISTANCE_REVOLUTION
207
+
208
+ infeed_drive_gear_in:
209
+ name: "Infeed drive - Gear IN"
210
+ comment: *COMMON_GEAR_IN
211
+
212
+ infeed_drive_gear_out:
213
+ name: "Infeed drive - Gear OUT"
214
+ comment: *COMMON_GEAR_OUT
215
+
216
+ infeed_drive_belt_length:
217
+ name: "Infeed drive - Length of belt [mm]"
218
+ comment: "Specify the length of the Infeed conveyor [in mm]"
@@ -0,0 +1,20 @@
1
+ module SetupConfiguration
2
+ end
3
+
4
+ def SetupConfiguration(name, &block)
5
+ suite=SetupConfiguration::Suite.instance
6
+ suite.name=name
7
+ suite.instance_eval(&block)
8
+ suite.validate_params()
9
+ rescue
10
+ raise
11
+ end
12
+
13
+ require 'pp'
14
+ require 'singleton'
15
+ require 'erb'
16
+ require 'fileutils'
17
+ require 'i18n'
18
+ require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/setup_config')
19
+ require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/suite_generator')
20
+ require File.expand_path(File.dirname(__FILE__) + '/setup_configuration/translation')
@@ -0,0 +1,183 @@
1
+ module SetupConfiguration
2
+
3
+ def self.description_ranges()
4
+ [(0..199), (200..599), (600..1299)]
5
+ end
6
+
7
+ def self.parameter_range()
8
+ Range.new(description_ranges().first().first(), description_ranges().last().last())
9
+ end
10
+
11
+ end
12
+
13
+ class SetupConfiguration::Suite
14
+ include Singleton
15
+
16
+ attr_accessor :categories
17
+ attr_accessor :settings
18
+ attr_accessor :name
19
+
20
+ def initialize
21
+ self.categories= Hash.new { |hash, key| hash[key] = [] }
22
+ self.settings= SetupConfiguration::Setting.new()
23
+ end
24
+
25
+ def category(category, &category_params)
26
+ if category_params then
27
+ # puts "executes category in Suite: #{category}"
28
+
29
+ #this code calls instance_eval and delivers the context object
30
+ parameter_factory = SetupConfiguration::ParameterFactory.new()
31
+ parameter_factory.instance_eval(&category_params)
32
+ categories[category] << parameter_factory.params()
33
+
34
+ # this .instance_eval call returns the last value of the last executed code (an array from method param in Parameters)
35
+ #categories[category] << SetupConfiguration::Parameters.new().instance_eval(&category_params)
36
+
37
+ # flatten is needed: Parameters#param returns an array which is inserted in an array...
38
+ categories[category].flatten!
39
+ else
40
+ puts "WARNING: Empty category '#{category}' will be ignored. "
41
+ end
42
+ end
43
+
44
+ def setting(&setting_params)
45
+ settings.instance_eval(&setting_params) if setting_params
46
+ end
47
+
48
+ # Gets all known parameters.
49
+ def parameters()
50
+ categories.values.flatten
51
+ end
52
+
53
+ #
54
+ # Finds a Parameter with the given key.
55
+ # If there is no such parameter the method returns nil.
56
+ #
57
+ def find_param(key)
58
+ find_param_by_key(key)
59
+ end
60
+
61
+ #
62
+ # Finds a Parameter with the given key.
63
+ # If there is no such parameter the method returns nil.
64
+ #
65
+ def find_param_by_key(key)
66
+ self.parameters().select(){|p| p.key.eql?(key)}.first
67
+ end
68
+
69
+ #
70
+ # Finds a Parameter with the given number.
71
+ # If there is no such parameter the method returns nil.
72
+ #
73
+ def find_param_by_number(number)
74
+ self.parameters().select(){|p| p.number.eql?(number)}.first
75
+ end
76
+
77
+ #
78
+ # Validates the uniqueness of parameter keys and numbers.
79
+ #
80
+ def validate_params()
81
+
82
+ keys=[]
83
+ numbers=[]
84
+ #valid parameter numbers start at 1
85
+ valid_param_numbers=Range.new(SetupConfiguration.parameter_range().first()+1, SetupConfiguration.parameter_range().last)
86
+
87
+ self.parameters().each() do |p|
88
+
89
+ throw RuntimeError.new("ERROR: parameter number '#{p.number}' not supported. Number must be in range #{valid_param_numbers}") unless valid_param_numbers.member?(p.number)
90
+
91
+ if keys.include? p.key
92
+ # todo error handling
93
+ throw RuntimeError.new("ERROR: parameter key '#{p.key}' defined more than once")
94
+ else
95
+ keys << p.key
96
+ end
97
+
98
+ if numbers.include? p.number
99
+ # todo error handling
100
+ throw RuntimeError.new("ERROR: parameter number '#{p.number}' defined more than once")
101
+ else
102
+ numbers << p.number
103
+ end
104
+ end
105
+ end
106
+
107
+ end
108
+
109
+
110
+ class SetupConfiguration::Setting
111
+
112
+ attr_reader :minimum
113
+ attr_reader :maximum
114
+ attr_reader :balance_minimum
115
+ attr_reader :balance_maximum
116
+
117
+ def initialize
118
+ @minimum=(0..0)
119
+ @maximum=(0..0)
120
+ @balance_minimum=(0..0)
121
+ @balance_maximum=(0..0)
122
+ end
123
+
124
+ def min(range)
125
+ @minimum=range
126
+ end
127
+
128
+ def max(range)
129
+ @maximum=range
130
+ end
131
+
132
+ def balance_min(range)
133
+ @balance_minimum=range
134
+ end
135
+
136
+ def balance_max(range)
137
+ @balance_maximum=range
138
+ end
139
+ end
140
+
141
+ class SetupConfiguration::ParameterFactory
142
+
143
+ attr_accessor :params
144
+
145
+ def initialize
146
+ self.params= []
147
+ end
148
+
149
+ def param(parameter, number, &parameter_def)
150
+ # puts "executed param in Parameters: #{parameter}"
151
+ # evaluate given block in Parameter context and return new parameter
152
+ p = SetupConfiguration::Parameter.new(parameter)
153
+ p.number=(number)
154
+ p.instance_eval(&parameter_def) if parameter_def
155
+ params << p
156
+ end
157
+
158
+ end
159
+
160
+ class SetupConfiguration::Parameter
161
+
162
+ attr_accessor :key
163
+ attr_accessor :number
164
+ attr_reader :dependency
165
+ attr_reader :machine_type
166
+
167
+ def initialize(name)
168
+ # depends upon no other parameter
169
+ @dependency=:none
170
+ # valid on all machines
171
+ @machine_type=0
172
+ @key= name
173
+ end
174
+
175
+ def depends_on(dependency)
176
+ @dependency=dependency
177
+ end
178
+
179
+ def for_machine_type(machine_type)
180
+ @machine_type=machine_type
181
+ end
182
+
183
+ end
@@ -0,0 +1,252 @@
1
+ module SetupConfiguration::Generator
2
+ @output_path=""
3
+
4
+ def output_path
5
+ @output_path
6
+ end
7
+
8
+ def output_path=(out)
9
+ @output_path=out
10
+ end
11
+
12
+ class TemplateBinding
13
+
14
+ attr_accessor :suite
15
+ attr_accessor :output
16
+
17
+ def categories
18
+ suite.categories.keys()
19
+ end
20
+
21
+ # Support templating of member data.
22
+ def get_binding
23
+ binding
24
+ end
25
+
26
+ end
27
+
28
+ class ParameterTemplateBinding < TemplateBinding
29
+ attr_accessor :lang
30
+ attr_accessor :parameter_range
31
+
32
+ def initialize(lang, range, output)
33
+ @lang=lang
34
+ @parameter_range=range
35
+ @output=output
36
+ end
37
+
38
+ def lang_name
39
+ SetupConfiguration::Translation.language_name(lang)
40
+ end
41
+
42
+ def cat_name(key)
43
+ name, desc=SetupConfiguration::Translation::Translator.new().translate(key, @lang)
44
+ name
45
+ end
46
+
47
+ def name(number)
48
+ p_name= translate(number) { |name, desc| name }
49
+ p_name.empty? ? "placeholder for mps3.exe" : p_name
50
+ end
51
+
52
+ def description(number)
53
+ translate(number) do |name, desc|
54
+ escape(desc)
55
+ end
56
+ end
57
+
58
+ def translate(number, &extractor)
59
+ #todo use suite as singleton!
60
+ p=self.suite.find_param_by_number(number)
61
+ if p
62
+ key=p.key
63
+ translation = SetupConfiguration::Translation::Translator.new().translate(key, @lang)
64
+ if extractor
65
+ extractor.call( translation)
66
+ else
67
+ translation
68
+ end
69
+ else
70
+ ""
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ #
77
+ # Zeilenumbr�che werden mit '��' dargestellt
78
+ #
79
+ def escape(message)
80
+ message.gsub(/\n\s?/, '��')
81
+ end
82
+
83
+ end
84
+
85
+ class MPSTemplateBinding < TemplateBinding
86
+
87
+
88
+ def languages
89
+ SetupConfiguration::Translation.language_names.values
90
+ end
91
+
92
+ def settings
93
+ self.suite.settings
94
+ end
95
+
96
+ def param_infos(category_key)
97
+ parameters=suite.categories[category_key]
98
+ depends, machine_type, number=[], [], []
99
+ parameters.each() do |param|
100
+ machine_type << param.machine_type
101
+ number << param.number
102
+ depends << depends_on(param.dependency)
103
+ end
104
+ [prepare(depends), prepare(machine_type), prepare(number) ]
105
+ end
106
+
107
+ :private
108
+
109
+ def prepare(array)
110
+ array.join(',')
111
+ end
112
+
113
+ def depends_on(key)
114
+
115
+ if :none.eql?(key) then
116
+ -1
117
+ else
118
+ param=suite.find_param(key)
119
+ if param
120
+ param.number
121
+ else
122
+ puts "ERROR: parameter with key '#{key}' not found."
123
+ # depends on no other parameter
124
+ -1
125
+ end
126
+ end
127
+ end
128
+
129
+ end
130
+
131
+ # [:de, "deutsch", (0..199), "deutsch1.lng"],
132
+ # [:de, "deutsch", (200..599), "deutsch2.lng"],
133
+ # [:de, "deutsch", (600..1299), "deutsch3.lng"],
134
+ # [:en, "english", (0..199), "english1.lng"],
135
+ # [:en, "english", (200..599), "english2.lng"],
136
+ # [:en, "english", (600..1299), "english3.lng"],
137
+ def description_bindings()
138
+ SetupConfiguration::Translation.languages().collect() do |lang|
139
+ SetupConfiguration.description_ranges().collect() do |range|
140
+ # constructs the output file names
141
+ out= "#{SetupConfiguration::Translation.language_name(lang)}#{SetupConfiguration.description_ranges().index(range)+1}.lng"
142
+ ParameterTemplateBinding.new(lang, range, out)
143
+ end
144
+ end.flatten()
145
+ end
146
+
147
+ def description_template
148
+ %q{
149
+ [<%= lang_name.upcase %>]
150
+ <% parameter_range.each do |number| %>
151
+ HILFEPARAM<%= number %>=<%= description(number) %>
152
+ <% end %>
153
+ }.gsub(/^\s*/, '')
154
+ end
155
+
156
+ def parameter_bindings()
157
+ SetupConfiguration::Translation.languages().collect() do |lang|
158
+ # constructs the output file names
159
+ out= "#{SetupConfiguration::Translation.language_name(lang)}.lng"
160
+ ParameterTemplateBinding.new(lang, SetupConfiguration.parameter_range(), out)
161
+ end
162
+ end
163
+
164
+ def parameter_template(lang)
165
+ template=File.join(File.dirname(__FILE__), "templates", "#{lang.to_s}.lng.erb")
166
+ if File.file?(template)
167
+ File.read(template)
168
+ else
169
+ puts "WARNING: Template file #{template} expected but not found"
170
+ end
171
+ end
172
+
173
+ def mps_template()
174
+ template=File.join(File.dirname(__FILE__), "templates", "mps3.ini.erb")
175
+ if File.file?(template)
176
+ File.read(template)
177
+ else
178
+ puts "WARNING: Template file #{template} expected but not found"
179
+ end
180
+ end
181
+
182
+ def mps_binding()
183
+ mps=MPSTemplateBinding.new
184
+ mps.output="mps3.ini"
185
+ mps
186
+ end
187
+
188
+
189
+ end
190
+
191
+
192
+ class SetupConfiguration::SuiteGenerator
193
+ include SetupConfiguration::Generator
194
+
195
+ attr_accessor :suite
196
+ attr_accessor :do_not_run
197
+
198
+ def initialize
199
+ self.do_not_run = false
200
+ self.suite = SetupConfiguration::Suite.instance
201
+ end
202
+
203
+ def self.do_not_run
204
+ self.do_not_run=true
205
+ end
206
+
207
+ def generate
208
+ return "no output" if self.do_not_run
209
+
210
+ description_bindings().each() do |bind|
211
+ bind.suite=self.suite
212
+ rhtml = ERB.new(description_template, nil, "<>")
213
+
214
+ File.open(File.join(output_path, bind.output), "w") do |f|
215
+ f << rhtml.result(bind.get_binding)
216
+ end
217
+ end
218
+
219
+ # extras:
220
+ # -every PARAMETER key needs a value!
221
+ # -use Windows line terminators CRLF - \r\n
222
+ # - do not use [] - output is an INI-file
223
+ parameter_bindings().each() do |bind|
224
+ bind.suite=self.suite
225
+ template = parameter_template(bind.lang_name())
226
+ if template then
227
+ rhtml = ERB.new( template, nil, "<>")
228
+
229
+ File.open(File.join(output_path, bind.output), "w") do |f|
230
+ f << rhtml.result(bind.get_binding)
231
+ end
232
+ else
233
+ puts "WARNING: No template found. Generation of #{bind.output} aborted."
234
+ end
235
+ end
236
+
237
+ bind=mps_binding()
238
+ bind.suite=self.suite
239
+ mps_template=mps_template()
240
+ if mps_template then
241
+ rhtml = ERB.new( mps_template, nil, "<>")
242
+
243
+ File.open(File.join(output_path, bind.output), "w") do |f|
244
+ f << rhtml.result(bind.get_binding)
245
+ end
246
+ else
247
+ puts "WARNING: No template found. Generation of #{bind.output} aborted."
248
+ end
249
+
250
+ end
251
+ end
252
+