Driver Programming: Difference between revisions

From SweepMe! Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
A [[Device Class]] is a '''main.py''' file in which a python class-Object is inherited from a parent class called EmptyDeviceClass.
A [[Device Class]] is a '''main.py''' file in which a python class-Object is inherited from a parent class called EmptyDeviceClass.
EmptyDeviceClass has to be loaded at the beginning like any other python module by using the line:


{{syntaxhighlight|lang=python|code=
{{syntaxhighlight|lang=python|code=
from EmptyDeviceClass import EmptyDevice
from EmptyDeviceClass import EmptyDevice # Loading the EmptyDevice Class
 
     class Device(EmptyDevice):           # Creating a new Device Class by inheriting from EmptyDevice
     class Device(EmptyDevice):
         def __init__(self):               # The python class object need to be initialized
 
           EmptyDevice.__init__(self)     # Finally, the initialization of EmptyDevice has to be done
         def __init__(self):
       
           EmptyDevice.__init__(self)
}}
}}


This EmptyDevice object has all basic function included which do
This is a minimal working example to create a Device Class.

Revision as of 08:37, 9 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.