Skip to content

Commit 99ffe9a

Browse files
committed
Removing Abstract References from XSD for the moment
1 parent c580489 commit 99ffe9a

16 files changed

+78
-52
lines changed

projects/cli/bg-cli-main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ bool genRuntime(std::string pathName)
117117
// This function parses the multword value list of a GENERATE
118118
// keyword and proeprly queues the correct operations needed to process
119119
// the command
120-
void parse_generate_arguments(biogears::Arguments::MultiwordValue&& args)
120+
void parse_generate_arguments
121+
122+
(biogears::Arguments::MultiwordValue&& args)
121123
{
122124

123125
auto is_keyword = [](const std::string& v) { return v == "data" || v == "patients" || v == "runtime" || v == "states" || v == "sepsis" || v == "tables"; };
@@ -126,6 +128,8 @@ void parse_generate_arguments(biogears::Arguments::MultiwordValue&& args)
126128
auto end = args.end();
127129
for (; current != end; ++current) {
128130
const auto& arg = *current;
131+
std::transform(current->begin(), current->end(), current->begin(), ::tolower);
132+
129133
if (arg == "data") {
130134
g_run_generate_data = true;
131135
} else if (arg == "patients") {
@@ -428,8 +432,8 @@ int main(int argc, char** argv)
428432
if (runs) {
429433
driver.queue(runs, as_subprocess);
430434
} else {
431-
std::cout << "Unable to run " << biogears::branded_version_string_str() << std::endl;
432-
exit(BG_CLI_SUCCESS);
435+
std::cout << "Failed to read " << arg << std::endl;
436+
exit(BG_CLI_PARSE_ERROR);
433437
}
434438
}
435439
}

projects/cli/src/exec/Driver.cpp

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ void Driver::queue_Scenario(Executor exec, bool as_subprocess)
380380
const auto patient_file = scenario->InitialParameters()->PatientFile().get();
381381
std::string nc_patient_file = patient_file;
382382
std::transform(nc_patient_file.begin(), nc_patient_file.end(), nc_patient_file.begin(), ::tolower);
383+
//When the user provides the ALL directive
384+
//We will load one file for every patient in patients/
383385
if ("all" == nc_patient_file) {
384386
auto patient_files = biogears::ListFiles("patients", R"(.*\.xml)", false);
385387
#if BIOGEARS_IO_PRESENT
@@ -390,20 +392,27 @@ void Driver::queue_Scenario(Executor exec, bool as_subprocess)
390392
#endif
391393
queue_from_patient_files(exec, patient_files, scenario_launch);
392394
}
393-
else if (filesystem::exists(scenario->InitialParameters()->PatientFile().get())) {
394-
if (filesystem::is_directory(scenario->InitialParameters()->PatientFile().get())) {
395-
auto patient_files = biogears::ListFiles(scenario->InitialParameters()->PatientFile().get(), R"(.*\.xml)", false);
395+
//When the user provides a directory we treat it as an ALL
396+
//But for the directory given
397+
else if (filesystem::exists(patient_file)) {
398+
if (filesystem::is_directory(patient_file)) {
399+
auto patient_files = biogears::ListFiles(patient_file, R"(.*\.xml)", false);
396400
queue_from_patient_files(exec, patient_files, scenario_launch);
397401
return;
398-
} else {
402+
}
403+
else {
399404
exec.Patient(patient_file);
400405
_pool.queue_work(std::bind(scenario_launch, std::move(exec), false));
401406
++_total_work;
402407
return;
403408
}
404-
} else if (filesystem::exists("patients/" + scenario->InitialParameters()->PatientFile().get())) {
405-
if (filesystem::is_directory("patients/" + scenario->InitialParameters()->PatientFile().get())) {
406-
auto patient_files = biogears::ListFiles("patients/" + scenario->InitialParameters()->PatientFile().get(), R"(.*\.xml)", false);
409+
}
410+
//Historically biogears auto falls back on a assumed directory structure
411+
//If the given exist in patients/ and is a directory we will treat it as
412+
//if ALL was given but for the provided directory
413+
else if (filesystem::exists("patients/" + patient_file)) {
414+
if (filesystem::is_directory("patients/" + patient_file)) {
415+
auto patient_files = biogears::ListFiles("patients/" + patient_file, R"(.*\.xml)", false);
407416
queue_from_patient_files(exec, patient_files, scenario_launch);
408417
return;
409418
} else {
@@ -412,11 +421,21 @@ void Driver::queue_Scenario(Executor exec, bool as_subprocess)
412421
++_total_work;
413422
return;
414423
}
415-
} else {
416-
auto matching_patients = find_matching_files(scenario->InitialParameters()->PatientFile().get());
424+
}
425+
//As the user has not provided ALL or given a directory we will now
426+
//find matching files across all the IO call backs and queue correctly.
427+
//We support some wild cards so we may have more then one result.
428+
else {
429+
auto matching_patients = find_matching_files(patient_file);
417430
if (matching_patients.empty()) {
418-
matching_patients = find_matching_files("patients/" + scenario->InitialParameters()->PatientFile().get());
431+
matching_patients = find_matching_files("patients/" + patient_file);
432+
}
433+
if (matching_patients.empty()){
434+
// As all fallback locations have failed we have no furtherways to process the patient and should abort processing.
435+
std::cout << "Error unable to process InitialParameter Patient " << patient_file << " no patient specified.\n";
436+
return;
419437
}
438+
420439
queue_from_patient_files(exec, matching_patients, scenario_launch);
421440
}
422441
} else if (scenario->InitialParameters().present() && scenario->InitialParameters()->Patient().present()) {
@@ -460,7 +479,9 @@ void Driver::queue_from_sate_files(const Executor& exec, const std::vector<files
460479
void Driver::queue_from_patient_files(const Executor& exec, const std::vector<filesystem::path>& patient_files, std::function<void(Executor, bool)> scenario_launch_func)
461480
{
462481
for (auto& patient_file : patient_files) {
463-
std::cout << "\t" << patient_file << std::endl;
482+
if (patient_files.size() != 1) {
483+
std::cout << "\t" << patient_file << std::endl;
484+
}
464485
Executor patientEx { exec };
465486
patientEx.Patient(patient_file);
466487

@@ -740,9 +761,9 @@ void Driver::async_execute(biogears::Executor& ex, bool multi_patient_run)
740761
// NOTE: This loses non relative prefixes as the split will eat the leading path_separator
741762
filesystem::path parent_dir = split_scenario_path.parent_path();
742763

743-
//if (multi_patient_run) {
744-
// ex.Name(ex.Name() + "-" + patient_no_extension);
745-
//}
764+
// if (multi_patient_run) {
765+
// ex.Name(ex.Name() + "-" + patient_no_extension);
766+
// }
746767

747768
std::string base_file_name = (multi_patient_run) ? scenario_no_extension + "-" + patient_no_extension : scenario_no_extension;
748769
std::string console_file = base_file_name + ".log";

projects/cli/src/utils/Config.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,6 @@ bool grab_next_word_or_fail(Tokenizer::token_list::iterator& tokenItr, Tokenizer
858858
++next;
859859
if (next == end) {
860860
std::cerr << "Error: Unexpected EOF after " << error_context << "\n";
861-
862861
} else if (next->type == ETokenClass::Whitespace) {
863862
continue;
864863
} else if (next->type == ETokenClass::Newline) {

share/xsd/cdm/AnesthesiaActions.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License.
1616
<xs:include schemaLocation="Anesthesia.xsd"/>
1717

1818
<!-- @brief Base anesthesia machine action type. -->
19-
<xs:complexType name="AnesthesiaMachineActionData" abstract="true">
19+
<xs:complexType name="AnesthesiaMachineActionData" >
2020
<xs:complexContent>
2121
<xs:extension base="ActionData"/>
2222
</xs:complexContent>

share/xsd/cdm/Circuit.xsd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ specific language governing permissions and limitations under the License.
3232
</xs:restriction>
3333
</xs:simpleType>
3434

35-
<xs:complexType name="CircuitData" abstract="true">
35+
<xs:complexType name="CircuitData" >
3636
<xs:complexContent>
3737
<xs:extension base="ObjectData">
3838
<xs:sequence>
@@ -42,7 +42,8 @@ specific language governing permissions and limitations under the License.
4242
</xs:extension>
4343
</xs:complexContent>
4444
</xs:complexType>
45-
<xs:complexType name="CircuitNodeData" abstract="true">
45+
46+
<xs:complexType name="CircuitNodeData" >
4647
<xs:complexContent>
4748
<xs:extension base="ObjectData">
4849
<xs:sequence>
@@ -51,7 +52,8 @@ specific language governing permissions and limitations under the License.
5152
</xs:extension>
5253
</xs:complexContent>
5354
</xs:complexType>
54-
<xs:complexType name="CircuitPathData" abstract="true">
55+
56+
<xs:complexType name="CircuitPathData" >
5557
<xs:complexContent>
5658
<xs:extension base="ObjectData">
5759
<xs:sequence>

share/xsd/cdm/Compartment.xsd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ specific language governing permissions and limitations under the License.
2525
</xs:restriction>
2626
</xs:simpleType>
2727

28-
<xs:complexType name="CompartmentData" abstract="true">
28+
<xs:complexType name="CompartmentData" >
2929
<xs:complexContent>
3030
<xs:extension base="ObjectData">
3131
<xs:sequence>
@@ -36,7 +36,7 @@ specific language governing permissions and limitations under the License.
3636
</xs:extension>
3737
</xs:complexContent>
3838
</xs:complexType>
39-
<xs:complexType name="CompartmentLinkData" abstract="true">
39+
<xs:complexType name="CompartmentLinkData" >
4040
<xs:complexContent>
4141
<xs:extension base="ObjectData">
4242
<xs:sequence>
@@ -49,7 +49,7 @@ specific language governing permissions and limitations under the License.
4949
</xs:extension>
5050
</xs:complexContent>
5151
</xs:complexType>
52-
<xs:complexType name="CompartmentGraphData" abstract="true">
52+
<xs:complexType name="CompartmentGraphData" >
5353
<xs:sequence>
5454
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
5555

@@ -58,7 +58,7 @@ specific language governing permissions and limitations under the License.
5858
</xs:sequence>
5959
</xs:complexType>
6060

61-
<xs:complexType name="FluidCompartmentData" abstract="true">
61+
<xs:complexType name="FluidCompartmentData" >
6262
<xs:complexContent>
6363
<xs:extension base="CompartmentData">
6464
<xs:sequence>
@@ -70,7 +70,7 @@ specific language governing permissions and limitations under the License.
7070
</xs:extension>
7171
</xs:complexContent>
7272
</xs:complexType>
73-
<xs:complexType name="FluidCompartmentLinkData" abstract="true">
73+
<xs:complexType name="FluidCompartmentLinkData" >
7474
<xs:complexContent>
7575
<xs:extension base="CompartmentLinkData">
7676
<xs:sequence>
@@ -79,7 +79,7 @@ specific language governing permissions and limitations under the License.
7979
</xs:extension>
8080
</xs:complexContent>
8181
</xs:complexType>
82-
<xs:complexType name="FluidCompartmentGraphData" abstract="true">
82+
<xs:complexType name="FluidCompartmentGraphData" >
8383
<xs:complexContent>
8484
<xs:extension base="CompartmentGraphData">
8585
<xs:sequence>

share/xsd/cdm/EngineConfiguration.xsd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ specific language governing permissions and limitations under the License.
3737

3838

3939

40-
<xs:complexType name="PhysiologyEngineStabilizationData" abstract="true">
40+
<xs:complexType name="PhysiologyEngineStabilizationData" >
4141
<xs:complexContent>
4242
<xs:extension base="ObjectData">
4343
</xs:extension>
4444
</xs:complexContent>
4545
</xs:complexType>
4646

47-
<xs:complexType name="PhysiologyEngineConditionStabilizationData" abstract="true">
47+
<xs:complexType name="PhysiologyEngineConditionStabilizationData" >
4848
<xs:complexContent>
4949
<xs:extension base="ObjectData">
5050
<xs:attribute name="Name" type="xs:string" use="required"/>
@@ -110,4 +110,4 @@ specific language governing permissions and limitations under the License.
110110
</xs:complexType>
111111
<xs:element name="PhysiologyEngineDynamicStabilization" type="PhysiologyEngineDynamicStabilizationData"/>
112112

113-
</xs:schema>
113+
</xs:schema>

share/xsd/cdm/EnvironmentActions.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License.
1616
<xs:include schemaLocation="Scenario.xsd"/>
1717

1818
<!-- @brief Base Environmental Action type -->
19-
<xs:complexType name="EnvironmentActionData" abstract="true">
19+
<xs:complexType name="EnvironmentActionData" >
2020
<xs:complexContent>
2121
<xs:extension base="ActionData"/>
2222
</xs:complexContent>

share/xsd/cdm/EnvironmentConditions.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License.
1616
<xs:include schemaLocation="Scenario.xsd"/>
1717

1818
<!-- @brief Base environmental condition type -->
19-
<xs:complexType name="EnvironmentConditionData" abstract="true">
19+
<xs:complexType name="EnvironmentConditionData" >
2020
<xs:complexContent>
2121
<xs:extension base="ConditionData"/>
2222
</xs:complexContent>

share/xsd/cdm/InhalerActions.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License.
1616
<xs:include schemaLocation="Inhaler.xsd"/>
1717

1818
<!-- @brief Base inhaler action type. -->
19-
<xs:complexType name="InhalerActionData" abstract="true">
19+
<xs:complexType name="InhalerActionData" >
2020
<xs:complexContent>
2121
<xs:extension base="ActionData"/>
2222
</xs:complexContent>

0 commit comments

Comments
 (0)