Functions

gs_probe.cpp File Reference

#include <oct.h>
#include <stdio.h>
#include <stdlib.h>
#include "grpc.h"
#include "gs_oct.h"
Include dependency graph for gs_probe.cpp:

Go to the source code of this file.

Functions

 DEFUN_DLD (gs_probe, args, nargout,"Octave client for GridSolve")

Function Documentation

DEFUN_DLD ( gs_probe  ,
args  ,
nargout  ,
"Octave client for GridSolve"   
)

Definition at line 22 of file gs_probe.cpp.

                                                                   {
    octave_value_list bad_retval;   //bad return value
    grpc_error_t status;            //GridRPC status/error code
    grpc_sessionid_t req_id;        //GridRPC non-blocking call session id


    //meaningless return value for error condition
    //or those calls that do not make grpc function call
    for (int i = 0; i < nargout; i++) {
        bad_retval(i) = Matrix(0, 0);
    }

    //number of input arguments
    int nargin = args.length();

    //input argument error checking
    if (nargin <= 0) {
        fprintf(stderr, "No input service name found. Aborted.\n");
        return bad_retval;
    }

    if (nargin > 1) {
        fprintf(stderr, "Exactly one argument (session id) is expected. Aborted.\n");
        return bad_retval;
    }
    
    //otherwise, the input is correct
    
    //initialize the GridSolve environment
    status = grpc_initialize(NULL);
    if (status != GRPC_NO_ERROR && status != GRPC_ALREADY_INITIALIZED) {
        fprintf(stderr, "%s\n", grpc_error_string(status));
        return bad_retval;
    }

    //the GRPC session id
    req_id = args(0).int_value();
    //probe the job status
    status = grpc_probe(req_id);

    if (status == GRPC_NOT_COMPLETED) { //not completed
        printf("Job has not completed.\n");
    }
    else if (status == GRPC_NO_ERROR) { //completed
        printf("Job has completed.\n");
    } else {
        fprintf(stderr, "Error in probing.\n");
        return bad_retval;
    }

    return octave_value(status);
}

Here is the call graph for this function: