public void Day7_TestMethod2_input_Part2() { List <ProgramModel> programList = _fileReader.ReadFile(@"C:\Users\li.wirstrom\Documents\Code is King\FFCG.CodeIsKing\AdventofCode\AdventOfCode_2017\AdventOfCode_2017_Day7_Test\input.txt"); ProgramHandler programHandler = new ProgramHandler(programList); string bottomProgram = programHandler.GetBottom(programList); Assert.AreEqual("uownj", bottomProgram); }
public void Day7_TestMethod1_Part2() { List <ProgramModel> programList = _fileReader.ReadFile(@"C:\Users\li.wirstrom\Documents\Code is King\FFCG.CodeIsKing\AdventofCode\AdventOfCode_2017\AdventOfCode_2017_Day7_Test\testInput.txt"); ProgramHandler programHandler = new ProgramHandler(programList); string rootProgramName = programHandler.GetBottom(programList); int originalRootWeight = programList.FirstOrDefault(p => p.Name == rootProgramName).Weight; int rootProgramHolding = programHandler.GetHoldingWeight(rootProgramName); //int rootProgramWeight = programList.FirstOrDefault(p => p.Name == rootProgramName).Weight - originalRootWeight; //Assert.AreEqual(737, rootProgramWeight); Assert.AreEqual(737, rootProgramHolding); //int adjustedWeight = _programHandler.GetAdjustedWeight(); }
// Start is called before the first frame update void Awake() { handler = FindObjectOfType <ProgramHandler>(); grid = FindObjectOfType <Grid>(); // add functions commandDict = new Dictionary <string, Action <List <string> > > { { "move", MoveCommand } }; // we need to add an interpreter that should be set up to this object, as well as an input field AddInterpreter(); // store this object in the programHandlers' list of executing objects, allowing it to sychronise the execution of each command step handler.StoreInterpreter(interpreter); // setup initial values FinishedExecutingCommand = true; // clamp initial starting position? transform.position = grid.GridClamp(transform.position); }
private void RunFile(string neededFile, string neededDB, string neededLibrary, string destinationProgram) { log = new StringBuilder(); var errorFound = false; var waitHandle = new AutoResetEvent(false); var target = new ProgramHandler(); var hi = new HistoryItem { JobName = Path.GetDirectoryName(neededFile), JobType = destinationProgram, OutputDirectory = _outputDirectory, ProteinDatabase = neededDB, SpectralLibrary = destinationProgram == JobType.Library ? neededLibrary : null, Cpus = 0, CurrentStatus = string.Empty, StartTime = null, EndTime = null, RowNumber = 0, InitialConfigFile = new ConfigFile() { FilePath = "--Custom--", PropertyList = new List <ConfigProperty>() }, TagConfigFile = destinationProgram == JobType.Tag ? new ConfigFile() { FilePath = "--Custom--", PropertyList = new List <ConfigProperty>() } : null }; //File List hi.FileList = new List <InputFile> { new InputFile { FilePath = "\"" + neededFile + "\"", HistoryItem = hi } }; //set end event target.JobFinished = (x, y) => { errorFound = y; if (!errorFound && x) { target.StartNewJob(0, hi); } else { waitHandle.Set(); // signal that the finished event was raised } }; target.LogUpdate = x => log.AppendLine(x); target.ErrorForward = x => log.AppendLine(x); // call the async method target.StartNewJob(0, hi); // Wait until the event handler is invoked); if (!waitHandle.WaitOne(60000, false)) { var logstring1 = log.ToString(); if (logstring1 != "Test Case") { Assert.Fail("Test timed out." + Environment.NewLine + logstring1); } } var logstring = log.ToString(); Assert.IsFalse(errorFound, "Not as many output files as input" + Environment.NewLine + logstring); }
static void Main(string[] args) { ProgramHandler program = new ProgramHandler(); Console.WriteLine(program.Run(args)); }
/// <summary> /// Initialize the DataGridView with previous jobs and add row at bottom for easy job queuing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void QueueForm_Load(object sender, EventArgs e) { try { _jobLog = new LogForm(); #region Initialize program handler JobProcess = new ProgramHandler { JobFinished = (x, y) => { if (InvokeRequired) { var errors = JobProcess.GetErrorMessage(); if (errors != null) { ProgramHandler.LogDelegate logdelegate = ShowError; Invoke(logdelegate, errors); } ProgramHandler.ExitDelegate jobdelegate = IndicateJobDone; Invoke(jobdelegate, x, y); } else { var errors = JobProcess.GetErrorMessage(); if (errors != null) ShowError(errors); IndicateJobDone(x, y); } }, StatusUpdate = (x, y) => { if (InvokeRequired) { ProgramHandler.StatusDelegate statusdelegate = UpdateStatusText; Invoke(statusdelegate, x, y); } else UpdateStatusText(x, y); }, LogUpdate = x => { if (InvokeRequired) { ProgramHandler.LogDelegate logdelegate = AddLogLine; Invoke(logdelegate, x); } else AddLogLine(x); }, ErrorForward = x => { if (InvokeRequired) { ProgramHandler.LogDelegate logdelegate = ShowError; Invoke(logdelegate, x); } else ShowError(x); }, PercentageUpdate = x => { if (InvokeRequired) { ProgramHandler.PercentageDelegate percentdelegate = SetPercentage; Invoke(percentdelegate, x); } else SetPercentage(x); } }; #endregion //Load all jobs from database var historyItemList = _session.QueryOver<HistoryItem>().OrderBy(x => x.RowNumber).Asc.List(); foreach (var hi in historyItemList) InsertRowFromHistoryItem(hi, JobQueueDGV.Rows.Count); //Add line at end for quick job creation var values = new object[6]; values[0] = "Click to add new job"; values[1] = string.Empty; values[2] = string.Empty; values[3] = string.Empty; values[4] = string.Empty; values[5] = 0; JobQueueDGV.Rows.Add(values); JobQueueDGV.Rows[JobQueueDGV.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightGray; for (int x = JobQueueDGV.Rows.Count - 2; x >= 0; x--) { var progressCell = (DataGridViewProgressCell)JobQueueDGV[5, x]; if ((string)JobQueueDGV.Rows[x].Tag == "Finished" || (string)JobQueueDGV.Rows[x].Tag == "Unsuccessful") { progressCell.Message = (string)JobQueueDGV.Rows[x].Tag == "Finished" ? "Finished" : "Unsuccessful"; if (LastCompleted == -1) LastCompleted = x; } else if ((string)JobQueueDGV.Rows[x].Tag == "Locked") progressCell.Message = "Locked"; } //Configure IDPicker Location if (Properties.Settings.Default.IDPickerLocation == string.Empty || !File.Exists(Properties.Settings.Default.IDPickerLocation)) { if (!DetectLatestIDPicker()) iDPickerToolStripMenuItem.Visible = false; } } catch (Exception error) { MessageBox.Show("BumberDash could not load: " + error.Message + Environment.NewLine + error.StackTrace); throw; } }