Script execution
This commit is contained in:
@@ -1,3 +1,26 @@
|
||||
####################################################################################################
|
||||
# Simulated Devices
|
||||
####################################################################################################
|
||||
|
||||
class AnalogOutput(RegisterBase):
|
||||
def doRead(self):
|
||||
return self.val if hasattr(self, 'val') else 0.0
|
||||
|
||||
def doWrite(self, val):
|
||||
self.val = val
|
||||
|
||||
class AnalogInput(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
time.sleep(0.001)
|
||||
self.val = to_array(self.calc(), 'd')
|
||||
return self.val
|
||||
|
||||
|
||||
#Defintion
|
||||
add_device(AnalogOutput("ao1"), True)
|
||||
add_device(AnalogOutput("ao2"), True)
|
||||
|
||||
|
||||
class FitnessFunction(ReadonlyRegisterBase):
|
||||
def doRead(self):
|
||||
return 1000.0 - (math.pow(ao1.take()-18, 2) + math.pow(ao2.take()-6, 2))
|
||||
|
||||
Reference in New Issue
Block a user