#!/usr/local/bin/perl # # Filename: sample.pl # # Author: Kevin FitzGerrell # Comments to: kfitz@gci.net or fitzgerrell@yahoo.com # # Usage: as long as PERL is in the path, # to run, type: # perl sample.pl # to run with error checking type: # perl -w sample.pl # to run if your system will interpret the sheebang correctly: # sample.pl # # Description: This sample PERL script will get object # manager info, calculate costs, print results to standard # out and write results to DCS. # # Assign values for cost and weight to variables. $ABS_COST = 0.10; $ABS_PPG = 11.70; # From the system, get the time, strip line-feeds and assign to variables. chomp ($HOUR = `date +%H`); chomp ($MINUTE = `date +%M`); chomp ($SECOND = `date +%S`); # Read Object Manager values into variables by reading input string, splitting # into fields, and assigning relevant field to a variable. @IN = split(' ',`/opt/fox/bin/tools/omget -v ANALOG_FBM:REAG2_DTOX.RO03`); $ABS_FLOW = $IN[2]; @IN = split(' ',`/opt/fox/bin/tools/omget -v PID_GRND:WI_0270A.PNT`); $TONS = $IN[2] * 0.95; # Report time and Object Manager retrieved values to standard out. print "\n\n$HOUR:$MINUTE:$SECOND \n\n"; print "Base Information\n"; print "----------------\n"; print "ABS flow $ABS_FLOW gpm \n"; print "Tonnage (dry) $TONS tph \n\n\n"; # Run calculations. $ABS_PPT = ($ABS_FLOW * $ABS_PPG * 60) / $TONS; $ABS_CPT = $ABS_COST * $ABS_PPT; $ABS_CPH = $ABS_FLOW * 60 * $ABS_COST * $ABS_PPG; # Print calculated information. print "Current Information\n"; print "-------------------\n"; print "ABS usage lb/ton $ABS_PPT \n"; print "ABS cost \$/hr $ABS_CPH \n"; print "ABS cost \$/ton $ABS_CPT \n\n\n"; # Write the results back to DCS (Object Manager) system("/opt/fox/bin/tools/omset -v -f $ABS_CPT ABS_CPT"); system("/opt/fox/bin/tools/omset -v -f $ABS_CPH ABS_CPH"); system("/opt/fox/bin/tools/omset -v -f $ABS_PPT ABS_PPT"); # # DONE #