@@ -44,13 +44,10 @@ struct Fmi2Component
44
44
{ }
45
45
46
46
double lastSuccessfulTime{0 };
47
+ bool wantsToTerminate{false };
47
48
48
49
std::unique_ptr<pythonfmu::SlaveInstance> slave;
49
50
std::unique_ptr<Fmi2Logger> logger;
50
-
51
- double start{0 };
52
- std::optional<double > stop;
53
- std::optional<double > tolerance;
54
51
};
55
52
56
53
} // namespace
@@ -165,7 +162,7 @@ fmi2Status fmi2SetupExperiment(
165
162
stopTimeDefined ? std::optional (stopTime) : std::nullopt,
166
163
toleranceDefined ? std::optional (tolerance) : std::nullopt);
167
164
return fmi2OK;
168
- }catch (const pythonfmu::fatal_error& e) {
165
+ } catch (const pythonfmu::fatal_error& e) {
169
166
component->logger ->log (fmi2Fatal, e.what ());
170
167
return fmi2Fatal;
171
168
} catch (const std::exception& e) {
@@ -564,6 +561,7 @@ fmi2Status fmi2DoStep(
564
561
}
565
562
566
563
component->lastSuccessfulTime = endTime;
564
+ component->wantsToTerminate = true ;
567
565
return fmi2Discard;
568
566
} catch (const pythonfmu::fatal_error& e) {
569
567
component->logger ->log (fmi2Fatal, e.what ());
@@ -606,9 +604,9 @@ fmi2Status fmi2GetRealStatus(
606
604
return fmi2OK;
607
605
} else {
608
606
component->logger ->log (
609
- fmi2Error ,
607
+ fmi2Discard ,
610
608
" Invalid status inquiry for fmi2GetRealStatus" );
611
- return fmi2Error ;
609
+ return fmi2Discard ;
612
610
}
613
611
}
614
612
@@ -618,19 +616,24 @@ fmi2Status fmi2GetIntegerStatus(
618
616
fmi2Integer*)
619
617
{
620
618
static_cast <Fmi2Component*>(c)->logger ->log (
621
- fmi2Error ,
619
+ fmi2Discard ,
622
620
" FMI function not supported: fmi2GetIntegerStatus" );
623
- return fmi2Error ;
621
+ return fmi2Discard ;
624
622
}
625
623
626
624
fmi2Status fmi2GetBooleanStatus (
627
625
fmi2Component c,
628
- const fmi2StatusKind,
629
- fmi2Boolean*)
626
+ const fmi2StatusKind s ,
627
+ fmi2Boolean* value )
630
628
{
631
- static_cast <Fmi2Component*>(c)->logger ->log (
632
- fmi2Error, " FMI function not supported: fmi2GetBooleanStatus" );
633
- return fmi2Error;
629
+ const auto component = static_cast <Fmi2Component*>(c);
630
+ if (s == fmi2Terminated) {
631
+ *value = component->wantsToTerminate ? fmi2True : fmi2False;
632
+ return fmi2OK;
633
+ }
634
+ component->logger ->log (
635
+ fmi2Discard, " FMI function not supported: fmi2GetBooleanStatus" );
636
+ return fmi2Discard;
634
637
}
635
638
636
639
fmi2Status fmi2GetStringStatus (
@@ -639,7 +642,7 @@ fmi2Status fmi2GetStringStatus(
639
642
fmi2String*)
640
643
{
641
644
static_cast <Fmi2Component*>(c)->logger ->log (
642
- fmi2Error , " FMI function not supported: fmi2GetStringStatus" );
643
- return fmi2Error ;
645
+ fmi2Discard , " FMI function not supported: fmi2GetStringStatus" );
646
+ return fmi2Discard ;
644
647
}
645
648
}
0 commit comments