Skip to content
This repository was archived by the owner on Mar 27, 2018. It is now read-only.

Commit 6901dd3

Browse files
authored
Merge branch 'master' into spg_update
2 parents 3fc8df8 + 5264180 commit 6901dd3

File tree

26 files changed

+494
-53
lines changed

26 files changed

+494
-53
lines changed

org.eclipse.scanning.api/src/org/eclipse/scanning/api/IValidator.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,20 @@ default void validate(T model) throws ValidationException, InstantiationExceptio
4747
default void setService(IValidatorService vservice) {
4848

4949
}
50+
51+
/**
52+
* Same as Validation method above but returns any results sent back by validation.
53+
*
54+
* @param model
55+
* @return
56+
* @throws ValidationException
57+
*/
58+
default Object validateWithReturn(T model) throws ValidationException {
59+
try {
60+
validate(model);
61+
} catch (InstantiationException | IllegalAccessException e) {
62+
throw new ValidationException(e);
63+
}
64+
return null; // They should implement a validation which throws an exception
65+
}
5066
}

org.eclipse.scanning.api/src/org/eclipse/scanning/api/device/DeviceResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ private static void processRunnables(DeviceRequest request, IRunnableDeviceServi
178178
tdevice.terminate(action.to());
179179
} else if (action==DeviceAction.VALIDATE) {
180180
device.validate(request.getDeviceModel());
181+
} else if (action==DeviceAction.VALIDATEWITHRETURN) {
182+
request.setDeviceValue(device.validateWithReturn(request.getDeviceModel()));
181183
} else if (action==DeviceAction.CONFIGURE) {
182184
device.configure(request.getDeviceModel());
183185
} else if (action==DeviceAction.RUN) {

org.eclipse.scanning.api/src/org/eclipse/scanning/api/event/scan/DeviceAction.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public enum DeviceAction {
4747
/**
4848
* Disable device, stopping all activity.
4949
*/
50-
DISABLE;
50+
DISABLE,
51+
52+
/**
53+
* Validate, with an expectation that the result will be returned
54+
*/
55+
VALIDATEWITHRETURN;
5156

5257
public static DeviceAction as(TerminationPreference pref) {
5358
switch(pref) {

org.eclipse.scanning.api/src/org/eclipse/scanning/api/malcolm/IMalcolmDevice.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.scanning.api.device.IAttributableDevice;
1818
import org.eclipse.scanning.api.device.IRunnableEventDevice;
1919
import org.eclipse.scanning.api.points.IPointGenerator;
20+
import org.eclipse.scanning.api.scan.ScanningException;
2021

2122

2223
/**
@@ -67,17 +68,12 @@ public interface IMalcolmDevice<T> extends IRunnableEventDevice<T>, IMalcolmEven
6768
*/
6869
public boolean isLocked() throws MalcolmDeviceException ;
6970

70-
/**
71-
* Gets the value of an attribute on the device
72-
*/
73-
public <A> A getAttributeValue(String attribute) throws MalcolmDeviceException;
74-
7571
/**
7672
* Returns the axes that this malcolm device can move.
7773
* @return
78-
* @throws MalcolmDeviceException
74+
* @throws ScanningException
7975
*/
80-
public Set<String> getAxesToMove() throws MalcolmDeviceException;
76+
public Set<String> getAxesToMove() throws ScanningException;
8177

8278
/**
8379
* Set the point generator for the malcolm device.

org.eclipse.scanning.api/src/org/eclipse/scanning/api/malcolm/message/MalcolmMessage.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class MalcolmMessage {
3636
private String message;
3737
private Object arguments;
3838
private Object value;
39+
private Object rawValue;
3940

4041
public Type getType() {
4142
return type;
@@ -69,6 +70,7 @@ public int hashCode() {
6970
result = prime * result + ((param == null) ? 0 : param.hashCode());
7071
result = prime * result + ((type == null) ? 0 : type.hashCode());
7172
result = prime * result + ((value == null) ? 0 : value.hashCode());
73+
result = prime * result + ((rawValue == null) ? 0 : rawValue.hashCode());
7274
return result;
7375
}
7476

@@ -115,6 +117,11 @@ public boolean equals(Object obj) {
115117
return false;
116118
} else if (!value.equals(other.value))
117119
return false;
120+
if (rawValue == null) {
121+
if (other.rawValue != null)
122+
return false;
123+
} else if (!rawValue.equals(other.rawValue))
124+
return false;
118125
return true;
119126
}
120127
public Object getArguments() {
@@ -162,4 +169,10 @@ public String getEndpoint() {
162169
public void setEndpoint(String endPoint) {
163170
this.endpoint = endPoint;
164171
}
172+
public Object getRawValue() {
173+
return rawValue;
174+
}
175+
public void setRawValue(Object rawValue) {
176+
this.rawValue = rawValue;
177+
}
165178
}

org.eclipse.scanning.api/src/org/eclipse/scanning/api/scan/ScanEstimator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ScanEstimator {
5353
/**
5454
* Estimated time of scan
5555
*/
56-
private final long scanTime;
56+
private final long estimatedScanTime;
5757

5858
/**
5959
*
@@ -112,7 +112,7 @@ public ScanEstimator(IPointGenerator<?> gen, Map<String, Object> detectors, long
112112
this.size = getEstimatedSize(gen);
113113
this.rank = gen.iterator().next().getScanRank(); // The rank of the scan is constant
114114
this.timePerPoint = timePerPoint;
115-
this.scanTime = size*timePerPoint;
115+
this.estimatedScanTime = size*timePerPoint;
116116
}
117117

118118
private int getEstimatedSize(IPointGenerator<?> gen) throws GeneratorException {
@@ -140,8 +140,8 @@ public void setTimePerPoint(long timePerPoint) {
140140
this.timePerPoint = timePerPoint;
141141
}
142142

143-
public long getScanTime() {
144-
return scanTime;
143+
public long getEstimatedScanTime() {
144+
return estimatedScanTime;
145145
}
146146

147147
public int getRank() {

org.eclipse.scanning.api/src/org/eclipse/scanning/api/scan/ScanInformation.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class ScanInformation {
3434
private transient ScanEstimator estimator;
3535
private int[] shape;
3636
private ScanMode scanMode;
37+
private long estimatedScanTime;
3738

3839
public ScanInformation() {
3940

@@ -127,6 +128,12 @@ public int[] getShape() {
127128
shape = estimator!=null ? estimator.getShape() : null;
128129
return shape;
129130
}
131+
132+
public long getEstimatedScanTime() {
133+
if (estimatedScanTime > 0) return estimatedScanTime;
134+
estimatedScanTime = estimator != null ? estimator.getEstimatedScanTime() : 0;
135+
return estimatedScanTime;
136+
}
130137

131138
public void setShape(int[] shape) {
132139
this.shape = shape;

org.eclipse.scanning.api/src/org/eclipse/scanning/api/scan/models/ScanModel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.scanning.api.device.IRunnableDevice;
2323
import org.eclipse.scanning.api.event.scan.ScanBean;
2424
import org.eclipse.scanning.api.points.IPosition;
25+
import org.eclipse.scanning.api.scan.ScanInformation;
2526

2627
/**
2728
* A Model describing a scan to be performed.
@@ -80,6 +81,8 @@ public class ScanModel {
8081
*/
8182
private List<?> annotationParticipants;
8283

84+
private ScanInformation scanInformation;
85+
8386
public ScanModel() {
8487
this(null);
8588
}
@@ -240,4 +243,12 @@ public void setAnnotationParticipants(List<?> annotationParticipants) {
240243
this.annotationParticipants = annotationParticipants;
241244
}
242245

246+
public ScanInformation getScanInformation() {
247+
return scanInformation;
248+
}
249+
250+
public void setScanInformation(ScanInformation scanInformation) {
251+
this.scanInformation = scanInformation;
252+
}
253+
243254
}

org.eclipse.scanning.connector.epics/src/org/eclipse/scanning/connector/epics/EpicsV4MessageMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public MalcolmMessage convertCallPVStructureToMalcolmMessage(PVStructure structu
163163
result.setType(Type.RETURN);
164164
result.setEndpoint(message.getEndpoint());
165165
result.setId(message.getId());
166+
result.setRawValue(structure.toString());
166167

167168
if (structure.getStructure().getID().startsWith(ERROR_TYPE)) {
168169
result.setType(Type.ERROR);
@@ -182,6 +183,7 @@ public MalcolmMessage convertSubscribeUpdatePVStructureToMalcolmMessage(PVStruct
182183
result.setType(Type.UPDATE);
183184
result.setEndpoint(message.getEndpoint());
184185
result.setId(message.getId());
186+
result.setRawValue(structure.toString());
185187

186188
Object returnedObject = getEndpointObjectFromPVStructure(structure, message.getEndpoint());
187189

@@ -196,6 +198,7 @@ public MalcolmMessage convertGetPVStructureToMalcolmMessage(PVStructure structur
196198
result.setType(Type.RETURN);
197199
result.setEndpoint(message.getEndpoint());
198200
result.setId(message.getId());
201+
result.setRawValue(structure.toString());
199202

200203
if (structure.getStructure().getID().startsWith(ERROR_TYPE)) {
201204
result.setType(Type.ERROR);

org.eclipse.scanning.device.ui/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.107.0",
1616
org.eclipse.dawnsci.analysis.dataset;bundle-version="1.0.0",
1717
org.eclipse.richbeans.widgets.file;bundle-version="1.0.0",
1818
org.eclipse.scanning.api;bundle-version="1.0.0",
19-
org.eclipse.richbeans.annot;bundle-version="1.0.0"
19+
org.eclipse.richbeans.annot;bundle-version="1.0.0",
20+
org.eclipse.scanning.event.ui;bundle-version="1.0.0"
2021
Import-Package: org.osgi.framework;version="1.8.0",
2122
org.osgi.service.event;version="1.3.1",
2223
org.slf4j;version="1.7.2"

0 commit comments

Comments
 (0)