Functions

matlab_gs_mexFunction.c File Reference

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

Go to the source code of this file.

Functions

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

Detailed Description

Matlab client call

Definition in file matlab_gs_mexFunction.c.


Function Documentation

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

Mex gateway routine for the matlab client.

Each matlab client command is called via an M file which prepends an identifier for the routine and calls this MEX-C gateway routine. The gateway routine then uses the identifier to select and call the correct C function. The implementation was done this way because if each command was implemented as a seperate MEX file, then any static memory variables would be lost between commands (i.e., could not implement async routines easily).

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 38 of file matlab_gs_mexFunction.c.

{

  if (nrhs == 0 || !mxIsDouble(prhs[0]) ||
      mxGetM(prhs[0]) != 1 || mxGetN(prhs[0]) != 1)
    mexErrMsgTxt("Illegal call to mex functions");
  
  DBGPRINTF("nlhs %d nrhs %d \n", nlhs, nrhs);
  
  switch ((int)(mxGetScalar(prhs[0]))) 
  {
  case 1: matlab_gs_call(nlhs, plhs, nrhs, prhs); break;
  case 2: matlab_gs_call_async(nlhs, plhs, nrhs, prhs); break;
  case 3: matlab_gs_wait(nlhs, plhs, nrhs, prhs); break;
  case 4: matlab_gs_error_string(nlhs, plhs, nrhs, prhs); break;
  case 5: matlab_gs_get_last_error(nlhs, plhs, nrhs, prhs); break;
  case 6: matlab_gs_probe(nlhs, plhs, nrhs, prhs); break;
  case 7: matlab_gs_cancel(nlhs, plhs, nrhs, prhs); break;
  case 8: matlab_gs_info(nlhs, plhs, nrhs, prhs); break;
  case 9: matlab_gs_putenv(nlhs, plhs, nrhs, prhs); break;
  case 10: matlab_gs_probe_or(nlhs, plhs, nrhs, prhs); break;
    
  default: mexErrMsgTxt("Illegal function ID parameter");
  }

  DBGPRINTF("nlhs %d nrhs %d \n", nlhs, nrhs);
  return;
}

Here is the call graph for this function: