private AnalogSignal[] CreateOutputSignals(a.IDenseDacEvalBoard device, int deviceIndex)
        {
            var analogSignalsToReturn = new List <AnalogSignal>();

            for (var i = 0; i < 40; i++)
            {
                var thisSignal = new AnalogSignal
                {
                    Category           = "Outputs",
                    CollectionName     = "DAC Outputs",
                    FriendlyName       = $"DAC #{i}",
                    Id                 = $"AnalogDevices_AD536x/537x__DAC_OUTPUT[{deviceIndex}][{i}]",
                    Index              = i,
                    PublisherObject    = this,
                    Source             = device,
                    SourceFriendlyName = FriendlyName,
                    SourceAddress      = device?.SymbolicName,
                    SubSource          = (a.ChannelAddress)i + 8
                };
                thisSignal.SubSourceFriendlyName = ((a.ChannelAddress)thisSignal.SubSource).ToString();
                thisSignal.SubSourceAddress      = null;
                thisSignal.State          = 0;  //O Volts
                thisSignal.SignalChanged += DAC_OutputSignalChanged;
                thisSignal.Precision      = -1; //arbitrary decimal precision (limited to 14-16 bits output precision)
                thisSignal.IsVoltage      = true;
                thisSignal.MinValue       = -10;
                thisSignal.MaxValue       = 10;
                analogSignalsToReturn.Add(thisSignal);
            }
            return(analogSignalsToReturn.ToArray());
        }
        private static void ConfigureDevice(a.IDenseDacEvalBoard device, DeviceConfig deviceConfig)
        {
            if (device == null)
            {
                return;
            }
            device.DeviceState.UseRegisterCache = true;
            device.DacPrecision = deviceConfig?.DACPrecision != null &&
                                  deviceConfig.DACPrecision.Value != a.DacPrecision.Unknown
                ? deviceConfig.DACPrecision.Value
                : a.DacPrecision.SixteenBit;

            device.Reset();
            if (device.IsOverTemperature)
            {
                device.IsThermalShutdownEnabled = false;
                //reset temperature shutdown after previous over-temperature event
            }
            device.IsThermalShutdownEnabled = true; //enable over-temperature auto shutdown

            device.SetDacChannelDataSourceAllChannels(a.DacChannelDataSource.DataValueA);

            device.OffsetDAC0 = deviceConfig?.Calibration?.OffsetDAC0 ?? (ushort)0x2000;

            device.OffsetDAC1 = deviceConfig?.Calibration?.OffsetDAC1 ?? (ushort)0x2000;

            for (var channel = a.ChannelAddress.Dac0; channel <= a.ChannelAddress.Dac39; channel++)
            {
                ConfigureDeviceChannel(device, deviceConfig, channel);
            }
            device.UpdateAllDacOutputs();
        }
        public static AnalogDevicesHardwareSupportModule Create(a.IDenseDacEvalBoard device, int deviceIndex = 0,
                                                                DeviceConfig deviceConfig = null)
        {
            var module = new AnalogDevicesHardwareSupportModule();

            module.Initialize(device, deviceIndex, deviceConfig);
            return(module);
        }
 private void Initialize(a.IDenseDacEvalBoard device, int deviceIndex, DeviceConfig deviceConfig)
 {
     _device      = device;
     _deviceIndex = deviceIndex;
     ConfigureDevice(_device, deviceConfig);
     _analogOutputSignals = CreateOutputSignals(_device, _deviceIndex);
     InitializeOutputs();
 }
 private void Dispose(bool disposing)
 {
     if (!_isDisposed)
     {
         if (disposing)
         {
             Common.Util.DisposeObject(_device); //disconnect
             _device = null;
         }
     }
     _isDisposed = true;
 }
        private static void ConfigureDeviceChannel(a.IDenseDacEvalBoard device, DeviceConfig deviceConfig,
                                                   a.ChannelAddress channel)
        {
            var dacChannelConfiguration = GetDACChannelConfiguration(channel, deviceConfig);

            device.SetDacChannelDataValueA(channel,
                                           dacChannelConfiguration?.InitialState?.DataValueA ?? (ushort)0x8000);

            device.SetDacChannelDataValueB(channel,
                                           dacChannelConfiguration?.InitialState?.DataValueB ?? (ushort)0x8000);

            device.SetDacChannelOffset(channel,
                                       dacChannelConfiguration?.Calibration?.Offset ?? (ushort)0x8000);

            device.SetDacChannelGain(channel,
                                     dacChannelConfiguration?.Calibration?.Gain ?? (ushort)0xFFFF);
        }