Skip to content

Commit

Permalink
feat!: Migrate samples/demo-server to examples
Browse files Browse the repository at this point in the history
which removes it as workspace and allows cargo to index it.
  • Loading branch information
AiyionPrime committed Jul 31, 2024
1 parent 6a23e46 commit 2a605c9
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 56 deletions.
16 changes: 2 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ resolver = "2"
members = [
"lib",
"integration",
"samples/demo-server",
"tools/certificate-creator"
]
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,9 @@ The API documentation is generated from the latest published crates. This may be

<a href="https://docs.rs/opcua"><img src="https://docs.rs/opcua/badge.svg"></img></a>

# Samples/Examples
# Examples

The examples are currently being migrated to reside in `lib/examples`, a standard directory for examples in rust.
The ones which still have to be moved lie in `samples` and can be invoked as described below.

The `simple-server` example has been migrated to the new location already and can be executed like this:

```bash
cargo run --example simple-server
```

If you want to get stuck in, there are a number of samples in the samples/ folder. The `simple-client` and the `simple-server` projects are
If you want to get stuck in, there are a number of examples in the examples/ folder. The `simple-client` and the `simple-server` projects are
minimal client and server programs respectively.

```bash
Expand All @@ -67,12 +58,12 @@ cargo run --example simple-server
cargo run --example simple-client
```

The full list of samples:
The full list of examples:

1. [`simple-server`](lib/examples/simple-server) - an OPC UA server that adds 4 variables v1, v2, v3 and v4 and updates them from a timer via push and pull mechanisms.
2. [`simple-client`](lib/examples/simple-client) - an OPC UA client that connects to a server and subscribes to the values of v1, v2, v3 and v4.
3. [`discovery-client`](lib/examples/discovery-client) - an OPC UA client that connects to a discovery server and lists the servers registered on it.
4. [`chess-server`](lib/examples/chess-server) - an OPC UA server that connects to a chess engine as its back end and updates variables representing the state of the game.
5. [`demo-server`](samples/demo-server) - an OPC UA server that is more complex than the simple server and can be used for compliance testing.
5. [`demo-server`](lib/examples/demo-server) - an OPC UA server that is more complex than the simple server and can be used for compliance testing.
6. [`mqtt-client`](lib/examples/mqtt-client) - an OPC UA client that subscribes to some values and publishes them to an MQTT broker.
7. [`event-client`](lib/examples/event-client) - an OPC UA client that will connect to a server and subscribe to alarms / events.
9 changes: 7 additions & 2 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ tempdir = "0.3"
serde_json = "1.0"

# Include console-logging when building tests
opcua = { path = ".", features = ["console-logging"] }
opcua = { path = ".", features = ["console-logging", "http"] }

# Examples
## chess-server, discovery-client, event-client, mqtt-client, simple-client
## chess-server, demo-server, discovery-client, event-client, mqtt-client, simple-client
chrono = "0.4"
lazy_static = "1.4.0"
log = "0.4"
log4rs = "1.2"
pico-args = "0.5"
rand = "0.7"
rumqttc = "0.23"
tokio = { version = "1", features = ["full"] }
uci = "0.1.1"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ from `http://localhost:8585`, however you must start it from the `demo-server` d
and other resources.

```
cd opcua/samples/demo-server
cargo run
cargo run --example demo-server
```

## Testing configuration
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Default for Args {
raise_events = true;
config_path = PathBuf::from("server.conf");
if !config_path.exists() {
config_path = PathBuf::from("../server.conf");
config_path = PathBuf::from("samples/server.conf");
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ fn main() {
Args::usage();
} else {
// More powerful logging than a console logger
log4rs::init_file("log4rs.yaml", Default::default()).unwrap();
log4rs::init_file("lib/examples/demo-server/log4rs.yaml", Default::default()).unwrap();

// Create an OPC UA server with sample configuration and default node set
let mut server = Server::new(ServerConfig::load(&args.config_path).unwrap());
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 0 additions & 22 deletions samples/demo-server/Cargo.toml

This file was deleted.

0 comments on commit 2a605c9

Please sign in to comment.