// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java
// public interface PerChannelSource<C, T> {
// 	T forChannel(C channelId);
// }
// 
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java
// public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> {
// 	
// 	private final AnalogIOSourceCalibration<C> calibration;
// 	
// 	public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) {
// 		super(target);
// 		this.calibration = calibration;
// 	}
// 
// 	@Override
// 	public AnalogIO forChannel(C channelId) {
// 		return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId));
// 	}
// 	
// 	protected AnalogIOSourceCalibration<C> calibration() {
// 		return calibration;
// 	}
// }
// 
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java
// public class RawAnalogIO<C> implements AnalogIO {
// 	
// 	protected final AnalogIOController<C> controller;
// 	protected final C channelId;
// 	
// 	public RawAnalogIO(AnalogIOController<C> controller, C channelId) {
// 		this.controller = controller;
// 		this.channelId = channelId;
// 	}
// 
// 	@Override
// 	public MutableDouble value() {
// 		return controller.value(channelId);
// 	}
// }
// 
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java
// public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> {
// 	
// 	protected final Function<NewChannelId, DelegateChannelId> remapping;
// 	
// 	public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) {
// 		super(target);
// 		this.remapping = remapping;
// 	}
// 
// 	@Override
// 	public AnalogIO forChannel(NewChannelId channelId) {
// 		return delegate().forChannel(remapping.apply(channelId));
// 	}
// }


import java.util.function.Function;
import com.iamcontent.device.channel.PerChannelSource;
import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource;
import com.iamcontent.device.io.analog.impl.RawAnalogIO;
import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.device.io.analog;



/**
 * Represents a source of {@link AnalogIO}s.
 * @author Greg Elderfield
 * 
 * @param <C> The type used to identify an analog input/output channel. 
 */
public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> {
	
	/**
	 * Returns a AnalogIOSource that has new channel ids, as defined by the given function.
	 */
	default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) {
		return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping);
	}

	/**
	 * Returns a proxy AnalogIO that is two-way calibrated representation of this instance.
	 */
	default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) {
		return new CalibratedAnalogIOSource<C>(this, calibration);
	}

	public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) {

// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/channel/PerChannelSource.java
// public interface PerChannelSource<C, T> {
// 	T forChannel(C channelId);
// }
// 
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/CalibratedAnalogIOSource.java
// public class CalibratedAnalogIOSource<C> extends Delegator<AnalogIOSource<C>> implements AnalogIOSource<C> {
// 	
// 	private final AnalogIOSourceCalibration<C> calibration;
// 	
// 	public CalibratedAnalogIOSource(AnalogIOSource<C> target, AnalogIOSourceCalibration<C> calibration) {
// 		super(target);
// 		this.calibration = calibration;
// 	}
// 
// 	@Override
// 	public AnalogIO forChannel(C channelId) {
// 		return delegate().forChannel(channelId).calibrated(calibration.forChannel(channelId));
// 	}
// 	
// 	protected AnalogIOSourceCalibration<C> calibration() {
// 		return calibration;
// 	}
// }
// 
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RawAnalogIO.java
// public class RawAnalogIO<C> implements AnalogIO {
// 	
// 	protected final AnalogIOController<C> controller;
// 	protected final C channelId;
// 	
// 	public RawAnalogIO(AnalogIOController<C> controller, C channelId) {
// 		this.controller = controller;
// 		this.channelId = channelId;
// 	}
// 
// 	@Override
// 	public MutableDouble value() {
// 		return controller.value(channelId);
// 	}
// }
// 
// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/RemappedAnalogIOSource.java
// public class RemappedAnalogIOSource<NewChannelId, DelegateChannelId> extends Delegator<AnalogIOSource<DelegateChannelId>> implements AnalogIOSource<NewChannelId> {
// 	
// 	protected final Function<NewChannelId, DelegateChannelId> remapping;
// 	
// 	public RemappedAnalogIOSource(AnalogIOSource<DelegateChannelId> target, Function<NewChannelId, DelegateChannelId> remapping) {
// 		super(target);
// 		this.remapping = remapping;
// 	}
// 
// 	@Override
// 	public AnalogIO forChannel(NewChannelId channelId) {
// 		return delegate().forChannel(remapping.apply(channelId));
// 	}
// }


// Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java
import java.util.function.Function;
import com.iamcontent.device.channel.PerChannelSource;
import com.iamcontent.device.io.analog.impl.CalibratedAnalogIOSource;
import com.iamcontent.device.io.analog.impl.RawAnalogIO;
import com.iamcontent.device.io.analog.impl.RemappedAnalogIOSource;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.device.io.analog;



/**
 * Represents a source of {@link AnalogIO}s.
 * @author Greg Elderfield
 * 
 * @param <C> The type used to identify an analog input/output channel. 
 */
public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> {
	
	/**
	 * Returns a AnalogIOSource that has new channel ids, as defined by the given function.
	 */
	default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) {
		return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping);
	}

	/**
	 * Returns a proxy AnalogIO that is two-way calibrated representation of this instance.
	 */
	default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) {
		return new CalibratedAnalogIOSource<C>(this, calibration);
	}

	public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) {

		return new AnalogIOSource<C>() {
