Setting Application Data

The Storyboard IO plugin provides the capability to set application variable values using the Storyboard IO API, allowing external client programs to change data dynamically.

Clients can use the gre_io_add_mdata() function to serialize each variable value that is to be set. As values are added to the serialized buffer, it will be grown until it reaches a maximum size for the transport, at which point the gre_io_add_mdata() function will return -1 indicating it is full. The data can be then sent by using the gre_io_send_mdata() function which will send the change request to the Storyboard IO plugin and set the appropriate values in the Storyboard application.

gre_io_t                    *send_handle;
gre_io_serialized_data_t    *md_buffer = NULL;
uint32_t                    x;
char                        *ptr;
int                         ret;

/*
 * Connect to the application channel
 */
send_handle = gre_io_open("my_channel", GRE_IO_TYPE_WRONLY);
if(send_handle == NULL) {
  printf("Can't open send handle [%s]\n", argv[1]);
    return 0;
}

/*
 * Add some values to be set in the data manager
 */
ptr = "my string";
ret = gre_io_add_mdata(&md_buffer,
  "Test.String",
  "1s0",
  ptr, strlen(ptr)+1);

x = 1;
ret = gre_io_add_mdata(&md_buffer,
  "Test.Number",
  "4u1",
  &x, sizeof(uint32_t));

/*
 * Send the data to be set in the application.
 */
gre_io_send_mdata(send_handle, md_buffer);