from awlsim.common.cython_support cimport *

cdef class AbstractIO(object):
	cdef public object pixtend
	cdef public _Bool isV2
	cdef public uint32_t index
	cdef public uint32_t byteOffset
	cdef public uint32_t bitOffset
	cdef public uint32_t bitSize
	cdef public uint32_t byteSize
	cdef public _Bool directOnly
	cdef public object setter
	cdef public object getter
	cdef public object directionSetter

	cpdef setup(self, secondaryOffset)
	cdef set(self, bytearray dataBytes)
	cdef setWithByteOffset(self, bytearray dataBytes, uint32_t byteOffset)
	cdef get(self, bytearray dataBytes)
	cdef getWithByteOffset(self, bytearray dataBytes, uint32_t byteOffset)

cdef class AbstractBitIO(AbstractIO):
	cdef public uint32_t bitMask
	cdef public uint32_t invBitMask

	cdef setWithByteOffset(self, bytearray dataBytes, uint32_t byteOffset)
	cdef getWithByteOffset(self, bytearray dataBytes, uint32_t byteOffset)
	cpdef setup(self, secondaryOffset)

cdef class AbstractWordIO(AbstractIO):
	cdef setWithByteOffset(self, bytearray dataBytes, uint32_t byteOffset)
	cdef getWithByteOffset(self, bytearray dataBytes, uint32_t byteOffset)

cdef class Relay(AbstractBitIO):
	pass

cdef class DigitalOut(AbstractBitIO):
	pass

cdef class DigitalIn(AbstractBitIO):
	pass

cdef class GPIO(AbstractBitIO):
	cdef public object mode
	cdef public object pullUp

	cpdef setup(self, secondaryOffset)

cdef class EnvSensorBase(AbstractWordIO):
	cdef public uint32_t sensorType
	cdef public GPIO gpio

	cpdef setup(self, secondaryOffset)

cdef class TempIn(EnvSensorBase):
	cdef uint16_t __convert(self, double temp)

cdef class HumIn(EnvSensorBase):
	cdef uint16_t __convert(self, double hum)

cdef class AnalogIn(AbstractWordIO):
	cdef public object jumper10V
	cdef public object numberOfSamples

	cdef uint16_t __convertV(self, double V)
	cdef uint16_t __convertMA(self, double mA)
	cpdef setup(self, secondaryOffset)

cdef class AnalogOut(AbstractWordIO):
	cdef uint16_t __convert(self, uint16_t s7Value)

cdef class PWM0Period(AbstractWordIO):
	pass

cdef class PWM0(AbstractWordIO):
	cdef public _Bool enabled
	cdef public _Bool servoMode

	cpdef setup(self, secondaryOffset)

cdef class PWM1Period(AbstractWordIO):
	pass

cdef class PWM1(AbstractWordIO):
	cdef public _Bool enabled
	cdef public _Bool servoMode

	cpdef setup(self, secondaryOffset)
