assertTrue(
"file or directory does not exists: " + file.getAbsolutePath(),
file.exists());
Device device = new Device("mppsscu");
Connection conn = new Connection();
device.addConnection(conn);
ApplicationEntity ae = new ApplicationEntity("MPPSSCU");
device.addApplicationEntity(ae);
ae.addConnection(conn);
final MppsSCU main = new MppsSCU(ae);
main.setRspHandlerFactory(new MppsSCU.RSPHandlerFactory() {
@Override
public DimseRSPHandler createDimseRSPHandlerForNCreate(final MppsSCU.MppsWithIUID mppsWithUID) {
return new DimseRSPHandler(0) {
@Override
public void onDimseRSP(Association as, Attributes cmd,
Attributes data) {
switch(cmd.getInt(Tag.Status, -1)) {
case Status.Success:
case Status.AttributeListError:
case Status.AttributeValueOutOfRange:
mppsWithUID.iuid = cmd.getString(
Tag.AffectedSOPInstanceUID, mppsWithUID.iuid);
main.addCreatedMpps(mppsWithUID);
}
super.onDimseRSP(as, cmd, data);
MppsTest.this.onNCreateRSP(cmd);
}
};
}
@Override
public DimseRSPHandler createDimseRSPHandlerForNSet() {
return new DimseRSPHandler(0) {
@Override
public void onDimseRSP(Association as, Attributes cmd, Attributes data) {
super.onDimseRSP(as, cmd, data);
MppsTest.this.onNSetRSP(cmd);
}
};
}
});
// configure
main.getAAssociateRQ().setCalledAET(aeTitle);
main.getRemoteConnection().setHostname(host);
main.getRemoteConnection().setPort(port);
main.setTransferSyntaxes(new String[]{UID.ImplicitVRLittleEndian, UID.ExplicitVRLittleEndian, UID.ExplicitVRBigEndianRetired});
main.setAttributes(new 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();