Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating daily files, using procomm terminal and scripts as printersa 2

Status
Not open for further replies.

H3rk

Technical User
Jun 2, 2006
17
US
I'm looking for advice on how to fix a script that I have inherited.
I have no experience with ASPECT but I have some programming experience, none of this looks very foriegn, it just takes me a little time.

Here's my scenario:

I have an ABB Taylor Mod 300 DCS that used to have 2 printers, since then we've "upgraded" the printer setup, connected both printer serial outputs via DB25-DB9 Null modems (I'm pretty sure)to a computer running windows 2000. We're using Procomm as the terminal and there are two scripts running. Each is set up for a different COM port (1 or 2).

Com 1 comes from the DCS and this printer handles alarms, which come in and out at any time. A typical capture looks like this (partial):

LOGGER1 - 09 APR 09 PAGE 2


09:02:28 CWPH02 COOLING TWR PH MES HI 8.0033 A3 8.0000

09:14:33 MUF10 MU MINIFLOW VALVE CNTL PID OUT_MODE CHANGED FROM MANUAL TO AUTO BY BILLY-BOB

09:15:50 CWPH02 COOLING TWR PH MES ACK BY DON

.... and so on....




COM 2 is a printer that handles all of the periodic reports, and the *.txt file that it currently (when the planets align, and everything works right) looks like:



BILLING-0500 01 APR 22 04:59 PAGE 1
PRELIMINARY REVENUE MONITORING REPORT
POWER PLANT COGEN
CURRENT CURRENT DCS TAG #
*POWER*
U1 TOTAL MW HRS 526.68 MWH 32.967 NET MW U1 GROSS 33.786 1EEJ11-NT
U2 TOTAL MW HRS 489.55 MWH 30.769 NET MW U2 GROSS 31.966 2EEJ11-NT
U3 TOTAL MW HRS 430.40 MWH 26.984 NET MW 3EEJ11-NT
TOT TOTAL MWH TO NPC 1446.6 MWH 90.720 NET MW PLANT GROSS 92.736
TOT MWH TO NPC PER NPC METER 1418.4 MWH EEYY64
TOT MWH IMPORTED FROM NPC 0.0000 MWH EEYY63
AUX U1 AUX LOAD TOTAL 12.603 MWH 0.8193 MW
U2 AUX LOAD TOTAL 17.912 MWH 1.1965 MW
SUM OF AUX LOAD TOTALS 30.515 MWH 2.0159 MW
U2 NAT GAS TOTAL 284.36 KLBS 396.69 KSCFH 2FQG
U1 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1FGF20
U2 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2FGF20
AUX BLR #1 GAS TOTL 0.0000 KSCF 0.0000 KSCFH VOLCANO-NGAS
AUX BLR #2 GAS TOTL 0.0000 KSCF 0.0000 KSCFH BUD_BLR_NGAS
PLANT NAT GAS TOTL PER SPC METER 13598 KSCF 853.50 KSCFH FGF02
HYD U1 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1HXF20
U2 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2HXF20
TOTAL HYDROGEN RECEIVED 46.986 KSCF 0.0000 KSCFH HXF01
DECATHERMS OF HYDROGEN RECEIVED 14.729 MBTUS
OIL TOTAL FUEL OIL 0.0000 KLBS

*STEAM*
HP U1 HP STEAM FLOW TOTAL 2087.0 KLBS 131.20 KPPH 1HSF02
U2 HP STEAM FLOW TOTAL 2068.0 KLBS 130.05 KPPH 2HSF02
IP U1 IP STEAM MADE TOTL 270.42 KLBS 17.134 KPPH 1ISF02
U2 IP STEAM MADE TOTL 262.47 KLBS 17.155 KPPH 2ISF02
EXT CUSTOMER1 EXT STEAM TOTAL (NORMAL) 11.580 KLBS 0.0000 KPPH ESF12
CUSTOMER1 EXT STEAM TOTAL (AUX) 0.0000 KLBS 0.0000 KPPH ESF101
CUSTOMER2 EXT STEAM TOTAL 201.71 KLBS 14.859 KPPH OS-FT-STM
*CONDENSATE*
CUSTOMER1 CONDENSATE RETURN (2-4) TOTL 7.9159 KGALS 0.0000 GALS PCF01
CUSTOMER1 CONDENSATE RETURN (1ST) TOTL 2.2285 KGALS 0.0000 GALS PCF02B
CUSTOMER2 CONDENSATE RETURN 0.0000 KGALS 0.0000 GALS OS-FT-COND
*WATER*
SERVICE (RAW) WATER FLOW TOTAL 348.43 KGAL 392.53 GALS SWF01
POTABLE WATER 5.7751 KGAL 5.8000 GALS PWF01
DI WATER FROM PIONEER -0.910 KGAL -0.960 GALS DI-PCA-METR
WASTE WASTE WTR TO TANK 0.0000 GALS 0.0000 GALS WWF06
WASTE TO EVAP POND 0.0000 GALS ?0.0000 GALS WWF09
* * WASTE WTR TANK > PIONEER 0.1706 KGALS 0.1333 GALS WWF01

*TANK LEVELS*
FUEL OIL TANK 127250 GALS 16.967 % FULL FOL05
WASTE WATER TANK 25.784 FEET 64.459 % FULL WWL05A
PROCESS WATER TANK 392230 GALS 60.343 % FULL RWLY05
MAKE UP WATER TANK 131893 GALS 82.433 % FULL MUL02

*MISC.*
UNIT 1 NH3 TOTAL 294.69 KLBS 19.504 LBS/HR 1NHF05
UNIT 2 NH3 TOTAL 298.76 KLBS 15.769 LBS/HR 2NHF05

U1 TOTAL FIRED HOURS 45.900 HRS
U2 TOTAL FIRED HOURS 45.400 HRS



BILLING-10AM 01 APR 22 09:59 PAGE 1
PRELIMINARY REVENUE MONITORING REPORT
POWER PLANT COGEN
CURRENT CURRENT DCS TAG #
*POWER*
U1 TOTAL MW HRS 526.68 MWH 32.967 NET MW U1 GROSS 33.786 1EEJ11-NT
U2 TOTAL MW HRS 489.55 MWH 30.769 NET MW U2 GROSS 31.966 2EEJ11-NT
U3 TOTAL MW HRS 430.40 MWH 26.984 NET MW 3EEJ11-NT
TOT TOTAL MWH TO NPC 1446.6 MWH 90.720 NET MW PLANT GROSS 92.736
TOT MWH TO NPC PER NPC METER 1418.4 MWH EEYY64
TOT MWH IMPORTED FROM NPC 0.0000 MWH EEYY63
AUX U1 AUX LOAD TOTAL 12.603 MWH 0.8193 MW
U2 AUX LOAD TOTAL 17.912 MWH 1.1965 MW
SUM OF AUX LOAD TOTALS 30.515 MWH 2.0159 MW
U2 NAT GAS TOTAL 284.36 KLBS 396.69 KSCFH 2FQG
U1 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1FGF20
U2 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2FGF20
AUX BLR #1 GAS TOTL 0.0000 KSCF 0.0000 KSCFH VOLCANO-NGAS
AUX BLR #2 GAS TOTL 0.0000 KSCF 0.0000 KSCFH BUD_BLR_NGAS
PLANT NAT GAS TOTL PER SPC METER 13598 KSCF 853.50 KSCFH FGF02
HYD U1 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1HXF20
U2 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2HXF20
TOTAL HYDROGEN RECEIVED 46.986 KSCF 0.0000 KSCFH HXF01
DECATHERMS OF HYDROGEN RECEIVED 14.729 MBTUS
OIL TOTAL FUEL OIL 0.0000 KLBS

*STEAM*
HP U1 HP STEAM FLOW TOTAL 2087.0 KLBS 131.20 KPPH 1HSF02
U2 HP STEAM FLOW TOTAL 2068.0 KLBS 130.05 KPPH 2HSF02
IP U1 IP STEAM MADE TOTL 270.42 KLBS 17.134 KPPH 1ISF02
U2 IP STEAM MADE TOTL 262.47 KLBS 17.155 KPPH 2ISF02
EXT CUSTOMER1 EXT STEAM TOTAL (NORMAL) 11.580 KLBS 0.0000 KPPH ESF12
CUSTOMER1 EXT STEAM TOTAL (AUX) 0.0000 KLBS 0.0000 KPPH ESF101
CUSTOMER2 EXT STEAM TOTAL 201.71 KLBS 14.859 KPPH OS-FT-STM
*CONDENSATE*
CUSTOMER1 CONDENSATE RETURN (2-4) TOTL 7.9159 KGALS 0.0000 GALS PCF01
CUSTOMER1 CONDENSATE RETURN (1ST) TOTL 2.2285 KGALS 0.0000 GALS PCF02B
CUSTOMER2 CONDENSATE RETURN 0.0000 KGALS 0.0000 GALS OS-FT-COND
*WATER*
SERVICE (RAW) WATER FLOW TOTAL 348.43 KGAL 392.53 GALS SWF01
POTABLE WATER 5.7751 KGAL 5.8000 GALS PWF01
DI WATER FROM PIONEER -0.910 KGAL -0.960 GALS DI-PCA-METR
WASTE WASTE WTR TO TANK 0.0000 GALS 0.0000 GALS WWF06
WASTE TO EVAP POND 0.0000 GALS ?0.0000 GALS WWF09
* * WASTE WTR TANK > PIONEER 0.1706 KGALS 0.1333 GALS WWF01

*TANK LEVELS*
FUEL OIL TANK 127250 GALS 16.967 % FULL FOL05
WASTE WATER TANK 25.784 FEET 64.459 % FULL WWL05A
PROCESS WATER TANK 392230 GALS 60.343 % FULL RWLY05
MAKE UP WATER TANK 131893 GALS 82.433 % FULL MUL02

*MISC.*
UNIT 1 NH3 TOTAL 294.69 KLBS 19.504 LBS/HR 1NHF05
UNIT 2 NH3 TOTAL 298.76 KLBS 15.769 LBS/HR 2NHF05

U1 TOTAL FIRED HOURS 45.900 HRS
U2 TOTAL FIRED HOURS 45.400 HRS



BILLING-1600 01 APR 22 15:59 PAGE 1
PRELIMINARY REVENUE MONITORING REPORT
POWER PLANT COGEN
CURRENT CURRENT DCS TAG #
*POWER*
U1 TOTAL MW HRS 526.68 MWH 32.967 NET MW U1 GROSS 33.786 1EEJ11-NT
U2 TOTAL MW HRS 489.55 MWH 30.769 NET MW U2 GROSS 31.966 2EEJ11-NT
U3 TOTAL MW HRS 430.40 MWH 26.984 NET MW 3EEJ11-NT
TOT TOTAL MWH TO NPC 1446.6 MWH 90.720 NET MW PLANT GROSS 92.736
TOT MWH TO NPC PER NPC METER 1418.4 MWH EEYY64
TOT MWH IMPORTED FROM NPC 0.0000 MWH EEYY63
AUX U1 AUX LOAD TOTAL 12.603 MWH 0.8193 MW
U2 AUX LOAD TOTAL 17.912 MWH 1.1965 MW
SUM OF AUX LOAD TOTALS 30.515 MWH 2.0159 MW
U2 NAT GAS TOTAL 284.36 KLBS 396.69 KSCFH 2FQG
U1 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1FGF20
U2 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2FGF20
AUX BLR #1 GAS TOTL 0.0000 KSCF 0.0000 KSCFH VOLCANO-NGAS
AUX BLR #2 GAS TOTL 0.0000 KSCF 0.0000 KSCFH BUD_BLR_NGAS
PLANT NAT GAS TOTL PER SPC METER 13598 KSCF 853.50 KSCFH FGF02
HYD U1 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1HXF20
U2 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2HXF20
TOTAL HYDROGEN RECEIVED 46.986 KSCF 0.0000 KSCFH HXF01
DECATHERMS OF HYDROGEN RECEIVED 14.729 MBTUS
OIL TOTAL FUEL OIL 0.0000 KLBS

*STEAM*
HP U1 HP STEAM FLOW TOTAL 2087.0 KLBS 131.20 KPPH 1HSF02
U2 HP STEAM FLOW TOTAL 2068.0 KLBS 130.05 KPPH 2HSF02
IP U1 IP STEAM MADE TOTL 270.42 KLBS 17.134 KPPH 1ISF02
U2 IP STEAM MADE TOTL 262.47 KLBS 17.155 KPPH 2ISF02
EXT CUSTOMER1 EXT STEAM TOTAL (NORMAL) 11.580 KLBS 0.0000 KPPH ESF12
CUSTOMER1 EXT STEAM TOTAL (AUX) 0.0000 KLBS 0.0000 KPPH ESF101
CUSTOMER2 EXT STEAM TOTAL 201.71 KLBS 14.859 KPPH OS-FT-STM
*CONDENSATE*
CUSTOMER1 CONDENSATE RETURN (2-4) TOTL 7.9159 KGALS 0.0000 GALS PCF01
CUSTOMER1 CONDENSATE RETURN (1ST) TOTL 2.2285 KGALS 0.0000 GALS PCF02B
CUSTOMER2 CONDENSATE RETURN 0.0000 KGALS 0.0000 GALS OS-FT-COND
*WATER*
SERVICE (RAW) WATER FLOW TOTAL 348.43 KGAL 392.53 GALS SWF01
POTABLE WATER 5.7751 KGAL 5.8000 GALS PWF01
DI WATER FROM PIONEER -0.910 KGAL -0.960 GALS DI-PCA-METR
WASTE WASTE WTR TO TANK 0.0000 GALS 0.0000 GALS WWF06
WASTE TO EVAP POND 0.0000 GALS ?0.0000 GALS WWF09
* * WASTE WTR TANK > PIONEER 0.1706 KGALS 0.1333 GALS WWF01

*TANK LEVELS*
FUEL OIL TANK 127250 GALS 16.967 % FULL FOL05
WASTE WATER TANK 25.784 FEET 64.459 % FULL WWL05A
PROCESS WATER TANK 392230 GALS 60.343 % FULL RWLY05
MAKE UP WATER TANK 131893 GALS 82.433 % FULL MUL02

*MISC.*
UNIT 1 NH3 TOTAL 294.69 KLBS 19.504 LBS/HR 1NHF05
UNIT 2 NH3 TOTAL 298.76 KLBS 15.769 LBS/HR 2NHF05

U1 TOTAL FIRED HOURS 45.900 HRS
U2 TOTAL FIRED HOURS 45.400 HRS


BILLING-2400 01 APR 22 23:59 PAGE 1
PRELIMINARY REVENUE MONITORING REPORT
POWER PLANT COGEN
CURRENT CURRENT DCS TAG #
*POWER*
U1 TOTAL MW HRS 526.68 MWH 32.967 NET MW U1 GROSS 33.786 1EEJ11-NT
U2 TOTAL MW HRS 489.55 MWH 30.769 NET MW U2 GROSS 31.966 2EEJ11-NT
U3 TOTAL MW HRS 430.40 MWH 26.984 NET MW 3EEJ11-NT
TOT TOTAL MWH TO NPC 1446.6 MWH 90.720 NET MW PLANT GROSS 92.736
TOT MWH TO NPC PER NPC METER 1418.4 MWH EEYY64
TOT MWH IMPORTED FROM NPC 0.0000 MWH EEYY63
AUX U1 AUX LOAD TOTAL 12.603 MWH 0.8193 MW
U2 AUX LOAD TOTAL 17.912 MWH 1.1965 MW
SUM OF AUX LOAD TOTALS 30.515 MWH 2.0159 MW
U2 NAT GAS TOTAL 284.36 KLBS 396.69 KSCFH 2FQG
U1 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1FGF20
U2 NAT GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2FGF20
AUX BLR #1 GAS TOTL 0.0000 KSCF 0.0000 KSCFH VOLCANO-NGAS
AUX BLR #2 GAS TOTL 0.0000 KSCF 0.0000 KSCFH BUD_BLR_NGAS
PLANT NAT GAS TOTL PER SPC METER 13598 KSCF 853.50 KSCFH FGF02
HYD U1 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 1HXF20
U2 H2 GAS DUCT TOTL 0.0000 KSCF 0.0000 KSCFH 2HXF20
TOTAL HYDROGEN RECEIVED 46.986 KSCF 0.0000 KSCFH HXF01
DECATHERMS OF HYDROGEN RECEIVED 14.729 MBTUS
OIL TOTAL FUEL OIL 0.0000 KLBS

*STEAM*
HP U1 HP STEAM FLOW TOTAL 2087.0 KLBS 131.20 KPPH 1HSF02
U2 HP STEAM FLOW TOTAL 2068.0 KLBS 130.05 KPPH 2HSF02
IP U1 IP STEAM MADE TOTL 270.42 KLBS 17.134 KPPH 1ISF02
U2 IP STEAM MADE TOTL 262.47 KLBS 17.155 KPPH 2ISF02
EXT CUSTOMER1 EXT STEAM TOTAL (NORMAL) 11.580 KLBS 0.0000 KPPH ESF12
CUSTOMER1 EXT STEAM TOTAL (AUX) 0.0000 KLBS 0.0000 KPPH ESF101
CUSTOMER2 EXT STEAM TOTAL 201.71 KLBS 14.859 KPPH OS-FT-STM
*CONDENSATE*
CUSTOMER1 CONDENSATE RETURN (2-4) TOTL 7.9159 KGALS 0.0000 GALS PCF01
CUSTOMER1 CONDENSATE RETURN (1ST) TOTL 2.2285 KGALS 0.0000 GALS PCF02B
CUSTOMER2 CONDENSATE RETURN 0.0000 KGALS 0.0000 GALS OS-FT-COND
*WATER*
SERVICE (RAW) WATER FLOW TOTAL 348.43 KGAL 392.53 GALS SWF01
POTABLE WATER 5.7751 KGAL 5.8000 GALS PWF01
DI WATER FROM PIONEER -0.910 KGAL -0.960 GALS DI-PCA-METR
WASTE WASTE WTR TO TANK 0.0000 GALS 0.0000 GALS WWF06
WASTE TO EVAP POND 0.0000 GALS ?0.0000 GALS WWF09
* * WASTE WTR TANK > PIONEER 0.1706 KGALS 0.1333 GALS WWF01

*TANK LEVELS*
FUEL OIL TANK 127250 GALS 16.967 % FULL FOL05
WASTE WATER TANK 25.784 FEET 64.459 % FULL WWL05A
PROCESS WATER TANK 392230 GALS 60.343 % FULL RWLY05
MAKE UP WATER TANK 131893 GALS 82.433 % FULL MUL02

*MISC.*
UNIT 1 NH3 TOTAL 294.69 KLBS 19.504 LBS/HR 1NHF05
UNIT 2 NH3 TOTAL 298.76 KLBS 15.769 LBS/HR 2NHF05

U1 TOTAL FIRED HOURS 45.900 HRS
U2 TOTAL FIRED HOURS 45.400 HRS



Here are the scripts:


COM1 (Logger)

;*************************************************************************
;* Messages.WAS 8/23/00 *
;* *
;* An ASPECT script for initializing logger capture file for a MOD 300 *
;* system using a PC for the printer. *
;* I have initiated the file save in a subdirectory of Mod300 based on *
;* on the year. ie C:\Mod300\2000\*.txt etc *
;* Windows conditions: Regional settings for date mm/dd/yyyy *
;* Startup: *
;* Target: "C:\Program Files\Procomm Plus\Aspect\Messages.wax" *
;* Start in: "C:\Program Files\Procomm Plus\aspect" *
;* Tested using burst of 400 messages with a 1ms txpace value *
;* and 10 second pause to check for date. Lost no messages and overlap *
;* was minimal. Used no hardware or software flow control. *
;* I have provided for a copy of the closed archive to go to the "S" *
;* network drive but I have not been able to prove that it will work. *
;* It can be removed if it does not work. *
;* Make sure that there is a directory on the "s" drive S:\Mod300 *
;* Under the Mod300 directory, make a directories for S:\Mod300\2000 *
;* S:\Mod300\2001 .... 200x for as many years as may be required *
;*************************************************************************
proc main

string CapturePathRoot
string CapturePath
string ArchiveFileName
string DateStr
string SaveDateStr
string Month
string sYear
string lYear
string Day
string SourceF
string DestF
string Str1
string Str2 = "\"
string Str3
string Str4
string Str5
string Str6
Integer SaveDateNum
CapturePathRoot = "C:\DCS\al"
CapturePath = "C:\DCS\al\2001"
ArchiveFileName = "01_04_00.txt"

clear
locate 0 0
set terminal type 30
set port parity odd
set port databits 7
set port baudrate 4800
set txpace 50
set duplex FULL
set port softflow OFF
set port hardflow OFF
set modem connection "direct connect-Com1"
set terminal scroll ON
set statusline ON
set terminal blockcursor ON
set terminal Autosize FONT
set terminal fontname "Courier"
set terminal fontsize 12
set terminal frame OFF
set terminal linewrap ON
set terminal rows 48
set terminal columns 132
set terminal rxcr CR
set terminal sbpages 1000
set terminal scrollmethod NORMAL
set terminal stripbit8 OFF
set terminal tabstops 8
set terminal viewcursor ON
set terminal update FAST
set terminal rawprint OFF
set terminal backspace NONDEST
set quickselect ON
set actionbar top "logger.pwb"
set capture recordmode screen
set capture overwrite OFF
set capture query OFF
set capture path CapturePath
set aspect ctrlbreak ON
set terminal rxcr CR

If failure
mkdir CapturePathRoot
mspause 50
mkdir CapturePath
set capture path CapturePath
endif

NewArchive:

DateStr = $DATE
SaveDateStr = $DATE
atoi SaveDateStr SaveDateNum

substr Month DateStr 0 2
substr Day DateStr 3 2
substr sYear DateStr 8 2
substr lYear DateStr 6 4

strupdt ArchiveFileName Month 0 2
strupdt ArchiveFileName Day 3 2
strupdt ArchiveFileName sYear 6 2
strupdt CapturePath lYear 10 4
Str1 = CapturePath
Str4 = "S:\Mod300\"
Str5 = lYear
Str6 = ArchiveFileName
set capture path CapturePath

If failure
mkdir CapturePath
set capture path CapturePath
endif

set capture file ArchiveFileName
capture on

CheckDate:

DateStr = $DATE

if strncmp SaveDateStr DateStr 10
pause 10
goto CheckDate
else
capture off
mspause 200

;* This section can be commented out if the copy to drive "s" does not work

Str3 = ArchiveFileName
strcat Str1 Str2
strcat Str1 Str3
SourceF = Str1
Str4 = "f:\Mod300\"
strcat Str4 Str5
strcat Str4 Str2
strcat Str4 Str6
DestF = Str4


;*if not copyfile Sourcef Destf

;*errormsg "Couldn't copy file `"%s`"!" Sourcef

;*endif

;* End of network drive copy

goto NewArchive

endif
endproc


COM2 (Reports):

;*************************************************************************
;* Messages.WAS 8/23/00 *
;* *
;* An ASPECT script for initializing logger capture file for a MOD 300 *
;* system using a PC for the printer. *
;* I have initiated the file save in a subdirectory of Mod300 based on *
;* on the year. ie C:\Mod300\2000\*.txt etc *
;* Windows conditions: Regional settings for date mm/dd/yyyy *
;* Startup: *
;* Target: "C:\Program Files\Procomm Plus\Aspect\Messages.wax" *
;* Start in: "C:\Program Files\Procomm Plus\aspect" *
;* Tested using burst of 400 messages with a 1ms txpace value *
;* and 10 second pause to check for date. Lost no messages and overlap *
;* was minimal. Used no hardware or software flow control. *
;* I have provided for a copy of the closed archive to go to the "S" *
;* network drive but I have not been able to prove that it will work. *
;* It can be removed if it does not work. *
;* Make sure that there is a directory on the "s" drive S:\Mod300 *
;* Under the Mod300 directory, make a directories for S:\Mod300\2000 *
;* S:\Mod300\2001 .... 200x for as many years as may be required *
;*************************************************************************
proc main

string CapturePathRoot
string CapturePath
string ArchiveFileName
string DateStr
string SaveDateStr
string Month
string sYear
string lYear
string Day
string SourceF
string DestF
string Str1
string Str2 = "\"
string Str3
string Str4
string Str5
string Str6
Integer SaveDateNum
CapturePathRoot = "C:\DCS\rw"
CapturePath = "C:\DCS\rw\2001"
ArchiveFileName = "01_04_00.txt"

clear
locate 0 0
set terminal type 30
set port parity odd
set port databits 7
set port baudrate 4800
set txpace 50
set duplex FULL
set port softflow OFF
set port hardflow OFF
set modem connection "direct connect-Com2"
set terminal scroll ON
set statusline ON
set terminal blockcursor ON
set terminal Autosize FONT
set terminal fontname "Courier"
set terminal fontsize 12
set terminal frame OFF
set terminal linewrap ON
set terminal rows 48
set terminal columns 132
set terminal rxcr CR
set terminal sbpages 1000
set terminal scrollmethod NORMAL
set terminal stripbit8 OFF
set terminal tabstops 8
set terminal viewcursor ON
set terminal update FAST
set terminal rawprint OFF
set terminal backspace NONDEST
set quickselect ON
set actionbar top "reports.pwb"
set capture recordmode screen
set capture overwrite OFF
set capture query OFF
set capture path CapturePath
set aspect ctrlbreak ON
set terminal rxcr CR

If failure
mkdir CapturePathRoot
mspause 50
mkdir CapturePath
set capture path CapturePath
endif

NewArchive:

DateStr = $DATE
SaveDateStr = $DATE
atoi SaveDateStr SaveDateNum

substr Month DateStr 0 2
substr Day DateStr 3 2
substr sYear DateStr 8 2
substr lYear DateStr 6 4

strupdt ArchiveFileName Month 0 2
strupdt ArchiveFileName Day 3 2
strupdt ArchiveFileName sYear 6 2
strupdt CapturePath lYear 10 4
Str1 = CapturePath
Str4 = "\\powerplant1\projects\DCS\Reports\"
Str5 = lYear
Str6 = ArchiveFileName
set capture path CapturePath

If failure
mkdir CapturePath
set capture path CapturePath
endif

set capture file ArchiveFileName
capture on

CheckDate:

DateStr = $DATE

if strncmp SaveDateStr DateStr 10
pause 10
goto CheckDate
else
capture off
mspause 200

;* This section can be commented out if the copy to drive "s" does not work

Str3 = ArchiveFileName
strcat Str1 Str2
strcat Str1 Str3
SourceF = Str1
Str4 = "f:\Mod300A\"
strcat Str4 Str5
strcat Str4 Str2
strcat Str4 Str6
DestF = Str4


;*if not copyfile SourceF DestF

;*errormsg "Couldn't copy file `"%s`"!" SourceF

;*endif

;* End of network drive copy

goto NewArchive

endif
endproc


_______________________________________________________________________

So the way I see it, once the script is started, it creates a capture file based on the date, then reads from the com port to the capture buffer until the date string changes (as it compares DateStr to SaveDateStr) once the date changes, within 10 seconds, it 'capture off's, dumping the capture buffer to the file, and creates a new capture file and opens a new capture buffer....

At least that is how it was intended to work.

Both scripts run concurrently.

Regarding the Reports file there are a lot of problems:

The most common one is that the terminal locks up after a few days and the capture buffer stays the same day after day, creating identical files until someone notices it.

I tried to place a new label above all of the "set" statements only to find out that breaks the script, so I copied that whole block of initializing set's down right before goto NewArchive, with the thoughts that perhaps that would prevent the terminal from locking up, and to perhaps ensure that each day gets a fresh start with no garbage. I've been unlucky. It worked like I wanted as I tested by manually printing each of the four reports and using the computer clock to change the date... But over the weekend, it didn't work well. Only the 1600 report went through to the capture file.

Also, I'm able now to recreate a problem that has been reported in the past where a report prints out just fine in the procomm window, but when it's 'capture off' time, a chunk out of the middle of one of the reports, usually the last one, ends up missing in the final file... I tried experimenting with 'mspause 200's length to try to remedy this, but I have not been able to figure it out so far.

I'd like to eventually send custom reports that I can have processed into excel, to eliminate operator data entry but judging from my problems so far, I'm a long way off

I can modify the reports to send a special character sequence, allowing a loop in the script to detect the end of each individual report and 'capture off' and append to the file each time if that is a better way. I'm willing to roll my sleves up here, I'm just looking for some guidance. Ultimately I want a text file for each day with the logger alarms for that entire day. And I want the same thing for the reports. Is the framework I'm working with a good one to build from? or is there a better overall process? We dont use the section for copy to drive "s" yet, but we would like to be able to at some point.

Thanks in advance for any help or guidance you may have.
 
I have a question. Does the report output occur at the same times each day (roughly?) At 0500, 1000, 1600 and 2400?

If this is the case, you may want to consider keying your capture of the reports by using a 'waitfor "BILLING" FOREVER' and using 'waitquiet 10 forever'(or whatever timing works best) to end the capture. This way your capturing the data in smaller chunks.

This would serve two purposes. One, in case something bad happened (like your terminal crashing in the middle of the day) you would at least have partial data for the day. Secondly, you would reduce your dependence on the capture buffer, limiting the chances of your problem with missing data.

 
Thanks so much for such a quick and helpful reply, kodr:

Yes, it's always at the same time each day. I saw an example with waitfor in it, and it seemed like something I'd want to explore for similar reasons to what you gave. Thanks for the tip, I'll be trying it out.

As for my alarm logger script, it is completely random and there are usually several hundred alarms for any given day. would re-initializing everything with the set statements just before goto NewArchive be a good way to do it? These alarms can post seconds or fractions of a second apart, so waitfor is maybe a bad idea here.
 
To add, during the summer months, there's one more report that prints at 2200... That changes at the same time every year.
 
The 2200 time shouldn't be an issue if you key off of a bit of starting and ending text, so it will open, capture, and close a file regardless of what time it is. This will make it a bit more dynamic, and if for some reason the timing of these reports ever change due to some other system getting a software update, or needs change, you won't have to do anything to your code.

For your events logger, one possibility is to take your events and store them as an array, instead of capturing to a file directly. After the array gets to a certain size, then dump it to a file, and reset the array. You could also set it up where at certain times of the day the array is dumped to a file and reset regardless of the size, to minimize data loss due to unforeseen events.

Knob could probably address the issue of what might be happening with a capture file that is left open long term better than I can. To be honest, I've never seen that situation myself.
 
Regarding data missing from the capture file, one thing to try is issuing a clear command prior to the capture off command. Procomm requires that at least one line from the screen scroll off before the data is saved to the scrollback buffer and thus the capture file. Issuing the clear command will force the data (indeed, the whole screen) to scroll and should appear in the capture file. If you see this occur again, look in the scrollback buffer of Procomm and see if the missing data is there, or if it did not get sent as expected for some reason. The one downside to this change is that you will see some extra blank lines in the capture file.

I would also do something like what kodr mentioned regarding keying off the start and stops of the report to open and close the capture file. The less time you have the capture files open the better.

I haven't had a chance to check this yet, but have you tried comparing the two scripts to see what commands are in the problem (COM2) script that are not present in the COM1 script? That would help narrow down where that particular problem might lay.

 
Thanks a whole lot... That's exactly what I was going to post about this morning. I created a new script, keeping the initializing settings, and using a while 1 loop and waitfor FOREVER loop and it worked great, I set it up to keep the capture file open for 1 minute with a waitquiet 60 forever (I may change the report to give it something to turn off with, instead of time-based), I alos cleaned up the way the file name and path are created and re-created. Once I see the capture file close, I open it up, and I see exactly what you're talking about, knob, I see the top line that is visible in the terminal and everything below it looks good. Then there's missing data above it, the first few lines are ok though. Just a chunk out of the middle of the initial report is missing, right up until the top visible line of the terminal. I noticed that the terminal was set for 48 rows, my report has 60, but playing with that number didn't fix anything... Then I changed screen resolution so that I could see all 60 lines in the terminal, and the capture file was flawless. So that supports your advice, and has me excited to start out my day. Thanks a bunch. I'll be working on the COM1 file next, if this works. Thanks again!!!!
 
Great, well, the extra lines are a bit of a problem, but it works. I used the advice and came up with something else that should work, it's been working for me all day... With the screen resolution back to normal, I reduced the number of rows for the terminal to 36, that seems to get enough scrolled off to make it all save to the capture file every time.... So the big problems are seemingly fixed.

Another thing I'm having a problem getting to happen is having the screen clear sometime between the 0000 and 0500 report each day (not too close to the printing of the 0000 report).

I tried to use my time integers to create an 'if' like

if (ihour > 0) && (ihour < 4)

clear

endif

along with setting the timout for the waitfor to something like 10800. But that's not seeming to work for me...

Any ideas?


Also for the COM1, the DCS prints out page headers on it's own, after so many events. And each one starts with "LOGGER1" So I'm thinking that I'll somehow use that to both close and reopen the capture file...it's not ideal, but it's better than before.
 
Also, (sorry) I tried to use the when command since the help file states on the bottom of waitfor, that when commands stay active during waitfors but I haven't been able to figure that out enough to make any progress.
 
I just looked over an old program that I use to capture quiet a bit of data from. Some of my capture files are only 2 or 3 lines long. This made me wonder why I wasn't running into the problem with the capture file like you are.

Here's a snippet of my code:

Code:
waitfor ">" forever
clear
capture on
transmit "lis all^m"
waitfor ">" forever
capture off

In my case, the "lis all" triggers the output. For you, it may look something like:

Code:
... code here to name the file

waitfor "BILLING-" forever
capture on
waitquiet 10 forever
capture off
clear

You would need a clear call somewhere near the top of your code initially.

Is this close to what you currently have?
 
I forgot to pop back in and thank you for all of your help.

I've used your waitfor "x" FOREVER method to initiate the capture, and I included another waitfor "y" FOREVER to close the capture file and give a clear command. then it goes back through the while 1 loop to waitfor "x"... pretty much like you have it.

So yeah, it's pretty close.

It's eliminated the cut off captures, but I have a new problem.

The capture file is about 64 rows long, and I'm consistantly getting 64 lines of whitespace after each capture.

Is this common? I have a clear in the beginning of the program, before the while loop, in the beginning of the while loop before the first waitfor, and at the end of the loop, right after end capture. These extra rows are not on the buffer, only in the capture file.

Is there a fix for this?
What can I add to elaborate, if needed?
 
You might try commenting out the clear statements one at a time to see if there are some you can live without. In other words, some of them might not be truly needed and are increasing the amount of blank lines unnecessarily.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top