/// <summary> /// Marks a imaging as completed. /// </summary> public void ImagedPlate(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, string imagingID) { // 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"); } if (null == imagingID) { throw new System.NullReferenceException("imagingID must not be null"); } ImagingTask task; bool ok = _tasks.TryGetValue(imagingID, out task); if (ok) { task.SetInQueue(false); task.SetState(ImagingState.Completed); } return; }
/// <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> /// Construct an IImageProcessor instance for the specified IRobot and IProcessingInfo. /// </summary> /// <param name="robot">The Robot that took the images to be processed by this IImageProcessor instance</param> /// <param name="processingInfo">The description of the images to be processed by this IImageProcessor instance</param> public ImageProcessor2(IRobot robot, IProcessingInfo processingInfo, IPlateInfo plateInfo, IPlateType plateType) { // Get Logger. _log = LogManager.GetLogger(this.GetType()); _dateImaged = DateTime.MinValue; _lightPath = 0; _robot = robot; _processingInfo = processingInfo; _plateInfo = plateInfo; _plateType = plateType; _captureInfo = null; SetRegionName(_processingInfo.RegionID); SetProfileName(_processingInfo.ProfileID); _log.Info( "DropNumber=" + processingInfo.DropNumber + ";ImagingID=\"" + processingInfo.ImagingID + "\"" + ";PlatedID=\"" + processingInfo.PlateID + "\"" + ";ProfileID=\"" + processingInfo.ProfileID + "\"" + ";RegionID=\"" + processingInfo.RegionID + "\"" + ";RegionType=" + processingInfo.RegionType.ToString() + ";WellNumber=" + processingInfo.WellNumber + ";Robot.Name=\"" + _robot.Name + "\""); }
/// <summary> /// Marks a imaging as completed. /// </summary> void IImagingTaskProvider.ImagedPlate(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, string imagingID) { // 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"); } if (null == imagingID) { throw new System.NullReferenceException("imagingID must not be null"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".ImagedPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", imagingID=\"" + imagingID + "\")"; _log.Debug(msg); } // Set the request imagedPlate request = new imagedPlate(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); request.plateID = plateID; request.imagingID = imagingID; // Make the call WSPlate wsPlate = new WSPlate(); imagedPlateResponse response = null; try { response = wsPlate.imagedPlate(request); } catch (Exception e) { // Log it string msg = "WSPlate.imagedPlate threw " + e.GetType() + ": " + e.Message + " - panic!"; msg = msg + "\nin " + this + ".ImagedPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", imagingID=\"" + imagingID + "\")"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Fatal(msg, e); // Panic throw e; } // Webservice always returns true if it doesn't throw an exception return; }
/// <summary> /// Gets the capture profile for the plate under the microscope. /// </summary> /// <param name="plateID">The plateID to retrieve the capture profile for.</param> /// <returns>The default <c>ICaptureProfile</c> for this plateID, or <c>null</c> if the default imager configuration should be used.</returns> ICaptureProfile ICaptureProvider.GetDefaultCaptureProfile(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID) { // TODO: Add CaptureProvider.GetDefaultCaptureProfile implementation if (_log.IsInfoEnabled) { _log.Info("Called ICaptureProvider.GetDefaultCaptureProfile(" + Robot.ToString(robot) + ", \"" + plateID + "\") - returning null"); } return(null); }
/* * Added in Formulatrix.Integrations.ImagerLink.dll v2.0.0.73 (RockImager v2.0.3.18), * which is supposed to be more recent than v2.0.1.136 (RockImager v2.0.1.136). */ /// <summary> /// Gets an <c>ICapturePointList</c> to image for this plateID on the specified <c>imagingID</c>. /// </summary> /// <param name="robot"></param> /// <param name="plateID"></param> /// <param name="imagingID">The imaging ID started for this run.</param> /// <param name="includeOverview"></param> /// <param name="userSelectionCaptureProfileID"></param> /// <returns></returns> /// <remarks> /// Added in Formulatrix.Integrations.ImagerLink.dll v2.0.0.73 (RockImager v2.0.3.18), /// which is supposed to be more recent than v2.0.1.136 (RockImager v2.0.1.136). /// </remarks> ICapturePointList ICaptureProvider.GetCapturePoints(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, string imagingID, bool includeOverview, int userSelectionCaptureProfileID) { // TODO: Add CaptureProvider.GetCapturePoints implementation //return null; if (_log.IsInfoEnabled) { _log.Info("Called ICaptureProvider.GetCapturePoints(" + Robot.ToString(robot) + ", \"" + plateID + "\", \"" + imagingID + "\", " + includeOverview + ", " + userSelectionCaptureProfileID + ")"); } CapturePointList capturePointList = null; // OPPF Vis if (1 == userSelectionCaptureProfileID) { _log.Info("Returning empty ICapturePointList"); capturePointList = new CapturePointList(); } // OPPF UV else if (2 == userSelectionCaptureProfileID) { _log.Info("Returning ICapturePointList with PlateCaptureProfile and CapturePoints set to an ICaptureProfile with one IProperty of \"LightPath\" = \"1\""); // Create the property array containing the UV LightPath property IProperty[] properties = new OPPF.Integrations.ImagerLink.Property[1]; properties[0] = new OPPF.Integrations.ImagerLink.Property("LightPath", "1"); // Create a new CaptureProfile and apply the UV LightPath property CaptureProfile captureProfile = new CaptureProfile(); captureProfile.SetProfileID("2"); captureProfile.SetProperties(properties); // Create the array of capture profiles to be used for each drop - in this case only one CaptureProfile[] captureProfiles = new CaptureProfile[1]; captureProfiles[0] = captureProfile; // Create a CapturePoint for each drop using RockImager's default drop position and the UV LightPath // TODO: Get number of wells and drops from plate type int wells = 96; CapturePoint[] capturePoints = new CapturePoint[wells]; for (int i = 0; i < wells; i++) { // TODO: Loop over drops - currently assumes one drop per well capturePoints[i] = new CapturePoint(i + 1, 1, captureProfiles, null, null, "1", RegionType.Drop); } // Create the CapturePointList and set the PlateCaptureProfile and CapturePoints // NB I don't think RockImager actually uses the PlateCaptureProfile capturePointList = new CapturePointList(); capturePointList.SetPlateCaptureProfile(captureProfile); capturePointList.SetCapturePoints(capturePoints); } return(capturePointList); }
/// <summary> /// This method is intended to cause any resources that are no /// longer necessary to be released /// </summary> void IDisposable.Dispose() { _regionName = null; _profileName = null; _captureInfo = null; _robot = null; _processingInfo = null; _plateInfo = null; _plateType = null; }
/// <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"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".UpdatedPriority(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, priority=" + priority + ")"; _log.Debug(msg); } // Set the request updatedPriority request = new updatedPriority(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); request.plateID = plateID; // .NET < 2.0 //request.dateToImage = dateToImage; // .NET >= 2.0 request.dateToImage = dateToImage.ToUniversalTime(); request.priority = priority; // Make the call WSPlate wsPlate = new WSPlate(); try { wsPlate.updatedPriority(request); } catch (Exception e) { // Log it string msg = "WSPlate.updatedPriority threw " + e.GetType() + ": " + e.Message + " - ignoring"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Warn(msg, e); // Don't rethrow - just return - don't really care if this didn't work return; } // Webservice always returns true if there is no exception 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> /// Marks an imaging as skipped. /// </summary> void IImagingTaskProvider.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"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".SkippedImaging(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC)"; _log.Debug(msg); } // Set the request skippedImaging request = new skippedImaging(); request.robot = OPPF.Utilities.Robot2Utils.createProxy(robot); request.plateID = plateID; request.dateToImage = dateToImage.ToUniversalTime(); // Make the call WSPlate wsPlate = WSPlateFactory.getWSPlate2(); skippedImagingResponse response = null; try { response = wsPlate.skippedImaging(request); } catch (Exception e) { // Log it string msg = "WSPlate.skippedImaging threw " + e.GetType() + ": " + e.Message + " - ignoring"; msg = msg + "\nin " + this + ".SkippedImaging(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC)"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Warn(msg, e); // Don't rethrow - just return - don't really care if this didn't work return; } // Webservice always returns true if it doesn't throw an exception return; }
public ImageProcessor(Formulatrix.Integrations.ImagerLink.IRobot robot, IProcessingInfo processingInfo) { // Get Logger. _log = LogManager.GetLogger(this.GetType()); SetRegionName(""); SetProfileName(""); _captureInfo = null; _imageInfo = null; _robot = robot; _processingInfo = processingInfo; }
/// <summary> /// Return <c>true</c> if this provider supplies <c>IImagingTask.Priority</c>. /// Otherwise the imager should manage individual task priority. /// </summary> bool IImagingTaskProvider.SupportsPriority(Formulatrix.Integrations.ImagerLink.IRobot robot) { // OPPF PERFORMANCE BODGE - Actually this method should always return true! return(true); // Check arguments - do it up front to avoid possible inconsistencies later if (null == robot) { throw new System.NullReferenceException("robot must not be null"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".SupportsPriority(robot=" + RobotUtils.iRobotToString(robot) + ")"; _log.Debug(msg); } // Set the request supportsPriority request = new supportsPriority(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); // Make the call WSPlate wsPlate = new WSPlate(); supportsPriorityResponse response = null; try { response = wsPlate.supportsPriority(request); } catch (Exception e) { // Log it string msg = "WSPlate.supportsPriority threw " + e.GetType() + ": " + e.Message + " - ignoring"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Warn(msg, e); // Don't rethrow - just return false return(false); } // Return the response's value //_log.Debug("supportsPriority returned " + response.supportsPriorityReturn); return(response.supportsPriorityReturn); }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { // dispose managed resources } // free native resources _regionName = null; _profileName = null; _captureInfo = null; _robot = null; _processingInfo = null; _plateInfo = null; _plateType = null; disposed = true; } }
/// <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> /// 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"); } // Log the call to the method if (_log.IsInfoEnabled) { string msg = "Called " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", scheduled=\"" + scheduled + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Info(msg); } // Set the request imagingPlate request = new imagingPlate(); request.robot = global::OPPF.Utilities.Robot2Utils.createProxy(robot); request.plateID = plateID; request.scheduled = scheduled; //request.dateToImage = dateToImage.ToUniversalTime(); // Is this a fix for the date collision problem? if (scheduled) { request.dateToImage = dateToImage.ToUniversalTime(); } else { request.dateToImage = dateImaged.ToUniversalTime(); } request.dateImaged = dateImaged.ToUniversalTime(); // Make the call WSPlate wsPlate = WSPlateFactory.getWSPlate2(); imagingPlateResponse response = null; try { response = wsPlate.imagingPlate(request); } catch (Exception e) { string msg = "WSPlate.imagingPlate threw " + e.GetType() + ": " + e.Message + " - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; msg = msg + WSPlateFactory.SoapExceptionToString(e); _log.Fatal(msg, e); // Panic throw; } // If we got no response if (null == response) { string msg = "WSPlate.imagingPlate returned null - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Fatal(msg); // Panic throw new System.NullReferenceException(msg); } // If we got a null imagingID if (null == response.imagingPlateReturn) { string msg = "WSPlate.imagingPlate returned a null imagingID - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Fatal(msg); // Panic throw new System.NullReferenceException(msg); } // Return the imagingID return(response.imagingPlateReturn); }
/// <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"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".GetImagingTasks(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\")"; _log.Debug(msg); } // Declare the array that will be populated and returned - default to a zero-length array IImagingTask[] iImagingTasks = new IImagingTask[0]; // Bail out on test plates if ("ReliabilityTestPlate".Equals(plateID) || "ReservedSlot".Equals(plateID)) { return(iImagingTasks); } // Ensure connected to database - may throw an exception but we don't need/want to catch it if ((null == _dbConnection) || (System.Data.ConnectionState.Closed.Equals(_dbConnection.State))) { //connectToDB(); } // Try and read the imaging tasks from the db OdbcDataReader dataReader = null; try { // TODO - unnecessary check? Can connectToDB fail without throwing an exception? if (System.Data.ConnectionState.Open.Equals(_dbConnection.State)) { // Update the parameters _command.Parameters["@p1"].Value = plateID; // If we care which imager if (2 == _command.Parameters.Count) { _command.Parameters["@p2"].Value = robot.Name; } // Execute the select dataReader = _command.ExecuteReader(); // Read the data reader's rows into the ProjectList if (dataReader.HasRows) { // Get an ArrayList to hold the tasks System.Collections.ArrayList tasks = new System.Collections.ArrayList(); // Loop over all the returned rows while (dataReader.Read()) { // Create and populate a new ImagingTask global::OPPF.Integrations.ImagerLink.Scheduling.ImagingTask task = new global::OPPF.Integrations.ImagerLink.Scheduling.ImagingTask(); // .NET < 2.0 //task.DateToImage = dataReader.GetDateTime(0); // .NET >= 2.0 Only! task.SetDateToImage(DateTime.SpecifyKind(dataReader.GetDateTime(0), DateTimeKind.Utc)); if (dataReader.IsDBNull(1)) { task.SetDateImaged(DateTime.MinValue); } else { // .NET < 2.0 //task.DateImaged = dataReader.GetDateTime(1); // .NET >= 2.0 Only! task.SetDateImaged(DateTime.SpecifyKind(dataReader.GetDateTime(1), DateTimeKind.Utc)); //task.DateImaged = dataReader.GetDateTime(1).ToLocalTime(); } if (dataReader.IsDBNull(2)) { _log.Warn("Got null priority for plateID: " + plateID + " task: " + task.DateToImage.ToLongTimeString()); task.SetPriority(5); } else { task.SetPriority(dataReader.GetInt32(2)); } if (dataReader.IsDBNull(3)) { _log.Warn("Got null state for plateID: " + plateID + " task: " + task.DateToImage.ToLongTimeString()); if (dataReader.IsDBNull(1)) { task.SetState(Formulatrix.Integrations.ImagerLink.Scheduling.ImagingState.NotCompleted); } else { task.SetState(Formulatrix.Integrations.ImagerLink.Scheduling.ImagingState.Completed); } } else { task.SetState((Formulatrix.Integrations.ImagerLink.Scheduling.ImagingState)dataReader.GetInt32(3)); } task.SetInQueue(true); // Store this task in the ArrayList tasks.Add(task); //_log.Debug("> Got task: DateToImage=" + task.DateToImage + ", Priority=" + task.Priority + ", State=" + task.State + ", InQueue= " + task.InQueue); } // Convert ArrayList to IImagingTask[] iImagingTasks = (IImagingTask[])tasks.ToArray(typeof(IImagingTask)); } // Close the dataReader dataReader.Close(); } } catch (Exception e) { // Log it string msg = "Exception " + e.Message + " during direct db part of getImagingTasks() for plate " + plateID + " - will fail down to webservice call"; _log.Error(msg, e); try { // Clean up the dataReader if ((null != dataReader) && (!dataReader.IsClosed)) { dataReader.Close(); } dataReader = null; if (null != _dbConnection) { _dbConnection.Close(); } } catch (Exception e1) { // Log it string msg1 = "Exception " + e1.Message + " while handling exception during direct db part of direct db part of getImagingTasks() for plate " + plateID + " - will fail down to webservice call"; _log.Error(msg1, e1); } // Don't rethrow - fail down to webservice call } // If we got no or not enough tasks if ((null == iImagingTasks) || (iImagingTasks.GetLength(0) < MIN_IMAGING_TASKS)) { // Hit the webservice, which may cause a schedule to be created iImagingTasks = GetImagingTasksFromWebService(robot, plateID); } // Set an appropriate value for InQueue setInQueue(iImagingTasks); // Ensure we never return null if (null == iImagingTasks) { // Fix it iImagingTasks = new IImagingTask[0]; // Log it _log.Warn("Fixed null iImagingTasks at end of WSPlate.getImagingTasks() for plate " + plateID); } // Return the array of IImagingTasks return(iImagingTasks); }
/// <summary> /// Web service version of GetImagingTasks - useful because it will /// cause a full schedule to be written if one doesn't already /// exist. /// /// Warning - this is a lot slower than going straight to platedb! /// </summary> /// <param name="robot">The robot</param> /// <param name="plateID">The barcode of the plate</param> /// <returns></returns> public IImagingTask[] GetImagingTasksFromWebService(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"); } // Log the call if (_log.IsInfoEnabled) { string msg = "Calling WSPlate.getImagingTasks() for plate " + plateID + ", robot " + RobotUtils.iRobotToString(robot); _log.Info(msg); } // Declare the array that will be populated and returned // - default to a zero-length array IImagingTask[] iImagingTasks = new IImagingTask[0]; // Set the request getImagingTasks request = new getImagingTasks(); request.robot = global::OPPF.Utilities.Robot2Utils.createProxy(robot); request.plateID = plateID; // Make the call getImagingTasksResponse response = null; try { WSPlate wsPlate = WSPlateFactory.getWSPlate2(); wsPlate.Timeout = 10000; response = wsPlate.getImagingTasks(request); } catch (Exception e) { // Log it string msg = "WSPlate.getImagingTasks threw " + e.GetType() + ": " + e.Message + " for plateid \"" + plateID + "\" in robot \"" + robot.Name + "\" - returning empty IImagingTask[]"; msg = msg + WSPlateFactory.SoapExceptionToString(e); _log.Error(msg, e); // Don't rethrow - just return empty array return(iImagingTasks); } // If we got a response if (null != response) { // Get the array of ImagingTasks from the response global::OPPF.Proxies2.ImagingTask[] wrapper = response.wrapper; // Convert to IImagingTasks iImagingTasks = new IImagingTask[wrapper.GetLength(0)]; for (int i = 0; i < wrapper.GetLength(0); i++) { global::OPPF.Integrations.ImagerLink.Scheduling.ImagingTask task = new global::OPPF.Integrations.ImagerLink.Scheduling.ImagingTask(); if (wrapper[i].dateImaged.HasValue) { task.SetDateImaged(wrapper[i].dateImaged.Value); } task.SetDateToImage(wrapper[i].dateToImage); task.SetInQueue(wrapper[i].inQueue); task.SetPriority(wrapper[i].priority); task.SetState((Formulatrix.Integrations.ImagerLink.Scheduling.ImagingState)wrapper[i].state); iImagingTasks[i] = task; } } // Return the IImagingTask array return(iImagingTasks); }
/* * Added in Formulatrix.Integrations.ImagerLink.dll v2.0.0.73 (RockImager v2.0.3.18), * which is supposed to be more recent than v2.0.1.136 (RockImager v2.0.1.136). */ /// <summary> /// Gets an <c>ICapturePointList</c> to image for this plateID on the specified <c>imagingID</c>. /// </summary> /// <param name="robot"></param> /// <param name="plateID"></param> /// <param name="imagingID">The imaging ID started for this run.</param> /// <param name="includeOverview"></param> /// <param name="userSelectionCaptureProfileID"></param> /// <returns></returns> /// <remarks> /// Added in Formulatrix.Integrations.ImagerLink.dll v2.0.0.73 (RockImager v2.0.3.18), /// which is supposed to be more recent than v2.0.1.136 (RockImager v2.0.1.136). /// </remarks> public ICapturePointList GetCapturePoints(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, string imagingID, bool includeOverview, int userSelectionCaptureProfileID) { // TODO: Add CaptureProvider.GetCapturePoints implementation //return null; if (_log.IsInfoEnabled) { _log.Info("Called ICaptureProvider.GetCapturePoints(" + Robot.ToString(robot) + ", \"" + plateID + "\", \"" + imagingID + "\", " + includeOverview + ", " + userSelectionCaptureProfileID + ")"); } CapturePointList capturePointList = null; // If 0 then it is a scheduled imaging, need to find the inspection type (light path) if (userSelectionCaptureProfileID == 0) { userSelectionCaptureProfileID = GetLightPathForScheduledImaging(imagingID); } IPlateType plateType = _pip.GetPlateType(robot, _pip.GetPlateInfo(robot, plateID).PlateTypeID); int[] sampleLocations = GetSampleLocations(plateID); // OPPF Vis if (1 == userSelectionCaptureProfileID) { _log.Info("Returning ICapturePointList with CapturePoints for specific drops to be imaged, with a null ICaptureProfile (Should assume visible LightPath)"); capturePointList = new CapturePointList(); CapturePoint[] capturePoints = GetCapturePointsDetails(sampleLocations, plateType, null); capturePointList.SetCapturePoints(capturePoints); } // OPPF UV else if (2 == userSelectionCaptureProfileID) { _log.Info("Returning ICapturePointList with PlateCaptureProfile and CapturePoints set to an ICaptureProfile with one IProperty of \"LightPath\" = \"1\""); // Create the property array containing the UV LightPath property IProperty[] properties = new global::OPPF.Integrations.ImagerLink.Property[1]; properties[0] = new global::OPPF.Integrations.ImagerLink.Property("LightPath", "1"); // Create a new CaptureProfile and apply the UV LightPath property CaptureProfile captureProfile = new CaptureProfile(); captureProfile.SetProfileID("2"); captureProfile.SetProperties(properties); // Create the array of capture profiles to be used for each drop - in this case only one CaptureProfile[] captureProfiles = new CaptureProfile[1]; captureProfiles[0] = captureProfile; // Get specific well and drop numbers to be imaged CapturePoint[] capturePoints = GetCapturePointsDetails(sampleLocations, plateType, captureProfiles); // Create the CapturePointList and set the PlateCaptureProfile and CapturePoints // NB I don't think RockImager actually uses the PlateCaptureProfile capturePointList = new CapturePointList(); capturePointList.SetPlateCaptureProfile(captureProfile); capturePointList.SetCapturePoints(capturePoints); } // OPPF Teach 1 else if (3 == userSelectionCaptureProfileID) { _log.Info("Returning ICapturePointList with PlateCaptureProfile and CapturePoints set to an ICaptureProfile that only images the corners"); // Create the property array containing the UV LightPath property IProperty[] properties = new global::OPPF.Integrations.ImagerLink.Property[1]; properties[0] = new global::OPPF.Integrations.ImagerLink.Property("LightPath", "0"); // Create a new CaptureProfile and apply the UV LightPath property CaptureProfile captureProfile = new CaptureProfile(); captureProfile.SetProfileID("3"); captureProfile.SetProperties(properties); // Create the array of capture profiles to be used for each drop - in this case only one CaptureProfile[] captureProfiles = new CaptureProfile[1]; captureProfiles[0] = captureProfile; // Create a CapturePoint for each drop using RockImager's default drop position and the vis LightPath // TODO: Get number of wells and drops from plate type CapturePoint[] capturePoints = new CapturePoint[4]; capturePoints[0] = new CapturePoint(1, 1, captureProfiles, null, null, "1", RegionType.Drop); // A1 capturePoints[1] = new CapturePoint(12, 1, captureProfiles, null, null, "1", RegionType.Drop); // A12 capturePoints[2] = new CapturePoint(85, 1, captureProfiles, null, null, "1", RegionType.Drop); // H1 capturePoints[3] = new CapturePoint(96, 1, captureProfiles, null, null, "1", RegionType.Drop); // H12 // Create the CapturePointList and set the PlateCaptureProfile and CapturePoints // NB I don't think RockImager actually uses the PlateCaptureProfile capturePointList = new CapturePointList(); capturePointList.SetPlateCaptureProfile(captureProfile); capturePointList.SetCapturePoints(capturePoints); } // OPPF Teach 1-Full - Just to allow special handling in the IImageProcessor else if (4 == userSelectionCaptureProfileID) { _log.Info("Returning ICapturePointList with PlateCaptureProfile and CapturePoints set to an ICaptureProfile that only images the corners"); // Create the property array containing the UV LightPath property IProperty[] properties = new global::OPPF.Integrations.ImagerLink.Property[1]; properties[0] = new global::OPPF.Integrations.ImagerLink.Property("LightPath", "0"); // Create a new CaptureProfile and apply the UV LightPath property CaptureProfile captureProfile = new CaptureProfile(); captureProfile.SetProfileID("4"); captureProfile.SetProperties(properties); // Create the array of capture profiles to be used for each drop - in this case only one CaptureProfile[] captureProfiles = new CaptureProfile[1]; captureProfiles[0] = captureProfile; // Create a CapturePoint for each drop using RockImager's default drop position and the vis LightPath // TODO: Get number of wells and drops from plate type int wells = 96; CapturePoint[] capturePoints = new CapturePoint[wells]; for (int i = 0; i < wells; i++) { // TODO: Loop over drops - currently assumes one drop per well capturePoints[i] = new CapturePoint(i + 1, 1, captureProfiles, null, null, "1", RegionType.Drop); } // Create the CapturePointList and set the PlateCaptureProfile and CapturePoints // NB I don't think RockImager actually uses the PlateCaptureProfile capturePointList = new CapturePointList(); capturePointList.SetPlateCaptureProfile(captureProfile); capturePointList.SetCapturePoints(capturePoints); } return(capturePointList); }
/// <summary> /// Gets the first drop to move the plate to under the microscope. /// </summary> /// <param name="plateID">The plateID uniquely identifying the plate.</param> /// <param name="wellNumber">The first well number of the plate. The first well is <c>1</c>.</param> /// <param name="dropNumber">The first drop number in the first well. The first drop is <c>1</c>.</param> /// <param name="robot">The robot which the plate is under.</param> void ICaptureProvider.GetFirstDrop(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, ref int wellNumber, ref int dropNumber) { // TODO: Add CaptureProvider.GetFirstDrop implementation wellNumber = 1; dropNumber = 1; }
/// <summary> /// Gets an <c>ICapturePointList</c> to image for this plateID on the specified <c>imagingID</c>. /// </summary> /// <param name="robot"></param> /// <param name="plateID"></param> /// <param name="imagingID">The imaging ID started for this run.</param> /// <param name="includeOverview"></param> /// <returns>The list of <c>ICapturePoint</c>s, with an optional <c>ICaptureProfile</c> for this imaging.</returns> ICapturePointList ICaptureProvider.GetCapturePoints(Formulatrix.Integrations.ImagerLink.IRobot robot, string plateID, string imagingID, bool includeOverview) { // TODO: Add CaptureProvider.GetCapturePoints implementation _log.Debug("Called 4-arg ICaptureProvider.GetCapturePoints() - delegating to 5-arg version with userSelectionCaptureProfileID = 0"); return(((ICaptureProvider)this).GetCapturePoints(robot, plateID, imagingID, includeOverview, 0)); }
/// <summary> /// Return <c>true</c> if this provider supplies <c>IImagingTask.Priority</c>. /// Otherwise the imager should manage individual task priority. /// </summary> public bool SupportsPriority(Formulatrix.Integrations.ImagerLink.IRobot robot) { // OPPF PERFORMANCE BODGE - Actually this method should always return true! return(true); }
/// <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); }
/// <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> string IImagingTaskProvider.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"); } // Log the call to the method if (_log.IsDebugEnabled) { string msg = "Called " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Debug(msg); } // Set the request imagingPlate request = new imagingPlate(); request.robot = OPPF.Utilities.RobotUtils.createProxy(robot); request.plateID = plateID; request.scheduled = scheduled; request.dateToImage = dateToImage.ToUniversalTime(); request.dateImaged = dateImaged.ToUniversalTime(); // Make the call WSPlate wsPlate = new WSPlate(); imagingPlateResponse response = null; try { response = wsPlate.imagingPlate(request); } catch (Exception e) { string msg = "WSPlate.imagingPlate threw " + e.GetType() + ": " + e.Message + " - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; if (e is System.Web.Services.Protocols.SoapException) { System.Web.Services.Protocols.SoapException ee = (System.Web.Services.Protocols.SoapException)e; msg = msg + "\n\n" + ee.Detail.InnerXml; } _log.Fatal(msg, e); // Panic throw e; } // If we got no response if (null == response) { string msg = "WSPlate.imagingPlate returned null - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Fatal(msg); // Panic throw new System.NullReferenceException(msg); } // If we got a null imagingID if (null == response.imagingPlateReturn) { string msg = "WSPlate.imagingPlate returned a null imagingID - panic!"; msg = msg + "\nin " + this + ".ImagingPlate(robot=" + RobotUtils.iRobotToString(robot) + ", plateID=\"" + plateID + "\", dateToImage=" + dateToImage.ToUniversalTime().ToString() + " UTC, dateImaged=" + dateImaged.ToUniversalTime().ToString() + " UTC)"; _log.Fatal(msg); // Panic throw new System.NullReferenceException(msg); } // Return the imagingID return(response.imagingPlateReturn); }