Skip to content

Commit

Permalink
Merge pull request #493 from jluhrs/feature/SEQNG-552
Browse files Browse the repository at this point in the history
SEQNG-552 Set EPICS IO timeout.
  • Loading branch information
jluhrs authored Mar 14, 2018
2 parents c44ee1a + 3c5cb74 commit b591586
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/seqexec-server-gn/src/main/resources/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ seqexec-engine {
odbQueuePollingInterval = "3 seconds"
tops = "tcs=tcs:, ao=ao:, gm=gm:, gc=gc:, gws=ws:, m2=m2:, oiwfs=oiwfs:, ag=ag:, f2=f2:"
epics_ca_addr_list = "10.2.2.255 10.2.10.21 10.2.126.101"
ioTimeout = "5 seconds"
smartGCalHost = "gsodb.gemini.edu"
# Location of the csv files
smartGCalDir = "/home/software/.seqexec/smartgcal"
Expand Down
1 change: 1 addition & 0 deletions app/seqexec-server-gs/src/main/resources/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ seqexec-engine {
odbQueuePollingInterval = "3 seconds"
tops = "tcs=tcs:, ao=ao:, gm=gm:, gc=gc:, gws=ws:, m2=m2:, oiwfs=oiwfs:, ag=ag:, f2=f2:"
epics_ca_addr_list = "172.17.2.255 172.17.3.255 172.17.102.130 172.17.105.20 172.16.102.130 172.17.106.111 172.17.105.37 172.17.107.50 172.17.55.101 172.17.101.101 172.17.65.255 172.17.102.139 172.17.102.138"
ioTimeout = "5 seconds"
smartGCalHost = "gsodb.gemini.edu"
# Location of the csv files
smartGCalDir = "/home/software/.seqexec/smartgcal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package edu.gemini.epics.acm;

import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.Lock;
Expand Down Expand Up @@ -43,23 +44,24 @@ public final class CaService {
private final Map<String, CaApplySenderImpl> applySenders;
private final Map<String, CaObserveSenderImpl> observeSenders;
private final Map<String, CaCommandSenderImpl> commandSenders;
static private String addrList;
static private String addrList = "";
static private Duration ioTimeout = Duration.ofSeconds(1);
static private CaService theInstance;
static private Lock instanceLock = new ReentrantLock();

private CaService(String addrList) {
private CaService(String addrList, Duration timeout) {
statusAcceptors = new HashMap<>();
applySenders = new HashMap<>();
observeSenders = new HashMap<>();
commandSenders = new HashMap<>();
epicsService = new EpicsService(addrList);
epicsService = new EpicsService(addrList, Double.valueOf(timeout.getSeconds()));

epicsService.startService();
}

private CaService() {

this(System.getenv(EPICS_CA_ADDR_LIST).replaceAll("\\\\ ", " "));
this(System.getenv(EPICS_CA_ADDR_LIST).replaceAll("\\\\ ", " "), Duration.ofSeconds(1));

}

Expand All @@ -73,6 +75,16 @@ public static void setAddressList(String addrList) {
CaService.addrList = addrList;
}

/**
* Sets the timeout to wait for EPICS IO requests.
*
* @param timeout
* time to wait for EPICS requests.
*/
public static void setIOTimeout(Duration timeout) {
CaService.ioTimeout = timeout;
}

/**
* Retrieves the CaService single instance.
*
Expand All @@ -86,7 +98,7 @@ public static CaService getInstance() {
if (addrList == null) {
theInstance = new CaService();
} else {
theInstance = new CaService(addrList);
theInstance = new CaService(addrList, ioTimeout);
}
}
instanceLock.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ object SeqexecEngine {
val odbQueuePollingInterval = Duration(cfg.require[String]("seqexec-engine.odbQueuePollingInterval"))
val tops = decodeTops(cfg.require[String]("seqexec-engine.tops"))
val caAddrList = cfg.lookup[String]("seqexec-engine.epics_ca_addr_list")
val ioTimeout = Duration(cfg.require[String]("seqexec-engine.ioTimeout"))
val smartGCalHost = cfg.require[String]("seqexec-engine.smartGCalHost")
val smartGCalDir = cfg.require[String]("seqexec-engine.smartGCalDir")
val smartGcalEnable = cfg.lookup[Boolean]("seqexec-engine.smartGCalEnable").getOrElse(true)
Expand All @@ -530,7 +531,7 @@ object SeqexecEngine {
// the configuration file or from the environment
val caInit = caAddrList.map(a => Task.delay(CaService.setAddressList(a))).getOrElse {
Task.delay(Option(System.getenv("EPICS_CA_ADDR_LIST"))).flatMap {
case Some(_) => taskUnit // Do nothing, just check that it exists
case Some(_) => Task.delay(CaService.setIOTimeout(java.time.Duration.ofMillis(ioTimeout.toMillis)))
case _ => Task.fail(new RuntimeException("Cannot initialize EPICS subsystem"))
}
}
Expand All @@ -546,7 +547,7 @@ object SeqexecEngine {
val smartGcal = smartGcalEnable.fold(initSmartGCal(smartGCalHost, smartGCalDir), taskUnit)

smartGcal *>
caInit *>
caInit *>
tcsInit *>
gwsInit *>
gcalInit *>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ seqexec-engine {
odbQueuePollingInterval = "3 seconds"
tops = "tcs=tcs:, ao=ao:, gm=gm:, gc=gc:, gw=ws:, m2=m2:, oiwfs=oiwfs:, ag=ag:, f2=f2:"
epics_ca_addr_list = "127.0.0.1"
ioTimeout = "5 seconds"
# We normally always use GS for smartGCalDir
smartGCalHost = "gsodbtest.gemini.edu"
# Tmp file for development
Expand Down
4 changes: 2 additions & 2 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ object Settings {

val apacheXMLRPC = "3.1.3"
val opencsv = "2.1"
val epicsService = "0.17"
val gmpCommandRecords = "0.6.5"
val epicsService = "0.18"
val gmpCommandRecords = "0.6.6"
val guava = "16.0.1"
}

Expand Down

0 comments on commit b591586

Please sign in to comment.