atrea_control 1.3.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,269 @@
1
+ ---
2
+ de:
3
+ mainTitle: Ihr Spezialist für Lüftung mit Wärmerückgewinnung
4
+ save: Speichern
5
+ cancel: Abbrechen
6
+ copy: Kopieren
7
+ refresh: Überschreiben
8
+ change: Übernehmen
9
+ pleaseWait: Bitte warten
10
+ backToHome: Zurück zur Startseite
11
+ mainPage: Startseite
12
+ serviceMenu: Service Menü
13
+ activeFrom: Aktiv
14
+ hours: Analog
15
+ minutes: Minuten
16
+ record: Eintrag
17
+ allowed: Ermöglicht
18
+ netSetup: Netzeinstellungen
19
+ getFromDHCP: DHCP Einstellung
20
+ useNextValues: Folgende Einstellungen verwenden
21
+ addressIP: IP Addresse
22
+ subnetMask: Subnet Maske
23
+ defaultGW: Gateway
24
+ serverDNS: DNS Server
25
+ FTPsetup: FTP Server Passwort
26
+ passwordOld: 'Original Passwort '
27
+ passwordNew: Neues Passwort
28
+ passwordConfirm: Password bestätigen
29
+ airCond: Lüftungsgerät
30
+ airCondSetup: Geräte Einstellungen
31
+ temperature: Temperatur
32
+ tempSetup: Temperatur Einstellungen
33
+ notInDemo: Demoversion wird nicht unterstützt
34
+ thisTimeExist: Zeitvorgabe existiert bereits
35
+ serviceSetup: Service Einstellungen
36
+ activeAlarms: Aktive Alarme
37
+ alarmHistory: Alarm Historie
38
+ unitStarted: Anlauf
39
+ active: Aktiv
40
+ noAlarmDefined: Kein Alarm definiert
41
+ noAlarmDetected: Keine aktiven Alarme
42
+ values: Wert
43
+ parameters: Parameter
44
+ badInput: Falsche Eingabe
45
+ allowedRange: Erforderlicher Bereich
46
+ start: Start
47
+ stop: Stop
48
+ text: Text
49
+ digiVer: DIGI Module Version
50
+ rdVer: RD Module Version
51
+ unitAddress: Geräte Adresse
52
+ currentMode: Aktueller Modus
53
+ damageWarning: Achtung! Bei falscher Einstellung dieser Parameter, besteht die Möglichkeit,
54
+ dass das Gerät nicht richtig arbeitet. Für Schäden, die durch falsche Einstellung
55
+ entstehen, übernimmt der Hersteller keine Haftung!
56
+ parameter: Parameter
57
+ value: Wert
58
+ minimum: Minimum
59
+ maximum: Maximal
60
+ defValue: Standard Wert
61
+ warning: Warnung
62
+ error: Eingeben
63
+ accessPrompt: Geben Sie bitte den Service-Code ein
64
+ accessDenied: Zugriff verweigert, falscher Code
65
+ swVer: Software Version
66
+ orderNum: Produktionsnummer
67
+ userSetup: Benutzereinstellungen
68
+ switchman: Manuell
69
+ valueOutOfRange: Der Wert liegt außerhalb des Bereichs
70
+ fwStep1: Schritt 1 - Speichern der Parameter
71
+ fwStep2: Schritt 2 - Firmware Update
72
+ fwSTep3: Schritt 3 - Aktualisierung
73
+ saveSettings: Speichern der Parameter
74
+ updateIt: Updaten
75
+ restoreSettings: Wiederherstellen der Parameter
76
+ parsNotSaved: Parameter wurden nicht gespeichert
77
+ errLengthCoo: Fehler! - Bitte verwenden Sie einen anderen Browser
78
+ parsSaved: Parameter wurden gespeichert
79
+ updateInProcess: Update, bitte warten...
80
+ updateNoFile: Datei wurde nicht gefunden...
81
+ updateSucess: Update war erfolgreich!
82
+ updateError: Störung - Update
83
+ manControlOn: Manuelle Eingabe aktiv!
84
+ manControlOff: Manuelle Eingabe deaktiviert
85
+ notConnected: Nicht angeschlossen
86
+ PgFW_FS1: Backup Einstellungen wiederherstellen
87
+ PgFW_S1: Backup Serviceeinstellungen
88
+ PgFW_SB1: Backup
89
+ PgFW_S2: Serviceeinstellungen wiederherstellen
90
+ PgFW_SB2: Überschreiben
91
+ PgFW_S3: Werkseinstellungen wiederherstellen
92
+ PgFW_SB3: Überschreiben
93
+ PgFW_FS2: Update
94
+ PgFW_U2: Download Update Anwendungen
95
+ PgFW_UB1: Öffnen
96
+ PgFW_SB1c: Möchten Sie wirklich ein Backup der Serviceeinstellungen durchführen?
97
+ PgFW_SB2c: Möchten Sie wirklich die Serviceeinstellung wiederherstellen?
98
+ PgFW_SB3c: Möchten Sie wirklich die Standardeinstellungen wiederherstellen?
99
+ fwUnit: Vorhandene FW
100
+ fwAvail: Verfügbare FW
101
+ restInProgress: Parameter werden wiederhergestellt
102
+ restart: Neustart
103
+ activate: Aktivieren
104
+ deactivate: Deaktivieren
105
+ badTimeZone: Falsche Zeitzone
106
+ badTime: Falsche Zeiteinstellung
107
+ setByPC: Einstellen nach PC
108
+ msgFindAddr: Geben Sie eine neue Geräteadresse ein
109
+ dtFilterChange: Nächst. Filterwechsel
110
+ confirmFilter: Filter gewechselt
111
+ confFilterQuest: Wurden die Filter gewechselt?
112
+ 'off': Aus
113
+ 'on': Ein
114
+ dayOfWeek: Wochentag
115
+ monday: Montag
116
+ tuesday: Dienstag
117
+ wednesday: Mittwoch
118
+ thursday: Donnerstag
119
+ friday: Freitag
120
+ saturday: Samstag
121
+ sunday: Sonntag
122
+ medium: Mittlerer
123
+ night: Nacht
124
+ day: Tag
125
+ power: Luftleistung
126
+ automatic: Wochenprogramm
127
+ manual: Manuell
128
+ temporary: Vorübergehend
129
+ non: Keine
130
+ mode: Betriebsmodus
131
+ perVentilation: Periodische Lüftung
132
+ ventilation: Lüftung
133
+ circulation: Umluft
134
+ startUp: Anlauf
135
+ runDown: Auslauf
136
+ defrosting: Enteisung
137
+ external: Extern
138
+ inactive: Aus
139
+ zone: Lüftungszone
140
+ heating: Heizsaison
141
+ nonHeating: Nichtheizsaison
142
+ dateTime: Datum/Uhrzeit
143
+ filterChange: Filtertausch
144
+ notWhenAuto: Wenn die Temperatursteuerung im Automatik Modus läuft, ist dei momentane
145
+ Einstellung nur bis zum nächsten Wochenprogramm Intervall gültig.
146
+ heatingSched: Wochenprogramm - Heizsaison
147
+ nonHeatingSched: Wochenprogramm - Nichtheizsaison
148
+ userSetting: Benutzereinstellungen
149
+ season: Saison
150
+ modeAC: Lüftungsmodus
151
+ modeTemp: Temperaturmodus
152
+ controlSetting: Regelungsparameter
153
+ tempSenzorDev: Korrektur Raumtemperatur Sensor
154
+ inputBlock: Blockierung IN1/IN2
155
+ personsCount: Anzahl der Personen
156
+ thermostatFcn: Funktion Temperaturwächter
157
+ holidayParty: Urlaub / Party
158
+ texts: Bezeichnungen
159
+ txtZone1: Zone 1
160
+ txtZone2: Zone 2
161
+ txtZone12: Zone 1 2
162
+ swInfo: Software Information
163
+ alarms: Alarme
164
+ controlAC: Lüftungsregelung
165
+ controlTemp: Temperaturregelung
166
+ currentPower: Aktuelle Leistung
167
+ requiredPower: Ausgewählte Leistung
168
+ requiredTemp: Ausgewählte Temperatur
169
+ requiredMode: Ausgewählter Modus
170
+ indoorTemp: Raumtemperatur
171
+ inletTemp: Zulufttemperatur
172
+ czech: Tschechisch
173
+ german: Deutsch
174
+ english: Englisch
175
+ eqVent: Konstant Volumenstrom Modus
176
+ ventCirc: Lüftung mit Zirkulation
177
+ circDepend: Zirkulations intervall
178
+ overPrVent: Überdruck Lüftung
179
+ devHeating: Korrektur Abweichung Heizung
180
+ devCooling: Korrektur Abweichung Kühlung
181
+ devCoolMax: Maximale Temperaturabweichung für maximale Kühlung
182
+ productNumber: Produktionsnummer
183
+ unitType: Gerätetyp
184
+ polish: Polnisch
185
+ bySens: Automatik
186
+ hpDefrosting: Enteisung Nachheizregister PWW
187
+ userLogin: Benutzeranmeldung
188
+ passwordInput: Passwort eingeben
189
+ loginCmd: einloggen
190
+ weeklyProgram: Wochenprogramm
191
+ italiano: Italienisch
192
+ nightBefCool: Nachtkühlung
193
+ passwordMenu: Ändern des Passworts
194
+ enterAllFields: Geben Sie alle Daten
195
+ passwordNoChk: Neues Passwort und Bestätigung stimmen nicht überein!
196
+ passwordBad: Passwort darf nur aus folgenden Zeichen a-z or A-Z or 0-9 bestehen!
197
+ passwordSaved: Passwort wurde gespeichert
198
+ passwordSaveErr: Passwort wurde - errornicht gespeichert - Fehler.
199
+ unavail: nicht verfügbar
200
+ disabledRange: 'Unzulässige Auswahl '
201
+ emergMode: Notlauf-Funktion
202
+ outdoorTemp: Aussen Temperatur
203
+ currentZone: Aktueller Zone
204
+ components: Komponenten
205
+ all: Alles
206
+ modeAuto: Automatik
207
+ disbalance: Disbalance
208
+ saveActive: Speichern / Aktivieren
209
+ holidays: Feiertag
210
+ vacations: Ferienzeit
211
+ unitDesign: Konstruktion
212
+ unitSpec: Spezifikation
213
+ partyStart: Start
214
+ partyEnd: Ende
215
+ tsNtsSwitch: HS/NHS Schaltung
216
+ tsNtsTemp: HS/NHS Temperatur
217
+ in1Block: IN1 Eingang Deaktivieren
218
+ in2Block: IN2 Eingang Deaktivieren
219
+ hystHeat: Vol. Steigerüng Kühlung
220
+ hystCool: Vol. Steigerüng Heitzung
221
+ set: Einstellen
222
+ timeZone: Zeit Zone
223
+ settingTZ: Time zone setting
224
+ producer: Lieferant
225
+ unitLine: Serie
226
+ unitSize: Gereatgrosse
227
+ unitIntDesign: Spezifikationen
228
+ currentConfig: Aktueller Einstellung
229
+ monthName1: Januar
230
+ monthName2: Februar
231
+ monthName3: März
232
+ monthName4: April
233
+ monthName5: Mai
234
+ monthName6: Juli
235
+ monthName7: Juli
236
+ monthName8: August
237
+ monthName9: September
238
+ monthName10: Oktober
239
+ monthName11: November
240
+ monthName12: Dezember
241
+ holidayTip: Feiertag/Ferienzeit
242
+ prodCodeInput: Geben Sie den Lieferanten Code ein...
243
+ logType: Typ
244
+ current: Aktuell
245
+ week: Woche
246
+ month: Monat
247
+ selectDay: Wählen Sie einen Tag
248
+ show: Anzeige
249
+ dataNotFound: Daten wurden nicht gefunden
250
+ logLive: Eingeschaltet
251
+ holidayVacation: Feiertag und Ferienzeit
252
+ timeAutoSwitch: DST automatisch
253
+ timeSyncInet: Zeit mit Internet synchronisieren
254
+ unitTime: Gerätezeit
255
+ inputs: Eingänge
256
+ outputs: Ausgänge
257
+ others: Andere
258
+ heatIconTip: Heizung aktiviert
259
+ coolIconTip: Kühlung aktiviert
260
+ partyIconTip: Modus Party/Urlaub aktiviert
261
+ alarmIconTip: Aktiver Alarm
262
+ PgFW_S2A: Letzte Datensicherung
263
+ reset: Reset
264
+ commun: Kommunikation
265
+ serverPing: Funktion "Connect server"
266
+ acsService: Servicezugang
267
+ acsDistr: Lieferantenzugang
268
+ lastCommun: Letzte Kommunikation
269
+ unitName: Jméno jednotky
@@ -0,0 +1,269 @@
1
+ ---
2
+ en:
3
+ mainTitle: Your specialist for heat recovery and air-handling system economy
4
+ save: Save
5
+ cancel: Cancel
6
+ copy: Copy
7
+ refresh: Restore
8
+ change: Change
9
+ pleaseWait: Wait, please...
10
+ backToHome: Back to main page
11
+ mainPage: Main page
12
+ serviceMenu: Service menu
13
+ activeFrom: Active from
14
+ hours: Analog
15
+ minutes: Minutes
16
+ record: Record
17
+ allowed: Allowed
18
+ netSetup: Network setting
19
+ getFromDHCP: DHCP parameters setting
20
+ useNextValues: Use the following setting
21
+ addressIP: IP address
22
+ subnetMask: Net mask
23
+ defaultGW: Gateway
24
+ serverDNS: DNS server
25
+ FTPsetup: FTP server password
26
+ passwordOld: 'Original password '
27
+ passwordNew: 'New password '
28
+ passwordConfirm: Password confirmation
29
+ airCond: Air handling unit
30
+ airCondSetup: HVAC unit configuration
31
+ temperature: Temperature
32
+ tempSetup: Temperature setting
33
+ notInDemo: Demo version does not support
34
+ thisTimeExist: Set time already exists
35
+ serviceSetup: Service setting
36
+ activeAlarms: Active alarms
37
+ alarmHistory: Alarm history
38
+ unitStarted: Unit start
39
+ active: Active
40
+ noAlarmDefined: No alarm defined
41
+ noAlarmDetected: No alarm is active
42
+ values: Values
43
+ parameters: Parameters
44
+ badInput: Wrong value inserted
45
+ allowedRange: Required values range
46
+ start: Start
47
+ stop: Stop
48
+ text: Text
49
+ digiVer: DIGI module version
50
+ rdVer: RD module version
51
+ unitAddress: Address of unit
52
+ currentMode: Current mode
53
+ damageWarning: 'Attention! When setting following parameters, be carefull about
54
+ the set values, inadequate setting may cause malfunction of the Unit. The appliance
55
+ producer is not responsible in any case of harm! '
56
+ parameter: Parameter
57
+ value: Value
58
+ minimum: Minimum
59
+ maximum: Max
60
+ defValue: Default
61
+ warning: Warning
62
+ error: Set
63
+ accessPrompt: Access check, enter the service code!
64
+ accessDenied: Access denied, wrong code!
65
+ swVer: Software version
66
+ orderNum: Production number
67
+ userSetup: User setting
68
+ switchman: Manual
69
+ valueOutOfRange: Value exceeded the range
70
+ fwStep1: Step 1 - Save parameters
71
+ fwStep2: Step 2 - Firmware update
72
+ fwSTep3: Step 3 - Parameters refresh
73
+ saveSettings: Save parameters
74
+ updateIt: Make update
75
+ restoreSettings: Refresh parameters
76
+ parsNotSaved: No parameters has been saved till now
77
+ errLengthCoo: Data error, use different browser
78
+ parsSaved: Parameters have been saved
79
+ updateInProcess: The update is in progress, wait please.
80
+ updateNoFile: No file for update has been found
81
+ updateSucess: UPDATE finished
82
+ updateError: Update error
83
+ manControlOn: Manual control enabled
84
+ manControlOff: Manual control disabled
85
+ notConnected: Not connected
86
+ PgFW_FS1: Restore/back-up setting
87
+ PgFW_S1: The backup of the service setting
88
+ PgFW_SB1: Back-up
89
+ PgFW_S2: Service setting restore from back-up
90
+ PgFW_SB2: Restore
91
+ PgFW_S3: 'Restore to production setting '
92
+ PgFW_SB3: Restore
93
+ PgFW_FS2: Update
94
+ PgFW_U2: Download of the update application
95
+ PgFW_UB1: Open
96
+ PgFW_SB1c: Do you wish to make a back-up of the service setting?
97
+ PgFW_SB2c: 'Are you sure to restore service setting from the back-up file? '
98
+ PgFW_SB3c: Are you sure to restore the default setting?
99
+ fwUnit: Current fw ver.
100
+ fwAvail: Available fw ver.
101
+ restInProgress: Setting restore is in the progress
102
+ restart: Restart
103
+ activate: Activate
104
+ deactivate: Deactivate
105
+ badTimeZone: Wrong time zone
106
+ badTime: Wrong time setting
107
+ setByPC: Set according to the PC
108
+ msgFindAddr: Enter a new unit address.
109
+ dtFilterChange: Next filter change
110
+ confirmFilter: Confirm the change
111
+ confFilterQuest: Are you sure the filter has been changed?
112
+ 'off': 'Off'
113
+ 'on': 'On'
114
+ dayOfWeek: Day of week
115
+ monday: Monday
116
+ tuesday: Tuesday
117
+ wednesday: Wednesday
118
+ thursday: Thursday
119
+ friday: Friday
120
+ saturday: Saturday
121
+ sunday: Sunday
122
+ medium: Medium
123
+ night: Night
124
+ day: Day
125
+ power: Power
126
+ automatic: Schedule
127
+ manual: Manual
128
+ temporary: Temporary
129
+ non: Non
130
+ mode: Mode
131
+ perVentilation: Period. ventilation
132
+ ventilation: Ventilation
133
+ circulation: Circulation
134
+ startUp: Start-up
135
+ runDown: Run-out
136
+ defrosting: Defrosting
137
+ external: External
138
+ inactive: 'Off'
139
+ zone: Zone
140
+ heating: Heating
141
+ nonHeating: Non-heating
142
+ dateTime: 'Time and date '
143
+ filterChange: Filter change
144
+ notWhenAuto: Temperature control set to the Automatic mode, the current setting
145
+ is valid till the next week interval is active.
146
+ heatingSched: Heating season schedule
147
+ nonHeatingSched: Non-heating season schedule
148
+ userSetting: User setting
149
+ season: Season
150
+ modeAC: Mode air-handling
151
+ modeTemp: Temperature mode
152
+ controlSetting: Control procesor setting
153
+ tempSenzorDev: Temperature sensor correction - CP
154
+ inputBlock: IN Blocking
155
+ personsCount: Number of persons
156
+ thermostatFcn: Thermostat function
157
+ holidayParty: Holiday / party
158
+ texts: Texts
159
+ txtZone1: Text for zone 1
160
+ txtZone2: Text for zone 2
161
+ txtZone12: Text for zone 1 and 2
162
+ swInfo: About the control
163
+ alarms: Alarms
164
+ controlAC: Air-handling control
165
+ controlTemp: Temperature control
166
+ currentPower: Actual Power
167
+ requiredPower: Requested power
168
+ requiredTemp: Requested temperature
169
+ requiredMode: Requested mode
170
+ indoorTemp: Inner temperature
171
+ inletTemp: Supply air temperature
172
+ czech: Czech
173
+ german: German
174
+ english: English
175
+ eqVent: Equal volume flow
176
+ ventCirc: Ventilat. circulation
177
+ circDepend: Interval circulation
178
+ overPrVent: Overpressure
179
+ devHeating: Temperature hysteresis - heating
180
+ devCooling: Temperature hysteresis - cooling
181
+ devCoolMax: Max. temperature drop - max. cooling
182
+ productNumber: Production number
183
+ unitType: Unit type
184
+ polish: Polish
185
+ bySens: Auto - ventilation
186
+ hpDefrosting: HP defrosting
187
+ userLogin: User login
188
+ passwordInput: Enter the password
189
+ loginCmd: Login
190
+ weeklyProgram: Schedule
191
+ italiano: Italian
192
+ nightBefCool: Night precooling
193
+ passwordMenu: Password change
194
+ enterAllFields: Fill all the data
195
+ passwordNoChk: A new password and the confirmation does not match!
196
+ passwordBad: The password may only consist of figures a-z or A-Z or 0-9!
197
+ passwordSaved: The password has been saved
198
+ passwordSaveErr: Password was not saved - error.
199
+ unavail: Unavailable
200
+ disabledRange: Range is exceeded
201
+ emergMode: Emergency mode
202
+ outdoorTemp: Outdoor temperature
203
+ currentZone: Actual zone
204
+ components: Components
205
+ all: All
206
+ modeAuto: Automat
207
+ disbalance: Disbalance
208
+ saveActive: Save / Activate
209
+ holidays: Bank Holidays
210
+ vacations: Vacations
211
+ unitDesign: Design
212
+ unitSpec: Specification
213
+ partyStart: Starts at...
214
+ partyEnd: Expires at...
215
+ tsNtsSwitch: HS/NHS switching
216
+ tsNtsTemp: HS/NHS switch temp.
217
+ in1Block: IN1 input blocking
218
+ in2Block: IN2 input blocking
219
+ hystHeat: Hysteresis - heating
220
+ hystCool: Hysteresis - cooling
221
+ set: Set new
222
+ timeZone: Time zone
223
+ settingTZ: Time zone setting
224
+ producer: Supplier
225
+ unitLine: Line
226
+ unitSize: Unit size
227
+ unitIntDesign: Specification
228
+ currentConfig: Current setting
229
+ monthName1: January
230
+ monthName2: Fabruery
231
+ monthName3: March
232
+ monthName4: April
233
+ monthName5: May
234
+ monthName6: June
235
+ monthName7: July
236
+ monthName8: August
237
+ monthName9: September
238
+ monthName10: October
239
+ monthName11: November
240
+ monthName12: December
241
+ holidayTip: Bank holid./Vacation
242
+ prodCodeInput: Enter the supplier code...
243
+ logType: Log typ
244
+ current: Current
245
+ week: Week
246
+ month: Month
247
+ selectDay: Choose the week day
248
+ show: Show...
249
+ dataNotFound: Data are not found
250
+ logLive: On-line
251
+ holidayVacation: Bank holidays, Vacation
252
+ timeAutoSwitch: DST automaticaly
253
+ timeSyncInet: Internet time synchronisation
254
+ unitTime: Unit time
255
+ inputs: Inputs
256
+ outputs: Outputs
257
+ others: Others
258
+ heatIconTip: 'Heating activated '
259
+ coolIconTip: Cooling activated
260
+ partyIconTip: Party/Holiday mode activated
261
+ alarmIconTip: Activ alarm
262
+ PgFW_S2A: Last backup
263
+ reset: Reset
264
+ commun: Communication
265
+ serverPing: '"Connect server" service'
266
+ acsService: Service access
267
+ acsDistr: Distributor access
268
+ lastCommun: Last communication
269
+ unitName: Jméno jednotky
@@ -0,0 +1,120 @@
1
+ require "digest"
2
+ require "rest-client"
3
+ require "selenium-webdriver"
4
+
5
+ module AtreaControl
6
+ module Duplex
7
+ # Process login into RD5 with selenium to get `sid` ( auth_token ) for direct API communication
8
+ class Login
9
+
10
+ include AtreaControl::Logger
11
+
12
+ # @return [Hash] - user_id, unit_id, sid
13
+ def self.user_tokens(login:, password:)
14
+ i = new(login: login, password: password)
15
+ tokens = i.user
16
+
17
+ tokens
18
+ ensure
19
+ i.close
20
+ end
21
+
22
+ # @param [String] login
23
+ # @param [String] password
24
+ def initialize(login:, password:)
25
+ @login = login
26
+ @password = password
27
+ end
28
+ #
29
+ # def crypto_password
30
+ # md5 = Digest::MD5.new
31
+ # md5 << "\r\n"
32
+ # md5 << @password
33
+ # md5.hexdigest
34
+ # end
35
+ #
36
+ # def token
37
+ # RestClient.get "#{AtreaControl::Duplex::CONTROL_URI}/config/login.cgi", params: { magic: crypto_password }
38
+ # end
39
+
40
+ def user
41
+ raise AtreaControl::Error, "Must be logged in" unless login
42
+
43
+ logger.debug "refresh user data based on session"
44
+ @user_id = driver.execute_script("return window._user")
45
+ @unit_id = driver.execute_script("return window._unit")
46
+ @auth_token = driver.execute_script("return window.user")&.[]("auth") # sid
47
+
48
+ { user_id: @user_id, unit_id: @unit_id, sid: @auth_token }
49
+ end
50
+
51
+ # @return [Selenium::WebDriver::Firefox::Driver]
52
+ def driver
53
+ return @driver if defined?(@driver)
54
+
55
+ options = Selenium::WebDriver::Firefox::Options.new
56
+ options.headless! unless ENV["NO_HEADLESS"]
57
+ @driver ||= Selenium::WebDriver.for :firefox, capabilities: [options]
58
+ end
59
+
60
+ # Login into control
61
+ def login
62
+ return driver if @logged
63
+
64
+ @login_in_progress = true
65
+ logger.debug "start new login..."
66
+ driver.get "#{AtreaControl::Duplex::CONTROL_URI}?action=logout"
67
+ submit_login_form
68
+ finish_login
69
+ driver
70
+ ensure
71
+ @login_in_progress = false
72
+ end
73
+
74
+ # Submit given credentials and proceed login
75
+ def submit_login_form
76
+ form = driver.find_element(id: "loginFrm")
77
+ username = form.find_element(name: "username")
78
+ username.send_keys @login
79
+ password = form.find_element(name: "password")
80
+ password.send_keys @password
81
+ logger.debug "Submit login form..."
82
+
83
+ submit = form.find_element(css: "input[type=submit]")
84
+ submit.click
85
+ end
86
+
87
+ # Retrieve dashboard URI from object tag and open it again
88
+ def open_dashboard
89
+ uri = driver.find_element(tag_name: "object").attribute "data"
90
+ # Open "iframe" with atrea dashboard - it propagate window objects...
91
+ driver.get uri
92
+ logger.debug "login success"
93
+ @logged = true
94
+ end
95
+
96
+ # quit selenium browser
97
+ def close
98
+ driver.quit rescue nil
99
+ logger.debug "driver closed & destroyed"
100
+ ensure
101
+ remove_instance_variable :@driver
102
+ end
103
+
104
+ private
105
+
106
+ def finish_login
107
+ 30.times do |i|
108
+ return true if open_dashboard
109
+ rescue Selenium::WebDriver::Error::NoSuchElementError => e
110
+ logger.debug e.message
111
+ logger.debug "#{i + 1}/30 attempt for login..."
112
+ sleep 10
113
+ end
114
+ File.write("/tmp/failed_login-#{@login}.html", driver.page_source)
115
+ raise AtreaControl::Error, "unable to login"
116
+ end
117
+
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,30 @@
1
+ require "rest-client"
2
+
3
+ module AtreaControl
4
+ module Duplex
5
+ # Process request with duplex unit itself. Handle response
6
+ class Request
7
+ include AtreaControl::Logger
8
+
9
+ # @param [String, Integer] user_id
10
+ # @param [String, Integer] unit_id
11
+ # @param [String, Integer] sid
12
+ # @note `ver` is done by atrea server
13
+ def initialize(user_id:, unit_id:, sid:)
14
+ @params = {
15
+ _user: user_id.to_i,
16
+ _unit: unit_id,
17
+ auth: sid,
18
+ ver: AtreaControl::Duplex::CONTROL_VERSION,
19
+ }
20
+ end
21
+
22
+ # @param [Hash] params
23
+ # @option params [String] :_t ("config/xml.xml") file name
24
+ def call(params)
25
+ RestClient.get "#{AtreaControl::Duplex::CONTROL_URI}/comm/sw/unit.php", params: @params.merge(params)
26
+ end
27
+
28
+ end
29
+ end
30
+ end