// Requires a JSON in the body private dynamic connectDAQ() { log.info("Got request for DAQ connect"); try { string body = this.getJsonBody(); StringReader memeReader = new StringReader(body); JsonTextReader memer = new JsonTextReader(memeReader); JsonSerializer serializer = new JsonSerializer(); DAQconfig d = serializer.Deserialize <DAQconfig>(memer); log.info($"With parameters:"); log.info($"samplerate:\t{d.samplerate}"); log.info($"segment length:\t{d.segmentLength}"); bool connect = controller.connectDAQ(d); if (connect) { log.ok("DAQ connected"); return(200); } log.err("Connecting to DAQ failed"); return(500); // what if it's just a generic error? dunno lol use remmina... } catch (Exception e) { // should only catch deserialize error, dunno how xD log.err("malformed request"); Console.WriteLine(e); return(500); } }
public bool connectDAQ(DAQconfig d) { this.updateDeviceList(); bool devicePresent = (devices.Any(p => p[p.Length - 1] == 'A')); if (devicePresent) { try { this.daq.samplerate = d.samplerate; this.daq.segmentLength = d.segmentLength; this.daq.onChannelData = this.cm.OnChannelData; this.DAQconfigured = this.daq.connectDataAcquisitionDevice(0); // YOLO index arg this.DAQconfigured = true; log.info(this.daq.ToString()); } catch (Exception e) { // uhh... throw e; } } return(devicePresent && this.DAQconfigured); }