(Page 1 of 1 in this chapter)


Chapter 5

Demonstration Program


5.1 Introduction
5.2 Functional Overview
5.3 Running trunklog
5.3.1 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 Introduction

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 Overview

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 trunklog

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

5.3.1 Requirements

trunklog can work with any AG board with a coprocessor and DSPs (AG-T1, AG-E1, AG-24, AG-8). To compile and use the demonstration program, you need CT Access 1.0, or higher, installed on your system.

5.3.2 Compiling trunklog

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

5.3.3 Using trunklog

To run the demonstration program:

  1. Set up your AG configuration file to describe your board and software configuration. For more information, see the installation and developer's manual for your board, and the AG Runtime Configuration and Developer's Manual.

    
    
  2. Run agmon to make any AG 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 Features

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 Function

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 CTA 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:

    • DTMEVN_MONITOR_STARTED, which 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, which 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, which indicates that ctaWaitEvent timed out. process_events calls ctaWaitEvent again.

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

      
      
    • ADIEVN_BOARD_ERROR, which indicates that an unexpected error occurred on a board. process_events sends a message to stderr.



    (Page 1 of 1 in this chapter)


    tech_support@nmss.com
    Copyright © 1999, Natural MicroSystems, Inc. All rights reserved.