Functions

matlab_gs_probe_or.c File Reference

#include <stdio.h>
#include <string.h>
#include <matrix.h>
#include <mex.h>
#include "grpc.h"
#include "matlab_gs.h"
Include dependency graph for matlab_gs_probe_or.c:

Go to the source code of this file.

Functions

void matlab_gs_probe_or (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

Detailed Description

Matlab client call

Definition in file matlab_gs_probe_or.c.


Function Documentation

void matlab_gs_probe_or ( int  nlhs,
mxArray *  plhs[],
int  nrhs,
const mxArray *  prhs[] 
)

Return the status of a previous asynchronous request in the prhs array using grpc_probe_or.

Parameters:
nlhs - Number of left hand side arguments from Matlab
plhs - Pointer to left hand side arguments from Matlab
rlhs - Number of right hand side arguments from Matlab
plhs - Pointer to right hand side arguments from Matlab

Definition at line 30 of file matlab_gs_probe_or.c.

{
  int i;
  grpc_sessionid_t sessionId;
  grpc_error_t retval;
  int mrows, ncols;
  grpc_sessionid_t *sessionId_array = NULL;

  if (nrhs != 2 || nlhs != 2) {
    mexErrMsgTxt("Usage: [status, sessionId] = gs_probe_or(sessionId_array)\n");
    for (i=0;i<nlhs;i++) plhs[i] = mxCreateDoubleMatrix(0,0,mxREAL); 
    return;
  }

  /* reset global error setting */
  matlab_gs_error_num = 0;  
  matlab_gs_minor_errno = 256;   

  /* Init GRPC */
  retval = grpc_initialize(NULL);
  if ((retval != GRPC_NO_ERROR) && (retval != GRPC_ALREADY_INITIALIZED)) 
    DO_ERROR_MACRO(retval);

  /* Get sessionid array from rhs and its dimensions */
  mrows = (int)mxGetM(prhs[1]);
  ncols = (int)mxGetN(prhs[1]);
  sessionId_array = (int *)malloc(sizeof(grpc_sessionid_t)*mrows*ncols);
  for (i=0; i<mrows*ncols; i++) 
    sessionId_array[i] = (int)mxGetPr(prhs[1])[i];

  /* Make call to GridSolve C API */
  retval = grpc_probe_or(sessionId_array, mrows*ncols, &sessionId);

  /* Release space for sessionId array */
  if (sessionId_array) free(sessionId_array);

  /* Check for errors */
  if ((retval != GRPC_NO_ERROR) & (retval != GRPC_NONE_COMPLETED)) 
    DO_ERROR_MACRO(retval);
  
  /* Return values */
  plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
  plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
  mxGetPr(plhs[0])[0] = (double)retval;
  mxGetPr(plhs[1])[0] = (double)sessionId;

  return; 


 error:
  plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
  plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
  mxGetPr(plhs[0])[0] = (double)-1;
  mxGetPr(plhs[1])[0] = (double)-1;
  mexPrintf("Warning: GridSolve call failed: %d:%d: %s; %s\n", grpc_errno, grpc_minor_errno, grpc_error_string(grpc_errno), grpc_minor_error_string(grpc_minor_errno));  
  return;

}

Here is the call graph for this function:

Here is the caller graph for this function: