<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>ecat63ml.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">ecat63ml.c</div> </div> </div> <div class="contents"> <a href="ecat63ml_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/******************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"></span> <a name="l00003"></a>00003 <span class="comment"> Copyright (c) 2003-2007 Turku PET Centre</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> Library: ecat63ml.c</span> <a name="l00006"></a>00006 <span class="comment"> Description: Reading and writing ECAT 6.3 matrix list.</span> <a name="l00007"></a>00007 <span class="comment"> Assumptions:</span> <a name="l00008"></a>00008 <span class="comment"> 1. Assumes that matrix list data is in VAX little endian format</span> <a name="l00009"></a>00009 <span class="comment"> 2. Data is automatically converted to big endian when read, if necessary</span> <a name="l00010"></a>00010 <span class="comment"> according to the current platform.</span> <a name="l00011"></a>00011 <span class="comment"></span> <a name="l00012"></a>00012 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00013"></a>00013 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span> <a name="l00014"></a>00014 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00015"></a>00015 <span class="comment"> version 2.1 of the License, or (at your option) any later version.</span> <a name="l00016"></a>00016 <span class="comment"></span> <a name="l00017"></a>00017 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00018"></a>00018 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00019"></a>00019 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span> <a name="l00020"></a>00020 <span class="comment"> See the GNU Lesser General Public License for more details:</span> <a name="l00021"></a>00021 <span class="comment"> http://www.gnu.org/copyleft/lesser.html</span> <a name="l00022"></a>00022 <span class="comment"></span> <a name="l00023"></a>00023 <span class="comment"> You should have received a copy of the GNU Lesser General Public License</span> <a name="l00024"></a>00024 <span class="comment"> along with this library/program; if not, write to the Free Software</span> <a name="l00025"></a>00025 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </span> <a name="l00026"></a>00026 <span class="comment"></span> <a name="l00027"></a>00027 <span class="comment"> Turku PET Centre, Turku, Finland, http://www.turkupetcentre.fi/</span> <a name="l00028"></a>00028 <span class="comment"></span> <a name="l00029"></a>00029 <span class="comment"> Modification history:</span> <a name="l00030"></a>00030 <span class="comment"> 2003-07-21 Vesa Oikonen</span> <a name="l00031"></a>00031 <span class="comment"> Created from ecat63.c.</span> <a name="l00032"></a>00032 <span class="comment"> 2003-08-05 VO</span> <a name="l00033"></a>00033 <span class="comment"> Included functions ecat63SortMatlistByPlane(), ecat63SortMatlistByFrame()</span> <a name="l00034"></a>00034 <span class="comment"> and ecat63CheckMatlist().</span> <a name="l00035"></a>00035 <span class="comment"> 2004-06-20 VO</span> <a name="l00036"></a>00036 <span class="comment"> ecat63PrintMatlist(): blkNr is printed correctly (+1).</span> <a name="l00037"></a>00037 <span class="comment"> 2004-06-27 VO</span> <a name="l00038"></a>00038 <span class="comment"> Included ecat63DeleteLateFrames().</span> <a name="l00039"></a>00039 <span class="comment"> 2004-09-20 VO</span> <a name="l00040"></a>00040 <span class="comment"> Doxygen style comments.</span> <a name="l00041"></a>00041 <span class="comment"> 2007-02-27 VO</span> <a name="l00042"></a>00042 <span class="comment"> Added functions ecat63GetMatrixBlockSize() and ecat63GetPlaneAndFrameNr().</span> <a name="l00043"></a>00043 <span class="comment"> 2007-03-13 VO</span> <a name="l00044"></a>00044 <span class="comment"> Corrected comments.</span> <a name="l00045"></a>00045 <span class="comment"> Added functions ecat63GetNums() and ecat63GatherMatlist().</span> <a name="l00046"></a>00046 <span class="comment"> 2007-17-07 Harri Merisaari</span> <a name="l00047"></a>00047 <span class="comment"> Fixed for ANSI</span> <a name="l00048"></a>00048 <span class="comment"></span> <a name="l00049"></a>00049 <span class="comment">******************************************************************************/</span> <a name="l00050"></a>00050 <span class="preprocessor">#include <stdio.h></span> <a name="l00051"></a>00051 <span class="preprocessor">#include <stdlib.h></span> <a name="l00052"></a>00052 <span class="preprocessor">#include <math.h></span> <a name="l00053"></a>00053 <span class="preprocessor">#include <ctype.h></span> <a name="l00054"></a>00054 <span class="preprocessor">#include <string.h></span> <a name="l00055"></a>00055 <span class="preprocessor">#include <unistd.h></span> <a name="l00056"></a>00056 <span class="preprocessor">#include <time.h></span> <a name="l00057"></a>00057 <span class="comment">/*****************************************************************************/</span> <a name="l00058"></a>00058 <span class="preprocessor">#include <swap.h></span> <a name="l00059"></a>00059 <span class="preprocessor">#include "<a class="code" href="img_8h.html">include/img.h</a>"</span> <a name="l00060"></a>00060 <span class="preprocessor">#include "<a class="code" href="ecat63_8h.html">include/ecat63.h</a>"</span> <a name="l00061"></a>00061 <span class="comment">/*****************************************************************************/</span> <a name="l00062"></a>00062 <a name="l00063"></a>00063 <span class="comment">/*****************************************************************************/</span> <a name="l00069"></a><a class="code" href="ecat63_8h.html#a2477fe69c32ce33b443b9c0eaedae423">00069</a> <span class="keywordtype">void</span> <a class="code" href="ecat63ml_8c.html#a2477fe69c32ce33b443b9c0eaedae423">ecat63InitMatlist</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *mlist) { <a name="l00070"></a>00070 mlist-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>=mlist-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>=0; mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>=NULL; <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <span class="comment">/*****************************************************************************/</span> <a name="l00073"></a>00073 <a name="l00074"></a>00074 <span class="comment">/*****************************************************************************/</span> <a name="l00080"></a><a class="code" href="ecat63_8h.html#a2d931d7e3d4e21159731b7c480c209b9">00080</a> <span class="keywordtype">void</span> <a class="code" href="ecat63ml_8c.html#a2d931d7e3d4e21159731b7c480c209b9">ecat63EmptyMatlist</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *mlist) { <a name="l00081"></a>00081 <span class="keywordflow">if</span>(mlist-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>>0) free((<span class="keywordtype">char</span>*)(mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>)); <a name="l00082"></a>00082 mlist-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>=mlist-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>=0; <a name="l00083"></a>00083 } <a name="l00084"></a>00084 <span class="comment">/*****************************************************************************/</span> <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="comment">/*****************************************************************************/</span> <a name="l00097"></a><a class="code" href="ecat63_8h.html#a6cce9d0e541e82d56c9d162f16202179">00097</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a6cce9d0e541e82d56c9d162f16202179">ecat63ReadMatlist</a>(FILE *fp, <a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml) { <a name="l00098"></a>00098 <span class="keywordtype">int</span> i, err=0, little; <a name="l00099"></a>00099 <span class="keywordtype">int</span> blk=<a class="code" href="ecat63_8h.html#a08ed2cc1d5f72492fb6b4eceb66665ad">MatFirstDirBlk</a>, next_blk=0, nr_free, prev_blk, nr_used; <a name="l00100"></a>00100 <span class="keywordtype">size_t</span> sn; <a name="l00101"></a>00101 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dirbuf[<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4]; <a name="l00102"></a>00102 <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keywordflow">if</span>(<a class="code" href="ecat63_8h.html#a31112b67a89269c5bed48d48ce2957ed">ECAT63_TEST</a>) printf(<span class="stringliteral">"ecat63ReadMatlist(fp, mlist)\n"</span>); <a name="l00105"></a>00105 <span class="keywordflow">if</span>(fp==NULL) <span class="keywordflow">return</span>(1); <a name="l00106"></a>00106 little=little_endian(); <a name="l00107"></a>00107 <span class="comment">/* Make sure that matrix list is empty */</span> <a name="l00108"></a>00108 <a class="code" href="ecat63ml_8c.html#a2d931d7e3d4e21159731b7c480c209b9">ecat63EmptyMatlist</a>(ml); <a name="l00109"></a>00109 <span class="comment">/* Seek the first list block */</span> <a name="l00110"></a>00110 fseek(fp, (blk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>, SEEK_SET); <span class="keywordflow">if</span>(ftell(fp)!=(blk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>) <span class="keywordflow">return</span>(2); <a name="l00111"></a>00111 <span class="keywordflow">do</span> { <a name="l00112"></a>00112 <span class="comment">/* Read the data block */</span> <a name="l00113"></a>00113 <span class="keywordflow">if</span>(<a class="code" href="ecat63_8h.html#a31112b67a89269c5bed48d48ce2957ed">ECAT63_TEST</a>) printf(<span class="stringliteral">" reading dirblock %d\n"</span>, blk); <a name="l00114"></a>00114 sn=fread(dirbuf, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4, fp); <span class="keywordflow">if</span>(sn<<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4) <span class="keywordflow">return</span>(3); <a name="l00115"></a>00115 <span class="comment">/* Allocate (more) memory for one block */</span> <a name="l00116"></a>00116 <span class="keywordflow">if</span>(ml-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>==0) { <a name="l00117"></a>00117 ml-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>=<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4; <a name="l00118"></a>00118 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>=(<a class="code" href="structMatDir.html">MatDir</a>*)malloc(ml-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>*<span class="keyword">sizeof</span>(<a class="code" href="structMatDir.html">MatDir</a>)); <a name="l00119"></a>00119 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(ml-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a><(ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>+<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4)) { <a name="l00120"></a>00120 ml-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>+=<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4; <a name="l00121"></a>00121 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>=(<a class="code" href="structMatDir.html">MatDir</a>*)realloc(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>, <span class="keyword">sizeof</span>(<a class="code" href="structMatDir.html">MatDir</a>)*ml-><a class="code" href="structMATRIXLIST.html#abb03eb3a1f72f1f568673c7b4b127e38">matrixSpace</a>); <a name="l00122"></a>00122 } <a name="l00123"></a>00123 <span class="keywordflow">if</span>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>==NULL) <span class="keywordflow">return</span>(4); <a name="l00124"></a>00124 <span class="comment">/* Byte order conversion for ints in big endian platforms */</span> <a name="l00125"></a>00125 <span class="keywordflow">if</span>(!little) swawbip(dirbuf, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00126"></a>00126 <span class="comment">/* Read "header" integers */</span> <a name="l00127"></a>00127 nr_free = dirbuf[0]; <a name="l00128"></a>00128 next_blk = dirbuf[1]; <a name="l00129"></a>00129 prev_blk = dirbuf[2]; <a name="l00130"></a>00130 nr_used = dirbuf[3]; <a name="l00131"></a>00131 <span class="comment">/*printf("nr_free=%d next_blk=%d prev_blk=%d nr_used=%d\n", nr_free, next_blk, prev_blk, nr_used);*/</span> <a name="l00132"></a>00132 <span class="keywordflow">for</span>(i=4; i<<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4; i+=4) <span class="keywordflow">if</span>(dirbuf[i]>0) { <a name="l00133"></a>00133 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>=dirbuf[i]; <a name="l00134"></a>00134 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>].<a class="code" href="structMatDir.html#af91ca45aca86269901b03480b5b6d741">strtblk</a>=dirbuf[i+1]; <a name="l00135"></a>00135 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>].<a class="code" href="structMatDir.html#ad1781958d48d68431d0c3b630093994f">endblk</a>=dirbuf[i+2]; <a name="l00136"></a>00136 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>].<a class="code" href="structMatDir.html#a9096ac571f3dabee56894b264552f65f">matstat</a>=dirbuf[i+3]; <a name="l00137"></a>00137 <span class="comment">/*</span> <a name="l00138"></a>00138 <span class="comment"> printf("matnum=%d strtblk=%d endblk=%d matstat=%d matrixNr=%d\n",</span> <a name="l00139"></a>00139 <span class="comment"> ml->matdir[ml->matrixNr].matnum, ml->matdir[ml->matrixNr].strtblk,</span> <a name="l00140"></a>00140 <span class="comment"> ml->matdir[ml->matrixNr].endblk, ml->matdir[ml->matrixNr].matstat,</span> <a name="l00141"></a>00141 <span class="comment"> ml->matrixNr);</span> <a name="l00142"></a>00142 <span class="comment"> */</span> <a name="l00143"></a>00143 ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>++; <a name="l00144"></a>00144 } <a name="l00145"></a>00145 blk=next_blk; <a name="l00146"></a>00146 <span class="comment">/* Seek the next list block */</span> <a name="l00147"></a>00147 fseek(fp, (blk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>, SEEK_SET); <span class="keywordflow">if</span>(ftell(fp)!=(blk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>) err=1; <a name="l00148"></a>00148 } <span class="keywordflow">while</span>(err==0 && feof(fp)==0 && blk!=<a class="code" href="ecat63_8h.html#a08ed2cc1d5f72492fb6b4eceb66665ad">MatFirstDirBlk</a>); <a name="l00149"></a>00149 <span class="keywordflow">if</span>(err) {<a class="code" href="ecat63ml_8c.html#a2d931d7e3d4e21159731b7c480c209b9">ecat63EmptyMatlist</a>(ml); <span class="keywordflow">return</span>(5);} <a name="l00150"></a>00150 <span class="keywordflow">return</span>(0); <a name="l00151"></a>00151 } <a name="l00152"></a>00152 <span class="comment">/*****************************************************************************/</span> <a name="l00153"></a>00153 <a name="l00154"></a>00154 <span class="comment">/*****************************************************************************/</span> <a name="l00160"></a><a class="code" href="ecat63_8h.html#aabc712142bcbc9e27d79a840e80212ae">00160</a> <span class="keywordtype">void</span> <a class="code" href="ecat63ml_8c.html#aabc712142bcbc9e27d79a840e80212ae">ecat63PrintMatlist</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml) { <a name="l00161"></a>00161 <span class="keywordtype">int</span> i; <a name="l00162"></a>00162 <a class="code" href="structMatval.html">Matval</a> matval; <a name="l00163"></a>00163 <a name="l00164"></a>00164 printf(<span class="stringliteral">" matrix pl fr gate bed startblk blknr\n"</span>); <a name="l00165"></a>00165 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) { <a name="l00166"></a>00166 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &matval); <a name="l00167"></a>00167 printf(<span class="stringliteral">"%4d %8d %3d %3d %3d %3d %8d %3d\n"</span>, i+1, ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, <a name="l00168"></a>00168 matval.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>, matval.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>, matval.<a class="code" href="structMatval.html#ab317865439d3423f362a3094dd65fc18">gate</a>, matval.<a class="code" href="structMatval.html#a10e3bc89856eedcc00d72ba1a3086299">bed</a>, <a name="l00169"></a>00169 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#af91ca45aca86269901b03480b5b6d741">strtblk</a>, 1+ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#ad1781958d48d68431d0c3b630093994f">endblk</a>-ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#af91ca45aca86269901b03480b5b6d741">strtblk</a>); <a name="l00170"></a>00170 } <a name="l00171"></a>00171 <span class="keywordflow">return</span>; <a name="l00172"></a>00172 } <a name="l00173"></a>00173 <span class="comment">/*****************************************************************************/</span> <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="comment">/*****************************************************************************/</span> <a name="l00186"></a><a class="code" href="ecat63_8h.html#a01664c72df6a487a1de8d1da3bbc9983">00186</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a01664c72df6a487a1de8d1da3bbc9983">ecat63Matenter</a>(FILE *fp, <span class="keywordtype">int</span> matnum, <span class="keywordtype">int</span> blkNr) { <a name="l00187"></a>00187 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0, dirblk, little, busy=1, nxtblk=0, oldsize; <a name="l00188"></a>00188 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dirbuf[<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4]; <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keywordflow">if</span>(<a class="code" href="ecat63_8h.html#a31112b67a89269c5bed48d48ce2957ed">ECAT63_TEST</a>) printf(<span class="stringliteral">"ecat63Matenter(fp, %d, %d)\n"</span>, matnum, blkNr); <a name="l00191"></a>00191 <span class="keywordflow">if</span>(fp==NULL || matnum<1 || blkNr<1) <span class="keywordflow">return</span>(0); <a name="l00192"></a>00192 little=little_endian(); memset(dirbuf, 0, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00193"></a>00193 <span class="comment">/* Read first matrix list block */</span> <a name="l00194"></a>00194 dirblk=<a class="code" href="ecat63_8h.html#a08ed2cc1d5f72492fb6b4eceb66665ad">MatFirstDirBlk</a>; <a name="l00195"></a>00195 fseek(fp, (dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>, SEEK_SET); <a name="l00196"></a>00196 <span class="keywordflow">if</span>(ftell(fp)!=(dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>) <span class="keywordflow">return</span>(0); <a name="l00197"></a>00197 <span class="keywordflow">if</span>(fread(dirbuf, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4, fp) != <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4) <span class="keywordflow">return</span>(0); <a name="l00198"></a>00198 <span class="comment">/* Byte order conversion for ints in big endian platforms */</span> <a name="l00199"></a>00199 <span class="keywordflow">if</span>(!little) swawbip(dirbuf, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00200"></a>00200 <a name="l00201"></a>00201 <span class="keywordflow">while</span>(busy) { <a name="l00202"></a>00202 nxtblk=dirblk+1; <a name="l00203"></a>00203 <span class="keywordflow">for</span>(i=4; i<<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4; i+=4) { <a name="l00204"></a>00204 <span class="keywordflow">if</span>(dirbuf[i]==0) { <span class="comment">/* Check for end of matrix list */</span> <a name="l00205"></a>00205 busy=0; <span class="keywordflow">break</span>; <a name="l00206"></a>00206 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(dirbuf[i]==matnum) { <span class="comment">/* Check if this matrix already exists */</span> <a name="l00207"></a>00207 oldsize=dirbuf[i+2]-dirbuf[i+1]+1; <a name="l00208"></a>00208 <span class="keywordflow">if</span>(oldsize<blkNr) { <span class="comment">/* If old matrix is smaller */</span> <a name="l00209"></a>00209 dirbuf[i] = 0xFFFFFFFF; <a name="l00210"></a>00210 <span class="keywordflow">if</span>(!little) swawbip(dirbuf, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00211"></a>00211 fseek(fp, (dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>, SEEK_SET); <a name="l00212"></a>00212 <span class="keywordflow">if</span>(ftell(fp)!=(dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>) <span class="keywordflow">return</span>(0); <a name="l00213"></a>00213 <span class="keywordflow">if</span>(fwrite(dirbuf, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4, fp) != <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4) <span class="keywordflow">return</span>(0); <a name="l00214"></a>00214 <span class="keywordflow">if</span>(!little) swawbip(dirbuf, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00215"></a>00215 nxtblk=dirbuf[i+2]+1; <a name="l00216"></a>00216 } <span class="keywordflow">else</span> { <span class="comment">/* old matrix size is ok */</span> <a name="l00217"></a>00217 nxtblk=dirbuf[i+1]; dirbuf[0]++; dirbuf[3]--; busy=0; <a name="l00218"></a>00218 <span class="keywordflow">break</span>; <a name="l00219"></a>00219 } <a name="l00220"></a>00220 } <span class="keywordflow">else</span> <span class="comment">/* not this one */</span> <a name="l00221"></a>00221 nxtblk=dirbuf[i+2]+1; <a name="l00222"></a>00222 } <a name="l00223"></a>00223 <span class="keywordflow">if</span>(!busy) <span class="keywordflow">break</span>; <a name="l00224"></a>00224 <span class="keywordflow">if</span>(dirbuf[1]!=<a class="code" href="ecat63_8h.html#a08ed2cc1d5f72492fb6b4eceb66665ad">MatFirstDirBlk</a>) { <a name="l00225"></a>00225 dirblk=dirbuf[1]; <a name="l00226"></a>00226 fseek(fp, (dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>, SEEK_SET); <a name="l00227"></a>00227 <span class="keywordflow">if</span>(ftell(fp)!=(dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>) <span class="keywordflow">return</span>(0); <a name="l00228"></a>00228 <span class="keywordflow">if</span>(fread(dirbuf, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4, fp) != <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4) <span class="keywordflow">return</span>(0); <a name="l00229"></a>00229 <span class="keywordflow">if</span>(!little) swawbip(dirbuf, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00230"></a>00230 } <span class="keywordflow">else</span> { <a name="l00231"></a>00231 dirbuf[1]=nxtblk; <a name="l00232"></a>00232 <span class="keywordflow">if</span>(!little) swawbip(dirbuf, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00233"></a>00233 fseek(fp, (dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>, SEEK_SET); <a name="l00234"></a>00234 <span class="keywordflow">if</span>(ftell(fp)!=(dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>) <span class="keywordflow">return</span>(0); <a name="l00235"></a>00235 <span class="keywordflow">if</span>(fwrite(dirbuf, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4, fp) != <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4) <span class="keywordflow">return</span>(0); <a name="l00236"></a>00236 dirbuf[0]=31; dirbuf[1]=<a class="code" href="ecat63_8h.html#a08ed2cc1d5f72492fb6b4eceb66665ad">MatFirstDirBlk</a>; dirbuf[2]=dirblk; <a name="l00237"></a>00237 dirbuf[3]=0; dirblk=nxtblk; <a name="l00238"></a>00238 <span class="keywordflow">for</span>(i=4; i<<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4; i++) dirbuf[i]=0; <a name="l00239"></a>00239 } <a name="l00240"></a>00240 } <a name="l00241"></a>00241 dirbuf[i]=matnum; <a name="l00242"></a>00242 dirbuf[i+1]=nxtblk; <a name="l00243"></a>00243 dirbuf[i+2]=nxtblk+blkNr; <a name="l00244"></a>00244 dirbuf[i+3]=1; <a name="l00245"></a>00245 dirbuf[0]--; <a name="l00246"></a>00246 dirbuf[3]++; <a name="l00247"></a>00247 <span class="keywordflow">if</span>(!little) swawbip(dirbuf, <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>); <a name="l00248"></a>00248 fseek(fp, (dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>, SEEK_SET); <span class="keywordflow">if</span>(ftell(fp)!=(dirblk-1)*<a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>) <span class="keywordflow">return</span>(0); <a name="l00249"></a>00249 <span class="keywordflow">if</span>(fwrite(dirbuf, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4, fp) != <a class="code" href="ecat63_8h.html#abdf75c7aade8a596594e8e7ce8b16872">MatBLKSIZE</a>/4) <span class="keywordflow">return</span>(0); <a name="l00250"></a>00250 <span class="keywordflow">if</span>(<a class="code" href="ecat63_8h.html#a31112b67a89269c5bed48d48ce2957ed">ECAT63_TEST</a>) printf(<span class="stringliteral">"returning %d from ecat63Matenter()\n"</span>, nxtblk); <a name="l00251"></a>00251 <span class="keywordflow">return</span>(nxtblk); <a name="l00252"></a>00252 } <a name="l00253"></a>00253 <span class="comment">/*****************************************************************************/</span> <a name="l00254"></a>00254 <a name="l00255"></a>00255 <span class="comment">/*****************************************************************************/</span> <a name="l00266"></a><a class="code" href="ecat63_8h.html#a7561756da60d9e38a1419da8ebf220fb">00266</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a7561756da60d9e38a1419da8ebf220fb">mat_numcod</a>(<span class="keywordtype">int</span> frame, <span class="keywordtype">int</span> plane, <span class="keywordtype">int</span> gate, <span class="keywordtype">int</span> data, <span class="keywordtype">int</span> bed) { <a name="l00267"></a>00267 <span class="keywordflow">return</span>((frame&0xFFF)|((bed&0xF)<<12)|((plane&0xFF)<<16)| <a name="l00268"></a>00268 ((gate&0x3F)<<24)|((data&0x3)<<30)); <a name="l00269"></a>00269 } <a name="l00276"></a><a class="code" href="ecat63_8h.html#af566384e63f743897f71d8ee41b3b292">00276</a> <span class="keywordtype">void</span> <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(<span class="keywordtype">int</span> matnum, <a class="code" href="structMatval.html">Matval</a> *matval) { <a name="l00277"></a>00277 matval-><a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a> = matnum&0xFFF; <a name="l00278"></a>00278 matval-><a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a> = (matnum>>16)&0xFF; <a name="l00279"></a>00279 matval-><a class="code" href="structMatval.html#ab317865439d3423f362a3094dd65fc18">gate</a> = (matnum>>24)&0x3F; <a name="l00280"></a>00280 matval-><a class="code" href="structMatval.html#aeb91605091f93426d59492bae704d6e8">data</a> = (matnum>>30)&0x3; <a name="l00281"></a>00281 matval-><a class="code" href="structMatval.html#a10e3bc89856eedcc00d72ba1a3086299">bed</a> = (matnum>>12)&0xF; <a name="l00282"></a>00282 } <a name="l00283"></a>00283 <span class="comment">/*****************************************************************************/</span> <a name="l00284"></a>00284 <a name="l00285"></a>00285 <span class="comment">/*****************************************************************************/</span> <a name="l00291"></a><a class="code" href="ecat63_8h.html#aa2765243cddea6955fe20e0a7d453b36">00291</a> <span class="keywordtype">void</span> <a class="code" href="ecat63ml_8c.html#aa2765243cddea6955fe20e0a7d453b36">ecat63SortMatlistByPlane</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml) { <a name="l00292"></a>00292 <span class="keywordtype">int</span> i, j; <a name="l00293"></a>00293 <a class="code" href="structMatval.html">Matval</a> mv1, mv2; <a name="l00294"></a>00294 <a class="code" href="structMatDir.html">MatDir</a> tmpMatdir; <a name="l00295"></a>00295 <a name="l00296"></a>00296 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>-1; i++) { <a name="l00297"></a>00297 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &mv1); <a name="l00298"></a>00298 <span class="keywordflow">for</span>(j=i+1; j<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; j++) { <a name="l00299"></a>00299 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[j].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &mv2); <a name="l00300"></a>00300 <span class="keywordflow">if</span>(mv2.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a><mv1.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>||(mv2.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>==mv1.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>&&mv2.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a><mv1.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>)) { <a name="l00301"></a>00301 tmpMatdir=ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i]; <a name="l00302"></a>00302 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i]=ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[j]; ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[j]=tmpMatdir; <a name="l00303"></a>00303 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &mv1); <a name="l00304"></a>00304 } <a name="l00305"></a>00305 } <a name="l00306"></a>00306 } <a name="l00307"></a>00307 } <a name="l00308"></a>00308 <span class="comment">/*****************************************************************************/</span> <a name="l00309"></a>00309 <a name="l00310"></a>00310 <span class="comment">/*****************************************************************************/</span> <a name="l00316"></a><a class="code" href="ecat63_8h.html#af88528086eaae0762fa9c551f3e55d92">00316</a> <span class="keywordtype">void</span> <a class="code" href="ecat63ml_8c.html#af88528086eaae0762fa9c551f3e55d92">ecat63SortMatlistByFrame</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml) { <a name="l00317"></a>00317 <span class="keywordtype">int</span> i, j; <a name="l00318"></a>00318 <a class="code" href="structMatval.html">Matval</a> mv1, mv2; <a name="l00319"></a>00319 <a class="code" href="structMatDir.html">MatDir</a> tmpMatdir; <a name="l00320"></a>00320 <a name="l00321"></a>00321 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>-1; i++) { <a name="l00322"></a>00322 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &mv1); <a name="l00323"></a>00323 <span class="keywordflow">for</span>(j=i+1; j<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; j++) { <a name="l00324"></a>00324 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[j].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &mv2); <a name="l00325"></a>00325 <span class="keywordflow">if</span>(mv2.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a><mv1.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>||(mv2.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>==mv1.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>&&mv2.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a><mv1.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>)) { <a name="l00326"></a>00326 tmpMatdir=ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i]; <a name="l00327"></a>00327 ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i]=ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[j]; ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[j]=tmpMatdir; <a name="l00328"></a>00328 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &mv1); <a name="l00329"></a>00329 } <a name="l00330"></a>00330 } <a name="l00331"></a>00331 } <a name="l00332"></a>00332 } <a name="l00333"></a>00333 <span class="comment">/*****************************************************************************/</span> <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="comment">/*****************************************************************************/</span> <a name="l00342"></a><a class="code" href="ecat63_8h.html#ad1405b1c28549717097d834307abaa72">00342</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#ad1405b1c28549717097d834307abaa72">ecat63CheckMatlist</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml) { <a name="l00343"></a>00343 <span class="keywordtype">int</span> i; <a name="l00344"></a>00344 <a name="l00345"></a>00345 <span class="keywordflow">if</span>(ml==NULL) <span class="keywordflow">return</span>(1); <a name="l00346"></a>00346 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#a9096ac571f3dabee56894b264552f65f">matstat</a>!=1) <span class="keywordflow">return</span>(1); <a name="l00347"></a>00347 <span class="keywordflow">return</span>(0); <a name="l00348"></a>00348 } <a name="l00349"></a>00349 <span class="comment">/*****************************************************************************/</span> <a name="l00350"></a>00350 <a name="l00351"></a>00351 <span class="comment">/*****************************************************************************/</span> <a name="l00360"></a><a class="code" href="ecat63_8h.html#a9dc9509d99d809410fc5904410562856">00360</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a9dc9509d99d809410fc5904410562856">ecat63DeleteLateFrames</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml, <span class="keywordtype">int</span> frame_nr) { <a name="l00361"></a>00361 <span class="keywordtype">int</span> i, del_nr=0; <a name="l00362"></a>00362 <a class="code" href="structMatval.html">Matval</a> matval; <a name="l00363"></a>00363 <a name="l00364"></a>00364 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) { <a name="l00365"></a>00365 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &matval); <a name="l00366"></a>00366 <span class="keywordflow">if</span>(matval.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>>frame_nr) {del_nr++; ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#a9096ac571f3dabee56894b264552f65f">matstat</a>=-1;} <a name="l00367"></a>00367 } <a name="l00368"></a>00368 <span class="keywordflow">return</span>(del_nr); <a name="l00369"></a>00369 } <a name="l00370"></a>00370 <span class="comment">/*****************************************************************************/</span> <a name="l00371"></a>00371 <a name="l00372"></a>00372 <span class="comment">/*****************************************************************************/</span> <a name="l00382"></a><a class="code" href="ecat63_8h.html#a8955edf44cdf0be247f73cbc7dd808c1">00382</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a8955edf44cdf0be247f73cbc7dd808c1">ecat63GetMatrixBlockSize</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *mlist, <span class="keywordtype">int</span> *blk_nr) { <a name="l00383"></a>00383 <span class="keywordtype">int</span> m, prev_blk, blk; <a name="l00384"></a>00384 <a name="l00385"></a>00385 <span class="comment">/* Check input */</span> <a name="l00386"></a>00386 <span class="keywordflow">if</span>(mlist==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l00387"></a>00387 <span class="keywordflow">if</span>(blk_nr!=NULL) *blk_nr=0; <a name="l00388"></a>00388 <a name="l00389"></a>00389 <span class="comment">/* Calculate the size of first data matrix */</span> <a name="l00390"></a>00390 m=0; prev_blk=blk=mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[m].<a class="code" href="structMatDir.html#ad1781958d48d68431d0c3b630093994f">endblk</a> - mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[m].<a class="code" href="structMatDir.html#af91ca45aca86269901b03480b5b6d741">strtblk</a>; <a name="l00391"></a>00391 <span class="keywordflow">for</span>(m=1; m<mlist-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; m++) { <a name="l00392"></a>00392 blk=mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[m].<a class="code" href="structMatDir.html#ad1781958d48d68431d0c3b630093994f">endblk</a> - mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[m].<a class="code" href="structMatDir.html#af91ca45aca86269901b03480b5b6d741">strtblk</a>; <a name="l00393"></a>00393 <span class="keywordflow">if</span>(blk!=prev_blk) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae8ce9dbf165d2c5fdb9c4609c01d94e5">STATUS_VARMATSIZE</a>; <a name="l00394"></a>00394 <span class="keywordflow">else</span> prev_blk=blk; <a name="l00395"></a>00395 } <a name="l00396"></a>00396 <span class="keywordflow">if</span>(blk_nr!=NULL) *blk_nr=blk; <a name="l00397"></a>00397 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>; <a name="l00398"></a>00398 } <a name="l00399"></a>00399 <span class="comment">/*****************************************************************************/</span> <a name="l00400"></a>00400 <a name="l00401"></a>00401 <span class="comment">/*****************************************************************************/</span> <a name="l00414"></a><a class="code" href="ecat63_8h.html#a231a6f12df0eeec69699a0d4f3aa4c42">00414</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a231a6f12df0eeec69699a0d4f3aa4c42">ecat63GetPlaneAndFrameNr</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *mlist, <a class="code" href="structecat63__mainheader.html">ECAT63_mainheader</a> *h, <span class="keywordtype">int</span> *plane_nr, <span class="keywordtype">int</span> *frame_nr) { <a name="l00415"></a>00415 <a class="code" href="structMatval.html">Matval</a> matval; <a name="l00416"></a>00416 <span class="keywordtype">int</span> m, plane, frame, prev_plane, prev_frame, fnr, pnr; <a name="l00417"></a>00417 <a name="l00418"></a>00418 <span class="comment">/* Check input */</span> <a name="l00419"></a>00419 <span class="keywordflow">if</span>(mlist==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l00420"></a>00420 <span class="keywordflow">if</span>(plane_nr!=NULL) *plane_nr=0; <a name="l00421"></a>00421 <span class="keywordflow">if</span>(frame_nr!=NULL) *frame_nr=0; <a name="l00422"></a>00422 <a name="l00423"></a>00423 <span class="comment">/* Sort matrices by plane so that following computation works */</span> <a name="l00424"></a>00424 <a class="code" href="ecat63ml_8c.html#aa2765243cddea6955fe20e0a7d453b36">ecat63SortMatlistByPlane</a>(mlist); <a name="l00425"></a>00425 <a name="l00426"></a>00426 prev_plane=plane=-1; prev_frame=frame=-1; <a name="l00427"></a>00427 fnr=pnr=0; <a name="l00428"></a>00428 <span class="keywordflow">for</span>(m=0; m<mlist-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; m++) <span class="keywordflow">if</span>(mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[m].<a class="code" href="structMatDir.html#a9096ac571f3dabee56894b264552f65f">matstat</a>==1) { <a name="l00429"></a>00429 <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(mlist-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[m].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, &matval); <a name="l00430"></a>00430 plane=matval.<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>; <a name="l00431"></a>00431 <span class="keywordflow">if</span>(h-><a class="code" href="structecat63__mainheader.html#a01ad1f4be366fb3ad82da61022e9761c">num_frames</a>>=h-><a class="code" href="structecat63__mainheader.html#a5038021b6504d93e304931a95af64746">num_gates</a>) <a name="l00432"></a>00432 frame=matval.<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>; <a name="l00433"></a>00433 <span class="keywordflow">else</span> <a name="l00434"></a>00434 frame=matval.<a class="code" href="structMatval.html#ab317865439d3423f362a3094dd65fc18">gate</a>; <a name="l00435"></a>00435 <span class="keywordflow">if</span>(plane!=prev_plane) { <a name="l00436"></a>00436 fnr=1; pnr++; <a name="l00437"></a>00437 } <span class="keywordflow">else</span> { <a name="l00438"></a>00438 fnr++; <a name="l00439"></a>00439 <span class="keywordflow">if</span>(prev_frame>0 && frame!=prev_frame+1) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bad6498890650ae8d01e69f43514eb4fed">STATUS_MISSINGMATRIX</a>; <a name="l00440"></a>00440 } <a name="l00441"></a>00441 prev_plane=plane; prev_frame=frame; <a name="l00442"></a>00442 } <span class="comment">/* next matrix */</span> <a name="l00443"></a>00443 <span class="keywordflow">if</span>(fnr*pnr != mlist-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bad6498890650ae8d01e69f43514eb4fed">STATUS_MISSINGMATRIX</a>; <a name="l00444"></a>00444 <span class="keywordflow">if</span>(plane_nr!=NULL) *plane_nr=pnr; <a name="l00445"></a>00445 <span class="keywordflow">if</span>(frame_nr!=NULL) *frame_nr=fnr; <a name="l00446"></a>00446 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>; <a name="l00447"></a>00447 } <a name="l00448"></a>00448 <span class="comment">/*****************************************************************************/</span> <a name="l00449"></a>00449 <a name="l00450"></a>00450 <span class="comment">/*****************************************************************************/</span> <a name="l00462"></a><a class="code" href="ecat63_8h.html#a893d65a8344a7a475236f11b4471e9bd">00462</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a893d65a8344a7a475236f11b4471e9bd">ecat63GetNums</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml, <span class="keywordtype">short</span> <span class="keywordtype">int</span> *num_planes, <span class="keywordtype">short</span> <span class="keywordtype">int</span> *num_frames, <span class="keywordtype">short</span> <span class="keywordtype">int</span> *num_gates, <span class="keywordtype">short</span> <span class="keywordtype">int</span> *num_bed_pos) { <a name="l00463"></a>00463 <span class="keywordtype">int</span> i, nmax; <a name="l00464"></a>00464 <a class="code" href="structMatval.html">Matval</a>* matval; <a name="l00465"></a>00465 <a name="l00466"></a>00466 <span class="keywordflow">if</span>(ml==NULL) <span class="keywordflow">return</span>(1); <a name="l00467"></a>00467 <span class="keywordflow">if</span>(ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a><1) <span class="keywordflow">return</span>(2); <a name="l00468"></a>00468 <a name="l00469"></a>00469 <span class="comment">/* Allocate memory for matrix values */</span> <a name="l00470"></a>00470 matval = (<a class="code" href="structMatval.html">Matval</a>*)calloc(ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>,<span class="keyword">sizeof</span>(<a class="code" href="structMatval.html">Matval</a>)); <a name="l00471"></a>00471 <span class="keywordflow">if</span>(matval == NULL) <span class="keywordflow">return</span>(3); <a name="l00472"></a>00472 <a name="l00473"></a>00473 <span class="comment">/* And get the matrix values */</span> <a name="l00474"></a>00474 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, matval+i); <a name="l00475"></a>00475 <a name="l00476"></a>00476 <span class="comment">/* Planes */</span> <a name="l00477"></a>00477 <span class="keywordflow">if</span>(num_planes!=NULL) { <a name="l00478"></a>00478 nmax=matval[0].<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>; <a name="l00479"></a>00479 <span class="keywordflow">for</span>(i=1; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].plane>nmax) nmax=matval[i].<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>; <a name="l00480"></a>00480 *num_planes=nmax; <a name="l00481"></a>00481 } <a name="l00482"></a>00482 <span class="comment">/* Frames */</span> <a name="l00483"></a>00483 <span class="keywordflow">if</span>(num_frames!=NULL) { <a name="l00484"></a>00484 nmax=matval[0].<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>; <a name="l00485"></a>00485 <span class="keywordflow">for</span>(i=1; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].frame>nmax) nmax=matval[i].<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>; <a name="l00486"></a>00486 *num_frames=nmax; <a name="l00487"></a>00487 } <a name="l00488"></a>00488 <span class="comment">/* Gates */</span> <a name="l00489"></a>00489 <span class="keywordflow">if</span>(num_gates!=NULL) { <a name="l00490"></a>00490 nmax=matval[0].<a class="code" href="structMatval.html#ab317865439d3423f362a3094dd65fc18">gate</a>; <a name="l00491"></a>00491 <span class="keywordflow">for</span>(i=1; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].gate>nmax) nmax=matval[i].<a class="code" href="structMatval.html#ab317865439d3423f362a3094dd65fc18">gate</a>; <a name="l00492"></a>00492 *num_gates=nmax; <a name="l00493"></a>00493 } <a name="l00494"></a>00494 <span class="comment">/* Beds */</span> <a name="l00495"></a>00495 <span class="keywordflow">if</span>(num_bed_pos!=NULL) { <a name="l00496"></a>00496 nmax=matval[0].<a class="code" href="structMatval.html#a10e3bc89856eedcc00d72ba1a3086299">bed</a>; <a name="l00497"></a>00497 <span class="keywordflow">for</span>(i=1; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].bed>nmax) nmax=matval[i].<a class="code" href="structMatval.html#a10e3bc89856eedcc00d72ba1a3086299">bed</a>; <a name="l00498"></a>00498 *num_bed_pos=nmax; <a name="l00499"></a>00499 } <a name="l00500"></a>00500 free(matval); <a name="l00501"></a>00501 <span class="keywordflow">return</span>(0); <a name="l00502"></a>00502 } <a name="l00503"></a>00503 <span class="comment">/*****************************************************************************/</span> <a name="l00504"></a>00504 <a name="l00505"></a>00505 <span class="comment">/*****************************************************************************/</span> <a name="l00519"></a><a class="code" href="ecat63_8h.html#a39dccd7c874d89f8a84d57d86ce0e6b1">00519</a> <span class="keywordtype">int</span> <a class="code" href="ecat63ml_8c.html#a39dccd7c874d89f8a84d57d86ce0e6b1">ecat63GatherMatlist</a>(<a class="code" href="structMATRIXLIST.html">MATRIXLIST</a> *ml, <span class="keywordtype">short</span> <span class="keywordtype">int</span> do_planes, <span class="keywordtype">short</span> <span class="keywordtype">int</span> do_frames, <span class="keywordtype">short</span> <span class="keywordtype">int</span> do_gates, <span class="keywordtype">short</span> <span class="keywordtype">int</span> do_beds) { <a name="l00520"></a>00520 <span class="keywordtype">int</span> i, ncurr, n; <a name="l00521"></a>00521 <a class="code" href="structMatval.html">Matval</a>* matval; <a name="l00522"></a>00522 <a name="l00523"></a>00523 <span class="keywordflow">if</span>(ml==NULL) <span class="keywordflow">return</span>(1); <a name="l00524"></a>00524 <span class="keywordflow">if</span>(ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a><1) <span class="keywordflow">return</span>(0); <a name="l00525"></a>00525 <a name="l00526"></a>00526 <span class="comment">/* Allocate memory for matrix values */</span> <a name="l00527"></a>00527 matval = (<a class="code" href="structMatval.html">Matval</a>*)calloc(ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>,<span class="keyword">sizeof</span>(<a class="code" href="structMatval.html">Matval</a>)); <a name="l00528"></a>00528 <span class="keywordflow">if</span>(matval == NULL) <span class="keywordflow">return</span>(3); <a name="l00529"></a>00529 <a name="l00530"></a>00530 <span class="comment">/* And get the matrix values */</span> <a name="l00531"></a>00531 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <a class="code" href="ecat63ml_8c.html#af566384e63f743897f71d8ee41b3b292">mat_numdoc</a>(ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>, matval+i); <a name="l00532"></a>00532 <a name="l00533"></a>00533 <span class="comment">/* Planes */</span> <a name="l00534"></a>00534 <span class="keywordflow">if</span>(do_planes!=0) { <a name="l00535"></a>00535 ncurr=1; <a name="l00536"></a>00536 <span class="keywordflow">while</span>(ncurr <= ml->matrixNr) { <a name="l00537"></a>00537 <span class="comment">/* Find any matrix with this number? */</span> <a name="l00538"></a>00538 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].plane==ncurr) {n=1; <span class="keywordflow">break</span>;} <a name="l00539"></a>00539 <span class="comment">/* If yes, then go on to the next matrix number */</span> <a name="l00540"></a>00540 <span class="keywordflow">if</span>(n==1) {ncurr++; <span class="keywordflow">continue</span>;} <a name="l00541"></a>00541 <span class="comment">/* If not, then subtract 1 from all matrix numbers that are larger */</span> <a name="l00542"></a>00542 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <a name="l00543"></a>00543 <span class="keywordflow">if</span>(matval[i].plane>ncurr) { <a name="l00544"></a>00544 matval[i].<a class="code" href="structMatval.html#ac87d088d281d918936f987cd19148069">plane</a>--; n++; <a name="l00545"></a>00545 } <a name="l00546"></a>00546 <span class="comment">/* If no larger values were found any more, then quit */</span> <a name="l00547"></a>00547 <span class="keywordflow">if</span>(n<1) <span class="keywordflow">break</span>; <a name="l00548"></a>00548 } <a name="l00549"></a>00549 } <a name="l00550"></a>00550 <a name="l00551"></a>00551 <span class="comment">/* Frames */</span> <a name="l00552"></a>00552 <span class="keywordflow">if</span>(do_frames!=0) { <a name="l00553"></a>00553 ncurr=1; <a name="l00554"></a>00554 <span class="keywordflow">while</span>(ncurr <= ml->matrixNr) { <a name="l00555"></a>00555 <span class="comment">/* Find any matrix with this number? */</span> <a name="l00556"></a>00556 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].frame==ncurr) {n=1; <span class="keywordflow">break</span>;} <a name="l00557"></a>00557 <span class="comment">/* If yes, then go on to the next matrix number */</span> <a name="l00558"></a>00558 <span class="keywordflow">if</span>(n==1) {ncurr++; <span class="keywordflow">continue</span>;} <a name="l00559"></a>00559 <span class="comment">/* If not, then subtract 1 from all matrix numbers that are larger */</span> <a name="l00560"></a>00560 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <a name="l00561"></a>00561 <span class="keywordflow">if</span>(matval[i].frame>ncurr) {matval[i].<a class="code" href="structMatval.html#a514081d81e26c20a377de4e945499446">frame</a>--; n++;} <a name="l00562"></a>00562 <span class="comment">/* If no larger values were found any more, then quit */</span> <a name="l00563"></a>00563 <span class="keywordflow">if</span>(n<1) <span class="keywordflow">break</span>; <a name="l00564"></a>00564 } <a name="l00565"></a>00565 } <a name="l00566"></a>00566 <a name="l00567"></a>00567 <span class="comment">/* Gates */</span> <a name="l00568"></a>00568 <span class="keywordflow">if</span>(do_gates!=0) { <a name="l00569"></a>00569 ncurr=1; <a name="l00570"></a>00570 <span class="keywordflow">while</span>(ncurr <= ml->matrixNr) { <a name="l00571"></a>00571 <span class="comment">/* Find any matrix with this number? */</span> <a name="l00572"></a>00572 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].gate==ncurr) {n=1; <span class="keywordflow">break</span>;} <a name="l00573"></a>00573 <span class="comment">/* If yes, then go on to the next matrix number */</span> <a name="l00574"></a>00574 <span class="keywordflow">if</span>(n==1) {ncurr++; <span class="keywordflow">continue</span>;} <a name="l00575"></a>00575 <span class="comment">/* If not, then subtract 1 from all matrix numbers that are larger */</span> <a name="l00576"></a>00576 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <a name="l00577"></a>00577 <span class="keywordflow">if</span>(matval[i].gate>ncurr) {matval[i].<a class="code" href="structMatval.html#ab317865439d3423f362a3094dd65fc18">gate</a>--; n++;} <a name="l00578"></a>00578 <span class="comment">/* If no larger values were found any more, then quit */</span> <a name="l00579"></a>00579 <span class="keywordflow">if</span>(n<1) <span class="keywordflow">break</span>; <a name="l00580"></a>00580 } <a name="l00581"></a>00581 } <a name="l00582"></a>00582 <a name="l00583"></a>00583 <span class="comment">/* Beds */</span> <a name="l00584"></a>00584 <span class="keywordflow">if</span>(do_beds!=0) { <a name="l00585"></a>00585 ncurr=1; <a name="l00586"></a>00586 <span class="keywordflow">while</span>(ncurr <= ml->matrixNr) { <a name="l00587"></a>00587 <span class="comment">/* Find any matrix with this number? */</span> <a name="l00588"></a>00588 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <span class="keywordflow">if</span>(matval[i].bed==ncurr) {n=1; <span class="keywordflow">break</span>;} <a name="l00589"></a>00589 <span class="comment">/* If yes, then go on to the next matrix number */</span> <a name="l00590"></a>00590 <span class="keywordflow">if</span>(n==1) {ncurr++; <span class="keywordflow">continue</span>;} <a name="l00591"></a>00591 <span class="comment">/* If not, then subtract 1 from all matrix numbers that are larger */</span> <a name="l00592"></a>00592 <span class="keywordflow">for</span>(i=0, n=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) <a name="l00593"></a>00593 <span class="keywordflow">if</span>(matval[i].bed>ncurr) {matval[i].<a class="code" href="structMatval.html#a10e3bc89856eedcc00d72ba1a3086299">bed</a>--; n++;} <a name="l00594"></a>00594 <span class="comment">/* If no larger values were found any more, then quit */</span> <a name="l00595"></a>00595 <span class="keywordflow">if</span>(n<1) <span class="keywordflow">break</span>; <a name="l00596"></a>00596 } <a name="l00597"></a>00597 } <a name="l00598"></a>00598 <a name="l00599"></a>00599 <span class="comment">/* Write matrix values (possibly changed) into matrix list */</span> <a name="l00600"></a>00600 <span class="keywordflow">for</span>(i=0; i<ml-><a class="code" href="structMATRIXLIST.html#a7fcfb983a42851d8562084ddde1f9fcd">matrixNr</a>; i++) ml-><a class="code" href="structMATRIXLIST.html#a42676745379d69392b07b5c29626f6f9">matdir</a>[i].<a class="code" href="structMatDir.html#aeb0291ec1f5ac237c1e587ed3d23b1bb">matnum</a>=<a class="code" href="ecat63ml_8c.html#a7561756da60d9e38a1419da8ebf220fb">mat_numcod</a>( <a name="l00601"></a>00601 matval[i].frame, matval[i].plane, <a name="l00602"></a>00602 matval[i].gate, matval[i].data, <a name="l00603"></a>00603 matval[i].bed); <a name="l00604"></a>00604 free(matval); <a name="l00605"></a>00605 <span class="keywordflow">return</span>(0); <a name="l00606"></a>00606 } <a name="l00607"></a>00607 <span class="comment">/*****************************************************************************/</span> <a name="l00608"></a>00608 <a name="l00609"></a>00609 <span class="comment">/*****************************************************************************/</span> <a name="l00610"></a>00610 </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Mon Aug 8 2011 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>