Script execution

This commit is contained in:
gac-x03da
2021-05-31 18:55:14 +02:00
parent e2a32add49
commit 8857d3962a

View File

@@ -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))