Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gunterze committed Jul 1, 2018
0 parents commit 0344217
Show file tree
Hide file tree
Showing 9 changed files with 499 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.classpath
.project
*.iml
.settings/
.idea/
target/
.recommenders/
.metadata/
68 changes: 68 additions & 0 deletions c-echo-scp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ ***** BEGIN LICENSE BLOCK *****
~ Version: MPL 1.1/GPL 2.0/LGPL 2.1
~
~ The contents of this file are subject to the Mozilla Public License Version
~ 1.1 (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~ http://www.mozilla.org/MPL/
~
~ Software distributed under the License is distributed on an "AS IS" basis,
~ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
~ for the specific language governing rights and limitations under the
~ License.
~
~ The Original Code is part of dcm4che, an implementation of DICOM(TM) in
~ Java(TM), hosted at https://github.com/dcm4che.
~
~ The Initial Developer of the Original Code is
~ J4Care.
~ Portions created by the Initial Developer are Copyright (C) 2015-2018
~ the Initial Developer. All Rights Reserved.
~
~ Contributor(s):
~ See @authors listed below
~
~ Alternatively, the contents of this file may be used under the terms of
~ either the GNU General Public License Version 2 or later (the "GPL"), or
~ the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
~ in which case the provisions of the GPL or the LGPL are applicable instead
~ of those above. If you wish to allow use of your version of this file only
~ under the terms of either the GPL or the LGPL, and not to allow others to
~ use your version of this file under the terms of the MPL, indicate your
~ decision by deleting the provisions above and replace them with the notice
~ and other provisions required by the GPL or the LGPL. If you do not delete
~ the provisions above, a recipient may use your version of this file under
~ the terms of any one of the MPL, the GPL or the LGPL.
~
~ ***** END LICENSE BLOCK *****
~
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quickstart-parent</artifactId>
<groupId>org.dcm4che.quickstart</groupId>
<version>5.13.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>c-echo-scp</artifactId>

<dependencies>
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-net</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* **** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is part of dcm4che, an implementation of DICOM(TM) in
* Java(TM), hosted at https://github.com/dcm4che.
*
* The Initial Developer of the Original Code is
* J4Care.
* Portions created by the Initial Developer are Copyright (C) 2015-2018
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* See @authors listed below
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* **** END LICENSE BLOCK *****
*
*/

package org.dcm4che3.quickstart.cechoscp;

import org.dcm4che3.data.UID;
import org.dcm4che3.net.ApplicationEntity;
import org.dcm4che3.net.Connection;
import org.dcm4che3.net.Device;
import org.dcm4che3.net.TransferCapability;

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
* @author Gunter Zeilinger <[email protected]>
* @since Jul 2018
*/
public class CEchoSCP {
private Device device;
private ApplicationEntity ae;
private Connection conn;

public CEchoSCP(String calledAET, String bindAddress, int port) {
device = new Device("c-echo-scp");
ae = new ApplicationEntity(calledAET);
conn = new Connection(null, "127.0.0.1", port);
conn.setBindAddress(bindAddress);
device.addApplicationEntity(ae);
device.addConnection(conn);
ae.addConnection(conn);
ae.addTransferCapability(new TransferCapability(null,
UID.VerificationSOPClass, TransferCapability.Role.SCP, UID.ImplicitVRLittleEndian));
}

public void setExecutor(Executor executor) {
device.setExecutor(executor);
}

public void setScheduledExecutor(ScheduledExecutorService executor) {
device.setScheduledExecutor(executor);
}

public void start() throws IOException, GeneralSecurityException {
device.bindConnections();
}

public static void main(String[] args) throws Exception {
CLI cli = CLI.parse(args);
ExecutorService executor = Executors.newCachedThreadPool();
ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
CEchoSCP scp = new CEchoSCP(cli.calledAET, cli.bindAddress, cli.port);
scp.setExecutor(executor);
scp.setScheduledExecutor(scheduledExecutor);
scp.start();
}

private static class CLI {
final String calledAET;
final String bindAddress;
final int port;

CLI(String[] args) {
calledAET = args[0];
bindAddress = args[1];
port = Integer.parseInt(args[2]);
}

static CLI parse(String[] args) {
try {
return new CLI(args);
} catch (IndexOutOfBoundsException | NumberFormatException e) {
System.out.println("Usage: c-echo-scp <called-aet> <bind-address> <port>");
System.exit(-1);
return null;
}
}
}
}
5 changes: 5 additions & 0 deletions c-echo-scp/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
log4j.rootLogger=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %-5p - %m\n
67 changes: 67 additions & 0 deletions c-echo-scu/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ ***** BEGIN LICENSE BLOCK *****
~ Version: MPL 1.1/GPL 2.0/LGPL 2.1
~
~ The contents of this file are subject to the Mozilla Public License Version
~ 1.1 (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~ http://www.mozilla.org/MPL/
~
~ Software distributed under the License is distributed on an "AS IS" basis,
~ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
~ for the specific language governing rights and limitations under the
~ License.
~
~ The Original Code is part of dcm4che, an implementation of DICOM(TM) in
~ Java(TM), hosted at https://github.com/dcm4che.
~
~ The Initial Developer of the Original Code is
~ J4Care.
~ Portions created by the Initial Developer are Copyright (C) 2015-2018
~ the Initial Developer. All Rights Reserved.
~
~ Contributor(s):
~ See @authors listed below
~
~ Alternatively, the contents of this file may be used under the terms of
~ either the GNU General Public License Version 2 or later (the "GPL"), or
~ the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
~ in which case the provisions of the GPL or the LGPL are applicable instead
~ of those above. If you wish to allow use of your version of this file only
~ under the terms of either the GPL or the LGPL, and not to allow others to
~ use your version of this file under the terms of the MPL, indicate your
~ decision by deleting the provisions above and replace them with the notice
~ and other provisions required by the GPL or the LGPL. If you do not delete
~ the provisions above, a recipient may use your version of this file under
~ the terms of any one of the MPL, the GPL or the LGPL.
~
~ ***** END LICENSE BLOCK *****
~
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quickstart-parent</artifactId>
<groupId>org.dcm4che.quickstart</groupId>
<version>5.13.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>c-echo-scu</artifactId>

<dependencies>
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-net</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 0344217

Please sign in to comment.