tpm_traceelemedit

Land Desktop Development ARX CPP SDK

Up a level
tpm_traceelemedit
 
 

Modifies a tracing model element.

int

tpm_traceelemedit(

ade_id trace_id,

ade_id elem_id,

struct resbuf *new_val);

Returns RTNORM or an error code.

trace_id Model ID (returned by tpm_tracealloc).
elem_id Element ID.
new_val List consisting of a code for the property to modify and a new value for the property. See Properties and Values below.

Examples of building a resbuf for the new_val argument.

// For an integer value
rb = acutBuildList(
   RTLB, RTSHORT, code, RTSHORT, value, RTDOTE, 0);
// For a real value
rb = acutBuildList(
   RTLB, RTSHORT, code, RTREAL, value, RTDOTE, 0);

You must release the resbuf when you are finished with it.

Properties and Values
(40 . f_res) Resistance of node (RTREAL), or forward resistance of link
(41 . r_res) Reverse resistance of link (RTREAL)
(70 . dir) Link direction (RTSHORT):
-1 Reverse
 0 Bidirectional
 1 Forward

The following sample uses tpm_traceelemedit() to modify an element created using tpm_tracebestroute(). The trace_id param is obtained using tpm_tracealloc() and elem_id is obtained using tpm_elemid(). A resbuf is created which contains the property/value pair required to modify the forward resistance of the specified element, (link). Tpm_traceelemedit() is called with all required parameters, and the returned value is checked against RTNORM. A message indicating that the element has been modified is displayed, then the resbuf is released as required. Note, this example is based upon a trace which has been created, is loaded and open.

char* pszTopoName = "BestRouteTopology1";
int topoWriteAccess = 1;
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* pModElementRb = acutBuildList(
                                                RTLB,
                                                RTSHORT, 40,
                                                RTREAL, 100.0,
                                                RTDOTE,
                                                0);
int returnCode = tpm_traceelemedit(traceId, elementID, pModElementRb);
if (RTNORM == returnCode) {
    acutPrintf(
        "\nThe specified element has been modified.");
}
else {
    acutPrintf(
        "\nThe specified element was not modified.");
}
acutRelRb(pModElementRb);
tpm_acclose(topoId);