Changeset 17424 for trunk/psModules/src/concepts/pmConceptsAverage.c
- Timestamp:
- Apr 9, 2008, 8:31:42 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsAverage.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsAverage.c
r16947 r17424 226 226 } 227 227 228 bool pmConceptsAverageChips(pmChip *target, psList *sources, bool same) 229 { 230 PS_ASSERT_PTR_NON_NULL(target, false); 231 PS_ASSERT_PTR_NON_NULL(sources, false); 232 PS_ASSERT_INT_POSITIVE(sources->n, false); 233 234 float temp = 0.0; // Temperature 235 int x0 = 0, y0 = 0; // Offset 236 int xParity = 0, yParity = 0; // Parity 237 int xSize = 0, ySize = 0; 238 psString id = NULL; 239 240 int nChips = 0; // Number of cells; 241 psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources 242 pmChip *chip = NULL; // Source cell from iteration 243 while ((chip = psListGetAndIncrement(sourcesIter))) { 244 if (!chip) { 245 continue; 246 } 247 temp += psMetadataLookupF32(NULL, chip->concepts, "CHIP.TEMP"); 248 if (nChips == 1) { 249 xSize = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XSIZE"); 250 ySize = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YSIZE"); 251 xParity = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XPARITY"); 252 yParity = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YPARITY"); 253 x0 = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0"); 254 y0 = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0"); 255 id = psMetadataLookupStr(NULL, chip->concepts, "CHIP.ID"); 256 } else { 257 if (xSize != psMetadataLookupS32(NULL, chip->concepts, "CHIP.XSIZE")) { 258 psWarning("Differing CHIP.XSIZE in use: %d vs %d\n", 259 xSize, psMetadataLookupS32(NULL, chip->concepts, "CHIP.XSIZE")); 260 } 261 if (ySize != psMetadataLookupS32(NULL, chip->concepts, "CHIP.YSIZE")) { 262 psWarning("Differing CHIP.YSIZE in use: %d vs %d\n", 263 ySize, psMetadataLookupS32(NULL, chip->concepts, "CHIP.YSIZE")); 264 } 265 if (xParity != psMetadataLookupS32(NULL, chip->concepts, "CHIP.XPARITY")) { 266 psWarning("Differing CHIP.XPARITY in use: %d vs %d\n", 267 xParity, psMetadataLookupS32(NULL, chip->concepts, "CHIP.XPARITY")); 268 } 269 if (yParity != psMetadataLookupS32(NULL, chip->concepts, "CHIP.YPARITY")) { 270 psWarning("Differing CHIP.YPARITY in use: %d vs %d\n", 271 yParity, psMetadataLookupS32(NULL, chip->concepts, "CHIP.YPARITY")); 272 } 273 if (x0 != psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0")) { 274 psWarning("Differing CHIP.X0 in use: %d vs %d\n", 275 x0, psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0")); 276 } 277 if (y0 != psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0")) { 278 psWarning("Differing CHIP.Y0 in use: %d vs %d\n", 279 y0, psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0")); 280 } 281 psString newID = psMetadataLookupStr(NULL, chip->concepts, "CHIP.ID"); 282 if (id && newID && strcmp(id, newID)) { 283 psWarning("Differing CHIP.ID in use: %s vs %s\n", id, newID); 284 } 285 } 286 287 nChips++; 288 } 289 psFree(sourcesIter); 290 291 temp /= (float)nChips; 292 293 MD_UPDATE(target->concepts, "CHIP.TEMP", F32, temp); 294 if (same) { 295 MD_UPDATE(target->concepts, "CHIP.X0", S32, x0); 296 MD_UPDATE(target->concepts, "CHIP.Y0", S32, y0); 297 MD_UPDATE(target->concepts, "CHIP.XSIZE", S32, xSize); 298 MD_UPDATE(target->concepts, "CHIP.YSIZE", S32, ySize); 299 MD_UPDATE(target->concepts, "CHIP.XPARITY", S32, xParity); 300 MD_UPDATE(target->concepts, "CHIP.YPARITY", S32, yParity); 301 MD_UPDATE_STR(target->concepts, "CHIP.ID", id); 302 } 303 304 return true; 305 } 306
Note:
See TracChangeset
for help on using the changeset viewer.
