From 5a7d61f74016e75fb772de3f1842925158af9182 Mon Sep 17 00:00:00 2001
From: "ezekiel.dohmen" <ezekiel.dohmen@ligo.org>
Date: Thu, 22 Feb 2024 16:13:58 -0800
Subject: [PATCH] Adding define for system name, and using it for duotone
 struct member access

---
 src/epics/util/feCodeGen.pl |  6 ++++--
 src/fe/controllerIop.c      | 12 ++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/epics/util/feCodeGen.pl b/src/epics/util/feCodeGen.pl
index 8e7e3a82b..eb03a52ea 100755
--- a/src/epics/util/feCodeGen.pl
+++ b/src/epics/util/feCodeGen.pl
@@ -378,6 +378,8 @@ if($timemasterdepwarning == 1) {
 
 $systemName = substr($systemName, 2, 3);
 $plantName = $systemName; # Default plant name is the model name
+print OUTH "\#define SYSDEF    $systemName\n\n";
+
 
 #//	- Perform some specific part checks/processing.
 #//		- Check parts which require GROUND input in fact have ground connections. \n
@@ -1252,8 +1254,8 @@ $inCnt = 0;
 
 my $subs = substr($skeleton,5);
 
-print OUTH "#define MAX_FIR \t $firCnt\n";
-print OUTH "#define MAX_FIR_POLY \t $firCnt\n\n";
+print OUTH "#define MAX_FIR    $firCnt\n";
+print OUTH "#define MAX_FIR_POLY    $firCnt\n\n";
 print EPICS "\nEPICS CDS_EPICS dspSpace coeffSpace epicsSpace\n\n";
 print EPICS "\n\n";
 
diff --git a/src/fe/controllerIop.c b/src/fe/controllerIop.c
index 8fee869af..e3a5a2c6d 100644
--- a/src/fe/controllerIop.c
+++ b/src/fe/controllerIop.c
@@ -630,12 +630,12 @@ void fe_start_controller( void )
     double max_dt_diag_val = MAX_DT_DIAG_VAL + duotone_offset_usec;
 
     // set accepted duotone range in EPICS
-    pLocalEpics->iop.dtTimeFloat_high = max_dt_diag_val;
-    pLocalEpics->iop.dtTimeFloat_low = min_dt_diag_val;
+    pLocalEpics->SYSDEF.dtTimeFloat_high = max_dt_diag_val;
+    pLocalEpics->SYSDEF.dtTimeFloat_low = min_dt_diag_val;
 
     // add a bit more leeway and 4 extra cycles to dac limits
-    pLocalEpics->iop.dacDtTimeFloat_high = max_dt_diag_val + 2+(int)(4*(1e6/IOP_IO_RATE) + 0.5);
-    pLocalEpics->iop.dacDtTimeFloat_low = min_dt_diag_val - 2+(int)(4*(1e6/IOP_IO_RATE) + 0.5);
+    pLocalEpics->SYSDEF.dacDtTimeFloat_high = max_dt_diag_val + 2+(int)(4*(1e6/IOP_IO_RATE) + 0.5);
+    pLocalEpics->SYSDEF.dacDtTimeFloat_low = min_dt_diag_val - 2+(int)(4*(1e6/IOP_IO_RATE) + 0.5);
 
 
     /// calculate the best index to use for duotone values to get closest to the
@@ -1094,7 +1094,7 @@ void fe_start_controller( void )
                 duotoneTime =
                     duotime( dt_data_count, dt_adc_data_offset, dt_diag.meanAdc, dt_diag.adc );
 
-                pLocalEpics->iop.dtTimeFloat = (double)duotoneTime;
+                pLocalEpics->SYSDEF.dtTimeFloat = (double)duotoneTime;
                 pLocalEpics->epicsOutput.dtTime = (int)duotoneTime;
 
                 if ( ( ( duotoneTime < min_dt_diag_val ) ||
@@ -1114,7 +1114,7 @@ void fe_start_controller( void )
 
 
                 pLocalEpics->epicsOutput.dacDtTime = (int)duotoneTimeDac;
-                pLocalEpics->iop.dacDtTimeFloat = duotoneTimeDac;
+                pLocalEpics->SYSDEF.dacDtTimeFloat = duotoneTimeDac;
             }
 
 
-- 
GitLab