The Device Server Signal Interface

# 5. The Client Side

With the described commands, signals can be displayed in a generic way on the client side.

  1. To find out the data type used by the command DevReadSigValues, the function dev_cmd_query() of the API-library can be used. Filtering for the command indicates the data type of the outgoing arguments.

  2. By executing the command DevReadSigConfig the place of a signal in the array can be determined by its name. All other properties needed for a signal display are following the signal name in the described order (see "The Signal Properties" on page 2).

  3. DevReadSigValues returns the signal values in the same order as indicated by DevReadSigConfig.

An example shows how DevReadSigConfig and DevReadSigValues can be used to display signals in a device server menu. The data type in this case is known and dev_cmd_query() is not used.

     devserver                       device;
     DevVarStringArray       sig_config;
     DevVarFloatArray        param_array;
     long                              nu_of_properties;
     long                              nu_of_signals;
     long                              i, k;

     case (3) :
              /*
               *  Read the device signal values.
               */
                param_array.length   = 0;
                param_array.sequence = NULL;

               if (dev_putget (device, DevReadSigValues, NULL, D_VOID_TYPE,
                                       &param_array, D_VAR_FLOATARR, &error) < 0)
                       {
                       dev_printerror_no (SEND, "DevReadSigValues", error);
                       break;
    	                   }

                 /*
                  * Read the signal properies to display the values.
                  */
                 sig_config.length   = 0;
                 sig_config.sequence = NULL;

                 if (dev_putget (device, DevGetSigConfig, NULL, D_VOID_TYPE,
                                         &sig_config, D_VAR_STRINGARR, &error) < 0)
                       {
                       dev_printerror_no (SEND, "DevGetSigConfig", error);
                       break;
                       }
               /*
    	            * Find the label format and unit for the signal values.
                */
               nu_of_properties = atol (sig_config.sequence[0]);
               nu_of_signals    = (sig_config.length -1) / nu_of_properties;

               printf ("Device parameters:\n");
               for (i=0; i<nu_of_signals; i++)
                  {
                  sprintf (format, "%24s [%2s] : %s\n",
                  sig_config.sequence[(i*nu_of_properties) + 2],
                  sig_config.sequence[(i*nu_of_properties) + 3],
                  sig_config.sequence[(i*nu_of_properties) + 4]);
                  printf (format, param_array.sequence[i]);
                  }

               /*
                * Free the allocated arrays.
                */
              if ( dev_xdrfree (D_VAR_FLOATARR, &param_array, &error)
                                        < 0 )
                  {
                  dev_printerror_no (SEND, "dev_xdrfree", error);
                  }
               if ( dev_xdrfree (D_VAR_STRINGARR, &sig_config, &error) < 0 )
                  {
                  dev_printerror_no (SEND, "dev_xdrfree", error);
                  }
               break;

Generated with Harlequin WebMaker