Dawn Simulator PC Software

This page describes the PC software I wrote to control the Dawn Simulator device. It can be downloaded here, and is provided free for private, noncommercial use. Commercial use permitted only with my written permission (I really provide these things for hobbyists, not businesses, although I don't think I would have any particular problem granting permission--at least today). The software was written in Python, using ActiveState ActivePython 2.4.1 , although it should run well on earlier Python versions. The program uses no platform-specific calls, so should perform on any platform.

Running the Program

The program runs at the command-line and uses command-line arguments as shown in the "usage" display below:
     F:\>dawnsim
     DawnSim, v0.51.  Copyright (C) 2006, Tim Sharpe <beaststwo@yahoo.com>.
     Usage:  dawnsim [-startstate 0|1] [-hold <number>] [-interval <number>] [-dim] [-host <host>] [-port <port>]

     where:
         -startstate 0|1 = Option to determine the initial state of the
                              light (0=Off, 1=On). Default is off.
          -hold <number> = Option to set how long to hold the last state (minimum is
                              1 minute, default is 30 minutes).  If option is missing
                              no hold interval will occur.  If a hold is requested, the
                              the startstate is 0, and dim is selected, the hold will
                              occur at after of the dimming interval.  If a hold is
                              requested, the startstate is 1, and dim is selected, the
                              hold will occur before the dimming interval.
                    -dim = Option to dim lamp linearly from the starting state to
                              the opposite state (off->max brightness and vice
                              versa).  If not set, light state changes and stays
                              the same for the entire interval.  Default is non-dimming.
      -interval <number> = Option for the interval, in minutes, to change between
                              minimum and maximum brightness (minimum is 1 minute,
                              default is 30 minutes).
            -host <host> = Mandatory Hostname or IP Address.
            -port <port> = Mandatory TCP port.
Note that since the Dawn Simulator device uses the SitePlayer Telnet system for network connectivity, the "-port" entry will always be 23 (Telnet).

The options above give the ability to set dimming sequences that start with the lamp either off or at full intensity, hold at full intensity for some period, and move between off and full intensity either arbuptly or by dimming over some period of time. The program ends all sequences with the lamp off, but that is with an explict statement issued at the end of the sequence that can be "commented out" to permit sequences to end with the lamp on.

A typical dimming sequence that starts with the lamp off, brightens to full intensity over a period of 45 minutes, hold as full brightness for 60 minutes, then extinguishes the lamp, would look the following (note that the "-startstate" entry could have been left out to use the default):

                   dawnsim -statestate 0 -hold 60 -dim -interval 45 -host 10.0.0.1 -port 23

A dimming sequence that starts with the lamp on, hold as full brightness for 60 minutes, then extinguishes the lamp without dimming, would look the following:

                   dawnsim -statestate 1 -hold 60 -host 10.0.0.1 -port 23

Because of some idiosynracies of the Velleman DC-Controlled dimmer kit, there is a hard-coded variable to skip some initial light levels. In my implementation, after adjustment the dimmer doesn't provide any voltage to the lamp until around light level 7 or 8. The program contains a variable, named OffLevelOffset, that sets the number of light levels above zero to skip during dimming sequences to eliminate light levels where the lamp will remain off. This variable may be changed as needed. If not needed at all, set it to zero.

Error Handling

The program attempts to catch failed network connections, as well as catch invalid responses from the Dawn Simulator device. Each change the program sends to the Dawn Simulator device is starts a new network (TCP) sesson, which ends when the command is successfully completed. Error handling for communications with the Dawn Simulator device is as follows:

Scheduling

The program can be run from the operating system task scheduler (Task Scheduler under Windows, cron under Unix) to provide a fixed schedule for Dawn Simulator sequences. If desired, separate scheduled tasks can be created to make the system behave differently on different days.

In order to provide a more easily modified schedule for ourselves, I have created alternate software to schedule Dawn Simulator sequences around our schedule. It consists of a Microsoft Access database and another Python program. The Python program is kicked off each day just after midnight by the system scheduler and schedules Dawn Simulator sequences for the day just beginning on the system scheduler. This permits changes to the schedule by modifying the Access database wihout having to deal with the system scheduler directly. I didn't provide it here, as it is largely undocumented and Windows-specific (it uses Windows-specific ODBC for database access and the Windows "at" command to schedule tasks), but I'll provide it for private, noncommercial use upon request (inquire at the email address at the bottom of the page).

Operation

A sample of program output follows with explanation afterward:
          DawnSim, v0.51.  Copyright (C) 2006, Tim Sharpe .  

          Starting at 04/16/2006 06:45 Eastern Daylight Time

          Program options requested:
          Start State: 0
          Hold       : 90 minutes
          Host       : 192.168.1.51
          Port       : 23
          Dim option : 1
          Interval   : 45 minutes

          Making initial contact with the Dawn Simulator... Attention... ClearCancel... Attention... Success!
          Requesting maximum supported brightess level... Success!  MaxBrightness=63

          Starting program...
          Sending brightness level 0 command... Success!
          Waiting 46 seconds...
          Sending brightness level 6 command... Success!
          Waiting 46 seconds...
          Sending brightness level 7 command... Success!
          Waiting 46 seconds...
          Sending brightness level 8 command... Success!
          Waiting 46 seconds...
          Sending brightness level 9 command... Success!
          Waiting 46 seconds...
          Sending brightness level 10 command... Success!
          Waiting 46 seconds...
          Sending brightness level 11 command... Success!
          Waiting 46 seconds...
          Sending brightness level 12 command... Success!
          Waiting 46 seconds...
          Sending brightness level 13 command... Success!
          Waiting 46 seconds...
          Sending brightness level 14 command... Success!
          Waiting 46 seconds...
          Sending brightness level 15 command... Success!
          Waiting 46 seconds...
          Sending brightness level 16 command... Success!
          Waiting 46 seconds...
          Sending brightness level 17 command... Success!
          Waiting 46 seconds...
          Sending brightness level 18 command... Success!
          Waiting 46 seconds...
          Sending brightness level 19 command... Success!
          Waiting 46 seconds...
          Sending brightness level 20 command... Success!
          Waiting 46 seconds...
          Sending brightness level 21 command... Success!
          Waiting 46 seconds...
          Sending brightness level 22 command... Success!
          Waiting 46 seconds...
          Sending brightness level 23 command... Success!
          Waiting 46 seconds...
          Sending brightness level 24 command... Success!
          Waiting 46 seconds...
          Sending brightness level 25 command... Success!
          Waiting 46 seconds...
          Sending brightness level 26 command... Success!
          Waiting 46 seconds...
          Sending brightness level 27 command... Success!
          Waiting 46 seconds...
          Sending brightness level 28 command... Success!
          Waiting 46 seconds...
          Sending brightness level 29 command... Success!
          Waiting 46 seconds...
          Sending brightness level 30 command... Success!
          Waiting 46 seconds...
          Sending brightness level 31 command... Success!
          Waiting 46 seconds...
          Sending brightness level 32 command... Success!
          Waiting 46 seconds...
          Sending brightness level 33 command... Success!
          Waiting 46 seconds...
          Sending brightness level 34 command... Success!
          Waiting 46 seconds...
          Sending brightness level 35 command... Success!
          Waiting 46 seconds...
          Sending brightness level 36 command... Success!
          Waiting 46 seconds...
          Sending brightness level 37 command... Success!
          Waiting 46 seconds...
          Sending brightness level 38 command... Success!
          Waiting 46 seconds...
          Sending brightness level 39 command... Success!
          Waiting 46 seconds...
          Sending brightness level 40 command... Success!
          Waiting 46 seconds...
          Sending brightness level 41 command... Success!
          Waiting 46 seconds...
          Sending brightness level 42 command... Success!
          Waiting 46 seconds...
          Sending brightness level 43 command... Success!
          Waiting 46 seconds...
          Sending brightness level 44 command... Success!
          Waiting 46 seconds...
          Sending brightness level 45 command... Success!
          Waiting 46 seconds...
          Sending brightness level 46 command... Success!
          Waiting 46 seconds...
          Sending brightness level 47 command... Success!
          Waiting 46 seconds...
          Sending brightness level 48 command... Success!
          Waiting 46 seconds...
          Sending brightness level 49 command... Success!
          Waiting 46 seconds...
          Sending brightness level 50 command... Success!
          Waiting 46 seconds...
          Sending brightness level 51 command... Success!
          Waiting 46 seconds...
          Sending brightness level 52 command... Success!
          Waiting 46 seconds...
          Sending brightness level 53 command... Success!
          Waiting 46 seconds...
          Sending brightness level 54 command... Success!
          Waiting 46 seconds...
          Sending brightness level 55 command... Success!
          Waiting 46 seconds...
          Sending brightness level 56 command... Success!
          Waiting 46 seconds...
          Sending brightness level 57 command... Success!
          Waiting 46 seconds...
          Sending brightness level 58 command... Success!
          Waiting 46 seconds...
          Sending brightness level 59 command... Success!
          Waiting 46 seconds...
          Sending brightness level 60 command... Success!
          Waiting 46 seconds...
          Sending brightness level 61 command... Success!
          Waiting 46 seconds...
          Sending brightness level 62 command... Success!
          Waiting 46 seconds...
          Sending brightness level 63 command... Success!

          Holding at 04/16/2006 07:29 Eastern Daylight Time
          Holding 5400 seconds...


          Extinguishing light... 

          CANCEL!  The user pressed the Cancel/Override button.  Exiting...
There are a few items worth noting in the above listing: