|
|
HAL Database Extraction and Consistency Check Tool
#########################################################################
# This program is designed to break out HAL database files for the
# purpose of testing and examination, and to aid troubleshooting
#
# It performs the following actions:
# (1) Extracts database files to Comma Separated Values (.CSV) files
# These files can be opened with spreadsheet programs such as
# Excel and examined. They can also be manipulated with many
# other sorts of programs
#
# (2) Translates the .CSV files to plain text files for easy reading
# by human beings. These files can be easily read and reviewed
# with any text editor such as Notepad or Word.
#
# (3) While writing the text files, it looks for a comments.CSV file.
# If found, the comments are parsed and added to the listing.
#
# (4) Performs a consistency check on the major database structure.
# It examines the macros and rules and verifies that all flags
# timers and X10 devices referenced therein actually exists.
#
# To use this program:
# (1) Extract the Zip file in your C:\Perl directory.
# The directory C:\Perl\MySubs\ should be created by the process
# and a number of Perl script subroutines placed in that directory
# (2) Copy the Device, Macro, RuleMstr, RuleCond and RuleAct dbf files
# from the HAL\Data directory to c:\perl. We always work on a
# copy of the files, never the live, running files.
# (3) Invoke the program. It will read the DBF files and create .CSV
# files for each, plus DEVICE.TXT, MACRO.TXT and RULEMSTR.TXT.
# RULEMSTR.TXT contains the entire rule-set.
# (4) After creating the TXT files, it will then compare the device
# elements requested by the macros and rules against the contents
# of the DEVICE.CSV file, printing any exceptions.
#
# Program Architecture Notes:
#
# Referring to the primary file, HAL_DBF_Tool.pl you will note that
# this program illustrates several "KickAss" techniques for programming
# perl scripts.
#
# This program illustrates an advanced technique for modularizing perl
# scripts. Many functions are broken out into separate scripts and called
# as subroutines. All the subroutines are placed in a specific subdirectory
# named "MySubs". The top-level program is kept simple with minimal
# in the way of data headers, complex logic, etc. Everything is placed
# in the subroutines. Note that many of these subroutines have been
# written at different times and in different applications, and thus
# represent several different styles of programming and levels of ability.
#
# Not all subroutines provided in the "MySubs" directory are used in
# this program.
#
# On startup, the top-level program does two things before executing
# any actual program code.
#
# (1) Look for the directories "MySubs" and "CDBFlite", to verify that
# the required parts are available.
#
# (2) Look in "MySubs" and load all the subroutines present. This little
# trick means that it is not necessary to specify the names of
# required subroutines in the program, but merely ensure that they
# exist in the MySubs directory.
#
# (3) The remainder of the program code is in the three subroutines
# Extract_DB, Extract_Txt, and Check_Consistency. It is merely
# necessary to call them in the correct order with the correct
# arguments. Since the first two are called multiple times, with
# multiple arguments, we first place the arguments in an array
# called @DBFile and use recursion to call each in turn. This
# recursion technique is useful in curcumstances where a large
# number of calls need to be made, or the precise number of calls
# is not known in advance
#
#########################################################################
# HOW TO USE THIS SCRIPT
# 1. If you don't have PERL on your windows computer download the zip
# file from www.activestate.com/activeperl.com. You want the Win32
# binary file. You will also need winzip to unpack it
# 2. Unpack the zip file into directory c:\perl
# 3. If you don't have the free utility CDBFlite, download the zip
# file from www.whitetown.com. This is a $15 shareware program
# that you are allowed to download and use for 30 days for free.
# 4. Download the ZIP file and unpack it in your Perl directory,
# preserving the path so that the MySubs directory is created
# and the subroutine files are placed therein.
#
#########################################################################
#
# Sample run
C:\Perl>copy c:\"program files"\HAL\data\device.dbf
1 file(s) copied.
C:\Perl>copy c:\"program files"\HAL\data\macro.dbf
1 file(s) copied.
C:\Perl>copy c:\"program files"\HAL\data\rulemstr.dbf
1 file(s) copied.
C:\Perl>copy c:\"program files"\HAL\data\rulecond.dbf
1 file(s) copied.
C:\Perl>copy c:\"program files"\HAL\data\ruleact.dbf
1 file(s) copied.
C:\Perl>HAL_DBF_Tool.pl
Database name : Device.DBF
Type : FoxPro
Record count : 507
Output Filename : DEVICE.CSV
Database name : MACRO.DBF
Type : FoxPro
Record count : 1277
Output Filename : MACRO.CSV
Database name : RULEMSTR.DBF
Type : dBase III
Record count : 720
Output Filename : RULEMSTR.CSV
Database name : RuleAct.DBF
Type : FoxPro
Record count : 1513
Output Filename : RULEACT.CSV
Database name : RuleCond.DBF
Type : FoxPro
Record count : 1815
Output Filename : RULECOND.CSV
Writing DEVICE.CSV to DEVICE.TXT output
507 Records Converted
Writing MACRO.CSV to MACRO.TXT output
Total Actions = 1007
Macros, Scenes and Modes = 273
Reading Rules Index RULEMSTR.CSV File
Total Rules = 718
Reading Rules Conditions RULECOND.CSV File
Number of Secondary Conditions = 1813
Reading Rules Actions RULEACT.CSV File
Total Actions = 1543
writing data File RULEMSTR.TXT
Rules Database Written as Text File.
Performing Consistency Check of database.
Checking Devices...
507 Device entries found.
Checking Macros ...
Checking Macro Timers
Checking Macro X10 devices
Checking Macro Flags
Checking Rules...
Checking Rule Timers
Checking Rule Flags
Checking Rule X10 devices
Consistency Check Complete.
C:\Perl>
|
|