Gohtar
05-23-2007, 12:33 AM
I am having problems with creating the simplist of programs to control the 0/0/4. Here is my code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Phidgets;
using Phidgets.Events;
namespace MyPhidgets
{
public partial class Form1 : Form
{
Manager phidgetManager = null;
public Form1()
{
InitializeComponent();
}
private void getPhidgetList()
{
phidgetManager = new Manager();
phidgetManager.Attach += new AttachEventHandler(phidgetManager_Attach);
phidgetManager.Detach += new DetachEventHandler(phidgetManager_Detach);
phidgetManager.Error += new ErrorEventHandler(phidgetManager_Error);
phidgetManager.open();
int phidgetCount = phidgetManager.Devices.Count;
}
void phidgetManager_Error(object sender, Phidgets.Events.ErrorEventArgs e)
{
MessageBox.Show("Error: " + e.Description);
}
void phidgetManager_Detach(object sender, Phidgets.Events.DetachEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}
void phidgetManager_Attach(object sender, Phidgets.Events.AttachEventArgs e)
{
if (e.Device.Type.ToLower() == "phidgetinterfacekit")
{
//MessageBox.Show(e.Device.Name + " ");
int serial = e.Device.SerialNumber;
}
}
private void button1_Click(object sender, EventArgs e)
{
getPhidgetList();
}
}
}The problem is that if I try to use the e.Device.SerialNumber or the e.Device.Version the phidgetManager_Attach method never fires. I really don't understand why or how that could be happening. It seems to work just fine in the MSDN Christmas Light Sequencer program.
Thanks
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Phidgets;
using Phidgets.Events;
namespace MyPhidgets
{
public partial class Form1 : Form
{
Manager phidgetManager = null;
public Form1()
{
InitializeComponent();
}
private void getPhidgetList()
{
phidgetManager = new Manager();
phidgetManager.Attach += new AttachEventHandler(phidgetManager_Attach);
phidgetManager.Detach += new DetachEventHandler(phidgetManager_Detach);
phidgetManager.Error += new ErrorEventHandler(phidgetManager_Error);
phidgetManager.open();
int phidgetCount = phidgetManager.Devices.Count;
}
void phidgetManager_Error(object sender, Phidgets.Events.ErrorEventArgs e)
{
MessageBox.Show("Error: " + e.Description);
}
void phidgetManager_Detach(object sender, Phidgets.Events.DetachEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}
void phidgetManager_Attach(object sender, Phidgets.Events.AttachEventArgs e)
{
if (e.Device.Type.ToLower() == "phidgetinterfacekit")
{
//MessageBox.Show(e.Device.Name + " ");
int serial = e.Device.SerialNumber;
}
}
private void button1_Click(object sender, EventArgs e)
{
getPhidgetList();
}
}
}The problem is that if I try to use the e.Device.SerialNumber or the e.Device.Version the phidgetManager_Attach method never fires. I really don't understand why or how that could be happening. It seems to work just fine in the MSDN Christmas Light Sequencer program.
Thanks