Questions & Suggestions |
Please note: I am currently using I/A version 6.1 on 51B and 51B1 machines (Sun Sparcstation 5 and 4). Some of the following information (especially file locations) is different on other versions and platforms. While I find the normal historian configurator easy to use for making changes to a point or two, it is awkward and time consuming for making large scale changes to the historian's database. I/A provides a bulk configuration tool called cfgpts to make bulk configuration easier. The following examples use cfgpts and other Foxboro and Unix programs to make maintaining your historian's database easier. Using cfgpts to get configuration information from your historian You can find the cfgpts and in /opt/fox/hstorian/bin/ on the 51 series AP or AW. Documentation for this tool is in the same directory in cfgpts.doc. To get a list of configured points in your historian:
To get a summary of the data in the historian:
# cfgpts -sq Extracting the historian data points To get a list of just the configured points, you can use grep to select only those lines that start with "ID" (avoiding error messages and statistics), and nawk to print only the point name:
# cfgpts -Rv hist01 | grep "^ID" | nawk -F"[=,]" '{print $2}' # cfgpts -Rv hist01 | grep "^ID" | nawk -F"[=,]" '{print $2}' > hist01.txt Validate the historian data points To validate the collection points in the historian we can use the file (histpoints.txt) from the above example and Foxboro's omget tool (/opt/fox/bin/tools/omget) which returns the current value of a point if it is valid, or returns an error message if the point is invalid. Please note, with a large list of points this can take quite some time to run, especially if there are a large number of bad points. From the command line in the C shell: # foreach item ( `cat hist01.txt` )In the above example, the OM error 60 is the result of an bad parameter type for the valid block (no PNT parameter in a PID block), and the "does not exist" error is the result of a compound:block that can't be located. We can refine this to take the bad points and save them to a file: # rm hist01.badIn the examples above, note the back-quotes rather than quotes in ( `cat hist01.txt` ) which executes the enclosed command. The grep on "object" just selects the error lines. The nawk command sets the field separators to "[" and "]" for this command to enable us to print just the object between the brackets. The list of bad points is then appended to hist01.bad. Because we are appending a line at a time to the file hist01.bad, we delete any previous copies prior to starting the verification. The "sleep 1" reduces the load on the nodebus. Dealing with the bad points There are a number of causes for bad points in the historian database. The ones I see most include spelling mistakes in compound and block names, use of an improper parameter type, and the moving or deletion of the original block. If your verification of the historian's database turns up just a few bad points it is probably easiest to fix or delete them through the normal collection point configurator. If you have lots of bad points I find it is easiest to delete them all with cfgpts and add back the correct ones as I figure out what they should have been. Deleting the points we have determined to be bad is quite simple. WARNING -- Caution should be taken when using the cfgpts to add and delete points!!! Using the file hist01.bad generated in the last example we need to build a list of points to remove in the format recognized by cfgpts, which means "ID=" before the point name and a ";" at the end of each line. We can use sed to make these edits (without overwriting the original file) and send the result to cfgpts. The listing of points removed can be displayed or alternately sent to a file. The historian should be turned off before adding or deleting points. Also, it is good practice to get a backup listing of the historian's database: # histonoff hist01 OFFCheck the file hist01.removed for errors encountered during the deletion. If all went smoothly, you will have a list of the points deleted. To reverse this action in the event of an error (ie. CP was off while you were generating bad points list), you can undo the deletion by: # histonoff hist01 OFF Building a list of points for addition Sometimes there is a need to add a large group of points to the historian. If the information to be added can be expressed easily such as "MEAS, SPT and OUT parameters on all PIDX blocks in 36CP03 at a scan rate of 10 seconds and a dead-band of 0.5% of scale retaining 60 hours of data" then it is easy to build an input file for cfgpts to add the points. To do exactly this, we can use the iccprt tool to extract the information and format it for cfgpts with awk and sed. First the use iccprt to extract the parameter level information from a station:# cd /opt/fox/ciocfg/apiThe "-p" tells iccprt to extract parameters, "-o 36CP03.txt" says output to a file named 36CP03.txt, and the final 36CP03 is the station letterbug. This generates a file that can be used to build an addition file for cfgpts. First, sed can be used to change the "END" after each block in the text file to something that can be used as a record separator: sed 's/^END//' 36CP03.txtNext, the parameter identifier tags can be stripped out and replaced with a space: sed 's/^.*= / /'Next, awk (or nawk in this case to handle longer records) can be used to list just the fields we want. For the PIDX block, field 1 is the compound and block, 2 is the type (PIDX), 3 is the description, 8 is HSCI1, 9 is LSCI1, 21 is HSCO1 and 22 is LSCO1: nawk 'BEGIN {FS="\n"; RS=""} {print $1, $2, $3, $8, $9, $21, $22}'Finally grep can be used to list only the PIDX records: grep PIDXPutting it all together, on a command line: # sed 's/^END//' 36CP03.txt | sed 's/^.*= / /' | nawk 'BEGIN {FS="\n"; RS=""} {print $1, $2, $3, $8, $9, $21, $22}' | grep PIDXThis gives a list in the format NAME TYPE DESCRIPTION HSCI1 LSCI1 HSCO1 LSCO1 which is useful as a reference but can't be used as an input to cfgpts yet. The nawk portion of the command can also be used for formatting the output, and then sed can be used to strip extra information: # sed 's/^END//' 36CP03.txt | sed 's/^.*= / /' | nawk 'BEGIN {FS="\n"; RS=""} {print $2 "ID="$1".MEAS, PD="$3", DB="($8-$9)*0.005", SR=10, RC=216;"}' | grep PIDX | sed 's/^ PIDX//' | sed 's/= /=/g'This gives a properly formatted list for cfgpts, but only for the MEAS parameter. The print portion of the nawk statement can be expanded to add the SPT and OUT parameters. The output can be directed to a file and then used with cfgpts to add the points to the historian: # sed 's/^END//' 36CP03.txt | sed 's/^.*= / /' | nawk 'BEGIN {FS="\n"; RS=""} {print $2 "ID="$1".MEAS, PD="$3", DB="($8-$9)*0.005", SR=10, RC=216;"; print $2 "ID="$1".SPT, PD="$3", DB="($8-$9)*0.005", SR=10, RC=216;"; print $2 "ID="$1".OUT, PD="$3", DB="($21-$22)*0.005", SR=10, RC=216;"; }' | grep PIDX | sed 's/^ PIDX//' | sed 's/= /=/g' Foxboro and I/A Series are registered trademarks of The Foxboro Company. |
|