private void channel_values_Click(object sender, EventArgs e) { ECLib.CurrentValues cv = default(ECLib.CurrentValues); ECLib.ErrorCode err = ECLib.BL_GetCurrentValues(conn_id, selected_channel, ref cv); if (err != ECLib.ErrorCode.ERR_NOERROR) { MessageBox.Show("Get channel info failed: " + err.ToString()); } else { MessageBox.Show(struct_dump(cv, typeof(ECLib.CurrentValues))); } }
private void channel_info_Click(object sender, EventArgs e) { ECLib.ChannelInfo ci = default(ECLib.ChannelInfo); ECLib.ErrorCode err = ECLib.BL_GetChannelInfos(conn_id, selected_channel, ref ci); if (err != ECLib.ErrorCode.ERR_NOERROR) { MessageBox.Show("Get channel info failed: " + err.ToString()); } else { MessageBox.Show(struct_dump(ci, typeof(ECLib.ChannelInfo))); } }
private ECLib.ErrorCode loadTechnique() { // This function is special: we have to manually marshal the parameters structure, // because C# doesn't know how to correctly do it through automatic marshalling. // See ECLib.EccParams definition in ECLib.cs . string file = ""; string tech = technique_combo.SelectedItem.ToString(); ECLib.ErrorCode err = ECLib.ErrorCode.ERR_NOERROR; ECLib.EccParams parameters = default(ECLib.EccParams); switch (tech) { case "OCV": err = setOCVParams(ref parameters, ref file); break; case "ChronoPotentiometry": err = setCPParams(ref parameters, ref file); break; case "ChronoAmperometry": err = setCAParams(ref parameters, ref file); break; default: break; } // call LoadTechnique with the parameters that has been allocated through manual marshalling if (selected_channel != 0xff && parameters.len != 0 && file.Length != 0 && err == ECLib.ErrorCode.ERR_NOERROR) { err = ECLib.BL_LoadTechnique(conn_id, selected_channel, file, parameters, true, true, show_params.Checked); } else { MessageBox.Show("Error setting a parameter: " + err.ToString()); } // need to free the allocated memory if (parameters.pparams != null) { Marshal.FreeHGlobal(parameters.pparams); } return(err); }
private void start_btn_Click(object sender, EventArgs e) { ECLib.ErrorCode err = loadTechnique(); if (err != ECLib.ErrorCode.ERR_NOERROR) { MessageBox.Show("Error loading technique: " + err.ToString()); } else { err = ECLib.BL_StartChannel(conn_id, selected_channel); if (err == ECLib.ErrorCode.ERR_NOERROR) { ack_start_btn.Enabled = false; ack_stop_btn.Enabled = true; ack_state_radio.Checked = true; ack_state_radio.Text = "Started"; data_grid.Rows.Clear(); // reset finished indicator msg_done.Reset(); data_done.Reset(); // start threads in_acquisition = true; msg_worker.RunWorkerAsync(new ECLibThreadWork { id = conn_id, channel = selected_channel }); data_worker.RunWorkerAsync(new ECLibThreadWork { id = conn_id, channel = selected_channel }); } else { MessageBox.Show("Couldn't start acquisition"); } } }
private void connect_Click(object sender, EventArgs e) { if (ip_textbox.Text.Length == 0) { return; } ECLib.ErrorCode err = ECLib.BL_Connect(ip_textbox.Text, 3, ref conn_id, ref infos); if (err == ECLib.ErrorCode.ERR_NOERROR) { // update the form connect_btn.Enabled = false; disconnect_btn.Enabled = true; information_btn.Enabled = true; connect_radio.Checked = true; connect_radio.Text = "Connected"; log("Connected, id = " + conn_id + "."); setupChannels(); setupDataGrid(); } else { MessageBox.Show("Couldn't connect to the device at address " + ip_textbox.Text + ": " + err.ToString()); } }