/// <summary> /// Marks an imaging as skipped. /// </summary> public void SkippedImaging(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, DateTime dateToImage) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } string imagingID = DummyImagingTaskProvider.GetImagingID(plateID, dateToImage); ImagingTask task; bool ok = _tasks.TryGetValue(imagingID, out task); if (ok) { task.SetInQueue(false); task.SetState(ImagingState.Skipped); } return; }
/// <summary> /// Plate is starting to image. Returns an imaging identifier that will be /// embedded in the image names, and returned in ImagedPlate or null if /// the ImagingID is unavailable. /// </summary> public string ImagingPlate(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, bool scheduled, DateTime dateToImage, DateTime dateImaged) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } string imagingID = DummyImagingTaskProvider.GetImagingID(plateID, dateToImage); /* * Unnecessary code * * bool exists = true; * if (!scheduled) * { * ImagingTask task = new ImagingTask(); * task.SetDateImaged(dateImaged); * task.SetDateToImage(dateToImage); * task.SetInQueue(true); * task.SetPriority(5); * task.SetState(ImagingState.Imaging); * * lock (_tasks) * { * if (! _tasks.ContainsKey(imagingID)) * { * exists = false; * _tasks.Add(imagingID, task); * } * } * } * * * if (scheduled || exists) */ if (scheduled) { ImagingTask task; bool ok = _tasks.TryGetValue(imagingID, out task); if (ok) { task.SetDateImaged(dateImaged); task.SetState(ImagingState.Imaging); } } return(DummyImagingTaskProvider.GetImagingID(plateID, dateToImage)); }
/// <summary> /// If this <c>IImagingTaskProvider</c> supports changing priority, /// changes the priority of the IImagingTask with this <c>dateToImage</c>. /// </summary> void IImagingTaskProvider.UpdatedPriority(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, DateTime dateToImage, int priority) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } string imagingID = DummyImagingTaskProvider.GetImagingID(plateID, dateToImage); ImagingTask task; bool ok = _tasks.TryGetValue(imagingID, out task); if (ok) { task.SetPriority(priority); } return; }
/// <summary> /// Returns all scheduled <c>IImagingTask</c>s for the <c>plateID</c>. /// </summary> public IImagingTask[] GetImagingTasks(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID) { // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } if (null == plateID) { throw new System.NullReferenceException("plateID must not be null"); } IImagingTask[] myTasks = null; lock (_scheduled) { if (!_scheduled.Contains(plateID)) { _scheduled.Add(plateID); List <IImagingTask> myTaskList = new List <IImagingTask>(); DateTime now = DateTime.Now; for (int i = 0; i < 25; i++) { DateTime dateToImage = now.AddHours(i); string imagingID = DummyImagingTaskProvider.GetImagingID(plateID, dateToImage); ImagingTask task = new ImagingTask(); task.SetDateToImage(dateToImage); task.SetInQueue(true); task.SetPriority(5); task.SetState(ImagingState.NotCompleted); myTaskList.Add(task); try { _tasks.Add(imagingID, task); } catch (System.ArgumentException e) { // Swallow duplicate key errors if (!e.Message.Contains("same key has already been added")) { throw; } } } myTasks = myTaskList.ToArray(); } } if (null == myTasks) { List <IImagingTask> myTaskList = new List <IImagingTask>(); Dictionary <string, ImagingTask> .Enumerator en = _tasks.GetEnumerator(); while (en.MoveNext()) { if (en.Current.Key.StartsWith(plateID)) { myTaskList.Add(en.Current.Value); } } myTasks = myTaskList.ToArray(); setInQueue(myTasks); } return(myTasks); }