/// <summary> /// Sets the interface to <see cref="IOModes">IOModes.Intput</see> /// and reads a value. /// </summary> /// <returns>A Boolean value read from the interface.</returns> public bool Read() { this.IOMode = IOModes.Input; return this.port.Read(); }
/// <summary> /// Sets the interface to <see cref="IOModes">IOModes.Output</see> /// and writes the specified value. /// </summary> /// <param name="state">The value to write.</param> public void Write(bool state) { this.IOMode = IOModes.Output; this.port.Write(state); }
/// <summary> /// Sets the interface to <see cref="IOModes">IOModes.Intput</see> /// and reads a value. /// </summary> /// <returns>A Boolean value read from the interface.</returns> public bool Read() { this.IOMode = IOModes.Input; return(this.port.Read()); }
private void OnEncoderAttach(object sender, Phidget22.Events.AttachEventArgs e) { Phidget phidget = sender as Phidget; Version = phidget.DeviceVersion.ToString(); Channel = phidget.Channel.ToString(); if (phidget.IsHubPortDevice) { DeviceName = phidget.Hub.DeviceSKU + " - " + phidget.Hub.DeviceName; } else { DeviceName = phidget.DeviceSKU + " - " + phidget.DeviceName; } SerialNumber = phidget.DeviceSerialNumber.ToString(); if (phidget.DeviceClass == DeviceClass.VINT) { SerialNumberName = "Hub Serial Number:"; HubPortVisible = Visibility.Visible; HubPort = phidget.HubPort.ToString(); } else { SerialNumberName = "Serial Number:"; HubPortVisible = Visibility.Visible; } try { String StockKeepingUnit; if (phidget.IsHubPortDevice) { StockKeepingUnit = phidget.Hub.DeviceSKU.Split(new char[] { '/' })[0]; } else { StockKeepingUnit = phidget.DeviceSKU.Split(new char[] { '/' })[0]; } if (phidget.DeviceSKU.Contains("1018")) { StockKeepingUnit = "1018"; } Assembly _assembly = Assembly.GetExecutingAssembly(); String imageName = _assembly.GetManifestResourceNames().Where(img => img.EndsWith(StockKeepingUnit + ".png")).FirstOrDefault(); if (imageName != null) { ImageSource = BitmapFrame.Create(_assembly.GetManifestResourceStream(imageName)); ImageVisible = Visibility.Visible; } if (phidget.IsRemote) { RemoteVisible = Visibility.Visible; } else { RemoteVisible = Visibility.Collapsed; } } catch { } //Control par = this.Parent; //while (!(par is Form)) // par = par.Parent; //((Form)par).Text = phidget.ChannelName; Phidget22.Encoder attachedDevice = (Phidget22.Encoder)sender; if (_encoder.DeviceClass == DeviceClass.VINT) { try { DataIntervalUnitText = "ms"; DataIntervalMinText = attachedDevice.MinDataInterval.ToString(); DataIntervalMinimum = attachedDevice.MinDataInterval; DataIntervalMaxText = attachedDevice.MaxDataInterval.ToString(); DataIntervalMaximum = attachedDevice.MaxDataInterval; DataIntervalValue = attachedDevice.DataInterval; if (attachedDevice.MaxDataInterval == attachedDevice.MinDataInterval) { DataIntervalEnable = false; } ChangeTriggerUnitText = "ticks"; ChangeTriggerMinText = attachedDevice.MinPositionChangeTrigger.ToString(); ChangeTriggerMinimum = attachedDevice.MinPositionChangeTrigger; ChangeTriggerMaximum = attachedDevice.MaxPositionChangeTrigger; ChangeTriggerMaxText = attachedDevice.MaxPositionChangeTrigger.ToString(); ChangeTriggerValue = attachedDevice.PositionChangeTrigger; //ChangeTriggerMinText = attachedDevice.PositionChangeTrigger.ToString("F0"); } catch (PhidgetException ex) { MessageBox.Show("Error setting data interval or change trigger: ", ex.Message); } } else { DataIntervalEnable = false; ChangeTriggerEnable = false; IoModeEnable = false; } _dataInterval = attachedDevice.MinDataInterval; PositionChangeText = "N/A"; TimeChangeText = "N/A"; PositionText = "N/A"; IndexPositionText = "N/A"; switch (((Phidget)sender).DeviceID) { case DeviceID.PN_1047: DeviceEnable = true; IsEncoderChecked = true; IoModeEnable = true; break; case DeviceID.PN_HIN1101: DeviceEnable = true; IsEncoderChecked = true; IoModeEnable = true; break; case DeviceID.PN_ENC1000: foreach (EncoderIOMode ioMode in Enum.GetValues(typeof(EncoderIOMode))) { IOModes.Add(ioMode); } SelectedIOMode = IOModes.FirstOrDefault(); break; case DeviceID.PN_DCC1000: foreach (EncoderIOMode ioMode in Enum.GetValues(typeof(EncoderIOMode))) { IOModes.Add(ioMode); } SelectedIOMode = IOModes.FirstOrDefault(); break; } GroupBoxSettingsEnable = true; DataEnable = true; }
/// <summary> /// Sets the interface to <see cref="IOModes">IOModes.Output</see> /// and writes the specified value. /// </summary> /// <param name="state">The value to write.</param> public void Write(bool state) { this.IOMode = IOModes.Output; this.port.Write(state); }