ASPL Programming ver 1.00
© 2024 Bassem W. Jamaleddine


11-13

   WATER LEVEL BETWEEN BAY1 AND BAY2

[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 #

First, we created a grouping class BAYLEVELGROUP 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/"

Second, we started ASPL with a workspace named BAYS12MON whose grouping class is BAYLEVELGROUP

# aspl -wsname BAYS12MON -groupingclass BAYLEVELGROUP

Now 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> egCwhoami
    (ping the currently loaded grouping class)

②  aspl> attributes
    (display the attributes of the grouping class)

Here notice that point1,point2,... attributes are of 'tie' type.

③  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())

End of simulation, and that is it!

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]

 -L- Listing. 11.13.1   [Perl Script to Monitor Water Level With Email Notification][Perl Script to Monitor Water Level With Email Notification]
(raw 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.     

ASPL (C) 2024 Bassem Jamaleddine

       Figure BAYS12MON-img0.png
full view

Image File

 -F- Fig. 11.13.1   [Figure Monitoring Water Level With Tied Attributes - View1]
ASPL (C) 2024 Bassem Jamaleddine

       Figure BAYS12MON-img1.png
full view

Image File

 -F- Fig. 11.13.2   [Figure Monitoring Water Level With Tied Attributes - View2]
ASPL (C) 2024 Bassem Jamaleddine

       Figure BAYS12MON-img2.png
full view

Image File

 -F- Fig. 11.13.3   [Figure Monitoring Water Level With Tied Attributes - View3]
ASPL (C) 2024 Bassem Jamaleddine

This example is shown in the following terminal.

       terminal for example: WATER LEVEL BETWEEN BAY1 AND BAY2
viewme

 -E- Display. 11.13.1   [WATER LEVEL BETWEEN BAY1 AND BAY2][WATER LEVEL BETWEEN BAY1 AND BAY2]
Terminal showing WATER LEVEL BETWEEN BAY1 AND BAY2