Browse Source

cmScoreProc.c:cmScWriteMeasFile() now sorts file on the section label.

Also changed column order of the output file.
master
kevin 10 years ago
parent
commit
12800d428b
1 changed files with 94 additions and 11 deletions
  1. 94
    11
      app/cmScoreProc.c

+ 94
- 11
app/cmScoreProc.c View File

@@ -56,9 +56,11 @@ typedef struct
56 56
   cmTlMarker_t*   curMarkPtr;
57 57
   _cmScMeas_t*    list_beg;
58 58
   _cmScMeas_t*    list_end;
59
+  _cmScMeas_t*    slist_beg; 
59 60
 } cmSp_t;
60 61
 
61 62
 
63
+// read the dynamics reference array from the time-line project file.
62 64
 cmSpRC_t _cmJsonReadDynArray( cmJsonH_t jsH, unsigned** dynArray, unsigned* dynCnt )
63 65
 {
64 66
   cmJsonNode_t* np;
@@ -157,22 +159,49 @@ cmSpRC_t _cmScoreProcFinal( cmSp_t* p )
157 159
   return rc;
158 160
 }
159 161
 
160
-cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, const cmChar_t* outFn )
162
+unsigned _cmScMeasSectCount( cmSp_t* sp )
161 163
 {
162
-  cmFileH_t fH = cmFileNullHandle;
163
-  cmSpRC_t rc = kOkSpRC;
164
-  unsigned i;
164
+  const _cmScMeas_t* mp = sp->list_beg;
165
+  unsigned n = 0;
166
+  for(; mp != NULL; mp=mp->link)
167
+    n += mp->setPtr->sectCnt;
168
+
169
+  return n;
170
+}
171
+
165 172
 
166
-  if( cmFileOpen(&fH,outFn,kWriteFileFl,&ctx->rpt) != kOkFileRC )
167
-  {
168
-    rc = cmErrMsg(&sp->err,kFileFailSpRC,"Unable to create the output file '%s'.",cmStringNullGuard(outFn));
169
-    goto errLabel;
170
-  }
171 173
 
172
-  cmFilePrintf(fH,"{\n meas : \n[\n[\"seq\" \"mark\" \"typeId\" \"typeLabel\" \"loc\" \"evt\" \"sec\" \"val\" \"cost\" ]\n");
174
+typedef struct
175
+{
176
+  unsigned        srcSeqId;
177
+  const cmChar_t* srcMarkNameStr;
178
+  unsigned        srcTypeId;
179
+  const cmChar_t* srcTypeLabelStr;
180
+  unsigned        dstScLocIdx;
181
+  unsigned        dstEvtIdx;
182
+  const cmChar_t* dstSectLabelStr;
183
+  double          value;
184
+  double          cost;
185
+} _cmScMeasSect_t;
186
+
187
+int _cmScMeasSectCompare( const void* p0, const void* p1 )
188
+{
189
+  _cmScMeasSect_t* m0 = (_cmScMeasSect_t*)p0;
190
+  _cmScMeasSect_t* m1 = (_cmScMeasSect_t*)p1;
173 191
 
192
+  return (int)m0->dstScLocIdx - (int)m1->dstScLocIdx;
193
+}
194
+
195
+cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, const cmChar_t* outFn )
196
+{
197
+  cmFileH_t fH = cmFileNullHandle;
198
+  cmSpRC_t rc = kOkSpRC;
199
+  unsigned i,j,k;
174 200
   _cmScMeas_t* mp = sp->list_beg;
175
-  for(; mp!=NULL; mp=mp->link)
201
+
202
+  unsigned scnt = _cmScMeasSectCount(sp);
203
+  _cmScMeasSect_t sarray[ scnt ];
204
+  for(i=0,k=0; k<scnt && mp!=NULL; ++i,mp=mp->link)
176 205
   {
177 206
     const cmChar_t* typeLabel = NULL;
178 207
     switch(mp->setPtr->varId)
@@ -184,6 +213,58 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, const cmChar_t* outFn )
184 213
         { assert(0); }
185 214
     }
186 215
 
216
+    for(j=0; j<mp->setPtr->sectCnt; ++j,++k)
217
+    {
218
+      _cmScMeasSect_t* r = sarray + k;
219
+
220
+        r->srcSeqId        = mp->markPtr->obj.seqId,
221
+        r->srcMarkNameStr  = cmStringNullGuard(mp->markPtr->obj.name),
222
+        r->srcTypeId       = mp->setPtr->varId,
223
+        r->srcTypeLabelStr = typeLabel,
224
+        r->dstScLocIdx     = mp->setPtr->sectArray[j]->locPtr->index,
225
+        r->dstEvtIdx       = mp->setPtr->sectArray[j]->begEvtIndex,
226
+        r->dstSectLabelStr = cmStringNullGuard(mp->setPtr->sectArray[j]->label),
227
+        r->value           = mp->value,
228
+        r->cost            = mp->cost;
229
+
230
+    }
231
+  }
232
+
233
+  assert(mp==NULL && k==scnt);
234
+
235
+  qsort(sarray,scnt,sizeof(sarray[0]),_cmScMeasSectCompare);
236
+
237
+  if( cmFileOpen(&fH,outFn,kWriteFileFl,&ctx->rpt) != kOkFileRC )
238
+  {
239
+    rc = cmErrMsg(&sp->err,kFileFailSpRC,"Unable to create the output file '%s'.",cmStringNullGuard(outFn));
240
+    goto errLabel;
241
+  }
242
+
243
+  cmFilePrintf(fH,"{\n meas : \n[\n[  \"sec\"  \"typeLabel\"  \"val\" \"cost\" \"loc\" \"evt\" \"seq\" \"mark\" \"typeId\" ]\n");
244
+
245
+  for(i=0; i<scnt; ++i)
246
+  {
247
+    _cmScMeasSect_t* r = sarray + i;
248
+
249
+      cmFilePrintf(fH,"[  \"%s\"  \"%s\"  %f %f  %i %i %i \"%s\" %i ]\n",
250
+        r->dstSectLabelStr,
251
+        r->srcTypeLabelStr,
252
+        r->value,
253
+        r->cost,
254
+        r->dstScLocIdx,
255
+        r->dstEvtIdx,
256
+        r->srcSeqId,
257
+        r->srcMarkNameStr,
258
+        r->srcTypeId
259
+                   );
260
+
261
+  }
262
+
263
+  /*
264
+  mp = sp->list_beg;
265
+  for(; mp!=NULL; mp=mp->link)
266
+  {
267
+
187 268
     for(i=0; i<mp->setPtr->sectCnt; ++i)
188 269
     {
189 270
       cmFilePrintf(fH,"[ %i \"%s\" %i \"%s\" %i %i \"%s\" %f %f ]\n",
@@ -198,6 +279,7 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, const cmChar_t* outFn )
198 279
         mp->cost );
199 280
     } 
200 281
   }
282
+  */
201 283
 
202 284
   cmFilePrintf(fH,"\n]\n}\n");
203 285
 
@@ -208,6 +290,7 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, const cmChar_t* outFn )
208 290
   return rc;
209 291
 }
210 292
 
293
+
211 294
 void _cmScMatchCb( cmScMatcher* p, void* arg, cmScMatcherResult_t* rp )
212 295
 {
213 296
   cmSp_t*   sp = (cmSp_t*)arg;

Loading…
Cancel
Save