commit 2e8e9cd177f46ca4f28ae1a5b53412a6da330ff4 Author: Kyle Kiteveles Date: Fri Aug 4 12:52:37 2023 -0400 Init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/CTempFamily.xml b/CTempFamily.xml new file mode 100644 index 0000000..2374b5a --- /dev/null +++ b/CTempFamily.xml @@ -0,0 +1,831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2f2015b --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,453 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "RustXMLParseTest" +version = "0.1.0" +dependencies = [ + "clap", + "enum_index", + "enum_index_derive", + "lazy_static", + "phf", + "roxmltree", + "strum", +] + +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + +[[package]] +name = "cc" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c6b2562119bf28c3439f7f02db99faf0aa1a8cdfe5772a2ee155d32227239f0" +dependencies = [ + "libc", +] + +[[package]] +name = "clap" +version = "4.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +dependencies = [ + "heck", + "proc-macro2", + "quote 1.0.32", + "syn 2.0.28", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "enum_index" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5532bdea562e7be83060c36185eecccba82fe16729d2eaad2891d65417656dd" + +[[package]] +name = "enum_index_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ab22c8085548bf06190113dca556e149ecdbb05ae5b972a2b9899f26b944ee4" +dependencies = [ + "quote 0.3.15", + "syn 0.11.11", +] + +[[package]] +name = "errno" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote 1.0.32", + "syn 2.0.28", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" + +[[package]] +name = "quote" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "roxmltree" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8f595a457b6b8c6cda66a48503e92ee8d19342f905948f29c383200ec9eb1d8" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "rustix" +version = "0.38.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee020b1716f0a80e2ace9b03441a749e402e86712f15f16fe8a8f75afac732f" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +dependencies = [ + "quote 0.3.15", + "synom", + "unicode-xid", +] + +[[package]] +name = "syn" +version = "2.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +dependencies = [ + "proc-macro2", + "quote 1.0.32", + "unicode-ident", +] + +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "unicode-ident" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" + +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "xmlparser" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..320f044 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "RustXMLParseTest" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +roxmltree = "0.18.0" +strum = "0.25.0" +enum_index = "0.2.0" +enum_index_derive = "0.2.0" +phf = { version = "0.11.2", features = ["macros"] } +lazy_static = "1.4.0" +clap = { version = "4.3.19", features = ["derive"] } diff --git a/src/CTempFamily.xml b/src/CTempFamily.xml new file mode 100644 index 0000000..2374b5a --- /dev/null +++ b/src/CTempFamily.xml @@ -0,0 +1,831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/families.rs b/src/families.rs new file mode 100644 index 0000000..633f29a --- /dev/null +++ b/src/families.rs @@ -0,0 +1,136 @@ +#[derive(Debug, Display, Enum String, EnumIndex, IndexEnum)] +pub enum Families { + FmARCH, //0, This is used by the WACP architecture to provide messages for standard features. + FmECG, //1, This is used for the ElctroCardioGram (ECG) components. + FmIP, //2, This is used for the Impedance Pneumography (IP) Respiration components + FmTEMP, //3, This family is used for all components that perform temperature measurements (SureTemp and Oral/Skin/Core). The different types will be differentiated by species. + FmSPO2, //4, This is used for the SpO2 component that interfaces with all forms of OEM SpO2 boards. + FmNIBP, //5, This is used for all forms of Non-Invasive Blood Pressure (NIBP). + FmICG, //6, Non-Invasive Cardiac Output (Impedance CardioGraphy, ICG) + FmHEMODYNAMICS, //7, Hemodynamic Values + FmCO2, //8, This is used for mainstream and sidestream CO2 monitoring components. + FmIBP, //9, This is used for Invasive Blood Pressure components (IBP). + FmCARDIACOUTPUT, //10, This is used for all forms of cardiac output components. + FmUI, //11, This is used for all manner of user interface components. + FmBARCODE, //12, This is used for components that interface with a barcode reader. + FmCTR, //13, These are the main processing node controllers. An example is a “Monet” controller. + FmPATIENT, //14, Used for context for test results. + FmUSER, //15, Used for context in test results. + FmGLUCOSE, //16, This is used for Glucose components. + FmBODYMASSINDEX, //17, This is used for body mass index components. + FmRESPIRATION, //18, This is used for respiration components. + FmWEIGHT, //19, This is used for weight components. + FmINSURANCE, //20, This is used for insurance definition. + FmPHYSICIAN, //21, This is used for physician definition. + FmSITE, //22, This is used for site definition. + FmSESSION, //23, This is used for session components. + FmDEVICE, //24, Details the basic common attributes of a device or instrument. This may include model, serial etc… + FmINTERPRETATION, //25, This is used for interpretation components generated by a ECG analysis. + FmHEIGHT, //26, This is used for height component definition. + FmSPIRO, //27, This used for Spirometery components. + FmTRAP, //28, An architecture level definition for error and exceptions generated by application processes and OSI framework members. Used in network communications. + FmRENDEZVOUS, //29, A connection based component with messages that facilitate network connection sequences on multiple media. + FmCONNECTION, //30, A connection management component with base capabilities for managing connections (wireless) that are not guaranteed. + FmWAVESAMPLE, //31, The representation of points in any type of measured recording over time. + FmWAVE, //32, The representation of points in any type of measured recording over time. + FmDEV01, //33, Reserved for development use only. + FmDEV02, //34, '' + FmDEV03, //35, '' + FmDEV04, //36, '' + FmDEV05, //37, '' + FmDEV06, //38, '' + FmDEV07, //39, '' + FmDEV08, //40, '' + FmDEV09, //41, '' + FmDEV10, //42, '' + FmDEV11, //43, '' + FmDEV12, //44, '' + FmDEV13, //45, '' + FmDEV14, //46, '' + FmDEV15, //47, '' + FmDEV16, //48, '' + FmDEV17, //49, '' + FmDEV18, //50, '' + FmDEV19, //51, '' + FmDEV20, //52, '' + FmDEV21, //53, '' + FmDEV22, //54, '' + FmDEV23, //55, '' + FmDEV24, //56, '' + FmDEV25, //57, '' + FmDEV26, //58, '' + FmDEV27, //59, '' + FmDEV28, //60, '' + FmDEV29, //61, '' + FmDEV30, //62, '' + FmDEV31, //63, '' + FmDEV32, //64, '' + FmDEV33, //65, '' + FmDEV34, //66, '' + FmDEV35, //67, '' + FmDEV36, //68, '' + FmDEV37, //69, '' + FmDEV38, //70, '' + FmDEV39, //71, '' + FmDEV40, //72, '' + FmDEV41, //73, '' + FmDEV42, //74, '' + FmDEV43, //75, '' + FmDEV44, //76, '' + FmDEV45, //77, '' + FmDEV46, //78, '' + FmDEV47, //79, '' + FmDEV48, //80, '' + FmDEV49, //81, '' + FmDEV50, //82, '' + FmGLOBALMEASUREMENTS, //83, + FmLEADIMPEDANCEARRAY, //84, + FmLEADIMPEDANCE, //85, + FmMEASUREMENTMATRIX, //86, + FmLEADMEASUREMENT, //87, + FmQRSANNOTARRAY, //88, + FmQRSCOMPLEX, //89, + FmPACERARRAY, //90, + FmPACERINFO, //91, + FmDTCOLLECTION, //92, Collection Object + FmWACP, //93, WACP Object + FmFLASH, //94, Flash Programming Object + FmVERSION, //95, + FmPRINTER, //96, + FmRECORD, //97, Results generated by a device. + FmTCPIP, //98, TCPIP Settings + FmLOCATIONID, //99, Network Identification + FmPAIN, //100, + FmCLINICIAN, //101, + FmCALIBRATION, //102, + FmPATIENTLIST, //103, + FmFAX, //104, + FmMODULE, //105, + FmMODEM, //106, + FmNETWORK, //107, + FmTEST, //108, + FmENCRYPTION, //109, + FmTOC, //110, + FmBATTERY, //111, + FmFILESYS, //112, + FmMOIBSTRING, //113, + FmERROR, //114, + FmCOMMAND_LINE, //115, + FmDICTIONARY, //116, + FmNUMERIC, //117, + FmCHANNEL, //118, + FmORDER, //119, + FmQUERY, //120, + FmTYMP, //121, + FmDATATRANSFER, //122, + FmLIST, //123, + FmHR, //124, + FmSPHB, //125, + FmHIM, //126, + FmSPOC, //127, + FmSPCO, //128, + FmSPMET, //129, + FmPATIENT_MOTION, //130, + FmCUSTOM, //131, + FmMAX //132, The FmMAX is a sliding value that will be one enumerated value greater than the last family defined. The actual enumerated value may vary if additional families are added in the Constants Table XML document. This value is used to terminate the family enumeration list. +} \ No newline at end of file diff --git a/src/genera.rs b/src/genera.rs new file mode 100644 index 0000000..63bfbeb --- /dev/null +++ b/src/genera.rs @@ -0,0 +1,24 @@ +#[derive(Debug, Display, Enum String, EnumIndex, IndexEnum)] +pub enum Genera { + GnDATA, //0, An aggregate type that represents a number of attributes related to a particular family. + GnCOMMAND, //1, Used to send commands to components. + GnEVENT, //2, Notify the rest of the system that something has taken place. + GnERROR, //3, Used to notify the system that something has occurred that should not have occurred. + GnPARAMETER, //4, Used to send parameter information. + GnSTATUS, //5, The persistent status of the component during the current power up state of the processing node. + GnNUMERIC, //6, Used primarily for patient vital-signs numeric, but is not limited to representation of other numeric data. + GnRESERVE_A, //7, Reserved + GnCONFIG, //8, Used to contain the configuration data of the components. + GnRESERVE_B, //9, Reserved + GnRESERVE_C, //10, Reserved + GnREQUEST, //11, Used to request that one component send a message directly to another component. + GnRESERVE_D, //12, Reserved + GnRESERVE_E, //13, Reserved + GnRESERVE_F, //14, Reserved + GnRESPONSE, //15, Response + GnRESERVE_G, //16, Reserved + GnSTREAM, //17, Used for messaging while not requiring an ACK or NAK. + GnDATAEXT, //18, An aggregate type that represents a number of attributes related to a particular family, extended to 4 bytes. + GnANNOTATION, //19, Used to contain data that provides additional information for another object. + GnMAX //20, Used to contain data that provides additional information for another object. +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9b91e41 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,291 @@ +mod oop; +use std::{thread::{self, JoinHandle}, fs::copy, ops::Index, clone, borrow::Cow}; +use clap::Parser; +use roxmltree::{self, Document}; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct Args { + #[arg(short, long)] + dir: String +} + +fn main() { + let mut arg = Args::parse(); + let mut objects_filenames: Vec = Vec::new(); + let mut messages_filenames: Vec = Vec::new(); + let mut docs: Vec = Vec::new(); + let mut handles: Vec> = Vec::new(); + let mut file_name: Vec = Vec::new(); + + let opt = roxmltree::ParsingOptions { + allow_dtd: true, + ..roxmltree::ParsingOptions::default() + }; + + let paths = std::fs::read_dir(arg.dir).expect("No directory found."); + let mut temp:Vec> = Vec::new(); + for path in paths { + match path { + Ok(real_path) => { + file_name.push(real_path.path().to_string_lossy().to_string()); + }, + Err(unreal_path) => {panic!("Bad file path.")} + }; + objects_filenames.push(file_name.last().unwrap().trim_end_matches(".xml").to_string() + "_objects.rs"); + messages_filenames.push(file_name.last().unwrap().trim_end_matches(".xml").to_string() + "_messages.rs"); + temp.push(thread::spawn(move || { + let new_file_name = file_name.last().unwrap().to_owned(); + roxmltree::Document::parse_with_options(new_file_name.as_str(), opt).unwrap() + })); + } + + + for path in paths { + + temp.push(thread::spawn(move || { + let file_name; + match path { + Ok(real_path) => { + file_name = real_path.path().to_string_lossy().to_string(); + }, + Err(unreal_path) => {panic!("Bad file path.")} + }; + roxmltree::Document::parse_with_options(&file_name, opt).unwrap() + })); + } + + /*for arg in 0..args.files.len() { + let temp = args.files.remove(0); + objects_filenames.push(temp.trim_end_matches(".xml").to_string() + "_objects.rs"); + messages_filenames.push(temp.trim_end_matches(".xml").to_string() + "_messages.rs"); + docs.push(roxmltree::Document::parse_with_options(&temp, opt).unwrap()); + }*/ + + for doc in docs { + + } + + for handle in handles { + handle.join().unwrap(); + } +} + + + +fn parse(doc: &Document) -> oop::Family{ + let mut family: oop::Family = oop::Family::new(String::new(), Vec::new(), Vec::new()); + let mut messages: oop::Messages = oop::Messages::new(Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new()); + if doc.root_element().has_children() { + for child1 in doc.root_element().first_children() { + if child1.is_element() { + print!("\n{:?}: ", child1.tag_name()); + if child1.tag_name().name().to_string().as_str() == "FAMILY" { + for attr in child1.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()); + if attr.name() == "name" { + family.name = attr.value().to_string(); + } + else { + panic!("No family name found. Failed to initialize data structure.") + } + } + } + if child1.has_children() { + for child2 in child1.children() { + if child2.is_element() { + print!("\n {:?}: ", child2.tag_name()); + if child2.tag_name().name().to_string().as_str() == "SPECIES_KEY" { + for attr in child2.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + if child2.has_children() { + for child3 in child2.children() { + if child3.is_element() { + print!("\n {:?}: ", child3.tag_name()); + if child3.tag_name().name().to_string().as_str() == "GENUS" { + for attr in child3.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()); + if attr.name() == "name" { + family.push_genus(oop::Genus::new(attr.value().to_string(), Vec::new())); + } + } + } + if child3.has_children() { + for child4 in child3.children() { + if child4.is_element() { + print!("\n {:?}: {:?}={:?} {:?}={:?}", child4.tag_name(), child4.attribute_node("name").unwrap().name().to_string(), child4.attribute_node("name").unwrap().value().to_string(), child4.attribute_node("defaultvalue").unwrap().name().to_string(), child4.attribute_node("defaultvalue").unwrap().value().to_string()); + if child4.tag_name().name().to_string().as_str() == "SPECIES" { + family.genera.last_mut().unwrap().push(oop::Species::new(child4.attribute_node("name").unwrap().value().to_string(), child4.attribute_node("defaultvalue").unwrap().value().to_string(), Vec::new())); + } + } + } + } + } + } + } + } + } + else if child2.tag_name().name().to_string().as_str() == "DEFINITION" { + for attr in child2.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + if let Some(f) = child2.attribute_node("family") { + if f.value() == family.name { + for genus in family.genera.as_mut_slice() { + if let Some(g) = child2.attribute_node("genus") { + if g.value() == genus.name { + for species in genus.species.as_mut_slice() { + if let Some(s) = child2.attribute_node("species") { + if s.value() == species.name { + species.push(oop::Object::new(child2.attribute_node("class").unwrap().value().to_string(), child2.attribute_node("abrv").unwrap().value().to_string(), child2.attribute_node("version").unwrap().value().to_string(), Vec::new())) + } + } + } + } + } + } + } + } + if child2.has_children() { + for child3 in child2.children() { + if child3.is_element() { + if child3.tag_name().name().to_string().as_str() == "MEMBERS" { + print!("\n {:?}: ", child3.tag_name()); + for attr in child3.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + if child3.has_children() { + for child4 in child3.children() { + if child4.is_element() { + print!("\n {:?}: ", child4.tag_name()); + for attr in child4.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + if child4.tag_name().name().to_string().as_str() == "MEMBER" { + if let Some(s) = child2.attribute_node("family") { + if s.value() == family.name{ + for genus in family.genera.as_mut_slice() { + if let Some(g) = child2.attribute_node("genus") { + if g.value() == genus.name { + for species in genus.species.as_mut_slice() { + if let Some(s) = child2.attribute_node("species") { + if s.value() == species.name { + for object in species.objects.as_mut_slice() { + object.push(oop::ObjectMember::new(child4.attribute_node("type").unwrap().value().to_string(), child4.attribute_node("name").unwrap().value().to_string(), child4.attribute_node("minversion").unwrap().value().to_string(), child4.attribute_node("maxversion").unwrap().value().to_string(), Vec::new())); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + else if child3.tag_name().name().to_string().as_str() == "ENUMERATION" { + print!("\n {:?}: ", child3.tag_name()); + for attr in child3.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + if child3.has_children() { + for child4 in child3.children() { + if child4.is_element() { + print!("\n {:?}: ", child4.tag_name()); + for attr in child4.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + if child4.tag_name().name().to_string().as_str() == "ENUM" { + if let Some(f) = child2.attribute_node("family") { + if f.value() == family.name { + for genus in family.genera.as_mut_slice() { + if let Some(g) = child2.attribute_node("genus") { + if g.value() == genus.name { + for species in genus.species.as_mut_slice() { + if let Some(s) = child2.attribute_node("species") { + if s.value() == species.name { + for object in species.objects.as_mut_slice() { + for member in object.members.as_mut_slice() { + if let Some(m) = child3.attribute_node("name") { + if m.value() == member.name { + if child4.has_attribute("defaultvalue") { + member.enumerations.push(oop::MemberEnumeration::new(child4.attribute_node("name").unwrap().value().to_string(), child4.attribute_node("defaultvalue").unwrap().value().to_string())); + } + else { + member.enumerations.push(oop::MemberEnumeration::new(child4.attribute_node("name").unwrap().value().to_string(), String::new())); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + else if child2.tag_name().name().to_string().as_str() == "MESSAGES" { + for attr in child2.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + if child2.has_children() { + for child3 in child2.children() { + if child3.is_element() { + print!("\n {:?}: ", child3.tag_name()); + if child3.tag_name().name().to_string().as_str() == "MSG" { + for attr in child3.attributes() { + if attr.name() != "comment" { + print!("{:?}={:?} " , attr.name(), attr.value()) + } + } + messages.push(child3); + } + } + } + } + } + } + } + } + } + } + } + } + family.push_messages(messages); + return family; +} + +fn output(family: oop::Family) { + +} \ No newline at end of file diff --git a/src/oop.rs b/src/oop.rs new file mode 100644 index 0000000..b84a095 --- /dev/null +++ b/src/oop.rs @@ -0,0 +1,156 @@ +use phf::phf_ordered_map; +use crate::roxmltree::Node; + +const MESSAGETYPE: phf::OrderedMap<&'static str, &'static str> = phf_ordered_map! { + "Request" => "requests", + "Response" => "responses", + "Command" => "commands", + "Status" => "statuses", + "Stream" => "streams", +}; + +#[derive(Debug)] +pub struct Family { + pub name: String, + pub genera: Vec, + pub messages: Vec>, +} + +impl Family { + pub fn new(name: String, genera: Vec, messages: Vec>) -> Self { + Self { name, genera, messages } + } + + pub fn push_genus(&mut self, genus: Genus) { + self.genera.push(genus); + } + + pub fn push_messages(&mut self, messages: Messages) { + self.messages.push(messages.requests); + self.messages.push(messages.responses); + self.messages.push(messages.commands); + self.messages.push(messages.statuses); + self.messages.push(messages.streams); + } +} + +#[derive(Debug)] +pub struct Genus { + pub name: String, + pub species: Vec, +} + +impl Genus { + pub fn new(name: String, species: Vec) -> Self { + Self { name, species } + } + + pub fn push(&mut self, species: Species) { + self.species.push(species); + } +} + +#[derive(Debug)] +pub struct Species { + pub name: String, + default_value: String, + pub objects: Vec, +} + +impl Species { + pub fn new(name: String, default_value: String, objects: Vec) -> Self { + Self { name, default_value, objects } + } + + pub fn push(&mut self, object: Object) { + self.objects.push(object); + } +} + +#[derive(Debug)] +pub struct Object { + pub name: String, + abrv: String, + version: String, + pub members: Vec, +} + +impl Object { + pub fn new(name: String, abrv: String, version: String, members: Vec) -> Self { + Self { name, abrv, version, members } + } + + pub fn push(&mut self, member: ObjectMember) { + self.members.push(member); + } +} + +#[derive(Debug)] +pub struct ObjectMember { + member_type: String, + pub name: String, + minversion: String, + maxversion: String, + pub enumerations: Vec, +} + +impl ObjectMember { + pub fn new(member_type: String, name: String, minversion: String, maxversion: String, enumerations: Vec) -> Self { + Self { member_type, name, minversion, maxversion, enumerations } + } + + pub fn push(&mut self, enumeration: MemberEnumeration) { + self.enumerations.push(enumeration); + } +} + +#[derive(Debug)] +pub struct MemberEnumeration { + name: String, + default_value: String, +} + +impl MemberEnumeration { + pub fn new(name: String, default_value: String) -> Self { + Self { name, default_value } + } +} + +#[derive(Debug)] +pub struct Messages { + pub requests: Vec, + pub responses: Vec, + pub commands: Vec, + pub statuses: Vec, + pub streams: Vec, + error: String, +} + +impl Messages { + pub fn new(requests: Vec, responses: Vec, commands: Vec, statuses: Vec, streams: Vec) -> Self { + Self { requests, responses, commands, statuses, streams, error: String::from("") } + } + + pub fn push(&mut self, message: Node<'_, '_>) { + if let Some(t) = message.attribute_node("type") { + let message_type = t.value(); + if MESSAGETYPE.contains_key(message_type) { + if let Some(n) = message.attribute_node("name") { + let message_name = n.value(); + match MESSAGETYPE.get_index(message_type).unwrap().to_string().as_str() { + "0" => self.requests.push(message_name.to_string()), + "1" => self.responses.push(message_name.to_string()), + "2" => self.commands.push(message_name.to_string()), + "3" => self.statuses.push(message_name.to_string()), + "4" => self.streams.push(message_name.to_string()), + _ => { + let error_position = format!("{}{}", "Error: Unrecognized message type at position ", n.position().to_string().as_str()); + self.error.insert_str(0, error_position.as_str()) + } + }; + } + + } + } + } +} \ No newline at end of file