[97] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * INTERFACE: Matlab Rappture Library Source |
---|
| 4 | * |
---|
[154] | 5 | * [retStr,err] = rpUnitsGetUnitsName(unitsHandle) |
---|
[97] | 6 | * |
---|
| 7 | * ====================================================================== |
---|
| 8 | * AUTHOR: Derrick Kearney, Purdue University |
---|
[3177] | 9 | * Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
[115] | 10 | * |
---|
| 11 | * See the file "license.terms" for information on usage and |
---|
| 12 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
[97] | 13 | * ====================================================================== |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "RpMatlabInterface.h" |
---|
| 17 | |
---|
[154] | 18 | /**********************************************************************/ |
---|
| 19 | // METHOD: [retStr,err] = rpUnitsGetUnitsName(unitHandle) |
---|
| 20 | /// Return the unit and exponent of the Rappture Unit represented by unitHandle. |
---|
| 21 | /** |
---|
| 22 | * Retrieve the unit and exponent of the Rappture Units object with` |
---|
| 23 | * the handle 'unitHandle'. |
---|
| 24 | * Return the unit and exponent as one concatinated string. |
---|
| 25 | * Error code, err=0 on success, anything else is failure. |
---|
| 26 | */ |
---|
| 27 | |
---|
[97] | 28 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
| 29 | int nrhs, const mxArray *prhs[]) |
---|
| 30 | { |
---|
[141] | 31 | int unitsHandle = 0; |
---|
[154] | 32 | int err = 1; |
---|
[141] | 33 | const RpUnits* unitsObj = NULL; |
---|
| 34 | const char* retString = NULL; |
---|
[97] | 35 | |
---|
| 36 | /* Check for proper number of arguments. */ |
---|
| 37 | if (nrhs != 1) |
---|
| 38 | mexErrMsgTxt("Two input required."); |
---|
[154] | 39 | else if (nlhs > 2) |
---|
[97] | 40 | mexErrMsgTxt("Too many output arguments."); |
---|
| 41 | |
---|
| 42 | unitsHandle = getIntInput(prhs[0]); |
---|
| 43 | |
---|
| 44 | /* Call the C subroutine. */ |
---|
| 45 | if (unitsHandle > 0) { |
---|
| 46 | unitsObj = getObject_UnitsStr(unitsHandle); |
---|
| 47 | if (unitsObj) { |
---|
| 48 | retString = unitsObj->getUnitsName().c_str(); |
---|
[154] | 49 | if (retString) { |
---|
| 50 | err = 0; |
---|
| 51 | } |
---|
[97] | 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | /* Set C-style string output_buf to MATLAB mexFunction output*/ |
---|
| 56 | plhs[0] = mxCreateString(retString); |
---|
[154] | 57 | plhs[1] = mxCreateDoubleScalar(err); |
---|
[97] | 58 | |
---|
| 59 | return; |
---|
| 60 | } |
---|