import logging
log = logging.getLogger(__name__)

import numpy
import time

from spacq.interface.resources import Resource
from spacq.interface.units import Quantity
from spacq.tool.box import Synchronized

from ..abstract_device import AbstractDevice, AbstractSubdevice
from ..tools import quantity_unwrapped, BinaryEncoder

"""
Custom voltage source

Control the output voltages on all the ports.
"""


class Port(AbstractSubdevice):
	"""
	An output port on the voltage source.
	"""

	# Since there is no way to determine whether calibration has completed,
	# wait this long and hope for the best.
	calibration_delay = 2 # s

	@staticmethod
	def format_for_dac(msg):
		"""
		Perform some formatting to make the device happy: