home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / x10ctl21.zip / X10CTL21.TX_ < prev    next >
Text File  |  1992-12-25  |  21KB  |  458 lines

  1. X-10 Control Program for Windows (X10CTL)  Ver. 2.1
  2.  
  3.  
  4. **** NOTICE
  5.  
  6. This program is available at no cost from the Author, Larry E. Fosdick
  7. [CIS 70105,1142].  No warranty, either expressed or implied, covers 
  8. losses of data, fingernails, or hair from the use or abuse of this 
  9. software.  This program may be freely distributed.  No money is to 
  10. be collected for this software, especially by the author, who did this 
  11. for recreation. The source code is NOT available.
  12.  
  13.  
  14. INTRODUCTION
  15.  
  16. This program, written in Microsoft Visual BASIC, provides complete access
  17. and control for the X-10 Powerhouse Interface (X-10 USA Inc.).  Features 
  18. include:
  19.  
  20.    - True multiple window application
  21.    - X-10 clock can be automatically synchronized to computer system clock
  22.    - Console window for immediate control
  23.    - Descriptive unit definitions entered by user
  24.    - Timed events are easily added, deleted, or modified, with
  25.      changes downloaded    automatically to the interface
  26.    - Timed event sets can be saved to and restored from disk files
  27.    - Timed events can be set to 
  28.       Today, Tomorrow, Everyday, Weekdays, Weekends, or Specific Days
  29.    - Event list can be printed for reference
  30.    - 16-position dimmer function for lamp units or light switches
  31.    - Powerful Batch facility added (new in Version 2)
  32.  
  33. X10CTL requires the X-10 Powerhouse interface from X-10 (USA), Model CP290.
  34. It can be purchased from DAK Industries (at times), Radio Shack, CompUSA, 
  35. and probably others.
  36.  
  37. I do not endorse any equipment vendor.  This information is provided
  38. to answer queries Revision 1.00 generated.  There may be other vendors.
  39. I bought my X-10 Powerhouse from DAK in 1986, and it works very well.
  40.  
  41. I recently added a 486 motherboard to my computer system.  The DOS software
  42. supplied by X-10 USA no longer functions.  I'm contacting them to see if they
  43. provide technical support.  For you, this means I can no longer test my 
  44. software side-by-side with the original.  The last time I tried, it worked
  45. well (with one exception, described in the Technical Section).
  46.  
  47.  
  48. PROGRAM INSTALLATION
  49.  
  50. The following files, included with the X10CTL package, are 
  51. installed in the Windows SYSTEM directory:
  52.      spin.vbx     
  53.     cmdialog.vbx
  54.      gauge.vbx 
  55.  
  56. These files are part of the Microsoft Professional Toolkit. 
  57.  
  58. The following files are not included in this package to 
  59. conserve download time, and are available separately on 
  60. CompuServe:
  61.     VBRUN200.DLL
  62.     COMMDLG.DLL
  63.  
  64. No changes are made to WIN.INI or SYSTEM.INI.  A private .INI file,
  65. X10CTL.INI is created in the Windows directory.
  66.  
  67.  
  68. PROGRAM OPERATION
  69.  
  70. The first time the program is started, X10CTL.INI is created in your 
  71. Windows directory.  This file maintains initialization parameters for 
  72. X10CTL, including the COM port number, window positions, and unit 
  73. descriptions.  You will be required to enter the COM port for the 
  74. X-10 Interface the first time the program is run.  If you change the 
  75. port in the future, you will have to edit X10CTL.INI, since the program 
  76. will not operate without the Interface active.
  77.  
  78.  
  79. Main Window
  80.  
  81. The Main window provides access to the other windows in the application.
  82. Access can be gained by double-clicking the appropriate icon, or through 
  83. the menu system.  The Unit, Event, Batch, and Console windows can be open
  84. concurrently, with free movement between these windows.
  85.  
  86.  
  87. Unit Window
  88.  
  89. This window allows the user to describe up to 256 units (A1 - P16).  The 
  90. descriptions are stored in X10CTL.INI in the format
  91.  
  92.         HUU=Description String
  93.  
  94. where H is the House Code (A-P) and UU is the unit number (01-16).  The 
  95. leading zero is required.  Unit descriptions are added by first selecting 
  96. House and Unit codes, then clicking the Add/Edit button.  A dialog box is 
  97. opened, allowing the user to enter a series of characters describing the 
  98. function of the unit.  Changes are saved when the application is terminated.
  99.  
  100. Unit descriptions can be edited by first selecting the unit to be edited, 
  101. either using the House and Unit buttons, or by clicking the entry directly 
  102. on the list, followed by clicking the Add/Edit button. 
  103.  
  104. Unit descriptions can be deleted by selecting the unit of interest, followed
  105. by clicking the Delete button.
  106.  
  107. In Version 1.2 and later, unit number 17 (which does not exist physically)
  108. is predefined as "All Lights On/Units Off".  This function was added at the
  109. request of users, who wished to be able to program "All Off" functions as 
  110. events.  Note that any "On" events are translated automatically to "Dim00" 
  111. (Highest lamp unit output) so that "On" functions will only work on lights 
  112. connected to lamp or wall switch modules.  The "Off" functions will work 
  113. with all units assigned to the given House Code.
  114.  
  115. Event Window
  116.  
  117. When the Event window is first opened, the events stored in the X-10 
  118. Interface are uploaded to the computer, then displayed. Events can be 
  119. added, updated (modified), or deleted.  All changes to the event list 
  120. are sent to the X-10 Interface immediately.  The Event window thus always
  121. represents the current action list in the X-10 Interface.  The Event List 
  122. can be printed for reference or easy review.
  123.  
  124. Events are added by selecting the following components in any sequence:
  125.    - Unit
  126.    - Mode (Today, Tomorrow, Everyday, Weekdays, Weekends, or Specific Days)
  127.    - Action (On, Off, or Dim)
  128.    - Time (24-hour format)
  129.    - Security (Checked or Unchecked)
  130.  
  131. The Unit and Mode are selected from drop-down lists.  The Unit list is 
  132. constantly updated from the Unit window.  If a desired unit is not defined,
  133. simply switch to the Unit window, add the unit description needed, then 
  134. switch back to the Event window. 
  135.  
  136. Remember that both windows can be open concurrently.  I tried to
  137. make it possible to view both windows without overlap, but there
  138. is simply too much information needed for full functionality.
  139.  
  140. If Mode is Specific Days, a Day Selection control box is displayed.  Check
  141. the days you wish to have the action take place.  The box is not displayed
  142. in the other modes, since the days are implicit in the mode definition.
  143.  
  144. If Action is Dim, a Dim Level control is displayed.  Use the spin buttons to
  145. select the dim level between 0 (full bright) to 15 (full dim).
  146.  
  147. To change the Time, click on the hours or minutes areas, then use the spin
  148. buttons to change the selected value.
  149.  
  150. Events can be updated by first clicking on the line describing the event, 
  151. then changing controls as needed, followed by clicking on the Update button.
  152. When an event is selected by clicking on it, all controls are updated to 
  153. match.  This simplifies changes, since most controls will be correct.  
  154. Note that the days in the Specific Days mode appear gray to differentiate
  155. the days selected in the interface from those being changed.
  156.  
  157. Events can be deleted by clicking on the event, followed by clicking the 
  158. Delete button.  There is no undelete function.
  159.  
  160. Event files are accessed through the Event window by clicking on
  161. Save or Load.  The current list of events can be saved to disk (default
  162. extension is .X10).  Events loaded from a disk file will completely replace
  163. the events in the interface, i.e., any events in the interface are erased 
  164. when an event file is loaded.
  165.  
  166.  
  167. Batch Window
  168.  
  169. The Batch window contains commands you can send to the X-10 whenever you 
  170. want.  The batch sequences can be stored on disk, and there are no limits 
  171. to the number of batch files you can have.  Starting with Version 2.1, if 
  172. batch commands are in the list box, they are automatically saved to the 
  173. most recently accessed batch file when the program ends.  If no file was
  174. specified, the commands are stored in AutoLoad.X1b.  When the Batch window 
  175. is opened during a subsequent program run, the most recent file is loaded 
  176. automatically.
  177.  
  178. Each line in the Batch window is a separate batch sequence having the form
  179.  
  180.     H:OP.U1.U2.U3/
  181.  
  182. where     H is the House Code
  183.     OP is the operation (on, off, dim)
  184.     U1 is a unit descriptor
  185.  
  186. Examples
  187.  
  188. L:ON.1.2.3.4/L:D4.5.6/
  189. turns on units 1,2,3 and 4, then dims units 5 and 6 to Dim04 (D0 is full 
  190. bright, D15 is full dim).
  191.  
  192. L:OFF.1.2.4/L:ON.6/L:D9.11.13/
  193. turns 1,2, and 4 off; turns 6 on; dims 11 and 13 to Dim09.
  194.  
  195. Batch sequences are defined in a separate window, using simple point and 
  196. click operation.  Note that multiple units can be selected in batch mode.  
  197. Units having letters large and bold will be included in the batch sequence.
  198.  
  199. The batch files are stored as simple ASCII files.  You can create batch
  200. files with a text editor.  If you do, any typos are your responsibility.
  201. The BatchAdd function is easy to use, and it ensures proper syntax.
  202.  
  203.  
  204. GENERAL COMMENTS
  205.  
  206. Thanks to all the folks that provided feedback.  Without it, the bugs
  207. couldn't have been swatted as fast.  There may still be more, so be
  208. careful until you are satisfied.  I used the DOS-based software to
  209. save my event list before using this program at first, since you can
  210. easily restore any errors that way.  All you have to do is unplug the
  211. interface and remove the battery for a few seconds.  DON'T use the
  212. change base code function, since your unit descriptions get lost as
  213. well in the DOS-based version supplied with the interface.
  214.  
  215.  
  216. TECHNICAL ISSUES
  217.  
  218. 1.  To all of you claiming that your fast CPU was messing up the program: 
  219. NO WAY!  I upgraded to a 486/33 motherboard, and all versions back to 1.01
  220. worked as well as they did on my 386SX system.  The DOS software from 
  221. X-10 USA no longer works with my 486.
  222.  
  223.  
  224. 2.  COMM ports, the X-10, and Windows:  This is a little tougher, but you 
  225. must understand that the DOS X-10 software supplied with the X-10 console 
  226. does not use interrupts when communicating with the X-10 interface (this is
  227. true for Version 1.00 2/86, and probably for newer versions). Windows does,
  228. so all the limitations of sharing IRQ's applies.  In the IBM PC and AT 
  229. world (any ISA bus system), COM1 and COM3 share IRQ4, while COM2 and COM4 
  230. share IRQ3.  COM1 and COM3 can NOT be used at the same time, nor can COM2 
  231. and COM4 be used at the same time, PROVIDED that the software is using 
  232. interrupts.  All COMM programs, mouse drivers, and Windows applications 
  233. use IRQs, while the DOS-based X-10 software does not.
  234.  
  235. My system can serve as an example:
  236.     COM1     X-10 interface using IRQ4
  237.     COM2    internal modem using IRQ3
  238.     COM3    not attached at the moment, using IRQ4
  239.     COM4    not installed
  240.     MOUSE    InPort (bus) mouse, using IRQ5
  241.  
  242. You can see that my modem, mouse, and X-10 all have separate interrupts 
  243. assigned to them.  If I connect anything to COM3, then I can only use it 
  244. when I am not accessing the X-10 interface.
  245.  
  246. If you have a serial mouse, modem, and X-10 interface, then you should have 
  247. at least three COM ports(maybe four). My suggestion for configuring this 
  248. system is:
  249.     COM1    X-10 interface     (IRQ4)
  250.     COM2    mouse         (IRQ3)
  251.     COM3    modem         (IRQ4)
  252.  
  253. Note you can't use the modem and X-10 at the same time.  If you have 
  254. nothing using IRQ5, then you might want to reconfigure one of your ports 
  255. to use IRQ5.  Most mouse drivers and Windows 3.1 will accept a nonstandard 
  256. setup (provided you tell the software what you've done).
  257.  
  258. The last thing you want to do is try to share an interrupt between the mouse 
  259. and the X-10.  It just can't work with X10CTL.
  260.  
  261.  
  262. 3.  A user recently sent me a dump file of the commands in his X-10 unit.
  263. It reminded me that a command and an event are two different things.  A 
  264. command is "turn unit L01 on", while an event is "turn these units on house
  265. code L on".  X10CTL assigns one command to one event, which simplifies 
  266. bookeeping, but wastes the limited memory of the CP290 (only 128 events can
  267. be stored).
  268.  
  269. The DOS-based software from X-10 (his version, anyway) automatically 
  270. combined commands having the same operation, house code, and time, thus
  271. producing commands with two or three units.  This has the benefit of 
  272. conserving event memory.
  273.  
  274. X10CTL cannot work this way without major revisions and fundamental
  275. changes in its operation.  Right now, the events listed in the window
  276. constantly reflect the X-10 CP290 memory, so you know what is going on.
  277. If you turn off the computer, you won't have any surprises (at least
  278. from the X-10).  To combine commands into events, the software would
  279. have to increase greatly in complexity to remain matched to the
  280. interface memory, or the exact tracking would have to be sacrificed.
  281.  
  282. I have used the interface since 1986, and have used X-10 modules since
  283. 1980.  The largest event list I ever created had about 60 events.  I
  284. can't see the need to modify the code to the extent needed for commands
  285. combined into single events.
  286.  
  287. X10CTL 2.1 will look for these events, and will let you know when it
  288. runs into one.  It will display ?? instead of a unit number, and I
  289. strongly advise against updating or deleting these events from within
  290. X10CTL.
  291.  
  292. You can force the DOS version to separate the commands by changing the
  293. times by as little as one minute.  If you plan to use the DOS version
  294. alongside X10CTL, just remember to avoid having two identical commands
  295. and times.  When used in this way, one command = one event, and both
  296. programs should be happy.
  297.  
  298. If there is sufficient interest, I could write a utility to grab the
  299. event memory, massage it into shape, then dump it back out to the 
  300. interface.  This would probably be a separate program, minus all the
  301. fluff needed in the user interface.  I estimate that it would require
  302. 1-2 minutes to execute, depending on the number of events in the
  303. interface.  Interested parties can send me mail messages with
  304. their opinions.
  305.  
  306. If this seems inelegant to you, or if you feel that wasting event memory
  307. is not possible, then let me point out that X10CTL is free, and you may 
  308. use it or not as you see fit.  I appreciate the interest that many of you
  309. have expressed, but I wrote this for fun, and this change won't be fun.
  310.  
  311.  
  312. 4.  Additional features: The original program improved in robustness,
  313. performance, and features due to the interest and ideas I received from
  314. users.  The Batch facility and "All Lights On/Units Off" function were
  315. ideas I got from you.  I will still entertain ideas, since this can lead
  316. to uses that I would never conceive.
  317.  
  318. Another idea I received was to match events to sunset or sunrise.  A
  319. program called X10Win by Tenholder does this already.  I could do this,
  320. but the typing for geographic locations is not trivial.  Also, I never
  321. located an algorithm for calculating sunsets and sunrises (I could have
  322. looked, I suppose).  Right now, there are no plans to implement this.
  323.  
  324.  
  325. ERROR MESSAGES AND THEIR CAUSES
  326.  
  327. Error Opening Port
  328. Either some other program, such as a comm program or mouse driver, is using
  329. the port, or the X10CTL application suffered an uncontrolled crash.  If the
  330. former, adjust the port assignments in your computer (see Tech Section, 
  331. above).  If the X10CTL has crashed, you must restart Windows, since the port
  332. was not closed, and access is cut off.  If X10CTL crashes, record as much 
  333. information concerning your actions at that point, then e-mail a summary 
  334. to me.
  335.  
  336. Error with X-10 Interface
  337. The port has been opened and configured.  The initial attempt to communicate
  338. with the X-10 Interface has failed.  Possible causes include:
  339.     1.  Wrong com port selected
  340.     2.  X-10 Interface not connected
  341.     3.  X-10 Interface unplugged
  342.  
  343. Correct the cause(s), if found, and try again.  If everything seems normal, 
  344. then it may be an unknown bug in X10CTL.  If you can, try using a different
  345. program to access the interface to make sure the X-10 itself is OK.
  346.  
  347.  
  348. Please forward comments, compliments, complaints, bug reports,
  349. or suggestions to
  350.  
  351.     Larry E. Fosdick  [70105,1142]
  352.  
  353.  
  354. REVISION HISTORY
  355.  
  356. *** Changes in Version 2.1
  357.  
  358. Automatic save and load for batch files added (see Batch Mode, above).
  359.  
  360. The Main Window position can be changed and remembered from run to 
  361. run (an oversight.  I saved the position on exit, but never read it
  362. when starting up again).  
  363.  
  364. Multi-command events are recognized and brought to your attention, 
  365. but not dealt with further (see Technical Issues, above).
  366.  
  367. Text and stuff are adjusted when in 1024x768 (or higher) video mode.
  368.  
  369. Several minor tweaks and adjustments which I can't recall and you 
  370. probably wouldn't notice (unless you were the one that found the bugs).
  371.  
  372. *** Changes in Version 2.0
  373.  
  374. Batch command processing has been added, where you can predefine a series 
  375. of commands and send them whenever your little heart desires.  
  376.  
  377. Now that Windows has a common dialog function, I am using it.  You will see
  378. minor changes in file handling for event files.
  379.  
  380. I also experimented with gauges to show dim level and spin buttons instead
  381. of scroll bars where appropriate.
  382.  
  383. *** Changes in Version 1.4
  384.  
  385. A very helpful user determined that X10CTL crashed when first
  386. accessing an X-10 system with a clean memory, such as that caused
  387. by a power failure without battery backup.  This problem has been
  388. fixed.  The startup sequence has also been altered so that the
  389. Main window has the focus on startup.  On some systems, the 
  390. program lost the focus after the startup screen was removed.
  391.  
  392.  
  393. *** Changes in Version 1.3
  394.  
  395. Corrected some problems with the file handler.  It seems that
  396. events were uploaded to the Interface faster than it could accept
  397. them, resulting in garbage.  Also corrected some strange things 
  398. that crept into Version 1.2 somehow that affected the appearance
  399. but not the performance.
  400.  
  401.  
  402. *** Changes in Version 1.2
  403.  
  404. The ability to print the event list has been added.
  405.  
  406. A unit description of "All Lights On/Units Off" has been added to the
  407. Unit Window.  This was primarily added for those who wish to send
  408. "All Off" commands while away from home.  I have no idea who will
  409. use it to turn lights on.  Please note that the code uses DIM00 
  410. instead of ON, so that this control will only turn on lights that
  411. are connected to lamp modules or wall switches.  The off function
  412. affects all units on the selected house code.  The unit number for
  413. this function is 17, which is not real, but gives the software a hook.
  414.  
  415. *** Changes in Version 1.1
  416.  
  417. First of all, version numbers became two digits.
  418.  
  419. The event upload has been changed again.  It should now work for any
  420. speed CPU, without adding silly delays.  If you have trouble with this
  421. version, please retest the program with a slower cpu speed, if your
  422. computer allows cpu speed switching, then report the results to me.
  423.  
  424. The intro window was added once I saw how long the screen went blank
  425. while initializing the program.  An odd quirk of Windows causes the
  426. focus to go to a window other than the Main window on my system, so
  427. I tried to incorporate a work-around using the timer.  It caused more
  428. problems than it solved, so I took it back out.  If the Main window
  429. doesn't have the focus when it first comes up, sorry.
  430.  
  431. It turns out that if you terminate a multiple window Visual BASIC
  432. program (like this one), the Form Unload subprogram is only executed
  433. on the primary window unless you unload explicitly the other
  434. windows.  This "feature" caused problems with saving changes to the
  435. Unit Decription List.  This has now been fixed.
  436.  
  437. *** Changes in Version 1.01
  438.  
  439. Three changes were made.  The first addresses an "Illegal Function
  440. Call" error when first starting the program and setting the COM port
  441. for the X-10.  This was a silly oversight.  I use the timer function
  442. to ensure that the Main window gets the focus after the intro window
  443. is removed (normally, the focus goes to some other window).  I now start
  444. the timer after the port configuration window is closed.
  445.  
  446. The second fix deals with Event updates not working properly in 1.00.
  447. It was simply a bookeeping error.
  448.  
  449. The third fix deals with uploading events from the interface.  The X-10
  450. Powerhouse does not support any form of handshaking, and so the event
  451. uploading has to be handled by a combination of timing and waiting for 
  452. the right number of characters in the buffer.  There are actually two
  453. wait periods.  I have tried to improve the robustness of the routines,
  454. and have added message boxes to help determine where the errors lie.  If
  455. you get an error message box, please record the message and let me know.
  456. CPU's faster than my 16 MHz 386SX may be too fast for my algorithm.  I am
  457. trying to avoid making it too conservative, as this slows event uploads.
  458.