private void displayAllocationDetails(string TANFileContent, string configFileContent) { var allocations = TaskAllocationFileParser.GetAllocations(TANFileContent); foreach (var allocation in allocations) { float allocationRuntime = AllocationService.GetAllocationRuntime(configFileContent, allocation.Value); string allocationRuntimeErrorMsg = AllocationService.IsAllocationRuntimeValid(configFileContent, allocationRuntime); displayAllocation(allocation); if (allocationRuntimeErrorMsg == "") { float energyConsumed = AllocationService.GetTotalEnergyConsumed(configFileContent, allocation.Value); mainFormTextBox.AppendText($"Time = {allocationRuntime}, Energy = {energyConsumed}"); } else { mainFormTextBox.AppendText(allocationRuntimeErrorMsg); } mainFormTextBox.AppendText(Environment.NewLine); mainFormTextBox.AppendText(Environment.NewLine); } }
private void openTANFileToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); string TANfileName = openFileDialog1.FileName; string TANfileContent = FileService.ReadFile(TANfileName); string configFilename = TaskAllocationFileParser.GetConfigFilename(TANfileContent); if (configFilename != "") { string path = Path.GetDirectoryName(TANfileName); string configFilePath = path + @"\" + configFilename; string configFileContent = FileService.ReadFile(configFilePath); initFileValidation(); bool isTANFileValid = validateTANFile(TANfileContent); bool isConfigFileValid = validateConfigFile(configFileContent); if (isTANFileValid && isConfigFileValid) { displayAllocationDetails(TANfileContent, configFileContent); } } }