Skip to content

Commit 1fc6de1

Browse files
committed
250427.1
1 parent 075836e commit 1fc6de1

File tree

6 files changed

+138
-46
lines changed

6 files changed

+138
-46
lines changed

config.ecs

Lines changed: 112 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,18 @@
1616
layout HLayout
1717
groupbox Group
1818
label Label
19-
label MasterDeviceLabel
2019
label RelayStateLabel
2120
label StatusLabel
2221
pushbutton ResetConfigButton
23-
pushbutton ScanNetworkButton
24-
pushbutton SelectMasterButton
25-
pushbutton SelectSlaveButton
22+
pushbutton ScanDevicesButton
23+
pushbutton ClearSystemButton
2624
pushbutton DeleteSlaveButton
27-
pushbutton UpdateSlaveButton
25+
pushbutton UpdateDeviceButton
2826
pushbutton DeleteFileButton
2927
pushbutton ExitButton
3028
pushbutton ScanSystemsButton
3129
pushbutton RemoveSystemButton
30+
pushbutton MasterDeviceButton
3231
pushbutton RelayOffButton
3332
pushbutton RelayOnButton
3433
pushbutton SaveWidgetDataButton
@@ -59,25 +58,21 @@
5958

6059
create LeftPanel type QVBoxLayout
6160
add LeftPanel to MainPanel
62-
create ResetConfigButton text `Reset config`
61+
create ResetConfigButton text `Reset everything`
6362
on click ResetConfigButton go to ResetConfigFileClick
6463
add ResetConfigButton to LeftPanel
6564

66-
create ScanNetworkButton text `Scan network`
67-
on click ScanNetworkButton go to ScanNetworkClick
68-
add ScanNetworkButton to LeftPanel
65+
create ClearSystemButton text `Clear the selected system`
66+
on click ClearSystemButton go to ClearSystemClick
67+
add ClearSystemButton to LeftPanel
6968

70-
create SelectMasterButton text `Select master`
71-
on click SelectMasterButton go to SelectMasterClick
72-
add SelectMasterButton to LeftPanel
69+
create ScanDevicesButton text `Scan for devices`
70+
on click ScanDevicesButton go to ScanNetworkClick
71+
add ScanDevicesButton to LeftPanel
7372

74-
create SelectSlaveButton text `Select slave`
75-
on click SelectSlaveButton go to SelectSlaveClick
76-
add SelectSlaveButton to LeftPanel
77-
78-
create UpdateSlaveButton text `Update slave`
79-
on click UpdateSlaveButton go to UpdateSlaveClick
80-
add UpdateSlaveButton to LeftPanel
73+
create UpdateDeviceButton text `Update device`
74+
on click UpdateDeviceButton go to UpdateDeviceClick
75+
add UpdateDeviceButton to LeftPanel
8176

8277
create DeleteFileButton text `Delete file`
8378
add DeleteFileButton to LeftPanel
@@ -107,7 +102,7 @@
107102
create SystemsCombo
108103
on select SystemsCombo go to SystemsComboSelect
109104
add stretch SystemsCombo to Layout
110-
create ScanSystemsButton text `Scan`
105+
create ScanSystemsButton text `System Scan`
111106
disable ScanSystemsButton
112107
on click ScanSystemsButton go to ScanSystemsClick
113108
add ScanSystemsButton to Layout
@@ -122,8 +117,9 @@
122117
add Group to RightPanel
123118
create Layout type QHBoxLayout
124119
add Layout to Group
125-
create MasterDeviceLabel text `(none)`
126-
add MasterDeviceLabel to Layout
120+
create MasterDeviceButton text `(none)`
121+
add MasterDeviceButton to Layout
122+
on click MasterDeviceButton go to MasterDeviceClick
127123

128124
! Create the Slave Devices group
129125
create Group title `Slave devices`
@@ -133,6 +129,7 @@
133129
add Layout to Group
134130
create SlaveList
135131
add SlaveList to Layout
132+
on select SlaveList go to SelectSlaveClick
136133

137134
! Create the Selected Device group
138135
create Group title `Selected device`
@@ -246,6 +243,7 @@
246243
variable MasterDevice
247244
variable MasterSSID
248245
variable MasterIPAddr
246+
variable MasterDeviceName
249247
variable SlaveDevices
250248
variable RBRFlag
251249
variable Keys
@@ -260,6 +258,13 @@
260258
! The main program starts here
261259
Start:
262260

261+
! Disable various buttons
262+
disable ClearSystemButton
263+
disable ScanDevicesButton
264+
disable DeleteSlaveButton
265+
disable UpdateDeviceButton
266+
disable DeleteFileButton
267+
263268
! Load the main config file or create one if there is none
264269
put trim system `echo $HOME` cat `/.rbr.conf` into ConfigFile
265270
load Config from ConfigFile
@@ -311,28 +316,87 @@ Start:
311316
if Name is not empty
312317
begin
313318
select Name in SystemsCombo
319+
enable ClearSystemButton
314320
gosub to SetupSystem
315321
end
316322

317323
enable ScanSystemsButton
324+
enable ScanDevicesButton
318325
stop
319326

320327
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
321328
! Event handlers
322329
ResetConfigFileClick:
323-
delete file ConfigFile
324-
disable ScanSystemsButton
325-
go to Start
330+
create MessageBox on Window
331+
style question
332+
title `Master reset`
333+
message `This will remove all information. Continue?`
334+
show MessageBox giving Value
335+
if Value is `Yes`
336+
begin
337+
delete file ConfigFile
338+
disable RemoveSystemButton
339+
set the text of MasterDeviceButton to `(none)`
340+
clear SlaveList
341+
go to Start
342+
end
343+
stop
326344

327-
SelectMasterClick:
328-
log `Select the master device`
345+
ClearSystemClick:
346+
create MessageBox on Window
347+
style question
348+
title `System clear`
349+
message `This will remove all devices from ` cat SystemsCombo
350+
cat `. Continue?`
351+
show MessageBox giving Value
352+
if Value is `Yes`
353+
begin
354+
put SystemsCombo into Name
355+
put property Name of Systems into SystemConfig
356+
put property `mac` of SystemConfig into MAC
357+
put property `password` of SystemConfig into Password
358+
put json `{}` into Devices
359+
set property `devices` of SystemConfig to Devices
360+
set property Name of Systems to SystemConfig
361+
set property `systems` of Config to Systems
362+
post stringify SystemConfig to
363+
`https://rbrheating.com/ui/resources/php/rest.php/config/`
364+
cat MAC cat `/` cat Password
365+
or begin
366+
log `I couldn't post the config file`
367+
stop
368+
end
369+
disable RemoveSystemButton
370+
set the text of MasterDeviceButton to `(none)`
371+
clear SlaveList
372+
end
373+
stop
374+
375+
ScanNetworkClick:
376+
log `Scan the network for new devices`
377+
stop
378+
379+
MasterDeviceClick:
380+
log MasterDeviceButton
381+
if MasterDeviceButton is not empty
382+
begin
383+
log `Select the master device`
384+
set the text of DeviceNameInput to MasterDeviceName
385+
enable UpdateDeviceButton
386+
enable DeleteFileButton
387+
disable DeleteSlaveButton
388+
end
329389
stop
330390

331391
SelectSlaveClick:
332-
log `Select a slave device`
392+
log `Select ` cat SlaveList
393+
set the text of DeviceNameInput to SlaveList
394+
enable UpdateDeviceButton
395+
enable DeleteSlaveButton
396+
enable DeleteFileButton
333397
stop
334398

335-
UpdateSlaveClick:
399+
UpdateDeviceClick:
336400
log `Update the files om the selected device`
337401
stop
338402

@@ -344,12 +408,6 @@ DeleteSlaveClick:
344408
log `Delete the selected slave device`
345409
stop
346410

347-
ExitClick:
348-
log `Exit the configurator`
349-
save stringify Config to ConfigFile
350-
close Window
351-
exit
352-
353411
ScanSystemsClick:
354412
log `Scan systems`
355413
gosub to ScanSystems
@@ -358,7 +416,9 @@ ScanSystemsClick:
358416
stop
359417

360418
SystemsComboSelect:
361-
set property `current` of Config to SystemsCombo
419+
put SystemsCombo into Name
420+
set property `current` of Config to Name
421+
gosub to SetupSystem
362422
stop
363423

364424
RemoveSystemClick:
@@ -367,7 +427,7 @@ RemoveSystemClick:
367427
create MessageBox on Window
368428
style question
369429
title `Remove system`
370-
message `Are you sure you want to remove ` cat Name cat `?`
430+
message `Continue you want to remove ` cat Name cat `?`
371431
show MessageBox giving Value
372432
if Value is `Yes`
373433
begin
@@ -394,6 +454,12 @@ RelayOnClick:
394454
log `Turn the relay ON`
395455
stop
396456

457+
ExitClick:
458+
log `Exit the configurator`
459+
save stringify Config to ConfigFile
460+
close Window
461+
exit
462+
397463
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
398464
! Subroutines
399465

@@ -542,6 +608,7 @@ ScanSystems:
542608
gosub to Working
543609
get Result from url `http://` cat IPAddr cat `:17348/cgi-bin/mac.py` timeout 1 or go to SS2
544610
put trim Result into Result
611+
log IPAddr cat `: ` cat Result
545612
put the position of ` ` in Result into P
546613
put left P of Result into MAC
547614
increment P
@@ -579,7 +646,9 @@ GetConfigData:
579646
or log `Can't read the config file for ` cat Name
580647
! log Value cat newline
581648
put json Value into Value
582-
set property `devices` of SystemConfig to property `devices` of Value
649+
if Value has property `devices`
650+
set property `devices` of SystemConfig to property `devices` of Value
651+
else set property `devices` of SystemConfig to json `{}`
583652
set property Name of Systems to SystemConfig
584653
increment S
585654
end
@@ -604,11 +673,14 @@ RefreshSystemsCombo:
604673
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
605674
! Set up the system, given its name
606675
SetupSystem:
676+
if Name is empty return
607677
put property Name of Systems into System
608678
put property `devices` of System into Devices
609679
put the keys of Devices into Keys
610680
put empty into MasterDevice
681+
set the text of MasterDeviceButton to `(none)`
611682
put json `[]` into SlaveDevices
683+
clear SlaveList
612684
put 0 into D
613685
while D is less than the count of Keys
614686
begin
@@ -619,7 +691,8 @@ SetupSystem:
619691
put Device into MasterDevice
620692
put property `ssid` of MasterDevice into MasterSSID
621693
put property `ipaddr` of MasterDevice into MasterIPAddr
622-
set the text of MasterDeviceLabel to MasterSSID cat ` ` cat Name cat ` ` cat MasterIPAddr
694+
put Name into MasterDeviceName
695+
set the text of MasterDeviceButton to MasterSSID cat ` ` cat MasterIPAddr cat ` ` cat Name
623696
end
624697
else
625698
begin
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__ = "250425.1"
12+
__version__ = "250427.1"

easycoder/ec_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def compileToken(self):
168168
self.rewindTo(mark)
169169
else:
170170
self.rewindTo(mark)
171-
FatalError(self, f'Unable to compile "{token}" (in this context)')
171+
FatalError(self, f'Unable to compile this "{token}" command. Perhaps a syntax error?')
172172

173173
# Compile a single command
174174
def compileOne(self):

easycoder/ec_pyside6.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@ def r_createLabel(self, command, record):
424424
return self.nextPC()
425425

426426
def r_createPushbutton(self, command, record):
427-
pushbutton = QPushButton(self.getRuntimeValue(command['text']))
427+
text = self.getRuntimeValue(command['text'])
428+
pushbutton = QPushButton(text)
429+
pushbutton.setAccessibleName(text)
428430
if 'size' in command:
429431
fm = pushbutton.fontMetrics()
430432
c = pushbutton.contentsMargins()
@@ -689,7 +691,7 @@ def r_select(self, command):
689691
return self.nextPC()
690692

691693
# set [the] height [of] {groupbox} [to] {height}
692-
# set [the] text [of] {label}/{button} [to] {text}
694+
# set [the] text [of] {label}/{button}/{lineinput} [to] {text}
693695
def k_set(self, command):
694696
self.skip('the')
695697
token = self.nextToken()
@@ -709,7 +711,7 @@ def k_set(self, command):
709711
self.skip('of')
710712
if self.nextIsSymbol():
711713
record = self.getSymbolRecord()
712-
if record['keyword'] in ['label', 'pushbutton']:
714+
if record['keyword'] in ['label', 'pushbutton', 'lineinput']:
713715
command['name'] = record['name']
714716
self.skip('to')
715717
command['value'] = self.nextValue()
@@ -723,8 +725,12 @@ def r_set(self, command):
723725
groupbox = self.getVariable(command['name'])['widget']
724726
groupbox.setFixedHeight(self.getRuntimeValue(command['value']))
725727
elif what == 'text':
728+
record = self.getVariable(command['name'])
726729
widget = self.getVariable(command['name'])['widget']
727-
widget.setText(self.getRuntimeValue(command['value']))
730+
text = self.getRuntimeValue(command['value'])
731+
widget.setText(text)
732+
if record['keyword'] == 'pushbutton':
733+
widget.setAccessibleName(text)
728734
return self.nextPC()
729735

730736
# show {window}
@@ -861,7 +867,13 @@ def modifyValue(self, value):
861867
def v_symbol(self, symbolRecord):
862868
symbolRecord = self.getVariable(symbolRecord['name'])
863869
keyword = symbolRecord['keyword']
864-
if keyword == 'lineinput':
870+
if keyword == 'pushbutton':
871+
pushbutton = symbolRecord['widget']
872+
v = {}
873+
v['type'] = 'text'
874+
v['content'] = pushbutton.accessibleName()
875+
return v
876+
elif keyword == 'lineinput':
865877
lineinput = symbolRecord['widget']
866878
v = {}
867879
v['type'] = 'text'
@@ -873,6 +885,13 @@ def v_symbol(self, symbolRecord):
873885
v['type'] = 'text'
874886
v['content'] = combobox.currentText()
875887
return v
888+
elif keyword == 'listbox':
889+
listbox = symbolRecord['widget']
890+
content = listbox.currentItem().text()
891+
v = {}
892+
v['type'] = 'text'
893+
v['content'] = content
894+
return v
876895
return None
877896

878897
def v_count(self, v):

0 commit comments

Comments
 (0)