public FormServeurPicoscope() { InitializeComponent(); svh = new ServiceHost(new ServiceImplementation(this)); svh.AddServiceEndpoint(typeof(WCF.IServicePicoscope), new NetTcpBinding(), "net.tcp://localhost:8002"); svh.Open(); _pico = new PS3000ACSConsole.PS3000ACSConsole(); _range = new uint[4]; _trackbarValues = new String[] { " Off ", "100 mV", "200 mV", "500 mV", " 1 V", " 2 V", " 5 V", " 10 V", " 20 V" }; _range[0] = trackBarToRange(trackBarChA.Value); _range[1] = trackBarToRange(trackBarChB.Value); _range[2] = trackBarToRange(trackBarChC.Value); _range[3] = trackBarToRange(trackBarChD.Value); labelChA.Text = _trackbarValues[trackBarChA.Value]; labelChB.Text = _trackbarValues[trackBarChB.Value]; labelChC.Text = _trackbarValues[trackBarChC.Value]; labelChD.Text = _trackbarValues[trackBarChD.Value]; label_totalTime.Text = "Total capture time :"; if (_pico.getPicoStatus() == true) { setPico(); } else { buttonImediateBlock.Enabled = false; buttonTriggeredBlock.Enabled = false; listBox1.Items.Add("Unable to find the device"); } }
/* Set PicoScope */ private bool setPico() { if (_pico.getPicoStatus() == true) { /* Set sample count */ int sampleCount = 0; try { sampleCount = 2 * Convert.ToInt32(textBoxSampleCount.Text); } catch (Exception e) { listBox1.Items.Add("Error : invalid number of samples"); } if (sampleCount <= 0) { listBox1.Items.Add("Error : invalid number of samples"); return(false); } /* Set timebase */ string period = textBoxSetPeriod.Text; uint timebase; // T(ns) = (timebase-2) * 8 for timebase > 2 // T(ns) = 4 for timebase = 2 try { timebase = toTimeBase(Convert.ToUInt32(period)); } catch (Exception f) { listBox1.Items.Add("Error : invalid period."); return(false); } // Display the information of the new timebase to the user period = toPeriod(timebase).ToString(); textBoxSetPeriod.Text = period; /* calcul total time*/ int totalTime = sampleCount / 2 * (int)toPeriod(timebase); label_totalTime.Text = "Total capture time : " + totalTime.ToString() + " ns"; /* Set filename */ string filename = textBoxFileName.Text; _pico.setPico(timebase, sampleCount, filename, _range); buttonSetPico.Enabled = false; return(true); } else { // Trying to find the picoscope _pico = new PS3000ACSConsole.PS3000ACSConsole(); if (_pico.getPicoStatus() == true) { return(setPico()); } else { buttonImediateBlock.Enabled = false; buttonTriggeredBlock.Enabled = false; listBox1.Items.Add("Unable to find the device"); return(false); } } }