KMPRBD05 ;OAK/RAK - RUM Data Compression for Test Lab ;1/30/13 08:30
;;2.0;CAPACITY MANAGEMENT - RUM;**2**;May 28, 2003;Build 12
;
; Background Driver (cont.)
;
DAILY(KMPRTDAY) ;-- daily data compression and storage
;----------------------------------------------------------------------
; KMPRTDAY.. Day in $H format (+$H). This represents the
; ending point for compression. Only dates LESS than
; KMPRTDAY will be compressed.
;
; At midnight compress hourly info into daily stats. Daily stats are
; stored in file #8971.1. Hourly data is killed.
;----------------------------------------------------------------------
;
Q:'$G(KMPRTDAY)
;
N CNT,DATA,FMHDATE,HDATE,HR,I,JOB,LAB,MINUTES,NODE,OPTION,QUIET
;
K ^TMP($J)
;
; make sure DT is defined.
S:'$G(DT) DT=$$DT^XLFDT
;
; if not queued output dots
S QUIET=$D(ZTQUEUED)
W:'QUIET !,"Compiling stats..."
;
K ^KMPTMP("KMPR-TESTLAB"),^TMP($J)
S NODE=""
F S NODE=$O(^KMPTMP("KMPR","DLY",NODE)) Q:NODE="" D
.S HDATE=""
.F S HDATE=$O(^KMPTMP("KMPR","DLY",NODE,HDATE)) Q:HDATE=""!(HDATE'<KMPRTDAY) D
..;
..S FMHDATE=+$$HTFM^XLFDT(HDATE,1)
..;
..S HR=""
..F S HR=$O(^KMPTMP("KMPR","DLY",NODE,HDATE,HR)) Q:HR="" D
...S OPTION=""
...F S OPTION=$O(^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION)) Q:OPTION="" D
....S JOB=0
....F S JOB=$O(^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION,JOB)) Q:'JOB D
.....;
.....S DATA=^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION,JOB)
.....S MINUTES=$P(DATA,U,10,999)
.....;
.....S LAB=""
.....; if current data is negative
.....I $P(LAB,U,5)<0 D
......S $P(^KMPTMP("KMPR","NEG","DLY",OPTION,"C"),U,5)=$P(LAB,U,5)
.....;
.....; if new data is negative
.....I ($P(DATA,U,5)<0) D
......S $P(^KMPTMP("KMPR","NEG","DLY",OPTION,"N"),U,5)=$P(DATA,U,5)
.....;
.....; if sum of pieces are negative
.....I ($P(LAB,U,5)+$P(DATA,U,5))<0 D
......S $P(^KMPTMP("KMPR","NEG","DLY",OPTION,"T"),U,5)=($P(LAB,U,5))_"+"_($P(DATA,U,5))_"="_($P(LAB,U,5)+$P(DATA,U,5))
.....;
.....; accumulate totals
.....; data elements - pieces 1 - 8
.....F I=1:1:8 S $P(LAB,U,I)=$P($G(LAB),U,I)+$P(DATA,U,I)
.....;
.....; CNT(1) = minutes 0 = 29
.....; CNT(2) = minutes 30 = 59
.....F I=1:1:30 S $P(CNT(1),U,I)=$P(MINUTES,U,I)
.....F I=31:1:60 S $P(CNT(2),U,(I-30))=$P(MINUTES,U,I)
.....;
.....S ^TMP($J,HDATE,NODE,OPTION,HR)=LAB
.....F I=1:1:30 S $P(^TMP($J,HDATE,NODE,OPTION,HR,1),U,I)=$P($G(^TMP($J,HDATE,NODE,OPTION,HR,1)),U,I)+$P(CNT(1),U,I)
.....F I=1:1:30 S $P(^TMP($J,HDATE,NODE,OPTION,HR,2),U,I)=$P($G(^TMP($J,HDATE,NODE,OPTION,HR,2)),U,I)+$P(CNT(2),U,I)
.....; remove data from array
.....K ^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION,JOB)
.....W:'QUIET "."
;
;
; compile into daily stats
S HDATE=0
F S HDATE=$O(^TMP($J,HDATE)) Q:'HDATE S NODE="" D
.S FMHDATE=$$HTFM^XLFDT(HDATE) Q:'FMHDATE
.F S NODE=$O(^TMP($J,HDATE,NODE)) Q:NODE="" S OPTION="" D
..F S OPTION=$O(^TMP($J,HDATE,NODE,OPTION)) Q:OPTION="" S HR=0 D
...F S HR=$O(^TMP($J,HDATE,NODE,OPTION,HR)) Q:'HR D
....S ^KMPTMP("KMPR-TESTLAB",FMHDATE,NODE,OPTION)=FMHDATE_"^^"_NODE_"^"_$P(OPTION,"***")_"^"_$P(OPTION,"***",2)_"^"_$$RUMDESIG^KMPRBD03(OPTION)
....S ^KMPTMP("KMPR-TESTLAB",FMHDATE,NODE,OPTION,HR,1)=$G(^TMP($J,HDATE,NODE,OPTION,HR,1))
....S ^KMPTMP("KMPR-TESTLAB",FMHDATE,NODE,OPTION,HR,2)=$G(^TMP($J,HDATE,NODE,OPTION,HR,2))
....W:'QUIET "."
;
K ^TMP($J)
;
W:'QUIET " done!"
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPRBD05 3521 printed Dec 13, 2024@01:41:36 Page 2
KMPRBD05 ;OAK/RAK - RUM Data Compression for Test Lab ;1/30/13 08:30
+1 ;;2.0;CAPACITY MANAGEMENT - RUM;**2**;May 28, 2003;Build 12
+2 ;
+3 ; Background Driver (cont.)
+4 ;
DAILY(KMPRTDAY) ;-- daily data compression and storage
+1 ;----------------------------------------------------------------------
+2 ; KMPRTDAY.. Day in $H format (+$H). This represents the
+3 ; ending point for compression. Only dates LESS than
+4 ; KMPRTDAY will be compressed.
+5 ;
+6 ; At midnight compress hourly info into daily stats. Daily stats are
+7 ; stored in file #8971.1. Hourly data is killed.
+8 ;----------------------------------------------------------------------
+9 ;
+10 if '$GET(KMPRTDAY)
QUIT
+11 ;
+12 NEW CNT,DATA,FMHDATE,HDATE,HR,I,JOB,LAB,MINUTES,NODE,OPTION,QUIET
+13 ;
+14 KILL ^TMP($JOB)
+15 ;
+16 ; make sure DT is defined.
+17 if '$GET(DT)
SET DT=$$DT^XLFDT
+18 ;
+19 ; if not queued output dots
+20 SET QUIET=$DATA(ZTQUEUED)
+21 if 'QUIET
WRITE !,"Compiling stats..."
+22 ;
+23 KILL ^KMPTMP("KMPR-TESTLAB"),^TMP($JOB)
+24 SET NODE=""
+25 FOR
SET NODE=$ORDER(^KMPTMP("KMPR","DLY",NODE))
if NODE=""
QUIT
Begin DoDot:1
+26 SET HDATE=""
+27 FOR
SET HDATE=$ORDER(^KMPTMP("KMPR","DLY",NODE,HDATE))
if HDATE=""!(HDATE'<KMPRTDAY)
QUIT
Begin DoDot:2
+28 ;
+29 SET FMHDATE=+$$HTFM^XLFDT(HDATE,1)
+30 ;
+31 SET HR=""
+32 FOR
SET HR=$ORDER(^KMPTMP("KMPR","DLY",NODE,HDATE,HR))
if HR=""
QUIT
Begin DoDot:3
+33 SET OPTION=""
+34 FOR
SET OPTION=$ORDER(^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION))
if OPTION=""
QUIT
Begin DoDot:4
+35 SET JOB=0
+36 FOR
SET JOB=$ORDER(^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION,JOB))
if 'JOB
QUIT
Begin DoDot:5
+37 ;
+38 SET DATA=^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION,JOB)
+39 SET MINUTES=$PIECE(DATA,U,10,999)
+40 ;
+41 SET LAB=""
+42 ; if current data is negative
+43 IF $PIECE(LAB,U,5)<0
Begin DoDot:6
+44 SET $PIECE(^KMPTMP("KMPR","NEG","DLY",OPTION,"C"),U,5)=$PIECE(LAB,U,5)
End DoDot:6
+45 ;
+46 ; if new data is negative
+47 IF ($PIECE(DATA,U,5)<0)
Begin DoDot:6
+48 SET $PIECE(^KMPTMP("KMPR","NEG","DLY",OPTION,"N"),U,5)=$PIECE(DATA,U,5)
End DoDot:6
+49 ;
+50 ; if sum of pieces are negative
+51 IF ($PIECE(LAB,U,5)+$PIECE(DATA,U,5))<0
Begin DoDot:6
+52 SET $PIECE(^KMPTMP("KMPR","NEG","DLY",OPTION,"T"),U,5)=($PIECE(LAB,U,5))_"+"_($PIECE(DATA,U,5))_"="_($PIECE(LAB,U,5)+$PIECE(DATA,U,5))
End DoDot:6
+53 ;
+54 ; accumulate totals
+55 ; data elements - pieces 1 - 8
+56 FOR I=1:1:8
SET $PIECE(LAB,U,I)=$PIECE($GET(LAB),U,I)+$PIECE(DATA,U,I)
+57 ;
+58 ; CNT(1) = minutes 0 = 29
+59 ; CNT(2) = minutes 30 = 59
+60 FOR I=1:1:30
SET $PIECE(CNT(1),U,I)=$PIECE(MINUTES,U,I)
+61 FOR I=31:1:60
SET $PIECE(CNT(2),U,(I-30))=$PIECE(MINUTES,U,I)
+62 ;
+63 SET ^TMP($JOB,HDATE,NODE,OPTION,HR)=LAB
+64 FOR I=1:1:30
SET $PIECE(^TMP($JOB,HDATE,NODE,OPTION,HR,1),U,I)=$PIECE($GET(^TMP($JOB,HDATE,NODE,OPTION,HR,1)),U,I)+$PIECE(CNT(1),U,I)
+65 FOR I=1:1:30
SET $PIECE(^TMP($JOB,HDATE,NODE,OPTION,HR,2),U,I)=$PIECE($GET(^TMP($JOB,HDATE,NODE,OPTION,HR,2)),U,I)+$PIECE(CNT(2),U,I)
+66 ; remove data from array
+67 KILL ^KMPTMP("KMPR","DLY",NODE,HDATE,HR,OPTION,JOB)
+68 if 'QUIET
WRITE "."
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+69 ;
+70 ;
+71 ; compile into daily stats
+72 SET HDATE=0
+73 FOR
SET HDATE=$ORDER(^TMP($JOB,HDATE))
if 'HDATE
QUIT
SET NODE=""
Begin DoDot:1
+74 SET FMHDATE=$$HTFM^XLFDT(HDATE)
if 'FMHDATE
QUIT
+75 FOR
SET NODE=$ORDER(^TMP($JOB,HDATE,NODE))
if NODE=""
QUIT
SET OPTION=""
Begin DoDot:2
+76 FOR
SET OPTION=$ORDER(^TMP($JOB,HDATE,NODE,OPTION))
if OPTION=""
QUIT
SET HR=0
Begin DoDot:3
+77 FOR
SET HR=$ORDER(^TMP($JOB,HDATE,NODE,OPTION,HR))
if 'HR
QUIT
Begin DoDot:4
+78 SET ^KMPTMP("KMPR-TESTLAB",FMHDATE,NODE,OPTION)=FMHDATE_"^^"_NODE_"^"_$PIECE(OPTION,"***")_"^"_$PIECE(OPTION,"***",2)_"^"_$$RUMDESIG^KMPRBD03(OPTION)
+79 SET ^KMPTMP("KMPR-TESTLAB",FMHDATE,NODE,OPTION,HR,1)=$GET(^TMP($JOB,HDATE,NODE,OPTION,HR,1))
+80 SET ^KMPTMP("KMPR-TESTLAB",FMHDATE,NODE,OPTION,HR,2)=$GET(^TMP($JOB,HDATE,NODE,OPTION,HR,2))
+81 if 'QUIET
WRITE "."
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+82 ;
+83 KILL ^TMP($JOB)
+84 ;
+85 if 'QUIET
WRITE " done!"
+86 ;
+87 QUIT