tpm_traceelemget

Land Desktop Development ARX CPP SDK

Up a level
tpm_traceelemget
 
 

Lists information about a tracing model element.

struct resbuf

*tpm_traceelemget(

ade_id trace_id,

ade_id elem_id);

Returns an information list in a resbuf or NULL

trace_id Tracing model ID returned by tpm_tracealloc
elem_id Trace element ID

The contents of a resbuf for a node element could be as follows.

RestypeResval
RTLB  
RTSHORT -1
RTSHORT 1
RTDOTE  
RTLB  
RTSHORT 40
RTREAL 0.000000
RTDOTE  

The contents of a resbuf for a link element could be as follows.

RestypeResval
RTLB  
RTSHORT -1
RTSHORT 2
RTDOTE  
RTLB  
RTSHORT 1
RTREAL 9.000000
RTDOTE  
RTLB  
RTSHORT 2
RTREAL 18.000000
RTDOTE  
RTLB  
RTSHORT 40
RTREAL 3.000000
RTDOTE  
RTLB  
RTSHORT 41
RTREAL 3.000000
RTDOTE  
RTLB  
RTSHORT 70
RTSHORT 0
RTDOTE  

The list format depends on the element type. For each a-list, the first component is an integer code for the information type, and the second is the information.

List Format for Nodes
(-1 . elem_code) Element type code (RTSHORT). With node lists, always 1, meaning node element.
(40 . resistance) Node resistance (RTREAL).
List Format for Links
(-1 . elem_code) Element type code (RTSHORT). With link lists, always 2, meaning link element.
( 1 . topo_id) Topology ID of start node (RTREAL).
( 2 . topo_id) Topology ID of end node (RTREAL).
(40 . fwd_resist) Forward resistance (RTREAL).
(41 . rev_resist) Reverse resistance (RTREAL).
(70 . link_dir) Link direction (RTSHORT): -1, 0, or 1.
-1 = Reverse
 0 = Bidirectional
 1 = Forward

The following sample opens a network trace topology for read using tpm_acopen(). A tracing model is allocated using tpm_tracealloc() with the topology id returned by tpm_acopen(). A trace element id is obtained using tpm_elemid(), which is used in the call to tpm_traceelemget(). A resbuf is populated with information associated with the specified element, a portion of which is then displayed. The resbuf is then released as required.

char* pszTopoName = "BestRouteTopology1";
int topoWriteAccess = 0;
ade_id topoId = tpm_acopen(pszTopoName, topoWriteAccess);
ade_id traceId = tpm_tracealloc(topoId, NULL, NULL, NULL, NULL);
int elementType = 2;
long elementIndex = 5;
ade_id elementID = tpm_elemid(topoId, elementType, elementIndex);
struct resbuf* pTraceElementInfoRb = tpm_traceelemget(traceId, elementID);
if (NULL != pTraceElementInfoRb){
    struct resbuf* rb = pTraceElementInfoRb;
    while(NULL != rb) {
        if (rb->restype == RTSHORT) {
            const int nTraceVal = rb->resval.rint;
            switch(nTraceVal)
            {
                case 1:
                    acutPrintf(
                        "\nThe topology id of the starting node is: %0.lf"
                        , rb->rbnext->resval.rreal);
                    break;
                case 70:
                    acutPrintf(
                        "\nThe element direction is: %d"
                        , rb->rbnext->resval.rint);
                    break;
                    default:
                        break;
            }
        }
        rb = rb->rbnext;
    }
}
else {
    acutPrintf(
        "\nThe specified element was not found.");
}
acutRelRb(pTraceElementInfoRb);
tpm_acclose(topoId);