Skip to content

Commit ffdce38

Browse files
committed
250430.1
1 parent a3d9e19 commit ffdce38

File tree

7 files changed

+155
-81
lines changed

7 files changed

+155
-81
lines changed

config.ecs

Lines changed: 106 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
label Label
1919
label RelayStateLabel
2020
label StatusLabel
21+
label SSIDLabel
2122
pushbutton ResetConfigButton
2223
pushbutton ScanDevicesButton
2324
pushbutton ClearSystemButton
24-
pushbutton DeleteSlaveButton
25+
pushbutton RemoveSlaveButton
2526
pushbutton UpdateDeviceButton
2627
pushbutton DeleteFileButton
2728
pushbutton ExitButton
@@ -30,12 +31,11 @@
3031
pushbutton MasterDeviceButton
3132
pushbutton RelayOffButton
3233
pushbutton RelayOnButton
33-
pushbutton SaveWidgetDataButton
34+
pushbutton UpdateWidgetDataButton
3435
pushbutton OKButton
3536
pushbutton CancelButton
3637
lineinput LineInput
3738
lineinput DeviceNameInput
38-
lineinput ChannelInput
3939
lineinput LEDPinInput
4040
lineinput RelayPinInput
4141
lineinput DHT22PinInput
@@ -82,9 +82,9 @@
8282
add DeleteFileButton to LeftPanel
8383
on click DeleteFileButton go to DeleteFileClick
8484

85-
create DeleteSlaveButton text `Delete slave`
86-
add DeleteSlaveButton to LeftPanel
87-
on click DeleteSlaveButton go to DeleteSlaveClick
85+
create RemoveSlaveButton text `Remove slave`
86+
add RemoveSlaveButton to LeftPanel
87+
on click RemoveSlaveButton go to RemoveSlaveClick
8888

8989
add stretch to LeftPanel
9090

@@ -152,10 +152,10 @@
152152
add Label to Layout
153153
create DeviceNameInput size 40
154154
add DeviceNameInput to Layout
155-
create Label text `Channel:`
155+
create Label text `SSID:`
156156
add Label to Layout
157-
create ChannelInput size 5
158-
add ChannelInput to Layout
157+
create SSIDLabel
158+
add SSIDLabel to Layout
159159
add stretch to Layout
160160

161161
create Layout type QHBoxLayout
@@ -199,15 +199,14 @@
199199
create Label text `Path:`
200200
add Label to Layout
201201
create PathInput size 60
202+
set the width of PathInput to 250
202203
add PathInput to Layout
203204
add stretch to Layout
204205

205-
! The 'Save' button
206-
create Layout type QVBoxLayout
207-
add Layout to DeviceHPanel
208-
create SaveWidgetDataButton text `Save`
209-
on click SaveWidgetDataButton go to SaveWidgetData
210-
add SaveWidgetDataButton to Layout
206+
! The 'Update' button
207+
create UpdateWidgetDataButton text `Update`
208+
on click UpdateWidgetDataButton go to UpdateWidgetDataClick
209+
add UpdateWidgetDataButton to DeviceHPanel
211210

212211
add stretch to RightPanel
213212

@@ -222,6 +221,7 @@
222221

223222
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
224223

224+
stack Stack
225225
variable Config
226226
variable ConfigFile
227227
variable Name
@@ -248,7 +248,6 @@
248248
variable Message2
249249
variable Response
250250
variable Systems
251-
variable System
252251
variable Devices
253252
variable Device
254253
variable MasterDevice
@@ -278,6 +277,7 @@
278277
variable Pins
279278
variable Pin
280279
variable D
280+
variable K
281281
variable N
282282
variable P
283283
variable S
@@ -291,7 +291,7 @@ Start:
291291
! Disable various buttons
292292
disable ClearSystemButton
293293
disable ScanDevicesButton
294-
disable DeleteSlaveButton
294+
disable RemoveSlaveButton
295295
disable UpdateDeviceButton
296296
disable DeleteFileButton
297297

@@ -345,7 +345,6 @@ Start:
345345
begin
346346
select Name in SystemsCombo
347347
enable ClearSystemButton
348-
gosub to SetupSystem
349348
end
350349

351350
enable ScanSystemsButton
@@ -390,7 +389,6 @@ ClearSystemClick:
390389
put json `{}` into Devices
391390
set property `devices` of SystemConfig to Devices
392391
set property Name of Systems to SystemConfig
393-
set property `systems` of Config to Systems
394392
set the text of MasterDeviceButton to `(none)`
395393
put empty into MasterSSID
396394
clear SlaveList
@@ -484,7 +482,6 @@ ScanForDevicesClick:
484482
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
485483
! Show information about the master device
486484
MasterDeviceClick:
487-
log MasterDeviceButton
488485
if MasterDeviceButton is not empty
489486
begin
490487
log `Select the master device`
@@ -497,9 +494,10 @@ MasterDeviceClick:
497494
! Show information about a slave device
498495
SelectSlaveClick:
499496
log `Select ` cat SlaveList
500-
set the text of DeviceNameInput to SlaveList
497+
put property SlaveList of Devices into Device
498+
gosub to PopulateDeviceInfo
501499
enable UpdateDeviceButton
502-
enable DeleteSlaveButton
500+
enable RemoveSlaveButton
503501
enable DeleteFileButton
504502
stop
505503

@@ -511,8 +509,32 @@ DeleteFileClick:
511509
log `Delete a file on the selected device`
512510
stop
513511

514-
DeleteSlaveClick:
515-
log `Delete the selected slave device`
512+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
513+
! Remove a slave from the list
514+
RemoveSlaveClick:
515+
log `Remove the selected slave device`
516+
put SlaveList into Name
517+
log Name
518+
remove the selected item from SlaveList
519+
put the keys of Devices into Keys
520+
put 0 into D
521+
while D is less than the count of Keys
522+
begin
523+
put element D of Keys into Name
524+
put property Name of Devices into Device
525+
if property `master` of Device is false
526+
begin
527+
if property `name` of Device is Name
528+
begin
529+
delete property Name of Devices
530+
! set property `devices` of SystemConfig to Devices
531+
put property `name` of SystemConfig into Name
532+
set property Name of Systems to SystemConfig
533+
stop
534+
end
535+
end
536+
increment D
537+
end
516538
stop
517539

518540
ScanSystemsClick:
@@ -540,7 +562,7 @@ RemoveSystemClick:
540562
show MessageBox giving Value
541563
if Value is `Yes`
542564
begin
543-
remove current item from SystemsCombo
565+
remove the current item from SystemsCombo
544566
delete property Name of Systems
545567
set property `systems` of Config to Systems
546568
end
@@ -551,8 +573,13 @@ SaveHostInfoClick:
551573
log `Save the host information`
552574
stop
553575

554-
SaveWidgetDataClick:
555-
log `Save the widget data`
576+
UpdateWidgetDataClick:
577+
log Device
578+
set property `name` of Device to DeviceNameInput
579+
log Device
580+
put property `ssid` of Device into SSID
581+
put from 8 of SSID into MAC
582+
gosub to SendConfigFile
556583
stop
557584

558585
RelayOffClick:
@@ -565,7 +592,8 @@ RelayOnClick:
565592

566593
ExitClick:
567594
log `Exit the configurator`
568-
save stringify Config to ConfigFile
595+
! delete property `(none)` of Config
596+
save prettify Config to ConfigFile
569597
close Window
570598
exit
571599

@@ -766,21 +794,32 @@ GetConfigData:
766794
while S is less than the count of Keys
767795
begin
768796
put element S of Keys into Name
797+
! SystemConfig holds the data for a single system; Systems holds all of the SystemConfigs by system name
798+
! Get the data for this system
769799
put property Name of Systems into SystemConfig
770-
put property `mac` of SystemConfig into MAC
771-
put property `password` of SystemConfig into Password
800+
put property `mac` of SystemConfig into SystemMAC
801+
put property `password` of SystemConfig into SystemPassword
772802
get Value from url `https://rbrheating.com/ui/resources/php/rest.php/config/`
773-
cat MAC cat `/` cat Password
803+
cat SystemMAC cat `/` cat SystemPassword
774804
or
775805
begin
776806
put `Can't read the config file for ` cat Name cat `(` cat MAC cat `/` cat Password cat `)` into StatusMessage
777807
go to Error
778808
end
779-
! log Value cat newline
780809
put json Value into Value
781-
if Value has property `devices`
782-
set property `devices` of SystemConfig to property `devices` of Value
783-
else set property `devices` of SystemConfig to json `{}`
810+
push Name onto Stack
811+
push Keys onto Stack
812+
put the keys of Value into Keys
813+
put 0 into K
814+
while K is less than the count of Keys
815+
begin
816+
put element K of Keys into Name
817+
put property Name of Value into Item
818+
set property Name of SystemConfig to Item
819+
increment K
820+
end
821+
pop Keys from Stack
822+
pop Name from Stack
784823
set property Name of Systems to SystemConfig
785824
increment S
786825
end
@@ -806,10 +845,10 @@ RefreshSystemsCombo:
806845
! Set up the system, given its name
807846
SetupSystem:
808847
if Name is empty return
809-
put property Name of Systems into System
810-
put property `mac` of System into SystemMAC
811-
put property `password` of System into SystemPassword
812-
put property `devices` of System into Devices
848+
put property Name of Systems into SystemConfig
849+
put property `mac` of SystemConfig into SystemMAC
850+
put property `password` of SystemConfig into SystemPassword
851+
put property `devices` of SystemConfig into Devices
813852
put the keys of Devices into Keys
814853
put empty into MasterDevice
815854
set the text of MasterDeviceButton to `(none)`
@@ -890,17 +929,14 @@ SetupDevice:
890929
if MasterSSID is empty
891930
begin
892931
set IsMaster
893-
log `Deal with slave ` cat Name
932+
log `Deal with master ` cat Name
894933
put SSID into MasterSSID
895934
put Name into MasterDeviceName
896935
gosub to CreateDevice
897936
put Device into MasterDevice
898-
! Send the config data to the device
899-
put `config.json` into FileName
900-
put stringify MasterDevice into Content
901937
put MAC into MasterMAC
902938
put IPAddr into MasterIPAddr
903-
gosub to SendFileToDevice
939+
gosub to SendConfigFile
904940
if SendFail return
905941
gosub to RequestReset
906942
if SendFail return
@@ -911,6 +947,8 @@ SetupDevice:
911947
put MasterSSID cat ` ` cat MasterName into StatusMessage
912948
gosub to Working
913949
disable MasterDeviceButton
950+
951+
! Get the master IP address
914952
put `http://` cat MasterIPAddr cat `/?mac=` cat MasterMAC cat `&msg=ipaddr` into URL
915953
put `Interrogate the master device` into StatusMessage
916954
gosub to Working
@@ -926,33 +964,27 @@ SetupDevice:
926964
gosub to Idle
927965
set the text of MasterDeviceButton to MasterSSID cat ` ` cat MasterName cat ` ` cat MasterIPAddr cat ` ` cat Name
928966
set property `ipaddr` of MasterDevice to MasterIPAddr
929-
set property MasterName of Devices to MasterDevice
930-
set property `devices` of Config to Devices
931967
end
932968
else
933969
begin
934-
delete property Name of Devices
935-
set property `devices` of Config to Devices
936970
put `Failed to get Master ip address` into StatusMessage
937971
go to Error
938972
end
939-
disable DeleteSlaveButton
973+
disable RemoveSlaveButton
940974
enable MasterDeviceButton
941975
put MasterDevice into Device
942976
gosub to PopulateDeviceInfo
943977
end
944978
else
945979
begin
980+
clear IsMaster
946981
log `Deal with slave ` cat Name
982+
put the position of ` ` in Name into N
983+
increment N
984+
put from N of Name into Name
947985
append SSID cat ` ` cat Name to SlaveDevices
948986
set SlaveList to SlaveDevices
949-
clear IsMaster
950987
gosub to CreateDevice
951-
put `config.json` into FileName
952-
put stringify Device into Content
953-
put from 8 of SSID into MAC
954-
gosub to SendFileToDevice
955-
gosub to RequestReset
956988
end
957989
return
958990

@@ -987,7 +1019,9 @@ CreateDevice:
9871019
set property `dht22` of Pins to Pin
9881020
set property `pins` of Device to Pins
9891021
set property Name of Devices to Device
990-
set property `devices` of Config to Devices
1022+
set property `devices` of SystemConfig to Devices
1023+
set property Name of Systems to SystemConfig
1024+
set property `systems` of Config to Systems
9911025
return
9921026

9931027
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1011,12 +1045,22 @@ ConnectToDevice:
10111045
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10121046
! Populate the device information fields
10131047
PopulateDeviceInfo:
1014-
log `Populate device ` cat property `name` of Device
1015-
set the text of DeviceNameInput to property `name` of Device
1016-
enable UpdateDeviceButton
1017-
enable DeleteFileButton
1048+
if Device has property `name`
1049+
begin
1050+
log `Populate device ` cat property `name` of Device
1051+
set the text of DeviceNameInput to property `name` of Device
1052+
set the text of SSIDLabel to property `ssid` of Device
1053+
enable UpdateDeviceButton
1054+
enable DeleteFileButton
1055+
end
10181056
return
10191057

1058+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1059+
! Send the config file to a device
1060+
SendConfigFile:
1061+
put `config.json` into FileName
1062+
put stringify Device into Content
1063+
10201064
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10211065
! Send a file to a device
10221066
SendFileToDevice:
@@ -1128,7 +1172,7 @@ SendRBRMessage:
11281172
SendMessageToDevice:
11291173
gosub to GetDeviceData
11301174
put left 30 of Message into Message2
1131-
! log `Send '` cat Message2 cat `' to ` cat Name
1175+
log `Send '` cat Message2 cat `' to ` cat Name
11321176
put Message into Message2
11331177
if Path is not empty
11341178
begin
@@ -1147,6 +1191,7 @@ SendMessageToDevice:
11471191
end
11481192
end
11491193
put `http://` cat MasterIPAddr cat `/?mac=` cat MAC cat `&msg=` cat Message2 into URL
1194+
log URL
11501195
get Response from url URL
11511196
or begin
11521197
put `Could not message ` cat Name into StatusMessage
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__ = "250429.1"
12+
__version__ = "250430.1"

0 commit comments

Comments
 (0)