
M74050
1/4M IMAGING SPECTROGRAPHS
64
cs.disconnect();
}
void usbDevices_DeviceAttached(object sender, EventArgs e)
{
USBEventArgs usbEvent = e as USBEventArgs;
cs.connect();
connect();
}
void connect()
{
cornerstone = cs.device;
usbDevices = cs.usbDevices;
deviceCount = usbDevices.Count;
}
void toggleButtons(Boolean toggle)
{
btnResponse.Enabled = toggle;
btnSend.Enabled = toggle;
btnQuery.Enabled = toggle;
}
C# (Form file) code:
namespace CornerstoneApp
{
public partial class MainForm : Form
{
public Int32 nActiveUnit = 1; // Used only for multiple devices (default) below
private void btnSend_Click(object sender, EventArgs e)
{
cs.sendCommand(txtComand.Text);
txtInfo.Text = cs.getLastMessage();
}
private void btnResponse_Click(object sender, EventArgs e)
{
txtInfo.Text = cs.getResponse();
}
//====================== Second Controls for second device if needed
// NOT needed for only one device.
private void btnSend2_Click(object sender, EventArgs e)
{
cs.setActiveDevice(cs.usbDevices.Count);
cs.sendCommand(txtComand2.Text);
txtInfo.Text = cs.getLastMessage();