cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

SDK C Remote Service: Infotable inside Infotable

ddepsys
1-Newbie

SDK C Remote Service: Infotable inside Infotable

Hi Everyone,

I try to include infotable inside a infotable on a remote service. When I read it with sdk C, I have only the first infotable and the other has not row. someone know how to do it?

Remote service structure:

service name (testService)

input:

     INFOTABLE (infotable1)

String (stringvalue)

Integer (intvalue)

INFOTABLE (infotable2)

     String (stringvalue2)

Code C:

register_service(){

  twDataShape * ds = 0;

  ds = twDataShape_Create(twDataShapeEntry_Create("infotable1", NULL, TW_INFOTABLE));

  twApi_RegisterService(TW_THING, thing_name, "testService", NULL, ds, TW_NUMBER, NULL, sendDataService, NULL);

//get parameter

enum msgCodeEnum sendDataService(const char * entityName, const char * serviceName, twInfoTable * params, twInfoTable ** content, void * userdata) {

  int rc = 0;

  twPrimitive *infotable1_prim;

  twInfoTable *infotable1_info;

  (void) serviceName; (void) userdata;//remove warning compile

  if (!params || !content) {

  fprintf(stdout, "sendDataService - NULL params or content pointer\n");

  return TWX_BAD_REQUEST;

  }

  twInfoTable_GetPrimitive(params, "infotable1", 0, &infotable1_prim);

  if (dinfotable1_prim != NULL && infotable1prim->length > 0)

  infotable1_info = infotable1_prim->val.infotable;

  // init command to send

  if (infotable1_info != NULL && infotable1_info->length > 0){

  twList *rowsinfotable1 = infotable1_info->rows;

  if (rowsinfotable1 != NULL){

          char * stringvalue;

          int intvalue;

  twPrimitive *infotable2_prim;

  twInfoTable *infotable2_info;

  if (rowsinfotable1->count > 0){

  int i;

  for (i = 0; i < rowsinfotable1->count; i++){

  twInfoTable_GetPrimitive(infotable1_info, "infotable2", i, &infotable2_prim);

  if (infotable2_prim != NULL && infotable2_prim->length > 0)

      infotable2_info = infotable2_prim->val.infotable;

  // init command to send

  if (infotable2_info != NULL && infotable2_info->length > 0){

       twList *rowsinfotable2 = infotable2_info->rows;

       if (rowsinfotable2 != NULL){

            char *stringvalue2;

            if (rowsinfotable2->count > 0){

                 int i;

                 for (i = 0; i < rowsinfotable2->count; i++){

                      twInfoTable_GetString(infotable2_info, "stringvalue2", i, &stringvalue2);

                      fprintf(stdout,"stringvalue2: %s \n", stringvalue2);

                 }

                    }

               }

          }

          twInfoTable_GetString(infotable1_info, "stringvalue", i, &stringvalue);

          fprintf(stdout,"stringvalue: %s \n", stringvalue);

          twInfoTable_GetInteger(infotable1_info, "intvalue", i, &intvalue);

          fprintf(stdout,"intvalue: %d \n", intvalue);

  }

}

            }

  }

1 ACCEPTED SOLUTION

Accepted Solutions
ddepsys
1-Newbie
(To:CRArko)

Hello Craig,

Thanks for your answer.

I found the issue. It's was not on C sdk structure but on the server twx himself. I don't know why but one of my properties inside INFOTEAM had a type UNKOWN instead of INTERGER. I recreate this properties and my service works well now.

Regards

Simon

View solution in original post

2 REPLIES 2
CRArko
17-Peridot
(To:ddepsys)

Hello, Simon.

Based on the article https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS226131 you'd use twPrimitive_CreateFromInfoTable to create the nested infotable to start with. Can you verify that's how the infotable was created?

Thanks,

-- Craig A.

ddepsys
1-Newbie
(To:CRArko)

Hello Craig,

Thanks for your answer.

I found the issue. It's was not on C sdk structure but on the server twx himself. I don't know why but one of my properties inside INFOTEAM had a type UNKOWN instead of INTERGER. I recreate this properties and my service works well now.

Regards

Simon

Top Tags