/**
   * For testing, establish an association to the specified AE and send a DICOM instance (send a
   * C-STORE request).
   *
   * @param arg array of seven or nine strings - their hostname, their port, their AE Title, our AE
   *     Title, the filename containing the instance to send, optionally the SOP Class and the SOP
   *     Instance (otherwise will be read from the file), the compression level (0=none,1=propose
   *     deflate,2=propose deflate and bzip2) and the debugging level
   */
  public static void main(String arg[]) {
    try {
      String theirHost = null;
      int theirPort = -1;
      String theirAETitle = null;
      String ourAETitle = null;
      String fileName = null;
      String SOPClassUID = null;
      String SOPInstanceUID = null;
      int compressionLevel = 0;
      int debugLevel = 0;

      if (arg.length == 9) {
        theirHost = arg[0];
        theirPort = Integer.parseInt(arg[1]);
        theirAETitle = arg[2];
        ourAETitle = arg[3];
        fileName = arg[4];
        SOPClassUID = arg[5];
        SOPInstanceUID = arg[6];
        compressionLevel = Integer.parseInt(arg[7]);
        debugLevel = Integer.parseInt(arg[8]);
      } else if (arg.length == 7) {
        theirHost = arg[0];
        theirPort = Integer.parseInt(arg[1]);
        theirAETitle = arg[2];
        ourAETitle = arg[3];
        fileName = arg[4];
        SOPClassUID = null; // figured out by StorageSOPClassSCU() by reading the metaheader
        SOPInstanceUID = null; // figured out by StorageSOPClassSCU() by reading the metaheader
        compressionLevel = Integer.parseInt(arg[5]);
        debugLevel = Integer.parseInt(arg[6]);
      } else {
        throw new Exception("Argument list must be 7 or 9 values");
      }
      new TestSendingCommandAndDataInOnePDU(
          theirHost,
          theirPort,
          theirAETitle,
          ourAETitle,
          fileName,
          SOPClassUID,
          SOPInstanceUID,
          compressionLevel,
          debugLevel);
    } catch (Exception e) {
      e.printStackTrace(System.err);
      System.exit(0);
    }
  }
Ejemplo n.º 2
0
 public void TestSafePrivateGEPACSRelated_FromFile() throws Exception {
   AttributeList list = new AttributeList();
   String testFilePath = System.getProperty("com.pixelmed.test.filepath");
   // System.err.println("TestSafePrivateGEPACSRelated.TestSafePrivateGEPACSRelated_FromFile():
   // testFilePath = "+testFilePath);
   list.read(new java.io.File(testFilePath, "philipsctwithgepacsprivateattributes.dcm"));
   // System.err.print("TestSafePrivateGEPACSRelated.TestSafePrivateGEPACSRelated():\n"+list);
   list.removeUnsafePrivateAttributes();
   assertTrue(
       "Checking Creator is not removed", list.get(new AttributeTag(0x0903, 0x0010)) != null);
   assertTrue(
       "Checking Reject Image Flag is not removed",
       list.get(new AttributeTag(0x0903, 0x1010)) != null);
 }
 public void TestSafePrivatePhilipsPETRelated_ScaleFactors_FromFile() throws Exception {
   AttributeList list = new AttributeList();
   String testFilePath = System.getProperty("com.pixelmed.test.filepath");
   // System.err.println("TestSafePrivatePhilipsPETRelated.TestSafePrivatePhilipsPETRelated_ScaleFactors_FromFile(): testFilePath = "+testFilePath);
   list.read(new java.io.File(testFilePath, "philipssuvandactivityscalefactors.dcm"));
   // System.err.print("TestSafePrivatePhilipsPETRelated.TestSafePrivatePhilipsPETRelated_ScaleFactors():\n"+list);
   list.removeUnsafePrivateAttributes();
   assertTrue(
       "Checking Creator is not removed", list.get(new AttributeTag(0x7053, 0x0010)) != null);
   assertTrue(
       "Checking SUV Factor is not removed", list.get(new AttributeTag(0x7053, 0x1000)) != null);
   assertTrue(
       "Checking Activity Concentration Factor is not removed",
       list.get(new AttributeTag(0x7053, 0x1009)) != null);
 }
Ejemplo n.º 4
0
  @Override
  public String toString() {
    String eol = System.getProperty("line.separator");
    String returnString = "Device Observer:" + eol;
    returnString =
        returnString
            + "Device Observer UID = "
            + (this.deviceObserverUID != null ? this.deviceObserverUID : "null")
            + eol
            + "Device Observer Manufacturer = "
            + (this.deviceObserverManufacturer != null ? this.deviceObserverManufacturer : "null")
            + eol
            + "Device Observer Model Name = "
            + (this.deviceObserverModelName != null ? this.deviceObserverModelName : "null")
            + eol
            + "Device Observer Serial Number = "
            + (this.deviceObserverSerialNumber != null ? this.deviceObserverSerialNumber : "null")
            + eol
            + "Device Observer Physical Location  = "
            + (this.deviceObserverPhysicalLocation != null
                ? this.deviceObserverPhysicalLocation
                : "null")
            + eol
            + "Manufacturer = "
            + (this.manufacturer != null ? this.manufacturer : "null")
            + eol
            + "Institution Name = "
            + (this.institutionName != null ? this.institutionName : "null")
            + eol
            + "Station Name = "
            + (this.stationName != null ? this.stationName : "null")
            + eol
            + "Institutional Department Name = "
            + (this.institutionalDepartmentName != null ? this.institutionalDepartmentName : "null")
            + eol
            + "Manufacturer's Model Name = "
            + (this.manufacturersModelName != null ? this.manufacturersModelName : "null")
            + eol
            + "Device Serial Number = "
            + (this.deviceSerialNumber != null ? this.deviceSerialNumber : "null")
            + eol
            + "Software Version = "
            + (this.softwareVersions != null ? this.softwareVersions : "null")
            + eol;

    return returnString;
  }
 /**
  * @param association
  * @param affectedSOPClass
  * @param affectedSOPInstance
  * @param inputTransferSyntaxUID
  * @param din
  * @param presentationContextID
  * @param outputTransferSyntaxUID
  * @exception IOException
  * @exception DicomException
  * @exception DicomNetworkException
  * @exception AReleaseException
  */
 protected boolean sendOneSOPInstance(
     Association association,
     String affectedSOPClass,
     String affectedSOPInstance,
     String inputTransferSyntaxUID,
     DicomInputStream din,
     byte presentationContextID,
     String outputTransferSyntaxUID)
     throws AReleaseException, DicomNetworkException, DicomException, IOException {
   CStoreResponseHandler receivedDataHandler = new CStoreResponseHandler(debugLevel);
   association.setReceivedDataHandler(receivedDataHandler);
   if (inputTransferSyntaxUID.equals(outputTransferSyntaxUID)) {
     // din will already be positioned after meta-header and set for reading data set
     byte[] data = null;
     byte[] b = new byte[32768];
     while (true) {
       int bytesReceived = din.read(b, 0, 32768);
       if (bytesReceived == -1) {
         break;
       } else if (bytesReceived > 0) {
         if (data == null) {
           data = new byte[bytesReceived];
           System.arraycopy(b, 0, data, 0, bytesReceived);
         } else {
           data = ByteArray.concatenate(data, 0, data.length, b, 0, bytesReceived);
         }
       }
     }
     byte cStoreRequestCommandMessage[] =
         new CStoreRequestCommandMessage(affectedSOPClass, affectedSOPInstance).getBytes();
     association.send(presentationContextID, cStoreRequestCommandMessage, data);
   } else {
     throw new DicomException("Must be the same transfer syntax");
   }
   if (debugLevel > 1)
     System.err.println(
         new java.util.Date().toString()
             + ": TestSendingCommandAndDataInOnePDU.sendOneSOPInstance(): about to wait for PDUs");
   association.waitForCommandPDataPDUs();
   return receivedDataHandler.wasSuccessful();
 }
Ejemplo n.º 6
0
  /** @param arg */
  public static void main(String arg[]) {
    TestApp af = new TestApp();

    SourceImage sImg = null;

    int imagesPerRow = 0;
    int imagesPerCol = 0;

    int imgMin = 65536;
    int imgMax = 0;

    boolean signed = false;
    boolean inverted = false;
    boolean hasPad = false;
    int padValue = 0;

    if (arg.length == 6) {
      // do it with raw file
      int w = 0;
      int h = 0;
      int d = 0;
      try {
        w = Integer.valueOf(arg[1]).intValue();
        h = Integer.valueOf(arg[2]).intValue();
        d = Integer.valueOf(arg[3]).intValue();
        imagesPerRow = Integer.valueOf(arg[4]).intValue();
        imagesPerCol = Integer.valueOf(arg[5]).intValue();
      } catch (Exception e) {
        System.err.println(e);
        System.exit(0);
      }

      try {
        FileInputStream i = new FileInputStream(arg[0]);
        sImg = new SourceImage(i, w, h, d);
      } catch (Exception e) {
        System.err.println(e);
        System.exit(0);
      }
    } else {
      // do it with DICOM file

      if (arg.length > 2) {
        try {
          imagesPerRow = Integer.valueOf(arg[1]).intValue();
          imagesPerCol = Integer.valueOf(arg[2]).intValue();
        } catch (Exception e) {
          System.err.println(e);
          e.printStackTrace(System.err);
          System.exit(0);
        }
      } else {
        imagesPerRow = 1;
        imagesPerCol = 1;
      }

      try {
        DicomInputStream i = new DicomInputStream(new FileInputStream(arg[0]));
        sImg = new SourceImage(i);
      } catch (Exception e) {
        System.err.println(e);
        e.printStackTrace(System.err);
        System.exit(0);
      }
    }

    try {
      // com.apple.cocoa.application.NSMenu.setMenuBarVisible(false);							// Won't compile on
      // other platforms
      // Class classToUse =
      // ClassLoader.getSystemClassLoader().loadClass("com.apple.cocoa.application.NSMenu");	//
      // Needs "/System/Library/Java" in classpath
      Class classToUse =
          new java.net.URLClassLoader(new java.net.URL[] {new File("/System/Library/Java").toURL()})
              .loadClass("com.apple.cocoa.application.NSMenu");
      Class[] parameterTypes = {Boolean.TYPE};
      java.lang.reflect.Method methodToUse =
          classToUse.getDeclaredMethod("setMenuBarVisible", parameterTypes);
      Object[] args = {Boolean.FALSE};
      methodToUse.invoke(null /*since static*/, args);
    } catch (Exception e) { // ClassNotFoundException,NoSuchMethodException,IllegalAccessException
      e.printStackTrace(System.err);
    }

    java.awt.Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    int frameWidth = (int) d.getWidth();
    int frameHeight = (int) d.getHeight();
    System.err.println("frameWidth=" + frameWidth);
    System.err.println("frameHeight=" + frameHeight);
    af.setUndecorated(true);
    af.setLocation(0, 0);
    af.setSize(frameWidth, frameHeight);

    JPanel multiPanel = new JPanel();
    multiPanel.setLayout(new GridLayout(imagesPerCol, imagesPerRow));
    multiPanel.setBackground(Color.black);

    SingleImagePanel imagePanel[] = new SingleImagePanel[imagesPerRow * imagesPerCol];

    int singleWidth = frameWidth / imagesPerRow;
    int singleHeight = frameHeight / imagesPerCol;
    System.err.println("singleWidth=" + singleWidth);
    System.err.println("singleHeight=" + singleHeight);

    for (int x = 0; x < imagesPerCol; ++x) {
      for (int y = 0; y < imagesPerRow; ++y) {
        SingleImagePanel ip = new SingleImagePanel(sImg);
        // ip.setPreferredSize(new Dimension(img.getWidth(),img.getHeight()));
        // ip.setPreferredSize(new Dimension(sImg.getWidth(),sImg.getHeight()));
        ip.setPreferredSize(new Dimension(singleWidth, singleHeight));
        multiPanel.add(ip);
        imagePanel[x * imagesPerRow + y] = ip;
      }
    }

    // multiPanel.setSize(img.getWidth()*imagesPerRow,img.getHeight()*imagesPerRow);

    // JScrollPane scrollPane = new JScrollPane(multiPanel);

    Container content = af.getContentPane();
    content.setLayout(new GridLayout(1, 1));
    // content.add(scrollPane);
    content.add(multiPanel);

    af.pack();
    af.setVisible(true);
  }