Re: Cannot use channel 0 anymore
Posted: Tue Apr 12, 2022 4:31 pm
Oh wait, I do have something with the hub. I think I have this so I can catch when the user phycially attaches and detaches the hub. Is this not correct?
Code: Select all
private void Manager_Attach(object sender, Phidget22.Events.ManagerAttachEventArgs e)
{
Manager man = (Manager)sender;
try
{
if (e.Channel.ChannelClass == ChannelClass.Hub)
{
if ((null == VintHub) || (VintHub != (Hub)e.Channel))
{
VintHub = (Hub)e.Channel;
VintHub.Attach += Hub_Attach;
VintHub.Detach += Hub_Detach;
VintHub.Open();
Debug.WriteLine("Hub opened");
}
}
else if(e.Channel.ChannelClass == ChannelClass.VoltageRatioInput)
{
if (e.Channel.HubPort == 0)
{
Handler?.Invoke(PhidgetEvent.attach, 0);
}
else if (e.Channel.HubPort == 1)
{
Handler?.Invoke(PhidgetEvent.attach, 1);
}
else if (e.Channel.HubPort == 2)
{
Handler?.Invoke(PhidgetEvent.attach, 2);
}
else if (e.Channel.HubPort == 3)
{
Handler?.Invoke(PhidgetEvent.attach, 3);
}
}
}
catch(PhidgetException ex) { Debug.WriteLine("Open Hub exception: " + ex.ToString()); }
}