Skip to content

Commit 400e561

Browse files
committed
250506.2
1 parent ead8897 commit 400e561

File tree

6 files changed

+71
-46
lines changed

6 files changed

+71
-46
lines changed
Binary file not shown.

easycoder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
from .ec_timestamp import *
1010
from .ec_value import *
1111

12-
__version__ = "250506.1"
12+
__version__ = "250506.2"

easycoder/ec_pyside.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ def k_select(self, command):
690690
command['index'] = self.nextValue()
691691
self.skip('of')
692692
else:
693-
command['name'] = self.nextValue()
693+
command['name'] = self.getValue()
694694
self.skip('in')
695695
if self.nextIsSymbol():
696696
record = self.getSymbolRecord()

rbrconf.ecs

Lines changed: 68 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
! config.ecs
1+
! rbrconf.ecs
22

3-
script Configurator
3+
script RBRConfigurator
44

55
use graphics
66

@@ -109,7 +109,6 @@
109109
create Layout type QHBoxLayout
110110
add Layout to Group
111111
create SystemsCombo
112-
on select SystemsCombo go to SystemsComboSelect
113112
add stretch SystemsCombo to Layout
114113
create ScanSystemsButton text `System Scan`
115114
disable ScanSystemsButton
@@ -294,6 +293,7 @@
294293
variable Pin
295294
variable D
296295
variable F
296+
variable K
297297
variable N
298298
variable P
299299
variable S
@@ -319,6 +319,8 @@ Start:
319319
put empty into SystemIPAddr
320320
clear DeviceSelected
321321

322+
gosub to SetBusy
323+
322324
! Get the host SSID
323325
put `Getting host SSID...` into StatusMessage
324326
gosub to Working
@@ -352,17 +354,17 @@ Start:
352354
if the count of SystemsCombo is 0 put empty into SystemName
353355
else
354356
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
363364
end
364365

365366
gosub to ManageButtonStates
367+
on select SystemsCombo go to SystemsComboSelect
366368
stop
367369

368370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -403,13 +405,13 @@ ScanSystemsClick:
403405
stop
404406

405407
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
406-
! Scan the network for RBR system controllers
408+
! Scan the local network for RBR system controllers
407409
ScanSystems:
408410
log `Scan systems`
409411
put trim system `hostname -I` into MyIPAddr
410412
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
413415
begin
414416
put the position of the last `.` in MyIPAddr into P
415417
increment P
@@ -420,7 +422,6 @@ ScanSystems:
420422
get Result from url `http://` cat IPAddr cat `:17348/cgi-bin/mac.py` timeout 1 or go to SS2
421423
increment Count
422424
put trim Result into Result
423-
log Result
424425
log IPAddr cat `: ` cat Result
425426
put the position of ` ` in Result into P
426427
put left P of Result into SystemMAC
@@ -438,41 +439,56 @@ ScanSystems:
438439
set property `password` of SystemConfig to SystemPassword
439440
set property `devices` of SystemConfig to json `{}`
440441
log `Adding ` cat SystemName cat ` to Systems`
441-
gosub UpdateSystems
442-
log prettify SystemConfig
443442
gosub to GetConfigData
443+
! log prettify SystemConfig
444+
set property SystemName of Systems to SystemConfig
444445
SS2:
445446
wait 10 ticks
446447
increment N
447448
end
448449
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
450453
go to OK
451454

452455
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
453456
! Get the config data for a system
454457
GetConfigData:
455458
gosub to SetBusy
456459
if SystemName is empty return
460+
log prettify SystemConfig
457461
log `Get the config data for ` cat SystemName
458-
put property `devices` of SystemConfig into Devices
459462
get Value from url `https://rbrheating.com/ui/resources/php/rest.php/config/`
460463
cat SystemMAC cat `/` cat SystemPassword
461464
or
462465
begin
463466
put `Can't read the config file for ` cat SystemName cat `(` cat MAC cat `/` cat Password cat `)` into StatusMessage
464467
go to Error
465468
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
467472
if Value is empty put `{}` into Value
468473
if Value is not `{}`
469474
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
473489
end
474-
! log prettify SystemConfig
475-
gosub to PostConfigData
490+
gosub to UpdateSystems
491+
put property `devices` of SystemConfig into Devices
476492
return
477493

478494
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -496,19 +512,25 @@ RefreshSystemsCombo:
496512
SystemsComboSelect:
497513
gosub to ResumeSystemController
498514
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
508516
gosub to ManageButtonStates
509517
if not ErrorFlag gosub to OK
510518
stop
511519

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+
512534
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
513535
! Remove a system from the combo box
514536
RemoveSystemClick:
@@ -525,6 +547,9 @@ RemoveSystemClick:
525547
remove the current item from SystemsCombo
526548
delete property SystemName of Systems
527549
put empty into SystemName
550+
put empty into SystemConfig
551+
set the text of MasterDeviceButton to empty
552+
clear SlaveList
528553
set property `current-system` of Config to SystemsCombo
529554
set property `systems` of Config to Systems
530555
put empty into SystemHostSSID
@@ -930,7 +955,6 @@ MasterDeviceClick:
930955
set DeviceSelected
931956
set IsMaster
932957
put MasterDevice into Device
933-
log prettify Device
934958
gosub to PopulateDeviceInfo
935959
end
936960
gosub to ManageButtonStates
@@ -960,7 +984,7 @@ PopulateDeviceInfo:
960984
enable UpdateFilesButton
961985
enable DeleteFileButton
962986
end
963-
return
987+
go to OK
964988

965989
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
966990
! Show information about a slave device
@@ -1355,16 +1379,16 @@ CheckDevice:
13551379
begin
13561380
put `No response from ` cat Name into StatusMessage
13571381
gosub to Error
1358-
put 0 into Uptime
1382+
put `0` into Uptime
13591383
end
13601384
else put from 3 of Response into Uptime
13611385

13621386
CheckDevice2:
13631387
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
13651389
log Name cat ` uptime: ` cat Uptime
13661390
set the text of UptimeLabel to Uptime
1367-
return
1391+
go to OK
13681392

13691393
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13701394
! Turn a relay OFF
@@ -1485,14 +1509,15 @@ GetDeviceData:
14851509
! Post the config data
14861510
PostConfigData:
14871511
if CurrentSSID is not HostSSID gosub to ConnectToHost
1488-
if SystemMAC is empty return
14891512
save prettify Config to ConfigFile
14901513
! log `Config: ` cat prettify Config
1514+
if SystemMAC is empty return
1515+
if SystemConfig is empty return
14911516
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
14931519
post stringify SystemConfig to URL
1494-
or
1495-
begin
1520+
or begin
14961521
put `I couldn't post the config file` into StatusMessage
14971522
go to Error
14981523
end

rbrconf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from easycoder import Program
22

3-
Program('config.ecs').start()
3+
Program('rbrconf.ecs').start()

0 commit comments

Comments
 (0)