?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Dump Analyzer : Display Channel Status Flags Command' ??
MODULE dum$display_csf_command;

{ PURPOSE:
{   This module contains the command which displays the channel status flags that are contained
{   in the CSF and CS1 dump records.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc due$exception_condition_codes
?? POP ??
*copyc clp$close_display
*copyc clp$convert_integer_to_rjstring
*copyc clp$evaluate_parameters
*copyc clp$open_display_reference
*copyc clp$put_display
*copyc dup$determine_dump_information
*copyc dup$find_record_list_entry
*copyc dup$new_page_procedure
*copyc osp$append_status_integer
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc osp$set_status_abnormal
?? EJECT ??
*copyc duv$dump_environment_p
*copyc duv$execution_environment
*copyc duv$title_data
?? OLDTITLE ??
?? NEWTITLE := 'dup$display_csf_command', EJECT ??

{ PURPOSE:
{   This procedure displays the channel status flags.

  PROCEDURE [XDCL] dup$display_csf_command
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE display_channel_status_flags, discsf, display_channel_conditions, discc (
{   output, o: file = $optional
{   title, t: string 1..31 = 'display_channel_status_flags'
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??
  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 5] of clt$pdt_parameter_name,
      parameters: array [1 .. 3] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$string_type_qualifier,
        default_value: string (30),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 4, 18, 8, 56, 28, 616],
    clc$command, 5, 3, 0, 0, 0, 0, 3, ''], [
    ['O                              ',clc$abbreviation_entry, 1],
    ['OUTPUT                         ',clc$nominal_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 3],
    ['T                              ',clc$abbreviation_entry, 2],
    ['TITLE                          ',clc$nominal_entry, 2]],
    [
{ PARAMETER 1
    [2, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$optional_parameter, 0
  , 0],
{ PARAMETER 2
    [5, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 8,
  clc$optional_default_parameter, 0, 30],
{ PARAMETER 3
    [3, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$file_type]],
{ PARAMETER 2
    [[1, 0, clc$string_type], [1, 31, FALSE],
    '''display_channel_status_flags'''],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];
?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$output = 1,
      p$title = 2,
      p$status = 3;

    VAR
      pvt: array [1 .. 3] of clt$parameter_value;

    CONST
      c$number_of_channels = (34(8) + 10) * 2;

    TYPE
      t$channel_status_entry = PACKED RECORD
        unused: 0 .. 7,
        parity_error_disabled: boolean,
        channel_active: boolean,
        channel_full: boolean,
        channel_flag: boolean,
        channel_error: boolean,
      RECEND,

      t$channel_type = (c$nio, c$cio),

      t$data_line = RECORD
        CASE boolean OF
        = TRUE =
          line: string (70),
        = FALSE =
          unused_1: string (1),
          iou_name: string (3),
          iou_number: string (2),
          unused_2: string (1),
          cio_id: string (1),
          channel_name: string (2),
          channel_number: string (2),
          unused_3: string (2),
          channel_active: string (8),
          unused_4: string (3),
          channel_full: string (5),
          unused_5: string (4),
          channel_flag: string (5),
          unused_6: string (4),
          channel_error: string (5),
          unused_7: string (6),
          parity_error_disabled: string (5),
        CASEND,
      RECEND,

      t$register_list_entry = RECORD
        available: boolean,
        iou_number: 0 .. duc$de_maximum_ious,
        channel_number: 0 .. duc$de_maximum_channels,
        channel_type: t$channel_type,
        parity_error_disabled: boolean,
        channel_active: boolean,
        channel_full: boolean,
        channel_flag: boolean,
        channel_error: boolean,
      RECEND,

      t$title_line = RECORD
        CASE boolean OF
        = TRUE =
          line: string (70),
        = FALSE =
          unused_1: string (14),
          channel_active: string (8),
          unused_2: string (2),
          channel_full: string (7),
          unused_3: string (2),
          channel_flag: string (7),
          unused_4: string (2),
          channel_error: string (7),
          unused_5: string (2),
          parity_error_disabled: string (12),
        CASEND,
      RECEND;

    VAR
      cs1_entry_p: ^dut$de_other_record_entry,
      cell_p: ^cell,
      channel_number: 0 .. duc$de_maximum_channels,
      channel_status_p: ^t$channel_status_entry,
      channel_type: t$channel_type,
      channels_still_exist: boolean,
      checked_cs1: boolean,
      data_line: t$data_line,
      data_size: integer,
      data_value: clt$data_value,
      display_control: clt$display_control,
      dump_information: dut$dump_information,
      entry_p: ^dut$de_other_record_entry,
      ignore_status: ost$status,
      index: 1 .. c$number_of_channels,
      iou_number: 0 .. duc$de_maximum_ious,
      output_display_opened: boolean,
      register_list: ARRAY [1 .. c$number_of_channels] OF t$register_list_entry,
      restart_file_seq_p: ^SEQ ( * ),
      ring_attributes: amt$ring_attributes,
      title_line: t$title_line;

*copy dup$abort_handler
?? NEWTITLE := 'clean_up', EJECT ??

{ PURPOSE:
{   This procedure is called from the abort handler to close the file.

    PROCEDURE [INLINE] clean_up;

      VAR
        ignore_status: ost$status;

      IF output_display_opened THEN
        clp$close_display (display_control, ignore_status);
      IFEND;

    PROCEND clean_up;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;  {---->
    IFEND;

    IF duv$dump_environment_p = NIL THEN
      osp$set_status_abnormal (duc$dump_analyzer_id, due$no_restart_file, '', status);
      RETURN;  {---->
    IFEND;

    output_display_opened := FALSE;
    osp$establish_block_exit_hndlr (^abort_handler);

   /display_opened/
    BEGIN

    { Prepare the output display file.

      IF pvt [p$output].specified THEN
        ring_attributes.r1 := #RING (^ring_attributes);
        ring_attributes.r2 := #RING (^ring_attributes);
        ring_attributes.r3 := #RING (^ring_attributes);
        clp$open_display_reference (pvt [p$output].value^.file_value^, ^dup$new_page_procedure, fsc$list,
              ring_attributes, display_control, status);
        IF NOT status.normal THEN
          EXIT /display_opened/;  {---->
        IFEND;
        output_display_opened := TRUE;
      ELSE
        display_control := duv$execution_environment.output_file.display_control;
        display_control.line_number := display_control.page_length + 1;
      IFEND;

      duv$title_data.build_title := TRUE;
      duv$title_data.command_name := pvt [p$title].value^.string_value^;

      data_value.kind := clc$name;
      data_value.name_value := 'CSF';
      dup$find_record_list_entry (data_value, entry_p);
      IF entry_p = NIL THEN
        osp$set_status_abnormal (duc$dump_analyzer_id, due$data_not_on_dump, 'The specified record is',
              status);
        EXIT /display_opened/;  {---->
      IFEND;

      FOR index := 1 TO c$number_of_channels DO
        register_list [index].available := FALSE;
      FOREND;

      dup$determine_dump_information (dump_information);

      restart_file_seq_p := duv$execution_environment.data_file_p^.segment_pointer.sequence_pointer;
      cell_p := #ADDRESS (#RING (restart_file_seq_p), #SEGMENT (restart_file_seq_p), entry_p^.first_byte);
      RESET restart_file_seq_p TO cell_p;
      data_size := entry_p^.size;
      channels_still_exist := (data_size >= #SIZE (t$channel_status_entry));
      checked_cs1 := FALSE;
      iou_number := 0;
      channel_number := 0;
      channel_type := c$nio;
      index := 1;

      WHILE channels_still_exist DO
        NEXT channel_status_p IN restart_file_seq_p;
        IF channel_status_p = NIL THEN
          osp$set_status_abnormal (duc$dump_analyzer_id, due$nil_pointer, '', status);
          EXIT /display_opened/;  {---->
        IFEND;
        data_size := data_size - #SIZE (t$channel_status_entry);
        register_list [index].available := TRUE;
        register_list [index].iou_number := iou_number;
        register_list [index].channel_number := channel_number;
        register_list [index].channel_type := channel_type;
        register_list [index].parity_error_disabled := channel_status_p^.parity_error_disabled;
        register_list [index].channel_active := channel_status_p^.channel_active;
        register_list [index].channel_full := channel_status_p^.channel_full;
        register_list [index].channel_flag := channel_status_p^.channel_flag;
        register_list [index].channel_error := channel_status_p^.channel_error;
        IF channel_number = 33(8) THEN
          IF (dump_information.iou [iou_number].model = duc$di_im_i4_43) OR
                (dump_information.iou [iou_number].model = duc$di_im_i4_44) OR
                (dump_information.iou [iou_number].model = duc$di_im_i4_46) THEN
            data_size := 0;
          ELSE
            channel_number := 0;
            channel_type := c$cio;
          IFEND;
        ELSEIF (channel_number = 11(8)) AND (channel_type = c$cio) THEN
          data_size := 0;
        ELSE
          channel_number := channel_number + 1;
        IFEND;
        index := index + 1;
        IF data_size < #SIZE (t$channel_status_entry) THEN
          IF checked_cs1 THEN
            channels_still_exist := FALSE;
          ELSE
            checked_cs1 := TRUE;
            data_value.kind := clc$name;
            data_value.name_value := 'CS1';
            dup$find_record_list_entry (data_value, cs1_entry_p);
            IF cs1_entry_p = NIL THEN
              channels_still_exist := FALSE;
            ELSE
              restart_file_seq_p := duv$execution_environment.data_file_p^.segment_pointer.sequence_pointer;
              cell_p := #ADDRESS (#RING (restart_file_seq_p), #SEGMENT (restart_file_seq_p),
                    cs1_entry_p^.first_byte);
              RESET restart_file_seq_p TO cell_p;
              data_size := cs1_entry_p^.size;
              channels_still_exist := (data_size >= #SIZE (t$channel_status_entry));
              channel_number := 0;
              channel_type := c$nio;
              iou_number := 1;
            IFEND;
          IFEND;
        IFEND;
      WHILEND;

      clp$put_display (display_control, 'Channel Status Flags', clc$trim, ignore_status);
      clp$put_display (display_control, ' ', clc$trim, ignore_status);

      title_line.line := ' ';
      title_line.channel_active := 'CHANNEL';
      title_line.channel_full := 'CHANNEL';
      title_line.channel_flag := 'CHANNEL';
      title_line.channel_error := 'CHANNEL';
      title_line.parity_error_disabled := 'PARITY ERROR';
      clp$put_display (display_control, title_line.line, clc$trim, ignore_status);

      title_line.line := ' ';
      title_line.channel_active := 'ACTIVE';
      title_line.channel_full := 'FULL';
      title_line.channel_flag := 'FLAG';
      title_line.channel_error := 'ERROR';
      title_line.parity_error_disabled := 'DISABLED';
      clp$put_display (display_control, title_line.line, clc$trim, ignore_status);

      title_line.line := ' ';
      title_line.channel_active := '--------';
      title_line.channel_full := '-------';
      title_line.channel_flag := '-------';
      title_line.channel_error := '-------';
      title_line.parity_error_disabled := '------------';
      clp$put_display (display_control, title_line.line, clc$trim, ignore_status);

      FOR index := 1 TO c$number_of_channels DO
        IF NOT register_list [index].available THEN
          EXIT /display_opened/;  {---->
        IFEND;

        data_line.line := ' ';
        data_line.iou_name := 'IOU';
        clp$convert_integer_to_rjstring (register_list [index].iou_number, 8, FALSE, '0',
              data_line.iou_number, ignore_status);
        IF (register_list [index].channel_type = c$cio) OR
              (dump_information.iou[register_list [index].iou_number].model = duc$di_im_i4_43) OR
              (dump_information.iou[register_list [index].iou_number].model = duc$di_im_i4_44) OR
              (dump_information.iou[register_list [index].iou_number].model = duc$di_im_i4_46) THEN
          data_line.cio_id := 'C';
        IFEND;
        data_line.channel_name := 'CH';
        clp$convert_integer_to_rjstring (register_list [index].channel_number, 8, FALSE, '0',
              data_line.channel_number, ignore_status);

        IF register_list [index].channel_active THEN
          data_line.channel_active := ' ACTIVE ';
        ELSE
          data_line.channel_active := 'INACTIVE';
        IFEND;

        IF register_list [index].channel_full THEN
          data_line.channel_full := ' FULL';
        ELSE
          data_line.channel_full := 'EMPTY';
        IFEND;

        IF register_list [index].channel_flag THEN
          data_line.channel_flag := ' SET ';
        ELSE
          data_line.channel_flag := 'CLEAR';
        IFEND;

        IF register_list [index].channel_error THEN
          data_line.channel_error := ' SET ';
        ELSE
          data_line.channel_error := 'CLEAR';
        IFEND;

        IF (register_list [index].channel_type <> c$cio) AND
              (dump_information.iou [register_list [index].iou_number].model <> duc$di_im_i4_43) AND
              (dump_information.iou [register_list [index].iou_number].model <> duc$di_im_i4_44) AND
              (dump_information.iou [register_list [index].iou_number].model <> duc$di_im_i4_46) THEN
          IF register_list [index].parity_error_disabled THEN
            data_line.parity_error_disabled := ' SET ';
          ELSE
            data_line.parity_error_disabled := 'CLEAR';
          IFEND;
        IFEND;

        clp$put_display (display_control, data_line.line, clc$trim, ignore_status);
      FOREND;

    END /display_opened/;

    IF output_display_opened THEN
      clp$close_display (display_control, ignore_status);
    IFEND;
    osp$disestablish_cond_handler;

  PROCEND dup$display_csf_command;
MODEND dum$display_csf_command;
