/* * Routine: * Purpose: * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: * Side Effects: * TODO: None */ int mk_master(void *pDest, ds_key_t kIndex) { static int bInit = 0; struct S_PURCHASE_TBL *r; if (pDest == NULL) r = &g_s_purchase; else r = pDest; if (!bInit) { memset(&g_s_purchase, 0, sizeof(struct S_PURCHASE_TBL)); bInit = 1; } r->kID = kIndex + getUpdateBase(S_PURCHASE); r->kStoreID = mk_join(S_PURCHASE_STORE_ID, STORE, 1); r->kCustomerID = mk_join(S_PURCHASE_CUSTOMER_ID, CUSTOMER, 1); jtodt(&r->dtPurchaseDate, getUpdateDate(S_PURCHASE, kIndex)); genrand_integer(&r->nRegister, DIST_UNIFORM, 1, 17, 0, S_PURCHASE_REGISTER); genrand_integer(&r->nClerk, DIST_UNIFORM, 101, 300, 0, S_PURCHASE_CLERK); gen_text(&r->szComment[0], (int)(RS_S_PURCHASE_COMMENT * 0.6), RS_S_PURCHASE_COMMENT, S_PURCHASE_COMMENT); return(0); }
extern void initSystemData() { ptrsCounts.systemData = (struct SystemData *)FindFirstFlashStruct(NOR_STRUCT_ID_SYSTEM); ptrsCounts.systemCounts = (struct SystemCounts2 *)FindFirstFlashStruct(NOR_STRUCT_ID_COUNTS); ptrsCounts.period = (struct NORperiod *)FindLastFlashStruct(NOR_STRUCT_ID_PERIOD); ptrsCounts.corruptionDay = (struct NORcorruption *)FindLastFlashStruct(NOR_STRUCT_ID_CORRUPTION); ptrsCounts.cumulativeDays = (struct NORcumulativeDays *)FindLastFlashStruct(NOR_STRUCT_ID_CUMULATIVE_DAYS); ptrsCounts.latestRotation = (struct NORrotation *)FindLastFlashStruct(NOR_STRUCT_ID_ROTATION); ptrsCounts.powerups = (struct NORpowerups *)FindLastFlashStruct(NOR_STRUCT_ID_POWERUPS); systemCounts.year = getUpdateYear(); systemCounts.month = getUpdateMonth(); systemCounts.monthday = getUpdateDate() + getCumulativeDays(); fixBadDate(&systemCounts); }
extern void setSystemData(struct SystemData *sd) { struct SystemCounts2 sc; int size, totalSize, i, reflashes; dumpSystemDataToLog(sd); sd->structType = NOR_STRUCT_ID_SYSTEM; reflashes = getReflashCount(); if (!sd->countReflashes) sd->countReflashes = reflashes + 1; if (!sd->serialNumber[0]) { strcpy(sd->serialNumber,getSerialNumber()); if (!sd->serialNumber[0]) { strcpy(sd->serialNumber,(char *)"UNKNOWN"); } } if (!sd->location[0]) { strcpy(sd->location,getLocation()); if (!sd->location[0]) { strcpy(sd->location,(char *)"UNKNOWN"); } } if (!sd->imageName[0]) { strcpy(sd->imageName,getImageName()); if (!sd->imageName[0]) { strcpy(sd->imageName,(char *)"UNKNOWN"); } } if (!sd->updateNumber[0]) strcpy(sd->updateNumber,getUpdateNumber()); if (!sd->monthLastUpdated) sd->monthLastUpdated = getUpdateMonth(); if (!sd->dateLastUpdated) sd->dateLastUpdated = getUpdateDate(); if (!sd->yearLastUpdated) sd->yearLastUpdated = getUpdateYear(); dumpSystemDataToLog(sd); systemCounts.monthday = sd->dateLastUpdated; systemCounts.month = sd->monthLastUpdated; systemCounts.year = sd->yearLastUpdated; sc.structType = NOR_STRUCT_ID_COUNTS; sc.period = 0; sc.cumulativeDays = 0; sc.corruptionDay = 0; sc.powerups = 0; sc.lastInitVoltage = 0; sc.rotations[0].structType = NOR_STRUCT_ID_ROTATION; sc.rotations[0].rotationNumber = 0; sc.rotations[0].periodNumber = 0; sc.rotations[0].hoursAfterLastUpdate = 0; checkVoltage(); sc.rotations[0].initVoltage = vCur_1; for (i=1; i< MAX_ROTATIONS; i++) { sc.rotations[i].structType = -2; // -1 is bad since FF is unwritten memory } // startup() assumes that struct SystemData is written first at TB_SERIAL_NUMBER_ADDR totalSize = 0; size = sizeof(struct SystemData); // round up # of words write_app_flash((int *)sd, size, totalSize); totalSize += size; ptrsCounts.systemData = (struct SystemData *)(TB_SERIAL_NUMBER_ADDR); size = sizeof(struct SystemCounts2); // round up # of words write_app_flash((int *)&sc, size, totalSize); ptrsCounts.systemCounts = (struct SystemCounts2 *)(TB_SERIAL_NUMBER_ADDR + totalSize); ptrsCounts.period = NULL; ptrsCounts.cumulativeDays = NULL; ptrsCounts.powerups = NULL; ptrsCounts.corruptionDay = NULL; ptrsCounts.latestRotation = NULL; }