public LabExperimentStatus GetExperimentStatus(int experimentID) { const string STRLOG_MethodName = "GetExperimentStatus"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); LabExperimentStatus labExperimentStatus = null; // Get the identity of the caller string sbName = GetCallerName(authHeader); // Check caller access is authorised if (sbName != null) { // Pass on to experiment manager labExperimentStatus = Global.experimentManager.GetExperimentStatus(experimentID, sbName); } else { labExperimentStatus = new LabExperimentStatus( new ExperimentStatus((int)StatusCodes.Unknown)); } Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return(labExperimentStatus); }
//-------------------------------------------------------------------------------------------------// private LabExperimentStatus ConvertType(Proxy.LabExperimentStatus proxyLabExperimentStatus) { LabExperimentStatus labExperimentStatus = null; if (proxyLabExperimentStatus != null) { labExperimentStatus = new LabExperimentStatus(); labExperimentStatus.MinTimeToLive = proxyLabExperimentStatus.minTimetoLive; labExperimentStatus.ExperimentStatus = this.ConvertType(proxyLabExperimentStatus.statusReport); } return labExperimentStatus; }
//-------------------------------------------------------------------------------------------------// public LabExperimentStatus GetLabExperimentStatus(int experimentId, string sbName) { const string STRLOG_MethodName = "GetLabExperimentStatus"; string logMessage = STRLOG_experimentId + experimentId.ToString() + Logfile.STRLOG_Spacer + STRLOG_sbName + Logfile.STRLOG_Quote + sbName + Logfile.STRLOG_Quote + Logfile.STRLOG_Spacer + STRLOG_unitId + unitId.ToString(); Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage); LabExperimentStatus labExperimentStatus = new LabExperimentStatus( new ExperimentStatus((int)StatusCodes.Unknown)); int remainingRuntime = 0; lock (this.statusLock) { // // Check if the specified experiment is running on this engine // if ((this.labExperimentInfo != null) && (labExperimentInfo.experimentInfo.experimentId == experimentId) && (labExperimentInfo.experimentInfo.sbName.Equals(sbName, StringComparison.OrdinalIgnoreCase) == true)) { // // Update the status code // StatusCodes status = this.labExperimentInfo.experimentInfo.status; labExperimentStatus.statusReport.statusCode = (int)status; if (status == StatusCodes.Running) { // // The specified experiment is currently running, fill in information // labExperimentStatus.statusReport.estRuntime = (double)this.labExperimentInfo.experimentInfo.estExecutionTime; // Calculate time already passed for the experiment remainingRuntime = (int)((TimeSpan)(DateTime.Now - this.labExperimentInfo.startDateTime)).TotalSeconds; // Now calculate the time remaining for the experiment remainingRuntime = this.labExperimentInfo.experimentInfo.estExecutionTime - remainingRuntime; // // Estimated runtime may have been underestimated. Don't say remaining runtime is zero while // the experiment is still running. // if (remainingRuntime < 1) { remainingRuntime = 1; } labExperimentStatus.statusReport.estRemainingRuntime = (double)remainingRuntime; logMessage = STRLOG_estRuntime + labExperimentStatus.statusReport.estRuntime.ToString() + Logfile.STRLOG_Spacer + STRLOG_remainingRuntime + labExperimentStatus.statusReport.estRemainingRuntime.ToString(); } } else { // Unkown experiment labExperimentStatus = new LabExperimentStatus(new ExperimentStatus((int)StatusCodes.Unknown)); } } logMessage = STRLOG_statusCode + ((StatusCodes)labExperimentStatus.statusReport.statusCode).ToString() + Logfile.STRLOG_Spacer + logMessage; Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage); return (labExperimentStatus); }
//-------------------------------------------------------------------------------------------------// protected void btnCheck_Click(object sender, EventArgs e) { // // Get the experiment ID // int experimentID = ParseExperimentNumber(txbExperimentID.Text); if (experimentID <= 0) { return; } LabExperimentStatus labExperimentStatus = null; StatusCodes statusCode; // // Get the experiment status // try { // // Get the status of the selected experiment // labExperimentStatus = Master.ServiceBroker.GetExperimentStatus(experimentID); statusCode = (StatusCodes)labExperimentStatus.statusReport.statusCode; } catch (Exception) { statusCode = StatusCodes.Unknown; } // // Display the status code // ShowMessageNormal(STR_ExperimentNumber + experimentID.ToString() + STR_Spacer + statusCode.ToString()); if (statusCode == StatusCodes.Running) { // // Experiment is currently running, display time remaining // int seconds = (int)Decimal.Round((decimal)labExperimentStatus.statusReport.estRemainingRuntime); ShowMessageNormal(this.FormatTimeRemaining(seconds)); } else if (statusCode == StatusCodes.Waiting) { // // Experiment is waiting to run, get queue position (zero-based) // int position = labExperimentStatus.statusReport.wait.effectiveQueueLength; int seconds = (int)Decimal.Round((decimal)labExperimentStatus.statusReport.wait.estWait); seconds = (seconds < 0) ? 0 : seconds; ShowMessageNormal(this.FormatQueuePosition(position, seconds)); } else if (statusCode == StatusCodes.Completed || statusCode == StatusCodes.Failed || statusCode == StatusCodes.Cancelled) { // // Experiment status no longer needs to be checked // if (Master.MultiSubmit == true) { if (Session[Consts.STRSSN_SubmittedIDs] != null) { // // Get the list of submitted experiment IDs // int[] submittedIDs = (int[])Session[Consts.STRSSN_SubmittedIDs]; // // Find submitted experiment number // for (int i = 0; i < submittedIDs.Length; i++) { if (submittedIDs[i] == experimentID) { // // Add experiment number to the completed list in the session // if (Session[Consts.STRSSN_CompletedIDs] != null) { // Get the list of completed experiment IDs int[] completedIDs = (int[])Session[Consts.STRSSN_CompletedIDs]; // Create a bigger array and copy completed experiment IDs int[] newCompletedIDs = new int[completedIDs.Length + 1]; completedIDs.CopyTo(newCompletedIDs, 0); // Add the experiment ID to the bigger array newCompletedIDs[completedIDs.Length] = experimentID; // Save experiment ID in the session Session[Consts.STRSSN_CompletedIDs] = newCompletedIDs; } else { // Create an array and add the experiment ID int[] completedIDs = new int[1]; completedIDs[0] = experimentID; // Save experiment ID in the session Session[Consts.STRSSN_CompletedIDs] = completedIDs; } // // Remove experiment number from the submitted list in the session // if (submittedIDs.Length == 1) { Session[Consts.STRSSN_SubmittedIDs] = null; // // Clear dropdown list and hide // ddlExperimentIDs.Items.Clear(); ddlExperimentIDs.Visible = false; } else { // // Create a smaller array and copy submitted experiment IDs // int[] newSubmittedIDs = new int[submittedIDs.Length - 1]; // // Copy experiment IDs up to the one being removed // for (int j = 0; j < i; j++) { newSubmittedIDs[j] = submittedIDs[j]; } // // Copy experiment IDs after the one being removed // for (int j = i + 1; j < submittedIDs.Length; j++) { newSubmittedIDs[j - 1] = submittedIDs[j]; } // Save experiment IDs in the session Session[Consts.STRSSN_SubmittedIDs] = newSubmittedIDs; // Remove experiment ID from dropdown list ddlExperimentIDs.Items.Remove(experimentID.ToString()); } break; } } } } else { if (Session[Consts.STRSSN_SubmittedID] != null) { // // Check experiment ID against submitted experiment ID // int submittedId = (int)Session[Consts.STRSSN_SubmittedID]; if (experimentID == submittedId) { Session[Consts.STRSSN_CompletedID] = submittedId; Session[Consts.STRSSN_SubmittedID] = null; } } } } // Clear the LabServer status lblLabServerStatusMsg.Text = null; }
public void Notify(int experimentID) { const string STRLOG_MethodName = "Notify"; string logMessage = STRLOG_ExperimentId + experimentID.ToString(); Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage); bool success = false; try { // // Check LabServer's header information is valid // if (sbHeader == null) { throw new ArgumentNullException("sbHeader"); } if (sbHeader.couponPassKey == null) { throw new ArgumentNullException("couponPassKey"); } // // Determine LabServer // string strLabServerId = sbHeader.couponID.ToString("X"); string strCsvLabServer = Utilities.GetAppSetting(strLabServerId); string[] strSplit = strCsvLabServer.Split(new char[] { ',' }); if (strSplit.Length < 3) { throw new ArgumentException("CSV LabServer string has insufficient parameters"); } // // Check for valid passkey // if (sbHeader.couponPassKey.Equals(strSplit[0].Trim(), StringComparison.OrdinalIgnoreCase) == false) { throw new ArgumentException("couponPassKey is invalid"); } // // Create LabServer interface // string labserverUrl = strSplit[1].Trim(); LabServerWebService labServer = new LabServerWebService(); labServer.Url = labserverUrl; // // Create and fill in authorisation information // string sbGuid = Utilities.GetAppSetting(Consts.STRCFG_ServiceBrokerGuid); string sbToLsPasskey = strSplit[2].Trim(); AuthHeader authHeader = new AuthHeader(); authHeader.identifier = sbGuid; authHeader.passKey = sbToLsPasskey; labServer.AuthHeaderValue = authHeader; // // Retrieve result from LabServer // LabExperimentStatus labExperimentStatus = labServer.GetExperimentStatus(experimentID); if ((labExperimentStatus != null) && (labExperimentStatus.statusReport != null) && (labExperimentStatus.statusReport.statusCode >= (int)StatusCodes.Completed) && (labExperimentStatus.statusReport.statusCode != (int)StatusCodes.Unknown)) { ResultReport resultReport = labServer.RetrieveResult(experimentID); } success = true; } catch (Exception ex) { Logfile.WriteError(ex.Message); } logMessage = STRLOG_Success + success.ToString(); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage); }
public LabExperimentStatus GetExperimentStatus(int experimentID) { const string STRLOG_MethodName = "GetExperimentStatus"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); LabExperimentStatus labExperimentStatus = null; // Get the identity of the caller string sbName = GetCallerName(authHeader); // Check caller access is authorised if (sbName != null) { // Pass on to experiment manager labExperimentStatus = Global.experimentManager.GetExperimentStatus(experimentID, sbName); } else { labExperimentStatus = new LabExperimentStatus( new ExperimentStatus((int)StatusCodes.Unknown)); } Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return labExperimentStatus; }
//-------------------------------------------------------------------------------------------------// public LabExperimentStatus GetExperimentStatus(int experimentId, string sbName) { const string STRLOG_MethodName = "GetExperimentStatus"; LabExperimentStatus labExperimentStatus = null; lock (this.managerLock) { string logMessage = STRLOG_experimentId + experimentId.ToString() + Logfile.STRLOG_Spacer + STRLOG_sbName + Logfile.STRLOG_Quote + sbName + Logfile.STRLOG_Quote; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName, logMessage); labExperimentStatus = new LabExperimentStatus(); logMessage = string.Empty; // // Get the status of the experiment from the queue table // StatusCodes status = this.experimentQueue.GetExperimentStatus(experimentId, sbName); if (status == StatusCodes.Unknown) { // // The experiment never existed // } else if (status == StatusCodes.Waiting) { // // Experiment is waiting on the queue // QueuedExperimentInfo queuedExperimentInfo = this.experimentQueue.GetQueuedExperimentInfo(experimentId, sbName); if (queuedExperimentInfo != null && queuedExperimentInfo.position > 0) { // Set the experiment status labExperimentStatus.statusReport.statusCode = (int)queuedExperimentInfo.status; // Get the queue position and wait time labExperimentStatus.statusReport.wait = new WaitEstimate(queuedExperimentInfo.position, queuedExperimentInfo.waitTime); // Add in time for any currently running experiment ???? labExperimentStatus.statusReport.wait.estWait += GetMinRemainingRuntime(); // Get the time it takes to run the experiment labExperimentStatus.statusReport.estRuntime = queuedExperimentInfo.estExecutionTime; labExperimentStatus.statusReport.estRemainingRuntime = queuedExperimentInfo.estExecutionTime; logMessage = Logfile.STRLOG_Spacer + STRLOG_QueuePosition + labExperimentStatus.statusReport.wait.effectiveQueueLength.ToString() + Logfile.STRLOG_Spacer + STRLOG_QueueWaitTime + labExperimentStatus.statusReport.wait.estWait.ToString() + Logfile.STRLOG_Spacer + STRLOG_estRuntime + labExperimentStatus.statusReport.estRuntime.ToString() + Logfile.STRLOG_Spacer + STRLOG_remainingRuntime + labExperimentStatus.statusReport.estRemainingRuntime.ToString(); } } else if (status == StatusCodes.Running) { // // Experiment is currently running // labExperimentStatus = this.GetLabExperimentStatus(experimentId, sbName); } else { // // Experiment has completed, cancelled or failed // ResultReport resultReport = this.experimentResults.Load(experimentId, sbName); // Set the experiment status labExperimentStatus.statusReport.statusCode = resultReport.statusCode; } logMessage = STRLOG_statusCode + ((StatusCodes)labExperimentStatus.statusReport.statusCode).ToString() + Logfile.STRLOG_Spacer + logMessage; Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage); } return labExperimentStatus; }