Houselight day/night control species: any
Maintainer none Current version 0.1 View the changelog
Original Author Gary Bamberger Date last modified Mar-7-2005
License BSD MED-PC version 4
Example code for controlling the houselight based on the time obtained from the computer.
No references given. Click to e-mail a reference to the maintainer.
Code
How to use this code Download the code Download an example macro Download the profile
\ Outputs
^HouseLight = 7


\ A() = Control Variable with Assigned Aliases as Defined
Var_Alias HouseLight On Hour  = A(0)  \ Default = 7  (07:00 Hours or 7AM)
Var_Alias HouseLight On Min   = A(1)  \ Default = 0  (07:00 Hours or 7AM)
Var_Alias HouseLight Off Hour = A(2)  \ Default = 19 (19:00 Hours or 7PM)
Var_Alias HouseLight Off Min  = A(3)  \ Default = 0  (19:00 Hours or 7PM)


\ List Working Variables Here
\  H = Hour     (DOS Time)
\  M = Minutes  (DOS Time)
\  S = Seconds  (DOS Time)


DIM A = 3


\******************************************************
\  S1 - Set Default Values
\       HouseLight On Hour  (7  or 07:00 Hours or 7AM)
\       HouseLight On Min   (0  or 07:00 Hours or 7AM)
\       HouseLight Off Hour (19 or 19:00 Hours or 7PM)
\       HouseLight Off Min  (0  or 19:00 Hours or 7PM)
\******************************************************
S.S.1,
S1,
  0.01": SET A(0) = 7, A(1) = 0, A(2) = 19, A(3) = 0 ---> S2


\***************************************************
\                HOUSE LIGHT CONTROL
\***************************************************
S.S.4,
S1,     \ Check if HouseLight Should be Turned On
  #START: TIME H, M, S;
          IF A(2) >= A(0) [@CheckSeq1, @CheckSeq2]
             @Seq1: IF (H > A(0)) AND (H < A(2)) [@LightOn, @CheckMin]
                       @LightOn: ON ^HouseLight ---> S2
                       @CheckMin: IF H = A(0) [@StartHr, @EndHr]
                                     @StartHr: IF M >= A(1) [@LightOn, @Wait]
                                                  @LightOn: ON ^HouseLight ---> S2
                                                  @Wait: ---> S3
                                     @EndHr: IF M < A(3) [@LightOn, @Wait]
                                                @LightOn: ON ^HouseLight ---> S2
                                                @Wait: ---> S3
             @Seq2: IF (H > A(0)) OR (H < A(2)) [@LightOn, @Wait]
                       @LightOn: ON ^HouseLight ---> S2
                       @CheckMin: IF H = A(0) [@StartHr, @EndHr]
                                     @StartHr: IF M >= A(1) [@LightOn, @Wait]
                                                  @LightOn: ON ^HouseLight ---> S2
                                                  @Wait: ---> S3
                                     @EndHr: IF M < A(3) [@LightOn, @Wait]
                                                @LightOn: ON ^HouseLight ---> S2
                                                @Wait: ---> S3

S2,     \ Check if HouseLight Should be Turned Off
  1": TIME H, M, S;
      IF S = 0 [@CheckHr, @Wait]
         @CheckHr: IF H = A(2) [@CheckMin, @Wait]
                      @CheckMin: IF M = A(3) [@LightOff, @Wait]
                                    @LightOff: OFF ^HouseLight ---> S3
                                    @Wait: ---> S2
                      @Wait: ---> S2
         @Wait: ---> S2

S3,     \ Check if HouseLight Should be Turned On
  1": TIME H, M, S;
      IF S = 0 [@CheckHr, @Wait]
         @CheckHr: IF H = A(0) [@CheckMin, @Wait]
                      @CheckMin: IF M = A(1) [@LightOn, @Wait]
                                    @LightOn: ON ^HouseLight ---> S2
                                    @Wait: ---> S3
                      @Wait: ---> S3
         @Wait: ---> S3 
              
Related programs Other versions
No training programs submitted/required

No older versions available
No experimental versions available