public NeuropixelsV1Flex(ONIDeviceAddress device) : base(device, DeviceID.NeuropixelsV1, 0x50) { var sn = ReadBytes((uint)EEPROM.OFFSET_ID, 8); ProbeSN = (sn == null) ? null : (ulong?)BitConverter.ToUInt64(sn, 0); Version = ReadByte((uint)EEPROM.OFFSET_VERSION).ToString() + "." + ReadByte((uint)EEPROM.OFFSET_REVISION).ToString(); PartNo = ReadASCIIString((uint)EEPROM.OFFSET_FLEXPN, 20); ProbePartNo = ReadASCIIString((uint)EEPROM.OFFSET_PROBEPN, 20); }
public I2CConfiguration(ONIDeviceAddress address, DeviceID id, uint i2cAddress) { Valid = ONIXDeviceDescriptor.IsValid(id, address); context = ONIContextManager.ReserveContext(address.HardwareSlot); deviceAddress = address.Address; I2CAddress = i2cAddress; #if DEBUG Console.WriteLine("I2C context reserved by " + this.GetType()); #endif }
public static bool IsValid(DeviceID id, ONIDeviceAddress address) { if (string.IsNullOrEmpty(address.HardwareSlot.Driver) || !address.Address.HasValue) { return(false); } using (var c = ONIContextManager.ReserveContext(address.HardwareSlot)) { if (!(c.Context.DeviceTable[(uint)address.Address].ID == (uint)id)) { return(false); } } return(true); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { object result = null; var stringValue = value as string; if (!string.IsNullOrEmpty(stringValue)) { var matches = ReverseStringFormat("{0}/{1}/{2}", stringValue); result = new ONIDeviceAddress { HardwareSlot = new ONIHardwareSlot { Driver = matches[0], Index = Convert.ToInt32(matches[1]) }, Address = Convert.ToUInt32(matches[2]) }; } return(result ?? base.ConvertFrom(context, culture, value)); }
public ONIXDeviceDescriptor(DeviceID id, ONIDeviceAddress address) { if (string.IsNullOrEmpty(address.HardwareSlot.Driver)) { throw new ArgumentException("Invalid hardware driver."); } if (!address.Address.HasValue) { throw new ArgumentException("Invalid device address."); } using (var c = ONIContextManager.ReserveContext(address.HardwareSlot)) { if (!(c.Context.DeviceTable[(uint)address.Address].ID == (uint)id)) { throw new ArgumentException("Address " + address.ToString() + " does not contain a device with ID " + id); } } ID = id; Address = address; }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (context != null) { var workflowBuilder = (WorkflowBuilder)context.GetService(typeof(WorkflowBuilder)); if (workflowBuilder != null) { var hw_slots = (from builder in workflowBuilder.Workflow.Descendants() let ctx_config = ExpressionBuilder.GetWorkflowElement(builder) as ONIContext where ctx_config != null && !string.IsNullOrEmpty(ctx_config.ContextConfiguration.Slot.Driver) select ctx_config.ContextConfiguration.Slot) .Concat(ONIContextManager.LoadConfiguration()) .Distinct() .ToList(); // This device var deviceattribute = context.PropertyDescriptor.ComponentType.GetCustomAttributes(typeof(ONIXDeviceIDAttribute), true).FirstOrDefault() as ONIXDeviceIDAttribute; DeviceID deviceID = deviceattribute == null ? DeviceID.Null : deviceattribute.deviceID; // To fill after inspecting hardware var deviceAddresses = new List <ONIDeviceAddress>(); foreach (var hw in hw_slots) { try { using (var c = ONIContextManager.ReserveContext(hw)) { // Find valid device indices var dev_matches = c.Context.DeviceTable //.Where(dev => dev.Value.ID == (uint)device.ID) .Where(dev => { return(deviceID == DeviceID.Null ? dev.Value.ID != (uint)DeviceID.Null : dev.Value.ID == (uint)deviceID); }) .Select(x => { var d = new ONIDeviceAddress { HardwareSlot = hw, Address = x.Key }; return(d); }).ToList(); deviceAddresses = deviceAddresses.Concat(dev_matches).ToList(); } } catch (InvalidProgramException) // Bad context initialization { return(base.GetStandardValues(context)); } catch (oni.ONIException) // Something happened during hardware init { return(base.GetStandardValues(context)); } } return(deviceAddresses.Count == 0 ? base.GetStandardValues(context) : new StandardValuesCollection(deviceAddresses)); } } return(base.GetStandardValues(context)); }
public NeuropixelsV1Probe(ONIDeviceAddress device) : base(device, DeviceID.NeuropixelsV1, 0x70) { }