/// <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; }
public void iRobotToStringTest() { IRobot robot = null; // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = RobotUtils.iRobotToString(robot); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
/// <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> /// 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; }
/// <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); }
/// <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); }
/// <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); }