[Avida-cvs] [Avida2-svn] r139 - trunk/source/python/AvidaGui2

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Thu Apr 14 05:47:10 PDT 2005


Author: kaben
Date: 2005-04-14 08:47:10 -0400 (Thu, 14 Apr 2005)
New Revision: 139

Added:
   trunk/source/python/AvidaGui2/pyHardwareTracer.py
Modified:
   trunk/source/python/AvidaGui2/pyHardwareCPUTrace.py
Log:

* Added missing file pyHardwareTracer.py for tracing hardware in test cpu.

* Removed unused test_info argument in function
  pyHardwareCPUTrace.recordGenotypeSummary.



Modified: trunk/source/python/AvidaGui2/pyHardwareCPUTrace.py
===================================================================
--- trunk/source/python/AvidaGui2/pyHardwareCPUTrace.py	2005-04-13 09:32:08 UTC (rev 138)
+++ trunk/source/python/AvidaGui2/pyHardwareCPUTrace.py	2005-04-14 12:47:10 UTC (rev 139)
@@ -41,8 +41,9 @@
     )
     self.m_last_copy_info.append(self.m_last_copied_instruction)
 
-  def recordGenotypeSummary(self, cpu_test_info, genotype):
-    self.m_is_viable = genotype.GetViable()
-    self.m_gestation_time = genotype.GetGestTime()
-    self.m_fitness = genotype.GetFitness()
-    self.m_size = genotype.GetLength()
+  def recordGenotypeSummary(self, analyze_genotype):
+    self.m_is_viable = analyze_genotype.GetViable()
+    self.m_gestation_time = analyze_genotype.GetGestTime()
+    self.m_fitness = analyze_genotype.GetFitness()
+    self.m_size = analyze_genotype.GetLength()
+

Added: trunk/source/python/AvidaGui2/pyHardwareTracer.py
===================================================================
--- trunk/source/python/AvidaGui2/pyHardwareTracer.py	2005-04-13 09:32:08 UTC (rev 138)
+++ trunk/source/python/AvidaGui2/pyHardwareTracer.py	2005-04-14 12:47:10 UTC (rev 139)
@@ -0,0 +1,46 @@
+
+from pyHardwareCPUTrace import pyHardwareCPUTrace
+
+from AvidaCore import cCPUTestInfo, cTestCPU, pyHardwareTracerBase
+
+class pyHardwareTracer(pyHardwareTracerBase):
+
+  def TraceHardware_CPU(self, hardware):
+    self.m_hardware_trace.recordFrame(hardware)
+
+  def TraceHardware_CPUBonus(self, hardware):
+    self.m_hardware_trace.recordFrame(hardware)
+
+  def backupTestCPU(self, environment):
+    backup_environment = cTestCPU.GetEnvironment()
+    original_resource_count = cTestCPU.GetResourceCount()
+    backup_usage = cTestCPU.GetUseResources()
+
+    cTestCPU.SetEnvironment(environment)
+    cTestCPU.SetupResources()
+    cTestCPU.SetUseResources(True)
+
+    return backup_environment, original_resource_count, backup_usage
+
+  def restoreTestCPU(self, backup_environment, original_resource_count, backup_usage):
+    cTestCPU.SetEnvironment(backup_environment)
+    cTestCPU.GetResourceCount().SetTo(original_resource_count)
+    cTestCPU.SetUseResources(True)
+
+  def traceAnalyzeGenotype(self, analyze_genotype, environment, should_use_resources):
+    backup_environment = None
+    original_resource_count = None
+    backup_usage = None
+    if should_use_resources:
+      backup_environment, original_resource_count, backup_usage = self.backupTestCPU(environment)
+
+    test_info = cCPUTestInfo()
+    test_info.TestThreads()
+    self.m_hardware_trace = pyHardwareCPUTrace()
+    test_info.SetTraceExecution(self)
+    cTestCPU.TestGenome(test_info, analyze_genotype.GetGenome())
+
+    analyze_genotype.Recalculate()
+    self.m_hardware_trace.recordGenotypeSummary(analyze_genotype)
+
+    if should_use_resources: self.restoreTestCPU(backup_environment, original_resource_count, backup_usage)




More information about the Avida-cvs mailing list