1
- ! config .ecs
1
+ ! rbrconf .ecs
2
2
3
- script Configurator
3
+ script RBRConfigurator
4
4
5
5
use graphics
6
6
109
109
create Layout type QHBoxLayout
110
110
add Layout to Group
111
111
create SystemsCombo
112
- on select SystemsCombo go to SystemsComboSelect
113
112
add stretch SystemsCombo to Layout
114
113
create ScanSystemsButton text `System Scan`
115
114
disable ScanSystemsButton
294
293
variable Pin
295
294
variable D
296
295
variable F
296
+ variable K
297
297
variable N
298
298
variable P
299
299
variable S
@@ -319,6 +319,8 @@ Start:
319
319
put empty into SystemIPAddr
320
320
clear DeviceSelected
321
321
322
+ gosub to SetBusy
323
+
322
324
! Get the host SSID
323
325
put `Getting host SSID...` into StatusMessage
324
326
gosub to Working
@@ -352,17 +354,17 @@ Start:
352
354
if the count of SystemsCombo is 0 put empty into SystemName
353
355
else
354
356
begin
355
- put the keys of Systems into Keys
356
- put element 0 of Keys into SystemName
357
- end
358
- set property `current-system` of Config to SystemName
359
- if SystemName is not empty
360
- begin
361
- select SystemName in SystemsCombo
362
- enable ClearSystemButton
357
+ put property `current-system` of Config into SystemName
358
+ if SystemName is not empty
359
+ begin
360
+ select SystemName in SystemsCombo
361
+ ! log prettify SystemConfig
362
+ gosub to SelectSystem
363
+ end
363
364
end
364
365
365
366
gosub to ManageButtonStates
367
+ on select SystemsCombo go to SystemsComboSelect
366
368
stop
367
369
368
370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -403,13 +405,13 @@ ScanSystemsClick:
403
405
stop
404
406
405
407
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
406
- ! Scan the network for RBR system controllers
408
+ ! Scan the local network for RBR system controllers
407
409
ScanSystems:
408
410
log `Scan systems`
409
411
put trim system `hostname -I` into MyIPAddr
410
412
log MyIPAddr
411
- put 245 into N
412
- while N is less than 250
413
+ put 1 into N
414
+ while N is less than 255
413
415
begin
414
416
put the position of the last `.` in MyIPAddr into P
415
417
increment P
@@ -420,7 +422,6 @@ ScanSystems:
420
422
get Result from url `http://` cat IPAddr cat `:17348/cgi-bin/mac.py` timeout 1 or go to SS2
421
423
increment Count
422
424
put trim Result into Result
423
- log Result
424
425
log IPAddr cat `: ` cat Result
425
426
put the position of ` ` in Result into P
426
427
put left P of Result into SystemMAC
@@ -438,41 +439,56 @@ ScanSystems:
438
439
set property `password` of SystemConfig to SystemPassword
439
440
set property `devices` of SystemConfig to json `{}`
440
441
log `Adding ` cat SystemName cat ` to Systems`
441
- gosub UpdateSystems
442
- log prettify SystemConfig
443
442
gosub to GetConfigData
443
+ ! log prettify SystemConfig
444
+ set property SystemName of Systems to SystemConfig
444
445
SS2:
445
446
wait 10 ticks
446
447
increment N
447
448
end
448
449
set property `current-system` of Config to SystemName
449
- log `After scan: ` cat prettify Config
450
+ gosub to UpdateSystems
451
+ ! log `After scan: ` cat prettify Config
452
+ gosub to PostConfigData
450
453
go to OK
451
454
452
455
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
453
456
! Get the config data for a system
454
457
GetConfigData:
455
458
gosub to SetBusy
456
459
if SystemName is empty return
460
+ log prettify SystemConfig
457
461
log `Get the config data for ` cat SystemName
458
- put property `devices` of SystemConfig into Devices
459
462
get Value from url `https://rbrheating.com/ui/resources/php/rest.php/config/`
460
463
cat SystemMAC cat `/` cat SystemPassword
461
464
or
462
465
begin
463
466
put `Can't read the config file for ` cat SystemName cat `(` cat MAC cat `/` cat Password cat `)` into StatusMessage
464
467
go to Error
465
468
end
466
- ! If the server has data, use it instead of the local config
469
+ log Value
470
+ ! If the server has data, copy it into the local config
471
+ if Value is `""` put empty into Value
467
472
if Value is empty put `{}` into Value
468
473
if Value is not `{}`
469
474
begin
470
- log `Use config data from the server`
471
- put json Value into SystemConfig
472
- gosub to UpdateSystems
475
+ log `Add config data from the server`
476
+ put json Value into Value
477
+ log prettify Value
478
+ put the keys of Value into Keys
479
+ put 0 into K
480
+ while K is less than the count of Keys
481
+ begin
482
+ put element K of Keys into Name
483
+ log `Adding ` cat Name cat ` ` cat property Name of Value
484
+ if Name is `ssid` set property `host-ssid` of SystemConfig to property Name of Value
485
+ else if Name is `password` set property `host-password` of SystemConfig to property Name of Value
486
+ else set property Name of SystemConfig to property Name of Value
487
+ increment K
488
+ end
473
489
end
474
- ! log prettify SystemConfig
475
- gosub to PostConfigData
490
+ gosub to UpdateSystems
491
+ put property `devices` of SystemConfig into Devices
476
492
return
477
493
478
494
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -496,19 +512,25 @@ RefreshSystemsCombo:
496
512
SystemsComboSelect:
497
513
gosub to ResumeSystemController
498
514
put SystemsCombo into SystemName
499
- if SystemName is not empty
500
- begin
501
- log `Select system ` cat SystemName
502
- set property `current-system` of Config to SystemName
503
- put property SystemName of Systems into SystemConfig
504
- put property `ipaddr` of SystemConfig into SystemIPAddr
505
- gosub to PopulateSystemInfo
506
- gosub to PauseSystemController
507
- end
515
+ if SystemName is not empty gosub to SelectSystem
508
516
gosub to ManageButtonStates
509
517
if not ErrorFlag gosub to OK
510
518
stop
511
519
520
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
521
+ ! Select a system
522
+ SelectSystem:
523
+ log `Select system ` cat SystemName
524
+ set property `current-system` of Config to SystemName
525
+ put property SystemName of Systems into SystemConfig
526
+ put property `ipaddr` of SystemConfig into SystemIPAddr
527
+ put property `mac` of SystemConfig into SystemMAC
528
+ put property `password` of SystemConfig into SystemPassword
529
+ gosub to PopulateSystemInfo
530
+ gosub to PostConfigData
531
+ gosub to PauseSystemController
532
+ return
533
+
512
534
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
513
535
! Remove a system from the combo box
514
536
RemoveSystemClick:
@@ -525,6 +547,9 @@ RemoveSystemClick:
525
547
remove the current item from SystemsCombo
526
548
delete property SystemName of Systems
527
549
put empty into SystemName
550
+ put empty into SystemConfig
551
+ set the text of MasterDeviceButton to empty
552
+ clear SlaveList
528
553
set property `current-system` of Config to SystemsCombo
529
554
set property `systems` of Config to Systems
530
555
put empty into SystemHostSSID
@@ -930,7 +955,6 @@ MasterDeviceClick:
930
955
set DeviceSelected
931
956
set IsMaster
932
957
put MasterDevice into Device
933
- log prettify Device
934
958
gosub to PopulateDeviceInfo
935
959
end
936
960
gosub to ManageButtonStates
@@ -960,7 +984,7 @@ PopulateDeviceInfo:
960
984
enable UpdateFilesButton
961
985
enable DeleteFileButton
962
986
end
963
- return
987
+ go to OK
964
988
965
989
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
966
990
! Show information about a slave device
@@ -1355,16 +1379,16 @@ CheckDevice:
1355
1379
begin
1356
1380
put `No response from ` cat Name into StatusMessage
1357
1381
gosub to Error
1358
- put 0 into Uptime
1382
+ put `0` into Uptime
1359
1383
end
1360
1384
else put from 3 of Response into Uptime
1361
1385
1362
1386
CheckDevice2:
1363
1387
put the position of ` ` in Uptime into P
1364
- put left P of Uptime into Uptime
1388
+ if P is greater than 0 put left P of Uptime into Uptime
1365
1389
log Name cat ` uptime: ` cat Uptime
1366
1390
set the text of UptimeLabel to Uptime
1367
- return
1391
+ go to OK
1368
1392
1369
1393
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1370
1394
! Turn a relay OFF
@@ -1485,14 +1509,15 @@ GetDeviceData:
1485
1509
! Post the config data
1486
1510
PostConfigData:
1487
1511
if CurrentSSID is not HostSSID gosub to ConnectToHost
1488
- if SystemMAC is empty return
1489
1512
save prettify Config to ConfigFile
1490
1513
! log `Config: ` cat prettify Config
1514
+ if SystemMAC is empty return
1515
+ if SystemConfig is empty return
1491
1516
put `https://rbrheating.com/ui/resources/php/rest.php/config/` cat SystemMAC cat `/` cat SystemPassword into URL
1492
- log `Posting SystemConfig to ` cat URL
1517
+ ! log URL cat ` ` cat prettify SystemConfig
1518
+ ! log `Posting SystemConfig to ` cat URL
1493
1519
post stringify SystemConfig to URL
1494
- or
1495
- begin
1520
+ or begin
1496
1521
put `I couldn't post the config file` into StatusMessage
1497
1522
go to Error
1498
1523
end
0 commit comments