evolis-premium_sdk 1.0.0

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,114 @@
1
+ require 'evolis/premium_sdk/sdk_base'
2
+
3
+ module Evolis
4
+ module PremiumSdk
5
+ class Setting < SdkBase
6
+
7
+ # Initializes the class and sets SDK host and port
8
+ #
9
+ # @param host [String] host or IP for SDK
10
+ # @param port [String, Fixnum] port for SDK
11
+ def initialize(host, port)
12
+ super(host, port, 'SETTING')
13
+ end
14
+
15
+ # Starts a configuration session
16
+ #
17
+ # @param device [String] printer name
18
+ # @return [String] session id
19
+ def begin(device)
20
+ self.active_session = call_rpc('Begin', {
21
+ device: device
22
+ })
23
+ end
24
+
25
+ # Exports parameters
26
+ #
27
+ # @param format [String] format to export settings, `printer`, `text` or `xml`
28
+ # @return [true] on success with format `printer`
29
+ # @return [Array] of setting=value pairs on format `text`
30
+ # @return [String] base64 encoded xml
31
+ # @raise [Error::NoActiveSessionError] if no active session
32
+ # @raise [Error::InvalidExportFormatError] when format is invalid
33
+ def export(format = 'printer')
34
+ raise Error::NoActiveSessionError.new unless active_session?
35
+ raise Error::InvalidExportFormatError.new format unless %w[printer text xml].include?(format.downcase)
36
+
37
+ resp = call_rpc('Export', {
38
+ session: self.active_session,
39
+ format: format
40
+ })
41
+
42
+ return resp.split(';') if format == 'text'
43
+ return resp
44
+ end
45
+
46
+ # Imports parameters
47
+ #
48
+ # @param format [String] format to import settings, `printer`, `default` or `xml`
49
+ # @param data [nil, String] base64 encoded xml on format `xml`
50
+ # @return [true] on successful import
51
+ # @raise [Error::NoActiveSessionError] if no active session
52
+ # @raise [Error::InvalidImportFormatError] when format is invalid
53
+ # @raise [Error::Base64FormatError] on format `xml` and invalid base64 data
54
+ def import(format = 'printer', data = nil)
55
+ raise Error::NoActiveSessionError.new unless active_session?
56
+ raise Error::InvalidImportFormatError.new format unless %w[printer default xml].include?(format.downcase)
57
+ raise Error::Base64FormatError.new data if format == 'xml'
58
+
59
+ params = {
60
+ session: self.active_session,
61
+ format: format
62
+ }
63
+ params[:data] = data if format == 'xml'
64
+
65
+ call_rpc('Import', params)
66
+ end
67
+
68
+ # Gets the value of a parameter
69
+ #
70
+ # @param key [String] setting to read
71
+ # @return [String] value of setting
72
+ # @raise [Error::NoActiveSessionError] if no active session
73
+ # @raise [Error::InvalidPrintSettingError] on invalid key
74
+ def get(key)
75
+ raise Error::NoActiveSessionError.new unless active_session?
76
+ raise Error::InvalidPrintSettingError.new key unless valid_settings?(key, true)
77
+
78
+ call_rpc('Get', {
79
+ session: self.active_session,
80
+ data: key
81
+ })
82
+ end
83
+
84
+ # Edits the value of a parameter
85
+ #
86
+ # @param key [String] setting to set
87
+ # @param value [String] value for setting
88
+ # @return [true] if set successful
89
+ # @raise [Error::NoActiveSessionError] if no active session
90
+ # @raise [Error::InvalidPrintSettingError] if key=value pair does not validate
91
+ def set(key, value)
92
+ raise Error::NoActiveSessionError.new unless active_session?
93
+ raise Error::InvalidPrintSettingError.new key unless valid_settings?("#{key}=#{value}")
94
+
95
+ call_rpc('Set', {
96
+ session: self.active_session,
97
+ data: "#{key}=#{value}"
98
+ })
99
+ end
100
+
101
+ # Ends the session
102
+ #
103
+ # @return [true] if ended session
104
+ # @raise [Error::NoActiveSessionError] if no active session
105
+ def end
106
+ raise Error::NoActiveSessionError.new unless active_session?
107
+
108
+ call_rpc('End', {
109
+ session: self.active_session
110
+ })
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,384 @@
1
+ require 'evolis/premium_sdk/sdk_base'
2
+
3
+ module Evolis
4
+ module PremiumSdk
5
+ class Supervision < SdkBase
6
+
7
+ # Initializes the class and sets SDK host and port
8
+ #
9
+ # @param host [String] host or IP for SDK
10
+ # @param port [String, Fixnum] port for SDK
11
+ def initialize(host, port)
12
+ super(host, port, 'SUPERVISION')
13
+ end
14
+
15
+ # List all subscribed devices
16
+ #
17
+ # @param type_of_device [String] type of printer to list
18
+ # @param level [Fixnum] state level to list, printername, major and minor (0, 1, 2). Level 2 lists all states.
19
+ # @return [Array] list of printers and states
20
+ # @raise [Error::InvalidStateLevelError] if level not valid
21
+ def list(type_of_device, level = 2)
22
+ raise Error::InvalidStateLevelError.new level unless (0..2).cover?(level)
23
+
24
+ call_rpc('List', {
25
+ device: type_of_device,
26
+ level: String(level)
27
+ }).split(';')
28
+ end
29
+
30
+ # Subscribes a new device to the notification service
31
+ #
32
+ # @param device [String] printer name
33
+ # @return [true] on successful add
34
+ def add_device(device)
35
+ call_rpc('AddDevice', {
36
+ device: device
37
+ })
38
+ end
39
+
40
+ # Unsubscribes a new device to the notification service
41
+ #
42
+ # @param device [String] printer name
43
+ # @return [true] on successful removal
44
+ def remove_device(device)
45
+ call_rpc('RemoveDevice', {
46
+ device: device
47
+ })
48
+ end
49
+
50
+ # Requests the state of a device
51
+ #
52
+ # @param device [String] printer name
53
+ # @return [Array] major and minor state in array
54
+ def get_state(device)
55
+ call_rpc('GetState', {
56
+ device: device
57
+ }).split(',')
58
+ end
59
+
60
+ # Returns the notification of an unexpected event, as well as the list of actions for a device
61
+ #
62
+ # @param device [String] printer name
63
+ # @return [Array] minor state of printer, with actions if available
64
+ def get_event(device)
65
+ resp = call_rpc('GetEvent', {
66
+ device: device
67
+ })
68
+
69
+ if resp.include?(':')
70
+ event, actions = resp.split(':')
71
+ actions = actions.include?(',') ? actions.split(',') : [actions]
72
+ return event, actions
73
+ else
74
+ return [resp]
75
+ end
76
+ end
77
+
78
+ # Executes an action when an unexpected event is notified on a device during printing
79
+ #
80
+ # @param device [String] printer name
81
+ # @param event [String] minor state of printer
82
+ # @param action [String] action to apply to minor state
83
+ # @return [true] if action successful
84
+ # @raise [Error::InvalidEventError] if event is invalid
85
+ # @raise [Error::InvalidActionError] if action is invalid
86
+ def set_event(device, event, action)
87
+ raise Error::InvalidEventError.new event unless validate_event?(event.upcase)
88
+ raise Error::InvalidActionError.new action unless %w[CANCEL OK RETRY].include?(action.upcase)
89
+
90
+ call_rpc('SetEvent', {
91
+ action: "#{event}:#{action}",
92
+ device: device
93
+ })
94
+ end
95
+
96
+ # @return [Hash] list all possible minor states with grouping
97
+ def list_states
98
+ return {
99
+ ERROR: ERROR_EVENTS,
100
+ WARNING: WARNING_EVENTS,
101
+ READY: READY_EVENTS,
102
+ OFF: OFF_EVENTS
103
+ }
104
+ end
105
+
106
+ # @return [Array] of descriptions for all minor state
107
+ # @raise [Error::InvalidEventError] if no minor state (event) is not found
108
+ def print_event(event)
109
+ list_states.each do |status, events|
110
+ return events[event.to_sym] if events.has_key?(event.to_sym)
111
+ end
112
+
113
+ raise Error::InvalidEventError.new event
114
+ end
115
+
116
+ # @return [true, false] true if event exist, false if not
117
+ def validate_event?(event)
118
+ return ERROR_EVENTS.merge(WARNING_EVENTS).has_key?(event.to_sym)
119
+ end
120
+
121
+ # All error events with description
122
+ ERROR_EVENTS = {
123
+ ERR_BLANK_TRACK: [
124
+ 'Magnetic encoding failed',
125
+ 'Encoding fails on this card, please check the card position in the feeder.'
126
+ ],
127
+ ERR_COVER_OPEN: [
128
+ 'Cover open error',
129
+ 'The cover was opened during the printing cycle. Close the cover and click on resume.'
130
+ ],
131
+ ERR_HEAD_TEMP: [
132
+ 'Too high temperature',
133
+ 'Print head temperature too high - wait until it cools down.'
134
+ ],
135
+ ERR_HOPPER_FULL: [
136
+ 'Output Hopper Full',
137
+ 'Please remove all the printed cards from the output hopper to resume printing.'
138
+ ],
139
+ ERR_MAGNETIC_DATA: [
140
+ 'Magnetic encoding failed',
141
+ 'Invalid data format.'
142
+ ],
143
+ ERR_MECHANICAL: [
144
+ 'Mechanical error',
145
+ 'A mechanical error has occurred.'
146
+ ],
147
+ ERR_READ_MAGNETIC: [
148
+ 'Magnetic encoding failed',
149
+ 'Magnetic track reading failed.'
150
+ ],
151
+ ERR_REJECT_BOX_FULL: [
152
+ 'Reject Box Full',
153
+ 'Please remove all the cards from the reject hopper to resume printing.'
154
+ ],
155
+ ERR_RIBBON_ERROR: [
156
+ 'Ribbon problem',
157
+ 'The ribbon is cut or stuck to the card.'
158
+ ],
159
+ ERR_WRITE_MAGNETIC: [
160
+ 'Magnetic encoding failed',
161
+ 'Read-after-Write failure.'
162
+ ],
163
+ 'FEEDER_EMPTY (ERR_FEEDER_ERROR)': [
164
+ 'Card feed problem',
165
+ 'Please check cards, position in the card feeder and gauge adjustment.'
166
+ ],
167
+ INF_WRONG_ZONE_EXPIRED: [
168
+ 'Ribbon not valid',
169
+ 'Compatibility problem between ribbon and printouts credit limit reached. Please contact your reseller.'
170
+ ],
171
+ 'RIBBON_ENDED (ERR)': [
172
+ 'Ribbon end',
173
+ 'Ribbon end, please replace by a new one.'
174
+ ],
175
+ 'LAMINATE_END (ERR)': [
176
+ 'Film end',
177
+ 'Film end. Please replace the film.'
178
+ ],
179
+ ERR_LAMINATE: [
180
+ 'Film problem',
181
+ 'Film problem. The film is cut or stuck to the card.'
182
+ ],
183
+ ERR_LAMI_MECHANICAL: [
184
+ 'Mechanical error',
185
+ 'A mechanical error has occurred in the lamination module.'
186
+ ],
187
+ ERR_LAMI_TEMPERATURE: [
188
+ 'Temperature error',
189
+ 'The lamination module encountered a temperature error.'
190
+ ],
191
+ ERR_LAMI_COVER_OPEN: [
192
+ 'Door open during lamination',
193
+ 'The lamination module door got opened during the lamination process. Please close it and retry.'
194
+ ]
195
+ }
196
+
197
+ # All warning events with description
198
+ WARNING_EVENTS = {
199
+ INF_RIBBON_LOW: [
200
+ 'Ribbon close to the end',
201
+ 'Ribbon close to the end, please proceed with replenishment.'
202
+ ],
203
+ INF_FEEDER_NEAR_EMPTY: [
204
+ 'Feeder almost empty',
205
+ 'The card feeder is almost empty, please refill.'
206
+ ],
207
+ BUSY: [
208
+ 'Printer busy',
209
+ 'You cannot print while the printer is busy. Please wait or click on "Cancel".'
210
+ ],
211
+ CFG_FLIP: [
212
+ 'Single-sided Printer',
213
+ 'Your single-sided printer cannot print your dual- sided design.'
214
+ ],
215
+ CFG_MAGNETIC: [
216
+ 'Magnetic coding option not installed',
217
+ 'To continue printing without magnetic coding click on resume.'
218
+ ],
219
+ CFG_EXTENDED_RESOLUTION: [
220
+ 'Incompatible parameter',
221
+ 'This resolution parameter is not compatible with this printer / ribbon.'
222
+ ],
223
+ DEF_CARD_ON_EJECT: [
224
+ 'Remove card',
225
+ 'Remove the card from the manual feeder.'
226
+ ],
227
+ DEF_COOLING: [
228
+ 'Cooling in progress',
229
+ 'Printer cooling in progress.'
230
+ ],
231
+ DEF_COVER_OPEN: [
232
+ 'Cover open',
233
+ 'Close your printer cover.'
234
+ ],
235
+ DEF_HOPPER_FULL: [
236
+ 'Output Hopper Full',
237
+ 'Please remove all the printed cards from the output hopper to resume printing.'
238
+ ],
239
+ DEF_NO_RIBBON: [
240
+ 'No ribbon',
241
+ 'Replace the ribbon.'
242
+ ],
243
+ DEF_PRINTER_LOCKED: [
244
+ 'Communication with the printer is locked',
245
+ 'Contact your dealer'
246
+ ],
247
+ DEF_UNSUPPORTED_RIBBON: [
248
+ 'Ribbon incompatible with this printer model',
249
+ 'The ribbon inserted cannot work with this printer model.'
250
+ ],
251
+ DEF_WAIT_CARD: [
252
+ 'Waiting for a card insertion',
253
+ 'Please insert your card manually.'
254
+ ],
255
+ ERR_BAD_RIBBON: [
256
+ 'Ribbon installed is incompatible with settings',
257
+ 'The ribbon installed does not correspond to the manuallly defined settings. Printing cannot take place.'
258
+ ],
259
+ 'FEEDER_EMPTY (DEF)': [
260
+ 'Card feed problem',
261
+ 'Please check cards, position in the card feeder and gauge adjustment.'
262
+ ],
263
+ INF_CLEANING_ADVANCED: [
264
+ 'Advanced cleaning required',
265
+ 'Printer advanced cleaning is required.'
266
+ ],
267
+ INF_CLEANING_LAST_OUTWARRANTY: [
268
+ 'Regular cleaning mandatory',
269
+ 'Click on "Cancel" and proceed with cleaning immediately. Would you continue, this will void the print head warranty.'
270
+ ],
271
+ INF_CLEANING_REQUIRED: [
272
+ 'Regular cleaning mandatory - No card issuance allowed by your Administrator',
273
+ 'Click on "Cancel" and proceed with cleaning immediately.'
274
+ ],
275
+ 'INF_UNKNOWN_RIBBON (1)': [
276
+ 'Ribbon not identified',
277
+ 'Ribbon identification impossible. Please proceed with Manual settings.'
278
+ ],
279
+ 'INF_UNKNOWN_RIBBON (2)': [
280
+ 'Ribbon not identified',
281
+ 'Ribbon identification impossible. Please proceed with Manual settings.'
282
+ ],
283
+ INF_WRONG_ZONE_ALERT: [
284
+ 'Ribbon not valid',
285
+ 'Compatibility problem between ribbon and printer. Less than 50 printouts remaining. Please contact your reseller.'
286
+ ],
287
+ INF_WRONG_ZONE_RIBBON: [
288
+ 'Ribbon not valid',
289
+ 'Compatibility problem between ribbon and printer. Please contact your reseller.'
290
+ ],
291
+ 'RIBBON_ENDED (DEF)': [
292
+ 'Ribbon end',
293
+ 'Ribbon end, please replace by a new one.'
294
+ ],
295
+ DEF_NO_LAMINATE: [
296
+ 'No film',
297
+ 'No film in lamination module. Please replace the film.'
298
+ ],
299
+ INF_LAMINATE_UNKNOWN: [
300
+ 'Film not identified',
301
+ 'Unknown film. Please contact your reseller.'
302
+ ],
303
+ INF_LAMINATE_LOW: [
304
+ 'Film close to the end',
305
+ 'Film close to the end. Please arrange for replacement.'
306
+ ],
307
+ 'LAMINATE_END (DEF)': [
308
+ 'Film end',
309
+ 'Film end. Please replace the film.'
310
+ ],
311
+ DEF_LAMINATE_UNSUPPORTED: [
312
+ 'Incompatible film',
313
+ 'Film incompatible with lamination module. Please contact your reseller.'
314
+ ],
315
+ DEF_LAMI_COVER_OPEN: [
316
+ 'Door open',
317
+ 'Lamination module door open. Close the lamination module door.'
318
+ ],
319
+ INF_LAMI_TEMP_NOT_READY: [
320
+ 'Adjusting temperature',
321
+ 'Lamination module temperature adjustment in progress. Please wait...'
322
+ ],
323
+ DEF_LAMI_HOPPER_FULL: [
324
+ 'Output jammed',
325
+ 'The lamination output is jammed. Please remove the card(s) and retry.'
326
+ ]
327
+ }
328
+
329
+ # All ready events with description
330
+ READY_EVENTS = {
331
+ INF_CLEANING: [
332
+ 'Regular cleaning required'
333
+ ],
334
+ 'INF_CLEANING (INF_CLEAN_2ND_PASS)': [
335
+ 'Insert your adhesive cleaning card',
336
+ 'Please insert your sticky cleaning card. "Cancel" if you want to proceed with printing.'
337
+ ],
338
+ INF_CLEANING_RUNNING: [
339
+ 'Cleaning in progress'
340
+ ],
341
+ INF_ENCODING_RUNNING: [
342
+ 'Encoding in progress'
343
+ ],
344
+ INF_PRINTING_RUNNING: [
345
+ 'Printing in progress'
346
+ ],
347
+ INF_LAMINATING_RUNNING: [
348
+ 'Lamination in progress'
349
+ ],
350
+ INF_LAMI_CLEANING_RUNNING: [
351
+ 'Lamination module cleaning in progress'
352
+ ],
353
+ INF_LAMI_UPDATING_FIRMWARE: [
354
+ 'Lamination module firmware update in progress'
355
+ ],
356
+ INF_SLEEP_MODE: [
357
+ 'Printer in Standby mode'
358
+ ],
359
+ INF_UPDATING_FIRMWARE: [
360
+ 'Firmware update in progress'
361
+ ],
362
+ NOT_FLIP_ACT: [
363
+ 'Single-sided Printer'
364
+ ],
365
+ PRINTER_READY: [
366
+ 'Printer ready'
367
+ ]
368
+ }
369
+
370
+ # All off events with description
371
+ OFF_EVENTS = {
372
+ PRINTER_NOT_SUPERVISED: [
373
+ 'Not supervised by Evolis Print Center'
374
+ ],
375
+ PRINTER_OFFLINE: [
376
+ 'Printer offline'
377
+ ],
378
+ PRINTER_STATUS_DISABLED: [
379
+ 'Status disabled - Printer on-line'
380
+ ]
381
+ }
382
+ end
383
+ end
384
+ end