Driver Programming: Difference between revisions

From SweepMe! Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
{{syntaxhighlight|lang=python|code=
{{syntaxhighlight|lang=python|code=
from EmptyDeviceClass import EmptyDevice  # Loading the EmptyDevice Class
from EmptyDeviceClass import EmptyDevice  # Loading the EmptyDevice Class
    class Device(EmptyDevice):            # Creating a new Device Class by inheriting from EmptyDevice
 
        def __init__(self):              # The python class object need to be initialized
class Device(EmptyDevice):            # Creating a new Device Class by inheriting from EmptyDevice
          EmptyDevice.__init__(self)    # Finally, the initialization of EmptyDevice has to be done
    def __init__(self):              # The python class object need to be initialized
      EmptyDevice.__init__(self)    # Finally, the initialization of EmptyDevice has to be done
}}
}}


This is a minimal working example to create a Device Class.
This is a minimal working example to create a Device Class.

Revision as of 23:48, 30 November 2017

A Device Class is a main.py file in which a python class-Object is inherited from a parent class called EmptyDeviceClass.

from EmptyDeviceClass import EmptyDevice  # Loading the EmptyDevice Class

class Device(EmptyDevice):            # Creating a new Device Class by inheriting from EmptyDevice
    def __init__(self):               # The python class object need to be initialized
       EmptyDevice.__init__(self)     # Finally, the initialization of EmptyDevice has to be done

This is a minimal working example to create a Device Class.