Skip to content

Commit 76b0564

Browse files
Merge pull request #77 from INTO-CPS-Association/72-009-hotfix
This solves issues #70, #71 and #75
2 parents 987efe5 + 94ff225 commit 76b0564

File tree

6 files changed

+31
-47
lines changed

6 files changed

+31
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The current responsible for the tool maintenance is [Claudio Gomes](https://clag
5353
To display the synopsis use the `--help` flag.
5454

5555
```
56-
unifmu 0.0.9
56+
unifmu 0.0.10
5757
5858
Implement Functional Mock-up units (FMUs) in various source languages.
5959

assets/java/src/main/java/Model.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
import java.io.ByteArrayOutputStream;
77
import java.io.ObjectInputStream;
88
import java.io.ObjectOutputStream;
9+
import java.io.Serializable;
910

10-
public class Model {
11+
public class Model implements Serializable {
12+
13+
private static final long serialVersionUID = 1L;
1114

1215
public Double real_a;
1316
public Double real_b;
@@ -22,7 +25,7 @@ public class Model {
2225
public String string_b;
2326
public String string_c;
2427

25-
private ArrayList<Field> references_to_attributes;
28+
private transient ArrayList<Field> references_to_attributes;
2629

2730
public Model() throws Exception {
2831

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["Christian Legaard <clegaard@outlook.com>"]
33
edition = "2021"
44
name = "unifmu"
5-
version = "0.0.9"
5+
version = "0.0.10"
66

77
[dependencies]
88
clap = { version = "4.5.3", features = ["derive"] }

cli/tests/common/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl BreakableFmu for LocalFmu {
525525
fn do_step_function_line_number(&self) -> u64 {
526526
match self.language() {
527527
FmuBackendImplementationLanguage::CSharp => 50,
528-
FmuBackendImplementationLanguage::Java => 47,
528+
FmuBackendImplementationLanguage::Java => 51,
529529
FmuBackendImplementationLanguage::Python => {
530530
match self.version() {
531531
FmiVersion::Fmi2 => 38,
@@ -1263,9 +1263,12 @@ pub trait RemoteBackend: DistributedFileStructure {
12631263
FmuBackendImplementationLanguage::CSharp => duct::cmd!(
12641264
"dotnet", "run", "backend.cs", port
12651265
),
1266-
FmuBackendImplementationLanguage::Java => duct::cmd!(
1267-
"sh", "gradlew", "run", "--args='{port}'"
1268-
),
1266+
FmuBackendImplementationLanguage::Java => {
1267+
let args_list = format!("--args='{port}'");
1268+
duct::cmd!(
1269+
"sh", "gradlew", "run", args_list
1270+
)
1271+
},
12691272
FmuBackendImplementationLanguage::Python => {
12701273
// Unix systems differentiates version 2 and 3 of python in their binary names
12711274
// Windows doesn't
@@ -1365,7 +1368,7 @@ static CSHARP_FMI2: LazyLock<LocalFmu> = LazyLock::new(|| {
13651368
static JAVA_FMI2: LazyLock<LocalFmu> = LazyLock::new(|| {
13661369
LocalFmu::new_persistent(
13671370
FmiVersion::Fmi2,
1368-
FmuBackendImplementationLanguage::CSharp,
1371+
FmuBackendImplementationLanguage::Java,
13691372
"PROMETHEAN_java_fmi2",
13701373
)
13711374
});
@@ -1397,7 +1400,7 @@ static ZIPPED_CSHARP_FMI2: LazyLock<ZippedLocalFmu> = LazyLock::new(|| {
13971400
static ZIPPED_JAVA_FMI2: LazyLock<ZippedLocalFmu> = LazyLock::new(|| {
13981401
ZippedLocalFmu::new_persistent(
13991402
FmiVersion::Fmi2,
1400-
FmuBackendImplementationLanguage::CSharp,
1403+
FmuBackendImplementationLanguage::Java,
14011404
"PROMETHEAN_zipped_java_fmi2",
14021405
)
14031406
});
@@ -1429,7 +1432,7 @@ static DISTRIBUTED_CSHARP_FMI2: LazyLock<DistributedFmu> = LazyLock::new(|| {
14291432
static DISTRIBUTED_JAVA_FMI2: LazyLock<DistributedFmu> = LazyLock::new(|| {
14301433
DistributedFmu::new_persistent(
14311434
FmiVersion::Fmi2,
1432-
FmuBackendImplementationLanguage::CSharp,
1435+
FmuBackendImplementationLanguage::Java,
14331436
"PROMETHEAN_distributed_java_fmi2",
14341437
)
14351438
});
@@ -1461,7 +1464,7 @@ static ZIPPED_DISTRIBUTED_CSHARP_FMI2: LazyLock<ZippedDistributedFmu> = LazyLock
14611464
static ZIPPED_DISTRIBUTED_JAVA_FMI2: LazyLock<ZippedDistributedFmu> = LazyLock::new(|| {
14621465
ZippedDistributedFmu::new_persistent(
14631466
FmiVersion::Fmi2,
1464-
FmuBackendImplementationLanguage::CSharp,
1467+
FmuBackendImplementationLanguage::Java,
14651468
"PROMETHEAN_zipped_distributed_java_fmi2",
14661469
)
14671470
});

fmiapi/src/dispatcher.rs

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ impl Dispatch for Dispatcher {
7575
/// Holds the handle for the subprocess as well as the handle for the socket
7676
/// to said subprocess.
7777
pub struct LocalDispatcher {
78-
runtime: Runtime,
7978
socket: BackendSocket,
8079
subprocess: BackendSubprocess,
80+
runtime: Runtime,
8181
}
8282

8383
impl LocalDispatcher {
8484
pub fn create(
8585
resource_path: &Path,
8686
launch_command: &Vec<String>,
87-
) -> Result<Self, DispatcherError> {
87+
) -> DispatcherResult<Self> {
8888
let runtime = match tokio::runtime::Builder::new_current_thread()
8989
.enable_all()
9090
.build() {
@@ -107,9 +107,9 @@ impl LocalDispatcher {
107107

108108
Ok(
109109
Self {
110-
runtime,
111110
socket,
112-
subprocess
111+
subprocess,
112+
runtime,
113113
}
114114
)
115115
}
@@ -147,25 +147,16 @@ impl Dispatch for LocalDispatcher {
147147
}
148148
}
149149

150-
impl Drop for LocalDispatcher {
151-
fn drop(&mut self) {
152-
match self.subprocess.terminate() {
153-
Ok(_) => {},
154-
Err(_) => error!("Terminating subprocess returned an error.")
155-
};
156-
}
157-
}
158-
159150
/// Dispatcher for dispatching FMI commands to a remote backend.
160151
///
161152
/// Holds the socket to the remote backend.
162153
pub struct RemoteDispatcher {
163-
runtime: Runtime,
164154
socket: BackendSocket,
155+
runtime: Runtime,
165156
}
166157

167158
impl RemoteDispatcher {
168-
pub fn create() -> Result<Self, DispatcherError> {
159+
pub fn create() -> DispatcherResult<Self> {
169160
let runtime = match tokio::runtime::Builder::new_current_thread()
170161
.enable_all()
171162
.build() {
@@ -192,8 +183,8 @@ impl RemoteDispatcher {
192183

193184
Ok(
194185
Self {
195-
runtime,
196186
socket,
187+
runtime,
197188
}
198189
)
199190
}
@@ -273,7 +264,7 @@ struct BackendSocket {
273264
}
274265

275266
impl BackendSocket {
276-
pub async fn create(endpoint: &str) -> Result<Self, DispatcherError> {
267+
pub async fn create(endpoint: &str) -> DispatcherResult<Self> {
277268
let mut socket = RepSocket::new();
278269

279270
let endpoint = match socket.bind(endpoint).await {
@@ -297,7 +288,7 @@ impl BackendSocket {
297288
/// ZeroMQ message queue, NOT when the message has actually been received
298289
/// by the backend. As such, there is no absolute guarantee that the
299290
/// message has been received when this returns.
300-
async fn send<S: Message>(&mut self, msg: &S) -> Result<(), DispatcherError> {
291+
async fn send<S: Message>(&mut self, msg: &S) -> DispatcherResult<()> {
301292
let bytes_send: Bytes = msg.encode_to_vec().into();
302293
match self.socket.send(bytes_send.into()).await {
303294
Ok(_) => Ok(()),
@@ -317,7 +308,7 @@ impl BackendSocket {
317308
///
318309
/// A call to recv() will await until a message is received through the
319310
/// ZeroMQ socket.
320-
async fn recv<R: Message + Default>(&mut self) -> Result<R, DispatcherError> {
311+
async fn recv<R: Message + Default>(&mut self) -> DispatcherResult<R> {
321312
match self.socket.recv().await {
322313
Ok(buf) => {
323314
let buf: Bytes = match buf.get(0) {
@@ -347,7 +338,7 @@ impl BackendSocket {
347338
async fn send_and_recv<S: Message, R: Message + Default>(
348339
&mut self,
349340
msg: &S,
350-
) -> Result<R, DispatcherError> {
341+
) -> DispatcherResult<R> {
351342
self.send(msg).await?;
352343
self.recv().await
353344
}
@@ -443,17 +434,4 @@ impl BackendSubprocess {
443434
}
444435
}
445436
}
446-
447-
/// Terminates the subprocess
448-
///
449-
/// On Unix-like systems, this sends the `SIGTERM` signal to the
450-
/// subprocess, which can be caught by the subprocess in order to perform
451-
/// cleanup befoure exiting.
452-
///
453-
/// On Windows, it invokes `TerminateProcess` on the process handle, which
454-
/// cannot be caught.
455-
fn terminate(&mut self) -> DispatcherResult<()> {
456-
self.subprocess.terminate()
457-
.map_err(|_| DispatcherError::SubprocessError)
458-
}
459437
}

fmiapi/src/fmi2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use libc::size_t;
1212

1313

1414
use url::Url;
15-
use tracing::{error, warn};
15+
use tracing::{info, error, warn};
1616
use tracing_subscriber;
1717

1818
use std::{
@@ -176,7 +176,7 @@ impl Drop for Fmi2Slave {
176176
};
177177

178178
match self.dispatcher.send(&cmd) {
179-
Ok(_) => (),
179+
Ok(_) => {info!("Send free instance message to shut down backend");},
180180
Err(error) => error!(
181181
"Freeing instance failed with error: {:?}.", error
182182
),

0 commit comments

Comments
 (0)