18
18
label Label
19
19
label RelayStateLabel
20
20
label StatusLabel
21
+ label UptimeLabel
21
22
pushbutton ResetConfigButton
23
+ pushbutton RBRNowDirectoryButton
22
24
pushbutton ScanDevicesButton
23
25
pushbutton ClearSystemButton
24
26
pushbutton RemoveSlaveButton
63
65
on click ResetConfigButton go to ResetConfigFileClick
64
66
add ResetConfigButton to LeftPanel
65
67
68
+ create RBRNowDirectoryButton text `Get the RBR-Now directory`
69
+ on click RBRNowDirectoryButton go to RBRNowDirectoryClick
70
+ add RBRNowDirectoryButton to LeftPanel
71
+
66
72
create ClearSystemButton text `Clear the selected system`
67
73
on click ClearSystemButton go to ClearSystemClick
68
74
add ClearSystemButton to LeftPanel
151
157
add Label to Layout
152
158
create DeviceNameInput size 40
153
159
add DeviceNameInput to Layout
160
+ create Label text `Uptime:`
161
+ add Label to Layout
162
+ create UptimeLabel text `0`
163
+ add UptimeLabel to Layout
164
+ create Label text `sec`
165
+ add Label to Layout
154
166
add stretch to Layout
155
167
156
168
create Layout type QHBoxLayout
273
285
variable Files
274
286
variable Count
275
287
variable Content
288
+ variable Uptime
276
289
variable APInfo
277
290
variable Info
278
291
variable Keys
@@ -302,6 +315,10 @@ Start:
302
315
if Config does not have property `current-system` set property `current-system` of Config to empty
303
316
put property `hosts` of Config into Hosts
304
317
318
+ put empty into SystemHostSSID
319
+ put empty into SystemIPAddr
320
+ clear DeviceSelected
321
+
305
322
! Get the host SSID
306
323
put `Getting host SSID...` into StatusMessage
307
324
gosub to Working
@@ -320,6 +337,8 @@ Start:
320
337
put `Connected to ` cat HostSSID into StatusMessage
321
338
gosub to Idle
322
339
340
+ gosub to CheckFirmware
341
+
323
342
! Get the list of systems from Config, or create an empty list. Then populate the combo box
324
343
if Config has property `systems` put property `systems` of Config into Systems
325
344
else
@@ -329,12 +348,6 @@ Start:
329
348
end
330
349
gosub to RefreshSystemsCombo
331
350
332
- put empty into SystemHostSSID
333
- put empty into SystemIPAddr
334
- clear DeviceSelected
335
- put trim system `echo $HOME` into FirmwareDirectory
336
- put FirmwareDirectory cat `/dev/rbr/roombyroom/Controller/home/orangepi/firmware/NOW/` into FirmwareDirectory
337
-
338
351
! Select the current system
339
352
if the count of SystemsCombo is 0 put empty into SystemName
340
353
else
@@ -551,6 +564,42 @@ ClearSystemClick:
551
564
gosub to OK
552
565
stop
553
566
567
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
568
+ ! Get the RBR-Now directory and save it.
569
+ RBRNowDirectoryClick:
570
+ gosub to GetFirmware
571
+ gosub to CheckFirmware3
572
+ stop
573
+
574
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
575
+ ! Check if we have a valid firmware directory.
576
+ CheckFirmware:
577
+ if Config has property `firmware` put property `firmware` of Config into FirmwareDirectory
578
+ else put empty into FirmwareDirectory
579
+ CheckFirmware2:
580
+ if file FirmwareDirectory cat `/files.txt` exists
581
+ begin
582
+ set property `firmware` of Config to FirmwareDirectory
583
+ save prettify Config to ConfigFile
584
+ go to OK
585
+ end
586
+ put `Firmware directory is missing` into StatusMessage
587
+ gosub to Error
588
+ gosub to GetFirmware
589
+ CheckFirmware3:
590
+ if ReturnValue is empty return
591
+ put trim system `echo $HOME` cat `/` cat ReturnValue into FirmwareDirectory
592
+ go to CheckFirmware2
593
+
594
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
595
+ ! Get the RBR-Now firmware
596
+ GetFirmware:
597
+ put `RBR-Now firmware` into Title
598
+ put `Get the directory containing the RBR-Now firmware`
599
+ cat newline cat `(relative to your home directory)` into Prompt
600
+ put 80 into Length
601
+ go to GetRequestedText
602
+
554
603
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
555
604
! Scan the local network for new devices
556
605
ScanForDevicesClick:
@@ -868,7 +917,8 @@ PopulateSystemInfo:
868
917
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
869
918
! Update text on MasterDeviceButton
870
919
SetMasterDeviceButtonText:
871
- set the text of MasterDeviceButton to MasterSSID cat ` ` cat MasterIPAddr cat ` ` cat MasterDeviceName
920
+ ! set the text of MasterDeviceButton to MasterSSID cat ` ` cat MasterIPAddr cat ` ` cat MasterDeviceName
921
+ set the text of MasterDeviceButton to MasterSSID cat ` ` cat MasterDeviceName
872
922
return
873
923
874
924
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -893,7 +943,10 @@ PopulateDeviceInfo:
893
943
if Device has property `name`
894
944
begin
895
945
log `Populate device ` cat property `name` of Device
946
+ gosub to CheckDevice
896
947
set the text of DeviceNameInput to property `name` of Device
948
+ set the text of UptimeLabel to Uptime
949
+ set the text of RelayStateLabel to `???`
897
950
set the text of PathInput to property `path` of Device
898
951
put property `pins` of Device into Pins
899
952
put property `led` of Pins into Pin
@@ -970,6 +1023,7 @@ GetHostPassword:
970
1023
log `Get the host password`
971
1024
put `Type the host password:` into Prompt
972
1025
put `Host password` into Title
1026
+ put 40 into Length
973
1027
gosub to GetRequestedText
974
1028
put ReturnValue into HostPassword
975
1029
return
@@ -982,7 +1036,7 @@ GetRequestedText:
982
1036
add Label to VLayout
983
1037
create HLayout type QHBoxLayout
984
1038
add HLayout to VLayout
985
- create LineInput size 40
1039
+ create LineInput size Length
986
1040
add stretch LineInput to HLayout
987
1041
create HLayout type QHBoxLayout
988
1042
add HLayout to VLayout
@@ -1134,14 +1188,6 @@ UpdateWidgetDataClick:
1134
1188
gosub to ManageButtonStates
1135
1189
stop
1136
1190
1137
- RelayOffClick:
1138
- log `Turn the relay OFF`
1139
- stop
1140
-
1141
- RelayOnClick:
1142
- log `Turn the relay ON`
1143
- stop
1144
-
1145
1191
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1146
1192
! Update all the files on a device
1147
1193
UpdateFilesClick:
@@ -1262,6 +1308,7 @@ SendFileFail:
1262
1308
DeleteFileClick:
1263
1309
put `Name of file to delete:` into Prompt
1264
1310
put `Delete file` into Title
1311
+ put 40 into Length
1265
1312
gosub to GetRequestedText
1266
1313
if ReturnValue is not empty
1267
1314
begin
@@ -1299,6 +1346,67 @@ RequestReset:
1299
1346
put `Device ` cat Name cat ` has been reset` into StatusMessage
1300
1347
go to Working
1301
1348
1349
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1350
+ ! Check a device
1351
+ CheckDevice:
1352
+ put `uptime` into Message
1353
+ gosub to SendRBRMessage
1354
+ if Response is empty
1355
+ begin
1356
+ put `No response from ` cat Name into StatusMessage
1357
+ gosub to Error
1358
+ put 0 into Uptime
1359
+ end
1360
+ else put from 3 of Response into Uptime
1361
+
1362
+ CheckDevice2:
1363
+ put the position of ` ` in Uptime into P
1364
+ put left P of Uptime into Uptime
1365
+ log Name cat ` uptime: ` cat Uptime
1366
+ set the text of UptimeLabel to Uptime
1367
+ return
1368
+
1369
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1370
+ ! Turn a relay OFF
1371
+ RelayOffClick:
1372
+ log `Turn the relay OFF`
1373
+ put `off` into Message
1374
+ gosub to SendRBRMessage
1375
+ log `ON: ` cat Response
1376
+ if Response is empty
1377
+ begin
1378
+ put `No response from ` cat Name into StatusMessage
1379
+ gosub to Error
1380
+ put 0 into Uptime
1381
+ end
1382
+ begin
1383
+ put from 3 of Response into Uptime
1384
+ set the text of RelayStateLabel to `OFF`
1385
+ end
1386
+ gosub to CheckDevice2
1387
+ stop
1388
+
1389
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1390
+ ! Turn a relay ON
1391
+ RelayOnClick:
1392
+ log `Turn the relay ON`
1393
+ put `on` into Message
1394
+ gosub to SendRBRMessage
1395
+ log `ON: ` cat Response
1396
+ if Response is empty
1397
+ begin
1398
+ put `No response from ` cat Name into StatusMessage
1399
+ gosub to Error
1400
+ put 0 into Uptime
1401
+ end
1402
+ else
1403
+ begin
1404
+ put from 3 of Response into Uptime
1405
+ set the text of RelayStateLabel to `ON`
1406
+ end
1407
+ gosub to CheckDevice2
1408
+ stop
1409
+
1302
1410
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1303
1411
! Send an RBR-Now message to a device
1304
1412
SendRBRMessage:
0 commit comments