void DataBaseServer::ParseParameterStr (const KKStr& parameterStr) { VectorKKStr parameterPairs = parameterStr.Split ("\t"); VectorKKStr::iterator idx; for (idx = parameterPairs.begin (); idx != parameterPairs.end (); idx++) { VectorKKStr fields = (*idx).Split (":="); // Split by either ':' or '=' if (fields.size () < 2) { // Should be two fields; line must be malformed. continue; } KKStr parameterName = fields[0].ToUpper (); if ((parameterName == "EMBEDDED") || (parameterName == "EMB") || (parameterName == "E")) embedded = fields[1].ToBool (); else if ((parameterName == "MYSQLDATADIR") || (parameterName == "MYSQL") || (parameterName == "MDD")) mySqlDataDir = fields[1]; else if ((parameterName == "DESCRIPTION") || (parameterName == "DESC") || (parameterName == "D")) description = fields[1]; else if ((parameterName == "HOSTNAME") || (parameterName == "HOST") || (parameterName == "H")) hostName = fields[1]; else if ((parameterName == "USERNAME") || (parameterName == "USER") || (parameterName == "U")) userName = fields[1]; else if ((parameterName == "PASSWORD") || (parameterName == "PW") || (parameterName == "P")) passWord = fields[1]; else if ((parameterName == "PORTNUM") || (parameterName == "PN")) portNum = fields[1].ToUint32 (); else if ((parameterName == "DATABASENAME") || (parameterName == "DATABASE") || (parameterName == "DB")) dataBaseName = fields[1]; } if (description.EqualIgnoreCase ("Embedded")) embedded = true; } /* ParseParameterStr */
bool FileInStack (const KKStr& cmdFileName, const VectorKKStr& cmdFileStack ) { VectorKKStr::const_iterator idx; for (idx = cmdFileStack.begin (); idx != cmdFileStack.end (); idx++) { if (*idx == cmdFileName) return true; } return false; } /* FileInStack */
void AbundanceCorrectionStatsBuilder::Main () { if (Abort ()) return; if (reportFileName.Empty ()) { DateTime d = osGetLocalDateTime (); KKStr reportDir = osAddSlash (SipperVariables::PicesReportDir ()) + "AbundanceAdjustments"; osCreateDirectoryPath (reportDir); if (configFileName.Empty ()) reportFileName = osAddSlash (reportDir) + "NoConfigFile" + "_" + d.YYYYMMDDHHMMSS () + ".txt"; else reportFileName = osAddSlash (reportDir) + osGetRootName (configFileName) + "_" + d.YYYYMMDDHHMMSS () + ".txt"; } report = new ofstream (reportFileName.Str ()); PrintComandLineParameters (); if (configFileName.Empty ()) { log.Level (-1) << endl << endl << "AbundanceCorrectionStatsBuilder::Main ***ERROR*** Configuration File was not specified." << endl << endl; Abort (true); *report << endl << "*** NO CONFIGURATION FILE SPECIFIED ***" << endl << endl; return; } delete config; config = new TrainingConfiguration2 (fileDesc, configFileFullPath, log, true /**< 'true' = validateDirectories. */ ); if (!config->FormatGood ()) { log.Level (-1) << endl << "AbundanceCorrectionStatsBuilder::Main Config[" << configFileName << "] has invalid format." << endl << endl; VectorKKStr errors = config->FormatErrorsWithLineNumbers (); VectorKKStr::const_iterator idx; log.Level (-1) << endl; for (idx = errors.begin (); idx != errors.end (); ++idx) log.Level (-1) << (*idx) << endl; log.Level (-1) << endl << endl; *report << endl << endl << "*** Configuratiuon file[" << configFileName << " contains formatting errors." << endl << endl; config->PrintFormatErrors (*report); return; } bool changesMadeToTrainingLibraries = false; bool cancelFlag = false; DateTime latestImageTimeStamp; delete trainLibData; trainLibData = config->LoadFeatureDataFromTrainingLibraries (latestImageTimeStamp, changesMadeToTrainingLibraries, cancelFlag); if (!trainLibData) { log.Level (-1) << endl << "AbundanceCorrectionStatsBuilder::Main ***ERROR*** No training data was loaded." << endl << endl; *report << endl << "*** Failed to load training data ***" << endl; return; } otherClass = config->OtherClass (); if (!otherClass) otherClass = MLClass::CreateNewMLClass ("Other", -1); configClasses = config->ExtractClassList (); configClasses->SortByName (); if (configClasses->PtrToIdx (otherClass) >= 0) { log.Level (-1) << endl << "AbundanceCorrectionStatsBuilder::Main ***ERROR*** OtherClass[" << otherClass->Name () << "] is specified as a Training Class; it must be swepcified separatly." << endl << endl; *report << endl << "*** Failed to load other class data ***" << endl; return; } trainLibDataClasses = trainLibData->ExtractMLClassConstList (); trainLibDataClasses->SortByName (); if ((*configClasses) != (*trainLibDataClasses)) { Abort (true); log.Level (-1) << endl << "AbundanceCorrectionStatsBuilder::Main ***ERROR*** Class make up of training data does not correspond to configuration file." << endl << endl; *report << endl << "*** Training data contains different classes that Confg File ***" << endl; return; } allClasses = new MLClassConstList (*trainLibDataClasses); allClasses->PushOnBack (otherClass); otherClassData = config->LoadOtherClasssExamples (); if ((!otherClassData) || (otherClassData->QueueSize () < 1)) { Abort (true); log.Level (-1) << endl << "AbundanceCorrectionStatsBuilder::Main ***ERROR*** No Other[" << otherClass->Name () << "] class examples found in training library." << endl << endl; *report << endl << "*** No other class data loaded. ***" << endl; return; } PrintStartStatistics (); RemoveDuplicateImages (); normalizationParms = new NormalizationParms (config, *trainLibData, log); normalizationParms->NormalizeImages (trainLibData); normalizationParms->NormalizeImages (otherClassData); CreateInitialThreadInstaces (); ManageThreads (); if (oneOrMoreThreadsCrashed) { GenerateCrashReport (); } else { GenerateReportAndStats (); } } /* Main */