Ejemplo n.º 1
0
def main():
	startMessage()
	
	#servo = PWM.Servo()
	servo = "STUB"
	
	# Create objects
	projo = Projector()
	z_stepper = ZStepper()
	shutter = Shutter(servo)
	tilt = Tilt(servo)
	safety = Safety()
	safety.addActivePins(z_stepper.getUsedPins())
	safety.addActivePins(shutter.getUsedPins())
	safety.addActivePins(tilt.getUsedPins())
	
	# test projo function
	projo.switchOn()
	projo.switchOff()
	
	# test Z stepper
	z_stepper.setTargetPos(199800, 1000)
	z_stepper.run()
	
	# test shutter function
	shutter.close()
	shutter.open()
	shutter.close()
	
	#test tilt function
	tilt.tiltMe()
	
	# check output pins to desactivate for safety
	print "Safety pins watched :" + repr(safety.getActivePins())

	#listAllScenarioFiles("/home/lsa/Documents/DLP_Printer_soft_Freaky/gear.slice/")
	fenetre = Tk()
	label = Label(fenetre, text="Hello World")
	label.pack()
Ejemplo n.º 2
0
from shutter import Shutter

from time import sleep
if __name__ == "__main__":
    shutter = Shutter('COM7', 4)
    print shutter.is_open()
    shutter.open()
    print shutter.is_open()
    sleep(0.5)
    shutter.close()
    print shutter.is_open()
Ejemplo n.º 3
0
from shutter import Shutter

from time import sleep
if __name__ == "__main__":
    s = Shutter('/dev/ttyACM2', 4)
    s.open()
    print(s.is_open())
    sleep(0.5)
    s.close()
    print(s.is_open())
Ejemplo n.º 4
0
class XRayShutter (PyTango.Device_4Impl):

    #--------- Add you global variables here --------------------------
    #----- PROTECTED REGION ID(XRayShutter.global_variables) ENABLED START -----#
    EPS = 1e-5

    CONFIG_PATH = 'tango_ds.cfg'

    def get_port_from_config(self):
        config = ConfigParser.RawConfigParser()
        config.read(XRayShutter.CONFIG_PATH)
        shutter_port = config.get("shutter", "port")
        relay_number = int(config.get("shutter", "relay"))
        return shutter_port, relay_number

    #----- PROTECTED REGION END -----#  //  XRayShutter.global_variables

    def __init__(self,cl, name):
        PyTango.Device_4Impl.__init__(self,cl,name)
        self.debug_stream("In __init__()")
        XRayShutter.init_device(self)
        #----- PROTECTED REGION ID(XRayShutter.__init__) ENABLED START -----#
        
        #----- PROTECTED REGION END -----#  //  XRayShutter.__init__
        
    def delete_device(self):
        self.debug_stream("In delete_device()")
        #----- PROTECTED REGION ID(XRayShutter.delete_device) ENABLED START -----#
        #----- PROTECTED REGION END -----#  //  XRayShutter.delete_device

    def init_device(self):
        self.debug_stream("In init_device()")
        self.get_device_properties(self.get_device_class())
        #----- PROTECTED REGION ID(XRayShutter.init_device) ENABLED START -----#
        shutter_port, relay_number = self.get_port_from_config()

        self.shutter = Shutter(shutter_port, relay_number)
        if self.shutter.is_open():
            self.set_state(PyTango.DevState.OPEN)
        else:
            self.set_state(PyTango.DevState.CLOSE)

        #----- PROTECTED REGION END -----#  //  XRayShutter.init_device

    def always_executed_hook(self):
        self.debug_stream("In always_excuted_hook()")
        #----- PROTECTED REGION ID(XRayShutter.always_executed_hook) ENABLED START -----#
        
        #----- PROTECTED REGION END -----#  //  XRayShutter.always_executed_hook

    #-----------------------------------------------------------------------------
    #    XRayShutter read/write attribute methods
    #-----------------------------------------------------------------------------
    
    
    
        #----- PROTECTED REGION ID(XRayShutter.initialize_dynamic_attributes) ENABLED START -----#
        
        #----- PROTECTED REGION END -----#  //  XRayShutter.initialize_dynamic_attributes
            
    def read_attr_hardware(self, data):
        self.debug_stream("In read_attr_hardware()")
        #----- PROTECTED REGION ID(XRayShutter.read_attr_hardware) ENABLED START -----#
        
        #----- PROTECTED REGION END -----#  //  XRayShutter.read_attr_hardware


    #-----------------------------------------------------------------------------
    #    XRayShutter command methods
    #-----------------------------------------------------------------------------
    
    def Open(self, argin):
        """ Opens the shutter
        
        :param argin: Automatically closes the shutter after the given time. Stays opened if 0.
        :type: PyTango.DevDouble
        :return: 
        :rtype: PyTango.DevVoid """
        self.debug_stream("In Open()")
        #----- PROTECTED REGION ID(XRayShutter.Open) ENABLED START -----#
        # check time for reasonable values.
        # time in seconds currently, maybe we need ms. threading.Timer accepts floating point seconds.
        # looks like tango doesn't have function overloading. impossible to have zero or one argument for function
        
        time = argin

        self.shutter.open()
        self.set_state(PyTango.DevState.OPEN)

        if abs(time) < XRayShutter.EPS:
            pass
        elif time < 0:
            PyTango.Except.throw_exception("XRayShutter_IllegalArgument",
                                           "Time can't be negative",
                                           "XRayShutter.Open()")
        else:
            threading.Timer(time, self.Close, args=[0]).start()

        #----- PROTECTED REGION END -----#  //  XRayShutter.Open
        
    def Close(self, argin):
        """ Closes the shutter
        
        :param argin: Automatically opens the shutter after the given time. Stays closed if 0.
        :type: PyTango.DevDouble
        :return: 
        :rtype: PyTango.DevVoid """
        self.debug_stream("In Close()")
        #----- PROTECTED REGION ID(XRayShutter.Close) ENABLED START -----#

        time = argin

        self.shutter.close()
        self.set_state(PyTango.DevState.CLOSE)

        if abs(time) < XRayShutter.EPS:
            pass
        elif time < 0:
            PyTango.Except.throw_exception("XRayShutter_IllegalArgument",
                                           "Time can't be negative",
                                           "XRayShutter.Close()")
        else:
            threading.Timer(time, self.Open, args=[0]).start()
Ejemplo n.º 5
0
class XRayShutter(PyTango.Device_4Impl):

    #--------- Add you global variables here --------------------------
    #----- PROTECTED REGION ID(XRayShutter.global_variables) ENABLED START -----#
    EPS = 1e-5

    CONFIG_PATH = 'tango_ds.cfg'

    def get_port_from_config(self):
        config = ConfigParser.RawConfigParser()
        config.read(XRayShutter.CONFIG_PATH)
        shutter_port = config.get("shutter", "port")
        relay_number = int(config.get("shutter", "relay"))
        return shutter_port, relay_number

    #----- PROTECTED REGION END -----#  //  XRayShutter.global_variables

    def __init__(self, cl, name):
        PyTango.Device_4Impl.__init__(self, cl, name)
        self.debug_stream("In __init__()")
        XRayShutter.init_device(self)
        #----- PROTECTED REGION ID(XRayShutter.__init__) ENABLED START -----#

        #----- PROTECTED REGION END -----#  //  XRayShutter.__init__

    def delete_device(self):
        self.debug_stream("In delete_device()")
        #----- PROTECTED REGION ID(XRayShutter.delete_device) ENABLED START -----#
        #----- PROTECTED REGION END -----#  //  XRayShutter.delete_device

    def init_device(self):
        self.debug_stream("In init_device()")
        self.get_device_properties(self.get_device_class())
        #----- PROTECTED REGION ID(XRayShutter.init_device) ENABLED START -----#
        shutter_port, relay_number = self.get_port_from_config()

        self.shutter = Shutter(shutter_port, relay_number)
        if self.shutter.is_open():
            self.set_state(PyTango.DevState.OPEN)
        else:
            self.set_state(PyTango.DevState.CLOSE)

        #----- PROTECTED REGION END -----#  //  XRayShutter.init_device

    def always_executed_hook(self):
        self.debug_stream("In always_excuted_hook()")
        #----- PROTECTED REGION ID(XRayShutter.always_executed_hook) ENABLED START -----#

        #----- PROTECTED REGION END -----#  //  XRayShutter.always_executed_hook

    #-----------------------------------------------------------------------------
    #    XRayShutter read/write attribute methods
    #-----------------------------------------------------------------------------

    #----- PROTECTED REGION ID(XRayShutter.initialize_dynamic_attributes) ENABLED START -----#

    #----- PROTECTED REGION END -----#  //  XRayShutter.initialize_dynamic_attributes

    def read_attr_hardware(self, data):
        self.debug_stream("In read_attr_hardware()")
        #----- PROTECTED REGION ID(XRayShutter.read_attr_hardware) ENABLED START -----#

        #----- PROTECTED REGION END -----#  //  XRayShutter.read_attr_hardware

    #-----------------------------------------------------------------------------
    #    XRayShutter command methods
    #-----------------------------------------------------------------------------

    def Open(self, argin):
        """ Opens the shutter
        
        :param argin: Automatically closes the shutter after the given time. Stays opened if 0.
        :type: PyTango.DevDouble
        :return: 
        :rtype: PyTango.DevVoid """
        self.debug_stream("In Open()")
        #----- PROTECTED REGION ID(XRayShutter.Open) ENABLED START -----#
        # check time for reasonable values.
        # time in seconds currently, maybe we need ms. threading.Timer accepts floating point seconds.
        # looks like tango doesn't have function overloading. impossible to have zero or one argument for function

        time = argin

        self.shutter.open()
        self.set_state(PyTango.DevState.OPEN)

        if abs(time) < XRayShutter.EPS:
            pass
        elif time < 0:
            PyTango.Except.throw_exception("XRayShutter_IllegalArgument",
                                           "Time can't be negative",
                                           "XRayShutter.Open()")
        else:
            threading.Timer(time, self.Close, args=[0]).start()

        #----- PROTECTED REGION END -----#  //  XRayShutter.Open

    def Close(self, argin):
        """ Closes the shutter
        
        :param argin: Automatically opens the shutter after the given time. Stays closed if 0.
        :type: PyTango.DevDouble
        :return: 
        :rtype: PyTango.DevVoid """
        self.debug_stream("In Close()")
        #----- PROTECTED REGION ID(XRayShutter.Close) ENABLED START -----#

        time = argin

        self.shutter.close()
        self.set_state(PyTango.DevState.CLOSE)

        if abs(time) < XRayShutter.EPS:
            pass
        elif time < 0:
            PyTango.Except.throw_exception("XRayShutter_IllegalArgument",
                                           "Time can't be negative",
                                           "XRayShutter.Close()")
        else:
            threading.Timer(time, self.Open, args=[0]).start()