Loading
 
Support Support Home » APIs

sample_for_working_with_FFS.cpp

2014-05-09 09:04

Download (3 KB)

 
        <span class="comment">// sample_for_working_with_FFS.cpp program operations: </span>

        <span class="comment">//</span>

        <span class="comment">//   - gets and displays the information about FFS status (XI_PRM_FREE_FFS_SIZE, XI_PRM_USED_FFS_SIZE)</span>

        <span class="comment">//   - write short text from variable test_text to FFS as file with name test.txt</span>

        <span class="comment">//   - read short text from FFS from file test.txt to variable read_text</span>

        <span class="comment">//   - gets and displays the information about FFS status (XI_PRM_FREE_FFS_SIZE, XI_PRM_USED_FFS_SIZE)</span>

        

        <span class="preprocessor">#include</span> <span class="include">&quot;stdafx.h&quot;</span>

        

        <span class="preprocessor">#ifdef</span> __APPLE__

        <span class="preprocessor">#include</span> <span class="include">&lt;m3api/xiApi.h&gt;</span>

        <span class="preprocessor">#include</span> <span class="include">&lt;m3api/xiExt.h&gt;</span>

        <span class="preprocessor">#else</span>

        <span class="preprocessor">#include</span> <span class="include">&quot;xiApi.h&quot;</span>

        <span class="preprocessor">#include</span> <span class="include">&quot;xiExt.h&quot;</span>

        <span class="preprocessor">#endif</span>

        

        <span class="preprocessor">#define</span> HandleResult(res,place) <span class="keyword">if</span> (res!=XI_OK) {printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">Error after %s (%d)</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>,place,res);<span class="keyword">goto</span> finish;}

        

        <span class="predefined-type">int</span> _tmain(<span class="predefined-type">int</span> argc, _TCHAR* argv[])

        {

                <span class="comment">// image buffer</span>

                XI_IMG image;

                image.size = <span class="keyword">sizeof</span>(XI_IMG);

                image.bp = <span class="predefined-constant">NULL</span>;

                image.bp_size = <span class="integer">0</span>;

        

                <span class="comment">// Sample for XIMEA API V2.10</span>

                HANDLE xiH = <span class="predefined-constant">NULL</span>;

                XI_RETURN stat = XI_OK;

        

                <span class="comment">// Get number of camera devices</span>

                DWORD dwNumberOfDevices = <span class="integer">0</span>;

                stat = xiGetNumberDevices(&amp;dwNumberOfDevices);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiGetNumberDevices (no camera found)</span><span class="delimiter">&quot;</span></span>);

                

                <span class="keyword">if</span> (!dwNumberOfDevices)

                {

                        printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">No camera found</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>);

                        <span class="keyword">goto</span> finish;

                }

                

                <span class="comment">// Retrieving a handle to the camera device </span>

                stat = xiOpenDevice(<span class="integer">0</span>, &amp;xiH);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiOpenDevice</span><span class="delimiter">&quot;</span></span>);

                

                <span class="comment">//---------------------------------------------------------------</span>

                <span class="comment">// get FFS info</span>

        

                <span class="predefined-type">int</span> num_free = <span class="integer">0</span>;

                <span class="predefined-type">int</span> num_used = <span class="integer">0</span>;

                <span class="comment">// get FFS info</span>

                stat = xiGetParamInt(xiH, XI_PRM_FREE_FFS_SIZE, &amp;num_free);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiGetParamInt (XI_PRM_FREE_FFS_SIZE)</span><span class="delimiter">&quot;</span></span>);

                stat = xiGetParamInt(xiH, XI_PRM_USED_FFS_SIZE, &amp;num_used);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiGetParamInt (XI_PRM_USED_FFS_SIZE)</span><span class="char">\n</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>);

        

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">FFS stats:</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>);

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">Free bytes : %d </span><span class="char">\n</span><span class="delimiter">&quot;</span></span>, num_free);

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">Used bytes : %d </span><span class="char">\n</span><span class="delimiter">&quot;</span></span>, num_used);

        

        

                <span class="comment">//---------------------------------------------------------------</span>

                <span class="comment">// write file to FFS</span>

        

                <span class="predefined-type">char</span> test_file[MAX_PATH]=<span class="string"><span class="delimiter">&quot;</span><span class="content">test.txt</span><span class="delimiter">&quot;</span></span>;

                <span class="predefined-type">char</span> test_text[MAX_PATH]=<span class="string"><span class="delimiter">&quot;</span><span class="content">XIMEA was created by the group of industry leading Imaging and Vision veterans originating from DELARO and SOFTHARD companies.</span><span class="delimiter">&quot;</span></span>;

                

                stat = xiSetParamString(xiH, XI_PRM_FFS_FILE_NAME, test_file, MAX_PATH);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiSetParamString (XI_PRM_FFS_FILE_NAME)</span><span class="delimiter">&quot;</span></span>);

                stat = xiSetParamString(xiH, XI_PRM_WRITE_FILE_FFS, test_text, MAX_PATH);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiSetParamString (XI_PRM_WRITE_FILE_FFS)</span><span class="delimiter">&quot;</span></span>);

                

                

                <span class="comment">//---------------------------------------------------------------</span>

                <span class="comment">// read data from FFS</span>

        

                <span class="predefined-type">char</span> read_text[MAX_PATH]=<span class="string"><span class="delimiter">&quot;</span><span class="delimiter">&quot;</span></span>;        

                stat = xiGetParamString(xiH, XI_PRM_READ_FILE_FFS, read_text, MAX_PATH);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiSetParamString (XI_PRM_READ_FILE_FFS)</span><span class="delimiter">&quot;</span></span>);

        

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">Text read from FFS:</span><span class="char">\n</span><span class="content">%s</span><span class="char">\n</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>, read_text);

        

                <span class="comment">//---------------------------------------------------------------</span>

                <span class="comment">// get FFS info</span>

        

                stat = xiGetParamInt(xiH, XI_PRM_FREE_FFS_SIZE, &amp;num_free);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiGetParamInt (XI_PRM_FREE_FFS_SIZE)</span><span class="delimiter">&quot;</span></span>);

                stat = xiGetParamInt(xiH, XI_PRM_USED_FFS_SIZE, &amp;num_used);

                HandleResult(stat,<span class="string"><span class="delimiter">&quot;</span><span class="content">xiGetParamInt (XI_PRM_USED_FFS_SIZE)</span><span class="char">\n</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>);

        

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">FFS stats:</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>);

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">Free bytes : %d </span><span class="char">\n</span><span class="delimiter">&quot;</span></span>, num_free);

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">Used bytes : %d </span><span class="char">\n</span><span class="delimiter">&quot;</span></span>, num_used);

        

        <span class="label">finish:</span>

                <span class="comment">// Close device</span>

                <span class="keyword">if</span> (xiH)

                        xiCloseDevice(xiH);

                printf(<span class="string"><span class="delimiter">&quot;</span><span class="content">Done</span><span class="char">\n</span><span class="delimiter">&quot;</span></span>);

                getchar();

                <span class="keyword">return</span> <span class="integer">0</span>;

        }