From 8857d3962afa957bacd8bcdad4f86408867ebc8d Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Mon, 31 May 2021 18:55:14 +0200 Subject: [PATCH] Script execution --- script/test/MaximumSearch.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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))