private static DACChannelConfiguration GetDACChannelConfiguration(a.ChannelAddress channel, DeviceConfig deviceConfig) { var type = typeof(DACChannelConfigurations); DACChannelConfiguration toReturn = null; try { if ( deviceConfig?.DACChannelConfig != null ) { var propInfo = type.GetProperty($"DAC{(int) channel - 8}"); toReturn = propInfo != null ? propInfo.GetMethod.Invoke(deviceConfig.DACChannelConfig, null) as DACChannelConfiguration : null; } } catch (Exception e) { _log.Error(e.Message, e); } return(toReturn); }
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); }