Table of Contents Index NMS Glossary Previous Page Next Page Version


Chapter 5

Demonstration Program


5.1 Introduction
5.2 Functional Overview
5.3 Running trunklog
5.3.1 trunklog Requirements
5.3.2 Compiling trunklog
5.3.3 Using trunklog
5.4 Program Structure and Coding Features
5.4.1 The main Function

5.1 IntroductionTop of Page

This chapter describes the functionality and structure of the trunklog demonstration program, which is supplied with the DTM service. trunklog displays alarm events from digital trunks, using functions from the DTM service.

5.2 Functional OverviewTop of Page

trunklog passively monitors for alarm events from digital trunks. It writes to stdout whenever the alarm state of a digital trunk changes, as the following example output shows:

15:52:26  Board 1 Trunk 0: In service
15:52:37  Board 1 Trunk 0: Loss of frame
15:52:38  Board 1 Trunk 0: Loss of frame Far end alarm indication
15:52:54  Board 1 Trunk 0: Far end alarm indication
15:52:55  Board 1 Trunk 0: In service

5.3 Running trunklogTop of Page

This section describes the system requirements for running trunklog, and explains how to compile and use this demonstration program.

5.3.1 trunklog RequirementsTop of Page

trunklog can work with any AG board with a coprocessor and digital line interfaces. To compile and use the demonstration program, you need Natural Access installed on your system.

5.3.2 Compiling trunklogTop of Page

To compile the demonstration program, open a command window and:

5.3.3 Using trunklogTop of Page

To run the demonstration program:

  1. Set up the configuration file to describe the board and software configuration.

    
    If you are using OAM, refer to the board's installation and developer's manual for more information about configuration files.  If you are using agmon, refer to the AG Runtime Configuration and Developer's Manual for more information about configuration files.
  2. Boot the board to make any configuration file changes effective, and leave it running to monitor any errors.

    
    
  3. Start up trunklog by entering the following at the command line:

    
     trunklog
  4. To exit trunklog, press F3 or ESC.

5.4 Program Structure and Coding FeaturesTop of Page

The following sections explain the demonstration program structure and its routines in detail. You may want to use this as a model when developing your own application.

5.4.1 The main FunctionTop of Page

The main function of trunklog starts by calling initconsole. initconsole sets the keyboard to raw mode if trunklog is compiled for UNIX.

main then calls init_ct_access. init_ct_access does the following:

  1. Calls ctaSetErrorHandler to specify the errorhandler function as the error handling routine for trunklog.

    
    If an error occurs, errorhandler outputs lines to stderr, and calls doexit to terminate the program. Note that errorhandler does not report an error when calls to dtmStartTrunkMonitor return CTAERR_FUNCTION_NOT_AVAIL or CTAERR_INVALID_BOARD. This is so the start_monitor function is not interrupted if it attempts to start up the DTM service on a board number for which there is no corresponding board.
  2. Calls ctaInitialize to establish a list of available services for the application, including the DTM and ADI services.

    
    
  3. Calls ctaCreateQueue to create an event queue.

    
    
  4. Calls ctaCreateContext to create a context to handle the incoming call.

    
    
  5. Calls ctaOpenServices to start up the DTM and ADI services.

    
    
  6. Calls ctaWaitEvent to wait for a CTAEVN_OPEN_SERVICES_DONE event with a value field of 0, meaning that all services started successfully. If it receives this event, it returns. If it times out or if value does not equal 0, it displays an error message and calls doexit to terminate the program.

main then calls start_monitor, which:

  1. Sets the parameters in the DTM_START_PARMS structure. It sets maxevents to 2, so the DTM service will return two events per second. It sets reportmask to DTM_REPORT_ALARMS, so DTM will report any change in the alarm state.

    
    
  2. Starts monitoring trunks on boards 0 through 15 by calling dtmStartTrunkMonitor iteratively for each board number. Even if dtmStartTrunkMonitor returns an error (i.e., there is something wrong with a given board, or no board exists for the board number), start_monitor continues until it has tried all 16 board numbers.

If monitoring services have been successfully started on at least one board, main then calls process_events. This function:

  1. Repeatedly checks to see if the user has pressed the ESC or F3 key. If this happens, process_events calls doexit to terminate the program.

    
    
  2. Repeatedly calls ctaWaitEvent to wait for the following events:
    Event

    Description

    DTMEVN_MONITOR_STARTED

    Indicates that monitoring has started on a trunk. process_events calls dtmGetTrunkStatus to determine what board and trunk the monitoring has started on, and then calls display_data to send the trunk's initial conditions to stdout.

    DTMEVN_TRUNK_STATUS

    Indicates that an alarm state has changed on a trunk. process_events calls dtmGetTrunkStatus to determine what board and trunk the state change has taken place on, and then calls display_data to send the change to stdout.

    CTAEVN_WAIT_TIMEOUT

    Indicates that ctaWaitEvent timed out. process_events calls ctaWaitEvent again.

    DTMEVN_MONITOR_DONE

    Indicates that monitoring ended on a board. process_events determines which board monitoring ended on, and sends a message to stdout.

    ADIEVN_BOARD_ERROR

    Indicates that an unexpected error occurred on a board. process_events sends a message to stderr.



Table of Contents Index NMS Glossary Previous Page Next Page Version


Want to send us feedback on our documentation? Email: Tech_Pubs@nmss.com
Copyright © 2001, Natural MicroSystems, Inc. All rights reserved.