protected override void readResults(int taskID, long allObjectsCount, object taskDescription, out GeneratingStruct generation, out HypothesisStruct[] result) { generation = common.GetGeneratingStruct(taskID); List<HypothesisStruct> hypothesesResult = new List<HypothesisStruct>(); HypothesisStruct hypothesisStruct; AbstractQuantifierSetting quantifierSetting; DataTable hypothesis = common.ExecuteSelectQuery("SELECT * FROM tiHypothesisCF WHERE TaskID=" + taskID); LiteralStruct[] literals = common.GetCategorialLiterals(TaskTypeEnum.CF, taskID, taskDescription); foreach (DataRow hypothese in hypothesis.Rows) { int hypothesisID = Convert.ToInt32(hypothese["HypothesisID"]); hypothesisStruct = new HypothesisStruct(); hypothesisStruct.booleanLiterals = common.GetBooleanLiterals(taskID, hypothesisID); int rowLiteralId = common.CategorialLiteral[Convert.ToInt32(hypothese["CFLiteralDID"])]; LiteralStruct rowLiteral = new LiteralStruct(); foreach (LiteralStruct literal in literals) { if (literal.cedentType == CedentEnum.Antecedent && literal.literalIdentifier == rowLiteralId) rowLiteral = literal; } hypothesisStruct.literals = new LiteralStruct[] { rowLiteral }; quantifierSetting = new AbstractQuantifierSetting(); quantifierSetting.firstContingencyTableRows = common.GetContingecyTable(this.taskType, taskID, hypothesisID, rowLiteral.literalIdentifier, rowLiteral.literalIdentifier); quantifierSetting.secondContingencyTableRows = new int[0][]; quantifierSetting.allObjectsCount = allObjectsCount; hypothesisStruct.quantifierSetting = quantifierSetting; hypothesesResult.Add(hypothesisStruct); } result = hypothesesResult.ToArray(); }
protected override void readResults(int taskID, long allObjectsCount, object taskDescription, out GeneratingStruct generation, out HypothesisStruct[] result) { generation = common.GetGeneratingStruct(taskID); List<HypothesisStruct> hypothesesResult = new List<HypothesisStruct>(); HypothesisStruct hypothesisStruct; AbstractQuantifierSetting quantifierSetting; DataTable hypothesis = common.ExecuteSelectQuery("SELECT * FROM tiHypothesisDF WHERE TaskID=" + taskID); foreach (DataRow hypothese in hypothesis.Rows) { hypothesisStruct = new HypothesisStruct(); hypothesisStruct.booleanLiterals = common.GetBooleanLiterals(taskID, Convert.ToInt32(hypothese["HypothesisID"])); hypothesisStruct.literals = new LiteralStruct[0]; quantifierSetting = new AbstractQuantifierSetting(); quantifierSetting.firstContingencyTableRows = new int[2][]; quantifierSetting.firstContingencyTableRows[0] = new int[2] { Convert.ToInt32(hypothese["FirstFreqA"]), Convert.ToInt32(hypothese["FirstFreqB"]) }; quantifierSetting.firstContingencyTableRows[1] = new int[2] { Convert.ToInt32(hypothese["FirstFreqC"]), Convert.ToInt32(hypothese["FirstFreqD"]) }; quantifierSetting.secondContingencyTableRows = new int[2][]; quantifierSetting.secondContingencyTableRows[0] = new int[2] { Convert.ToInt32(hypothese["SecondFreqA"]), Convert.ToInt32(hypothese["SecondFreqB"]) }; quantifierSetting.secondContingencyTableRows[1] = new int[2] { Convert.ToInt32(hypothese["SecondFreqC"]), Convert.ToInt32(hypothese["SecondFreqD"]) }; quantifierSetting.allObjectsCount = allObjectsCount; hypothesisStruct.quantifierSetting = quantifierSetting; hypothesesResult.Add(hypothesisStruct); } result = hypothesesResult.ToArray(); }
public void RunTask(object taskDescription, string boxIdentity, out GeneratingStruct generation, out HypothesisStruct[] result) { this.boxIdentity = boxIdentity; this.Prepare(); int taskID = saveTask(taskDescription, boxIdentity); long allObjectsCount; remap(taskDescription, boxIdentity, taskID, out allObjectsCount); /* * /DSN "<data-source-name>" ... data source name of metabase * /TaskID <TaskID> ... TaskID of selected task * /Quiet ... errors reported to _AppLog.dat instead on screen * /NoProgress ... no progress dialog is displayed * /TimeOut <sec> ... optional: time-out in seconds (approx.) after result * (exluding initialisation) is automatically interrupted * /ODBCConnectionString="ODBC;<odbc-data-source-connection-string>" * */ this.metabase.Connection.Close(); System.Diagnostics.ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.Arguments = " /ODBCConnectionString=\"ODBC;" + this.metabase.Connection.ConnectionString + "\"" + " /TaskID " + taskID + " /Quiet "; processStartInfo.FileName = Path.Combine( exeDirectoryName, exeFileName ); processStartInfo.WindowStyle = ProcessWindowStyle.Normal; Debug.WriteLine("*Gen process start at: " + DateTime.Now.ToString()); Process genProcess = Process.Start(processStartInfo); do { if (!genProcess.HasExited) { if (genProcess.Responding) Debug.WriteLine("Status = Running"); else Debug.WriteLine("Status = Not Responding"); } } while (!genProcess.WaitForExit(250)); int genProcessExitCode = genProcess.ExitCode; if (genProcessExitCode != 0) { throw Ferda.Modules.Exceptions.BoxRuntimeError(null, boxIdentity, "Process \"" + processStartInfo.FileName + " " + processStartInfo.Arguments + "\" exited with code " + genProcessExitCode.ToString()); } Debug.WriteLine("*Gen process exit at: " + DateTime.Now.ToString() + ", witch exit code: " + genProcessExitCode.ToString()); this.metabase.Connection.Open(); Debug.WriteLine("Reading of result start at: " + DateTime.Now.ToString()); readResults(taskID, allObjectsCount, taskDescription, out generation, out result); Debug.WriteLine("Reading of result finished at: " + DateTime.Now.ToString()); this.metabase.Connection.Close(); //this.FinalizeMe(); }
public GeneratingStruct GetGeneratingStruct(int taskID) { string generationQuery = "SELECT GenerationNrOfTests,GenerationStartTime,GenerationTotalTime,HypothesisGenerated,GenerationInterrupted FROM taTask WHERE TaskID=" + taskID; DataTable generationDataTable = ExecuteSelectQuery(generationQuery); if (generationDataTable.Rows.Count != 1) return new GeneratingStruct();// throw new Exception(); DataRow generationDataRow = generationDataTable.Rows[0]; GeneratingStruct result = new GeneratingStruct(); result.generationNrOfTests = Convert.ToInt32(generationDataRow["GenerationNrOfTests"]); if (generationDataRow["GenerationStartTime"] != System.DBNull.Value) result.generationStartTime = new DateTimeTI(Convert.ToDateTime(generationDataRow["GenerationStartTime"])); else result.generationStartTime = new DateTimeTI(0, 0, 0, 0, 0, 0); result.generationTotalTime = new TimeTI(new TimeSpan(100000 * Convert.ToInt64(generationDataRow["GenerationTotalTime"]))); if (Convert.ToBoolean(generationDataRow["HypothesisGenerated"])) result.generationState = GenerationStateEnum.Completed; if (Convert.ToBoolean(generationDataRow["GenerationInterrupted"])) result.generationState = GenerationStateEnum.Interrupted; string generationNrOfHypothesesQuery = "SELECT * FROM tiHypothesis WHERE TaskID=" + taskID; result.generationNrOfHypotheses = ExecuteSelectQuery(generationNrOfHypothesesQuery).Rows.Count; return result; }
protected abstract void readResults(int taskID, long allObjectsCount, object taskDescription, out GeneratingStruct generation, out HypothesisStruct[] result);
public GenerationInfoTI(GeneratingStruct generatingStruct) { this.generationInfoValue = generatingStruct; }
/// <summary> /// Sets the generation info. /// </summary> /// <param name="boxModule">The box module.</param> /// <param name="value">The value.</param> public static void SetGenerationInfo(BoxModuleI boxModule, GeneratingStruct value) { GenerationInfoTI newValue = new GenerationInfoTI(value); boxModule.setProperty("GenerationInfo", newValue); }