from slic.core.device import Device, SimpleDevice
from slic.core.adjustable import PVAdjustable
from slic.devices.general.motor import Motor

class i0_chamber(Device):
    def __init__(self, ID, name="Cristallina I0 chamber with slits and foils", process_time=1, **kwargs):
        super().__init__(ID, name=name, **kwargs)
        
        self.foils = Motor(ID+":MCS3")  
        self.slits = i0_slits_unit(ID,name="Cristallina I0 chamber slits")

class i0_slits_unit(Device):
    def __init__(self, ID, **kwargs):
        super().__init__(ID, **kwargs)

        self.x = SimpleDevice(ID + "-X",
            center = PVAdjustable(ID + "-XSLIT:SLIT_POS",units='mm'),
            width  = PVAdjustable(ID + "-XSLIT:SLIT_WIDTH",units='mm')
        )

        self.y = SimpleDevice(ID + "-Y",
            center = PVAdjustable(ID + "-YSLIT:SLIT_POS",units='mm'),
            width  = PVAdjustable(ID + "-YSLIT:SLIT_WIDTH",units='mm')
        )
        
        self.motors = i0_slits_motors(ID,name='Individual I0 chamber slit motors')
        
class i0_slits_motors(Device):
    def __init__(self, ID, **kwargs):
        super().__init__(ID, **kwargs)

        self.x1 = Motor(ID + ":MCS4")
        self.x2 = Motor(ID + ":MCS5")
        self.y1 = Motor(ID + ":MCS2")
        self.y2 = Motor(ID + ":MCS1")
