From 63575392b3c744ff35f68da4d5ec3433cf8cff16 Mon Sep 17 00:00:00 2001
From: EJ Dohmen <ezekiel.dohmen@ligo.org>
Date: Wed, 8 Jun 2022 18:57:20 -0700
Subject: [PATCH] Adding SIMULATION build options so recv IPC will get added to
 the IPC file

---
 src/epics/util/feCodeGen.pl |  6 ++++++
 src/epics/util/lib/IPCx.pm  | 14 +++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/epics/util/feCodeGen.pl b/src/epics/util/feCodeGen.pl
index 4cc84b967..e0a6ffd58 100755
--- a/src/epics/util/feCodeGen.pl
+++ b/src/epics/util/feCodeGen.pl
@@ -362,6 +362,12 @@ for ($ii = 0; $ii < $partCnt; $ii++) {
 #//		- Process all IPC parts in one go. Requires <em>lib/IPCx.pm</em>, with call to procIpc. \n
 require "lib/IPCx.pm";
 ("CDS::IPCx::procIpc") -> ($partCnt);
+if(defined $ENV{'SIMULATION_BUILD'})
+{
+	# When in simulation build receivers are added to the IPC file
+	# But we need to reprocess so we can load their info
+	("CDS::IPCx::procIpc") -> ($partCnt);
+}
 
 
 #//		- Check that all subsystem INPUT parts are connected; else exit w/error. \n
diff --git a/src/epics/util/lib/IPCx.pm b/src/epics/util/lib/IPCx.pm
index 02493952a..7f4d9e16a 100644
--- a/src/epics/util/lib/IPCx.pm
+++ b/src/epics/util/lib/IPCx.pm
@@ -144,7 +144,7 @@ sub frontEndInitCode {
         for ($l = 0; $l < $::ipcxCnt; $l++) {
            if ($::ipcxParts[$l][6] == $i) {
               $found = 1;
- 
+
               if ( ($::ipcxParts[$l][7] =~ /^Ground/) || ($::ipcxParts[$l][7] =~ /\_Ground/) ) {
                  $calcExp .= "ipcInfo[$::ipcxInitDone]\.mode = IRCV;\n";
               }
@@ -570,8 +570,16 @@ $ipcxRcvrCnt = 0;
          $kk = $::ipcxParts[$ii][6];
 
          if ( ($::partInput[$kk][0] =~ /^Ground/) || ($::partInput[$kk][0] =~ /\_Ground/) ) {
-            $ipcxAdd[$ipcxNotFound][1] = 2;
-            $ipcxRcvrCnt++;
+
+             if(defined $ENV{'SIMULATION_BUILD'})
+             {
+                 $ipcxAdd[$ipcxNotFound][1] = 1;
+             }
+             else
+             {
+                $ipcxAdd[$ipcxNotFound][1] = 2;
+                $ipcxRcvrCnt++;
+            }
          }
          else {
             if ($::partOutCnt[$kk] != 0) {
-- 
GitLab