public String executeExperiment(Experiment experiment) { currentExpResult = new CVE_ExperimentResult(); try { XmlSerializer serializer = new XmlSerializer(typeof(CVE_Experiment)); StringReader stringReader = new StringReader(experiment.experimentSpecification); currentExperiment = (CVE_Experiment)serializer.Deserialize(stringReader); Console.WriteLine("Extracted Experimented Specification.\nApplied Load = " + currentExperiment.load); } catch(Exception ex){ Notification.writeError("Failed to deserialize lab project: " + ex.StackTrace); return this.serializeLabResult(currentExpResult); } expEngine = new CVE_experimentengine(); currentExpResult.experimentID = experiment.experimentID; if (currentExperiment.length != 0) { labSelect = 1; Console.WriteLine("Your Experiment is being simulated"); currentExpResult.spoints = this.expEngine.shearforcepoints(currentExperiment.load, currentExperiment.point, currentExperiment.length); currentExpResult.bpoints = this.expEngine.bendingmdpoints(currentExperiment.load, currentExperiment.point, currentExperiment.length); currentExpResult.deflection = this.expEngine.maximumdeflection(currentExperiment.load, currentExperiment.length, currentExperiment.modulus, currentExperiment.inertia); Console.WriteLine("Deflection = " + currentExpResult.deflection); } else { labSelect = 2; //at this point, we call the labVIEW dll to execute the experiment LabVIEWTool lv = new LabVIEWTool(); Console.WriteLine("LabVIEW dll has been successfully called"); Console.WriteLine("\tnow extending actuator"); //apply the load and read deflection /*arg 1 = 1- extend actuator to apply load and also read deflection *arg 1 = 2- retract actuator to stop applying load and prepare for next, then stop afterward *arg 1 = 3 stop! */ currentExpResult.deflection = lv.callDll(1, currentExperiment.load); Console.WriteLine("Deflection = "+currentExpResult.deflection); } return this.serializeLabResult(currentExpResult); }
public Experiment loadNextExperiment() { try { //Load experiment spec from database SqlCommand command = new SqlCommand("EXEC dbo.retrieveNextExperiment", _dbConnection); SqlDataReader dataReader = command.ExecuteReader(); dataReader.Read(); //ERRATA:!!!Look this up some time: why the hell was a decimal being returnd from a Sql "numeric" type? String strVal = dataReader.GetValue(dataReader.GetOrdinal("Experiment_ID")).ToString(); int experimentID = Int32.Parse(strVal); string experimentSpec = dataReader.GetString(dataReader.GetOrdinal("Experiment_specification")); dataReader.Close(); Experiment experiment = new Experiment(experimentID, experimentSpec); return experiment; } catch (Exception ex) { Notification.writeError(ex.StackTrace); } return null; }