Lookup Parameter Name From File1 Get Detailed Data From File 2
Using awk95 on Windows XP
I have one file that contains multiple lists. Each list begins with @NAME:, followed by the list name. Each list contains a list of parameter names. Each parameter name begins with @PARAM:. The @NUM_PARS: is equal to the number of expected parameters for each list.
Sample file containing multiple Lists and it’s associated Parameters: (sorry data is in UPPERCASE - I'm not shouting)
@NAME: 1CBC_GAINS
@DESC: Gains and Impedance Checks
@GENERAL_LIST
@NUM_PARS: 4
@PARAM: B1_17R_03_00 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@PARAM: B2_17R_03_00 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@PARAM: B1_17T_03_02 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@PARAM: B2_17T_03_02 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@NAME: 1C_A_FSLW
@DESC: ME Act A Data
@GENERAL_LIST
@NUM_PARS: 3
@PARAM: VCME_A_CMD_R @WRAP: ON @TYPE: EU @LOLIM: -3.0e+00 @HILIM: 3.0e+00 @DTVAR: 0.0e+00 @FMT: FLOAT @RES: 3
@PARAM: VCBAT_V_1 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 7.6e-01 @FMT: FLOAT @RES: 3
@PARAM: VCME_ACTAVLV_I_R @WRAP: ON @TYPE: EU @LOLIM: -6.0e-01 @HILIM: 6.0e-01 @DTVAR: 0.0e+00 @FMT: FLOAT @RES: 3
@NAME: 1C_BATCCV
@DESC: Battery Closed Circuit Voltage
@GENERAL_LIST
@DATA_TREND_LIST
@NUM_PARS: 3
@PARAM: VCBAT_V_1 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 7.6e-01 @FMT: FLOAT @RES: 3
@PARAM: VCBAT_I_1 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 2.0e+00 @FMT: FLOAT @RES: 3
@PARAM: VCBAT1_TMP @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 2.8e+00 @FMT: FLOAT @RES: 3
And I have a second file that contains detailed parameter data for all the parameter names above.
Sample Detailed Parameter data file:
NOTE: Each block of data begins with @NAME: and ends with @FMT:
@NAME: ASALARM_HB @STREAM: USER
@DESC: MAPS HEARTBEAT @UNITS: Bi-lvl
@DATAQ_AA
@ENABLE_LIMITS: NO
@PROC_LOC: FRONT END @FEND_NO: 1 @TIME_FMT: BINARY
@RAW_COMP: NONE
@RAW_CONV: IEEE FP
@EU_CAL: NULL
@EU_COMP: NONE
@YEL_LO: -9.999990e+05 @YEL_HI: 9.999990e+05 @RED_LO: -9.999990e+05 @RED_HI: 9.999990e+05
@DYN_LIMS: INACTIVE
@FMT: FLOAT @RES: 3
@NAME: VCME_A_CMD_R @STREAM: DERIVED
@DESC: MAIN RANGING @UNITS: Degree
@DATAQ_BB
@ENABLE_LIMITS: NO
@DER_TRIG: VCME_A_CMD_1 @DER_EXP:
IF ((M(VCME_A_CMD_1) > -9.5) AND (M(VCME_A_CMD_1) < 9.5)) THEN
DP = M(VCME_A_CMD_1_X);
ELSE DP = M(VCME_A_CMD_1);
@YEL_LO: -9.999990e+05 @YEL_HI: 9.999990e+05 @RED_LO: -9.999990e+05 @RED_HI: 9.999990e+05
@DYN_LIMS: INACTIVE
@ROC: INACTIVE
@FMT: FLOAT @RES: 3
@NAME: VCBAT_V_1 @STREAM: STR
@DESC: BATT VOLTAGE @UNITS: VDC
@DATAQ_EU
@TIME_TAG: NO @ENABLE_LIMITS: YES
@NUM_SYLS: 1
@SYL: 1 @IFRAME: 10 @IWORD: 197 @FR_INC: 10 @WD_INC: 0 @MSB: 7 @LSB: 0
@WD_TYPE: RAW
@RAW_COMP: NONE
@RAW_CONV: NONE
@EU_CAL: NTH @ORDER: 1
@C0: -4.596000e-01 @C1: 1.532000e-01
@EU_COMP: NONE
@SIM_TYPE: NONE
@YEL_LO: -9.999000e+03 @YEL_HI: 9.999000e+03 @RED_LO: -9.999000e+03 @RED_HI: 9.999000e+03
@DYN_LIMS: ACTIVE @TRANS_LIMS: YES @NUM_EVENTS: 4
@EVENT: 1 @DYN_TRIG: CCTM_ON_S @DYN_OPER: = @DYN_TVAL: 1.000000e+00
@DEL_Y_LO: 9.998500e+03 @DEL_Y_HI: -9.960240e+03 @DEL_R_LO: 9.998500e+03 @DEL_R_HI: -9.949000e+03
@TIME_ON: 3.000000e+00 @TIME_OFF: 3.000000e+00
@ON_Y_LO: 0.000000e+00 @ON_Y_HI: 0.000000e+00 @ON_R_LO: 0.000000e+00 @ON_R_HI: 0.000000e+00
@OFF_Y_LO: 0.000000e+00 @OFF_Y_HI: 0.000000e+00 @OFF_R_LO: 0.000000e+00 @OFF_R_HI: 0.000000e+00
@ROC: INACTIVE
@FMT: FLOAT @RES: 3
I would like to create a program where I can:
1. specify a list name (such as: 1C_A_FSLW) as part of the command line
2. have the program locate the list and it’s associated parameter names in the first file.
3. have it get the detailed parameter data from the second file and generate a new file containing the detailed parameters.
I have worked with code where I could get all names and descriptions (very simple code) such as:
# Get NAME
$1~/@NAME/ { a=$2 }
# Get Description
/@DESC/ { b=$0 }
# Print results
a!="" && b!="" { print a "\n",b “\n”; a=b="" }
But now I would like to get the detailed parameter data based on the list names and output them to a new file as stated above.
Using awk95 on Windows XP
I have one file that contains multiple lists. Each list begins with @NAME:, followed by the list name. Each list contains a list of parameter names. Each parameter name begins with @PARAM:. The @NUM_PARS: is equal to the number of expected parameters for each list.
Sample file containing multiple Lists and it’s associated Parameters: (sorry data is in UPPERCASE - I'm not shouting)
@NAME: 1CBC_GAINS
@DESC: Gains and Impedance Checks
@GENERAL_LIST
@NUM_PARS: 4
@PARAM: B1_17R_03_00 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@PARAM: B2_17R_03_00 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@PARAM: B1_17T_03_02 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@PARAM: B2_17T_03_02 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+05 @HILIM: 9.9e+05 @DTVAR: 0.0e+00 @FMT: HEX
@NAME: 1C_A_FSLW
@DESC: ME Act A Data
@GENERAL_LIST
@NUM_PARS: 3
@PARAM: VCME_A_CMD_R @WRAP: ON @TYPE: EU @LOLIM: -3.0e+00 @HILIM: 3.0e+00 @DTVAR: 0.0e+00 @FMT: FLOAT @RES: 3
@PARAM: VCBAT_V_1 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 7.6e-01 @FMT: FLOAT @RES: 3
@PARAM: VCME_ACTAVLV_I_R @WRAP: ON @TYPE: EU @LOLIM: -6.0e-01 @HILIM: 6.0e-01 @DTVAR: 0.0e+00 @FMT: FLOAT @RES: 3
@NAME: 1C_BATCCV
@DESC: Battery Closed Circuit Voltage
@GENERAL_LIST
@DATA_TREND_LIST
@NUM_PARS: 3
@PARAM: VCBAT_V_1 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 7.6e-01 @FMT: FLOAT @RES: 3
@PARAM: VCBAT_I_1 @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 2.0e+00 @FMT: FLOAT @RES: 3
@PARAM: VCBAT1_TMP @WRAP: ON @TYPE: EU @LOLIM: -9.9e+03 @HILIM: 9.9e+03 @DTVAR: 2.8e+00 @FMT: FLOAT @RES: 3
And I have a second file that contains detailed parameter data for all the parameter names above.
Sample Detailed Parameter data file:
NOTE: Each block of data begins with @NAME: and ends with @FMT:
@NAME: ASALARM_HB @STREAM: USER
@DESC: MAPS HEARTBEAT @UNITS: Bi-lvl
@DATAQ_AA
@ENABLE_LIMITS: NO
@PROC_LOC: FRONT END @FEND_NO: 1 @TIME_FMT: BINARY
@RAW_COMP: NONE
@RAW_CONV: IEEE FP
@EU_CAL: NULL
@EU_COMP: NONE
@YEL_LO: -9.999990e+05 @YEL_HI: 9.999990e+05 @RED_LO: -9.999990e+05 @RED_HI: 9.999990e+05
@DYN_LIMS: INACTIVE
@FMT: FLOAT @RES: 3
@NAME: VCME_A_CMD_R @STREAM: DERIVED
@DESC: MAIN RANGING @UNITS: Degree
@DATAQ_BB
@ENABLE_LIMITS: NO
@DER_TRIG: VCME_A_CMD_1 @DER_EXP:
IF ((M(VCME_A_CMD_1) > -9.5) AND (M(VCME_A_CMD_1) < 9.5)) THEN
DP = M(VCME_A_CMD_1_X);
ELSE DP = M(VCME_A_CMD_1);
@YEL_LO: -9.999990e+05 @YEL_HI: 9.999990e+05 @RED_LO: -9.999990e+05 @RED_HI: 9.999990e+05
@DYN_LIMS: INACTIVE
@ROC: INACTIVE
@FMT: FLOAT @RES: 3
@NAME: VCBAT_V_1 @STREAM: STR
@DESC: BATT VOLTAGE @UNITS: VDC
@DATAQ_EU
@TIME_TAG: NO @ENABLE_LIMITS: YES
@NUM_SYLS: 1
@SYL: 1 @IFRAME: 10 @IWORD: 197 @FR_INC: 10 @WD_INC: 0 @MSB: 7 @LSB: 0
@WD_TYPE: RAW
@RAW_COMP: NONE
@RAW_CONV: NONE
@EU_CAL: NTH @ORDER: 1
@C0: -4.596000e-01 @C1: 1.532000e-01
@EU_COMP: NONE
@SIM_TYPE: NONE
@YEL_LO: -9.999000e+03 @YEL_HI: 9.999000e+03 @RED_LO: -9.999000e+03 @RED_HI: 9.999000e+03
@DYN_LIMS: ACTIVE @TRANS_LIMS: YES @NUM_EVENTS: 4
@EVENT: 1 @DYN_TRIG: CCTM_ON_S @DYN_OPER: = @DYN_TVAL: 1.000000e+00
@DEL_Y_LO: 9.998500e+03 @DEL_Y_HI: -9.960240e+03 @DEL_R_LO: 9.998500e+03 @DEL_R_HI: -9.949000e+03
@TIME_ON: 3.000000e+00 @TIME_OFF: 3.000000e+00
@ON_Y_LO: 0.000000e+00 @ON_Y_HI: 0.000000e+00 @ON_R_LO: 0.000000e+00 @ON_R_HI: 0.000000e+00
@OFF_Y_LO: 0.000000e+00 @OFF_Y_HI: 0.000000e+00 @OFF_R_LO: 0.000000e+00 @OFF_R_HI: 0.000000e+00
@ROC: INACTIVE
@FMT: FLOAT @RES: 3
I would like to create a program where I can:
1. specify a list name (such as: 1C_A_FSLW) as part of the command line
2. have the program locate the list and it’s associated parameter names in the first file.
3. have it get the detailed parameter data from the second file and generate a new file containing the detailed parameters.
I have worked with code where I could get all names and descriptions (very simple code) such as:
# Get NAME
$1~/@NAME/ { a=$2 }
# Get Description
/@DESC/ { b=$0 }
# Print results
a!="" && b!="" { print a "\n",b “\n”; a=b="" }
But now I would like to get the detailed parameter data based on the list names and output them to a new file as stated above.