Esempio n. 1
0
int
MLXferAgent::xmitVectorOfImages(const MString& sourceAE,
	const MString& destAE,
	const MString& host,
	const MString& port)
{
  MStorageAgent agent;
  U16 result = 0;
  MString rtnMessage;
  int status;
  MLogClient logClient;

  logClient.log(MLogClient::MLOG_CONVERSATION,
	destAE,
	"MLXferAgent::xmitVectorOfImages",
	__LINE__,
	MString("About to export images to ") + host + MString(":") + port);

  MStringVector::iterator it = mFileNameVector.begin();
  for (; it != mFileNameVector.end(); it++) {
    status = agent.storeInstance(sourceAE, destAE,
		host, port.intData(),
		*it,
		result,
		rtnMessage);
    if (status != 0) {
      cout << "Unable to xfer: " << *it << endl;
      return 1;
    }
  }
  return 0;
}
Esempio n. 2
0
int
MDICOMProxyTCP::connect(const MString& host, const MString& port)
{
  int p = port.intData();
  return this->connect(host, p);
}
Esempio n. 3
0
int
LNMFrameWholeBody::extract(ofstream& f, MDICOMWrapper& w, MStringMap& m, ofstream& o)
{
  U32 frameSize = 0;
  U16 frameCount = 0;
  if (this->getFrameInformation(w, frameSize, frameCount, o) != 0) {
    return 1;
  }
  unsigned char* pixels = new unsigned char[frameSize];
  DCM_OBJECT* obj = w.getNativeObject();

  int energyWindowVectorLength;
  unsigned short* energyWindowVector = 0;
  if (w.getVector(energyWindowVectorLength, energyWindowVector, 0x00540010) != 0) {
    return 1;
  }
  int detectorVectorLength;
  unsigned short* detectorVector = 0;
  if (w.getVector(detectorVectorLength, detectorVector, 0x00540020) != 0) {
    return 1;
  }
  int matchingFrameCount = 0;
  int i;
  unsigned short fixedEnergyWindow = 0;
  unsigned short fixedDetector = 0;
  MString x;
  x = m["ENERGY"];
  if (x != "") fixedEnergyWindow = x.intData();
  x = m["DETECTOR"];
  if (x != "") fixedDetector = x.intData();

  void* ctx = 0;
  U32 rtnLength = 0;
  CONDITION cond = 0;
  DCM_ELEMENT pixelElement;
  ::memset(&pixelElement, 0, sizeof(pixelElement));
  pixelElement.tag = 0x7fe00010;
  ::DCM_LookupElement(&pixelElement);
  pixelElement.length = frameSize;

  for (i = 0; i < energyWindowVectorLength; i++) {
    bool matchingFrame = true;
    cout << energyWindowVector[i] << ' ' << detectorVector[i] << endl;
    if (fixedEnergyWindow != 0 && fixedEnergyWindow != energyWindowVector[i]) {
      matchingFrame = false;
    }
    if (fixedDetector != 0 && fixedDetector != detectorVector[i]) {
      matchingFrame = false;
    }
    cout << fixedEnergyWindow << ' ' << fixedDetector << ' ' << 'x' << matchingFrame << endl;
    pixelElement.d.ob = pixels;
    cond = ::DCM_GetElementValue(&obj, &pixelElement, &rtnLength, &ctx);
    if (matchingFrame) {
      matchingFrameCount++;
      f.write((const char*)pixels, frameSize);
      //o << frameSize << " " << frameCount;
    }
  }
  o << " " << matchingFrameCount << endl;
  cout << "matchingFrameCount: " << matchingFrameCount << endl;

  delete []energyWindowVector;
  delete []detectorVector;
  delete []pixels;
  return 0;
}
Esempio n. 4
0
int main(int argc, char **argv)
{
  bool verbose = false;
#if 0
  DOMParser::ValSchemes    gValScheme             = DOMParser::Val_Auto;
  bool                     gDoNamespaces          = true;
  bool                     gDoSchema              = true;
  bool                     gSchemaFullChecking    = false;
  bool                     gDoCreate              = false;
#endif

  MFileOperations f;
  char path[1024];

  f.expandPath(path, "MESA_TARGET", "runtime");
  ::strcat(path, "/IHE-syslog-audit-message-4.xsd");
  char* schemaDef = path;

  int detailLevel = 1;
  MString tmp;

  while (--argc > 0 && (*++argv)[0] == '-') {
    switch (*(argv[0] + 1)) {
    case 'l':
      argc--; argv++;
      if (argc < 1)
	usage();
      tmp = *argv;
      detailLevel = tmp.intData();
      break;
    case 's':
      argc--; argv++;
      if (argc < 1)
	usage();
      schemaDef = *argv;
      break;
    case 'v':
      verbose = true;
      break;
    default:
      break;
    }
  }

  if (argc < 1)
    usage();

  // Initialize the XML4C2 system
  try {
    XMLPlatformUtils::Initialize();
  }
  catch (const XMLException& e) {
    cout << "Unable to initialize Xerces-c software"
	 << DOMString(e.getMessage()) << endl;
    return 1;
  }


  DOMParser *parser = new DOMParser;
  parser->setValidationScheme(DOMParser::Val_Auto);
  parser->setDoNamespaces(true);
  parser->setDoSchema(true);
  parser->setValidationSchemaFullChecking(true);
  if (schemaDef != "") {
    parser->setExternalNoNamespaceSchemaLocation(schemaDef);
  }

  DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
  parser->setErrorHandler(errReporter);
  parser->setCreateEntityReferenceNodes(false);
  parser->setToCreateXMLDeclTypeNode(true);

  bool errorFlag = false;

  try {
    parser->parse(*argv);
    int count = parser->getErrorCount();
    if (count > 0) {
      errorFlag = true;
      return 1;
    }
  }
  catch (const XMLException& e) {
    cout << "Parsing error: " << DOMString(e.getMessage()) << endl;
    return 1;
  }
  catch (const DOM_DOMException& e) {
   cout << "DOM Error: " << e.code << endl;
   return 1;
  }

  catch (...) {
    cout << "Unspecified error" << endl;
    return 1;
  }

  DOM_Document doc = parser->getDocument();

  unsigned int elementCount = doc.getElementsByTagName("*").getLength();

  cout << "element count: " << elementCount << endl;

  return 0;
}
Esempio n. 5
0
int main(int argc, char** argv)
{
  int facility = 10;
  int severity = 0;
  int mode = 0;
  bool verbose = false;
  bool isCommand = false;
  MString tmp;
  MString tag = "";

  while (--argc > 0 && (*++argv)[0] == '-') {
    switch(*(argv[0] + 1)) {
    case 'c':
      isCommand = true;
      break;
    case 'f':
      if (argc < 1)
	usage();
      argc--; argv++;
      tmp = *argv;
      facility = tmp.intData();
      break;
    case 'm':
      if (argc < 1)
	usage();
      argc--; argv++;
      tmp = *argv;
      mode = tmp.intData();
      break;
    case 's':
      if (argc < 1)
	usage();
      argc--; argv++;
      tmp = *argv;
      severity = tmp.intData();
      break;
    case 't':
      if (argc < 1)
	usage();
      argc--; argv++;
      tag = *argv;
      break;
 
    case 'v':
      verbose = true;
      break;

    default:
      break;
    }
  }

  if (argc < 1)
    usage();

  tmp = argv[0];
  int testNumber = tmp.intData();
  int rtn = 1;

  switch (testNumber) {
    case 0:
      rtn = test0(argc, argv);
      break;
    case 1:
      rtn = test1(argc, argv);
      break;
    case 2:
      rtn = test2(argc, argv);
      break;
    case 3:
      rtn = test3(argc, argv);
      break;
    case 4:
      rtn = test4(argc, argv);
      break;
    default:
      cout << "Undefined test: " << argv[0] << endl;
      break;
  }

#if 0
  char* syslogHost = argv[0];
  tmp = argv[1];
  int syslogPort = tmp.intData();

  MSyslogClient c;
  c.setTestMode(mode);

  int status = c.open(syslogHost, syslogPort);
  if (status != 0) {
    cout << "Unable to connect to server" << endl;
    return 1;
  }

  char* txt;
  if (isCommand) {
    txt = argv[2];
  } else {
    char* path = argv[2];
    MFileOperations f;
    txt = f.readAllText(path);
    if (txt == 0) {
      cout << "Unable to read XML text from: " << path << endl;
      return 1;
    }
  }

  MSyslogMessage5424 m(facility, severity, tag, txt);
  if (!isCommand)
    delete []txt;

  status = c.sendMessage(m);
  if (status != 0) {
    cout << "Unable to send message to server" << endl;
    return 1;
  }

#endif
  return 0;
}