Beispiel #1
0
            void OnPhidgetAttached(object sender, ManagerAttachEventArgs args)
            {
                if (hashMap == null)
                {
                    hashMap = new Dictionary <int, int>();
                }
                // add device to the list
                VoltageRatioInput input = new VoltageRatioInput();

                input.DeviceSerialNumber = args.Channel.DeviceSerialNumber;
                input.Channel            = args.Channel.Channel;
                input.DeviceLabel        = Phidget.AnyLabel;
                input.HubPort            = Phidget.AnyHubPort;
                input.Error += Input_Error;
                input.VoltageRatioChange += Input_VoltageRatioChange;
                input.Detach             += Input_Detach;
                input.PropertyChange     += Input_PropertyChange;
                input.SensorChange       += Input_SensorChange;

                input.Open(0);
                input.BridgeEnabled = false;

                hashMap.Add(hashMap.Count, input.GetHashCode());
                var info = new InputInfo(input);

                listOfPhidgets.Add(new InputInfo(input));
            }
        void OnPhidgetAttached(object sender, ManagerAttachEventArgs args)
        {
            // add device to the list
            VoltageRatioInput input = new VoltageRatioInput();

            input.DeviceSerialNumber = args.Channel.DeviceSerialNumber;
            input.Channel            = args.Channel.Channel;
            input.DeviceLabel        = Phidget.AnyLabel;
            input.HubPort            = Phidget.AnyHubPort;
            input.Error += Input_Error;
            input.Open(0);
            input.BridgeEnabled = false;



            var info       = new InputInfo(input);
            int targetHash = input.DeviceSerialNumber * 10 + input.Channel;
            int i          = 0;

            for (; hashMap[i] != targetHash; i++)
            {
                if (i >= hashMap.Count)
                {
                    throw new NotImplementedException("wrongHash");
                }
            }
            listOfPhidgets.Add(i, new InputInfo(input));
            listOfPhidgetsReady.Add(i, false);
            System.Diagnostics.Trace.WriteLine("PhidgetReciver OnPhidgetAttached " + input.DeviceSerialNumber + " " + input.Channel);
        }