assertTrue(
"file or directory does not exists: " + file.getAbsolutePath(),
file.exists());
Device device = new Device("storescu");
Connection conn = new Connection();
device.addConnection(conn);
ApplicationEntity ae = new ApplicationEntity("STORESCU");
device.addApplicationEntity(ae);
ae.addConnection(conn);
StoreSCU main = new StoreSCU(ae);
main.setRspHandlerFactory(new StoreSCU.RSPHandlerFactory() {
@Override
public DimseRSPHandler createDimseRSPHandler(final File f) {
return new DimseRSPHandler(0) {
@Override
public void onDimseRSP(Association as, Attributes cmd,
Attributes data) {
super.onDimseRSP(as, cmd, data);
StoreTest.this.onCStoreRSP(cmd, f);
}
};
}
});
// configure
main.getAAssociateRQ().setCalledAET(aeTitle);
main.getRemoteConnection().setHostname(host);
main.getRemoteConnection().setPort(port);
// specify attributes added to the sent object(s). attr can be
// specified by keyword or tag value (in hex), e.g. PatientName
// or 00100010. Attributes in nested Datasets can be specified
// by including the keyword/tag value of the sequence attribute,
// e.g. 00400275/00400009 for Scheduled Procedure Step ID in
// the Request Attributes Sequence.
String[] attributes = new String[0];
main.setAttributes(new Attributes());
CLIUtils.addAttributes(main.getAttributes(), attributes);
// scan
t1 = System.currentTimeMillis();
main.scanFiles(Arrays.asList(file.getAbsolutePath()), false); // do not
// printout
t2 = System.currentTimeMillis();
// create executor
ExecutorService executorService = Executors.newSingleThreadExecutor();
ScheduledExecutorService scheduledExecutorService = Executors
.newSingleThreadScheduledExecutor();
device.setExecutor(executorService);
device.setScheduledExecutor(scheduledExecutorService);
// open and send
try {
main.open();