Download Remote Microscope for Polymer Crystallization

Transcript
# <newDeviceName>.py
from RemoteMicroscope.hardware.Controller import Controller
from RemoteMicroscope.hardware.InstrumentException import InstrumentException
class <newDeviceName>(Controller):
-name- ='<newDeviceName>'
settings = {}
def _init_(self, config, options):
Controller.__init_(self, config, options)
if self.options.verbose:
print "Initializing <newDeviceName> controller..."
# Set initial settings
self.set_<setting1 >(<initialVal>)
def set_<settingl>(self, value):
# Checks to see if the value given is of the correct type
if (type(value) !=type(<typeSetting1 >)):
raise TypeError ("Parameter to set_<settingi> is not of the correct type.")
if self.options.verbose:
print "Setting <settingi> to value: ",value
# Add code that sets hardware setting
self.settings['<settingl>'] = value
def get_<settingl >(self):
return self.settings['<settingl >']
def close(self):
if self.options.verbose:
print "<newDeviceName> controller is closing"
Figure 15 - New Controller Module Template
The first step for implementing a new controller class is to replace the name
<newDeviceName> on the Python file above with the given device filename. Then for
each hardware setting that can be changed, the Python file should contain a set and get
method. An example of how these methods are defined and what most be in them are
51