Skip to content

Commit

Permalink
Fix some formatting and logging ( more cleanup might be req )
Browse files Browse the repository at this point in the history
  • Loading branch information
shroffk committed Jun 24, 2024
1 parent 82f93bf commit aeaf7a7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void update()
close();
}
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.WARNING, "failed to update pv: " + getName() , e);
close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ public class ReplayPVFactory implements PVFactory
final public static String TYPE = "replay";

@Override
public String getType() {
public String getType()
{
return TYPE;
}

@Override
public PV createPV(String name, String base_name) throws Exception {
public PV createPV(String name, String base_name) throws Exception
{
// Determine simulation function name and (optional) parameters
final String pvName;
int sep = base_name.indexOf('(');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.time.Instant;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Level;

/**
* A Connection to a PV in the archiver
Expand All @@ -22,7 +23,8 @@ public class ArchivePV extends PV {
* @param completeName
* @param name
*/
public ArchivePV(String completeName, String name) {
public ArchivePV(String completeName, String name)
{
this(completeName, name, Instant.now());
}

Expand All @@ -32,7 +34,8 @@ public ArchivePV(String completeName, String name) {
* @param name
* @param instant
*/
public ArchivePV(String completeName, String name, Instant instant) {
public ArchivePV(String completeName, String name, Instant instant)
{
super(completeName);
try {
ValueIterator i = service.getReader().getRawValues(name, instant, instant);
Expand All @@ -41,21 +44,24 @@ public ArchivePV(String completeName, String name, Instant instant) {
notifyListenersOfValue(i.next());
}
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.WARNING, "failed to create pv: " + getName() , e);
}
}

public void disconnected() {
public void disconnected()
{
notifyListenersOfDisconnect();
}

@Override
protected void close() {
protected void close()
{
super.close();
}

@Override
public boolean isReadonly() {
public boolean isReadonly()
{
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class ArchivePVFactory implements PVFactory
final public static String TYPE = "archive";

@Override
public String getType() {
public String getType()
{
return TYPE;
}

Expand All @@ -49,14 +50,18 @@ public PV createPV(String name, String base_name) throws Exception {
parameters = base_name.substring(sep+1, end);
}

if(parameters.isEmpty()) {
if(parameters.isEmpty())
{
return new ArchivePV(name, pvName);
} else {
}
else
{
Instant time;
List<String> parameterList = Arrays.stream(parameters.split(","))
.map(String::strip)
.collect(Collectors.toList());
if(parameterList.size() == 1) {
if(parameterList.size() == 1)
{
String timeParameter = parameterList.get(0);
try {
switch (parameterList.get(0).length()) {
Expand All @@ -70,7 +75,9 @@ public PV createPV(String name, String base_name) throws Exception {
} catch (DateTimeException e) {
throw new Exception("Time value defined in a unknown format, '" + timeParameter + "'");
}
} else {
}
else
{
throw new Exception("Incorrect number of parameters defined '" + name + "'");
}
}
Expand Down

0 comments on commit aeaf7a7

Please sign in to comment.