public IHttpActionResult SetPowerBisection(double power_watts) { //Be sure to add a trailing slash when calling this. Action <double> variable_set = (double v) => { //Set noise eater modulation voltage SR7265Controller.SetDAC(1, v); Thread.Sleep(2000); }; Func <double> process_read = () => { //Get the actual power reading return(FieldMaxController.SingleMeasurement()); }; double w = WavelengthController.GetLightfieldWavelength(); FieldMaxController.SetWavelengthCorrection((int)Math.Floor(w)); Thread.Sleep(2000); if (BisectionControl(variable_set, process_read, power_watts, 0.0, 2.5, 0.5e-6)) { return(Ok("Power set point found within tolerance")); } else { return(Ok("Failed to find set point")); } }
static public Int32 OpenDriver() { //TODO: place into a lock var h = fm2LibOpenDriver(0); StringBuilder SerialNumber = new StringBuilder(); Int16 i = 16; FieldMaxController.fm2LibGetSerialNumber(h, SerialNumber, ref i); return(h); }
static public void DoJobLock(Action <Int32, string> job) { lock (lockObj) { Int32 h = fm2LibOpenDriver(0); StringBuilder SerialNumber = new StringBuilder(); Int16 i = 16; FieldMaxController.fm2LibGetSerialNumber(h, SerialNumber, ref i); job(h, SerialNumber.ToString()); fm2LibCloseDriver(h); } }