ASPL Manual v 1.00
© 2024 by SetSphere.COM
[WATER LEVEL BETWEEN BAY1 AND BAY2]
WORKSPACE BAYS12MON DESCRIPTION:
This example shows how you can tie attributes to sensors and have an attribute with anonymous function to process the data collected by these tied attributes. In what follows, the ASPL commands are these that start with aspl> and the UNIX shell commands start with hash #
This sample workspace has the grouping class BAYLEVELGROUP that we created with the following command:
# metagrouping -creategrouping BAYLEVELGROUP -attributes "point1,t" "point2,t" "point3,t" \ "mean123,c,__mean123 point1 point2 point3 /[0.0,4.99] 1-5feet/[5.0,6.5] 5-6feet/>6.5 above7feet/" \ "point4,t" "point5,t" "point6,t" \ "mean456,c,__mean456 point4 point5 point6 /[0.0,4.99] 1-5feet/[5.0,6.5] 5-6feet/>6.5 above7feet/"
Now we start ASPL with a workspace named BAYS12MON whose grouping class is BAYLEVELGROUP
We do a simulation to monitor the water level between BAY1 and BAY2. We have the sensors on BAY1 attached (tied) to point1, point2, and point3; and the sensors on BAY2 attached (tied) to point4, point5, and point6.
# aspl -wsname BAYS12MON -groupingclass BAYLEVELGROUP
(start ASPL loading the sample workspace BAYS12MON)
① aspl> egCwhoami
(ping the currently loaded grouping class)
② aspl> attributes
(display the attributes of the grouping class)
③ aspl> waterlevelday1 = ggbaylevel()
(today water level assigned to waterlevelday1)
④ aspl> ?45,1 waterlevelday1
(interrogate waterlevelday1 45 times with 1 second delay)
⑤ aspl> split waterlevelday1 into BAY1 BAY2 CRITICAL GOOD WARN
(split waterlevelday1 into the five groups)
⑥ aspl> ks mean123 mtime aelm
(set ks vector to mean123 mtime aelm)
⑦ aspl> f&`ks= CRITICAL BAY1 BAY2
(display when BAY1 and BAY2 are CRITICAL level)
⑧ aspl> f&`ks= WARN BAY1 BAY2
(display when BAY1 and BAY2 are WARN level)
⑨ aspl> f&`ks= CRITICAL BAY1
(display when BAY1 is at CRITICAL level)
⑩ aspl> f&`ks= CRITICAL BAY2
(display when BAY2 is at CRITICAL level)
⑪ aspl> DEF FN critical := {fU {f&`ks= CRITICAL BAY1}{f&`ks= CRITICAL BAY2}}
(define function critical())
⑫ aspl> DEF FN warn := {fU {f&`ks= CRITICAL BAY1}{f&`ks= CRITICAL BAY2}{f&`ks= WARN BAY1}{f&`ks= WARN BAY2}}
(define function warn())
⑬ aspl> FN critical()
(call function critical())
⑭ aspl> FN warn()
(call function warn())
See also bay12mon.pl that shows how to monitor the water level by looping periodically and send email notification when it is critical.
[Top Text]
1. #!/usr/bin/perl 2. 3. use strict; 4. 5. my $interpreter = "aspl -groupingclass BAYLEVELGROUP -wsname TRANSIENT"; 6. 7. for (1..17) { 8. open(ASPL, "| $interpreter -STDIN") or die "ERROR OPENING A PIPE TO aspl: $! \n"; 9. print ASPL <<END; 10. ;;redirecttoemail bassem\@localhost 11. displayoff 12. ks mean123 mtime aelm 13. x = ggbaylevel() 14. split x into BAY1 BAY2 CRITICAL GOOD WARN 15. displayon 16. {fU {f&`ks= CRITICAL BAY1} {f&`ks= CRITICAL BAY2}} 17. END 18. close ASPL; 19. sleep 1; 20. } 21. 22.
Figure BAYS12MON-img0.png
Figure BAYS12MON-img1.png
Figure BAYS12MON-img2.png
This example is shown in the following terminal.
terminal for example: WATER LEVEL BETWEEN BAY1 AND BAY2