diff --git a/script/test/MaximumSearch.py b/script/test/MaximumSearch.py index 426a1dbc..9d2ce273 100644 --- a/script/test/MaximumSearch.py +++ b/script/test/MaximumSearch.py @@ -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))