private void buttonRunScript_Click(object sender, EventArgs e) { if (!portMSSIM.IsOpen || !portPSP.IsOpen) { printLine("Devices not connected, cannot start script, press autoconnect to automatically discover connected devices"); return; } if (String.IsNullOrEmpty(textBoxFileName.Text)) { printLine("Error : No script file selected"); return; } myScriptReader = new ScriptReader(textBoxFileName.Text); try { int numberOfPoints = myScriptReader.ReadMeasurementsFromFile(); printLine("Read :" + numberOfPoints + " points"); } catch (Exception ex) { printLine("Failed to read measurement points from file"); printLine("Exception" + ex.Message); return; } try { SetNumericButtons(false); printLine("Starting script."); myScriptReader.Listener = new ScriptReader.MeasurementListener(UpdateGaugesFromMeasurement); myScriptReader.CompleteListener = new ScriptReader.ScriptCompleteListener(ScriptComplete); myScriptReader.PlayScript(); } catch (Exception ex) { printLine("Could not load script " + ex.Message); } }