gmt_dos_clients_scope/lib.rs
1/*!
2# GMT DOS Actors Scope
3
4`gmt_dos-clients_scope` is a client/server graphical display implementation for [gmt_dos-actors](https://docs.rs/gmt_dos-actors/) models.
5
6`gmt_dos-clients_scope` has 2 features: `server` and `client`.
7The `server` feature need to be enabled only on the server applications:
8```shell
9cargo add gmt_dos-clients_scope --features=server
10```
11and the `client` feature only on the machine displaying the scopes:
12```shell
13cargo add gmt_dos-clients_scope --features=client
14```
15When both the server and the client are run on the same local machine, the IP address of the server is set to `127.0.0.1`
16and the client address is set to `0.0.0.0:0`.
17If you want to run the server on a different remote machine,
18you need to set the server IP address with the environment variable `SCOPE_SERVER_IP` on both the server and the client.
19
20For a server running in the AWS cloud, on an AWS instance, the server IP address is set
21to the private IP address of the instance whereas the server IP address is set
22to the public IP address of the instance on the client machine.
23*/
24
25const SERVER_IP: &'static str = "127.0.0.1";
26#[cfg(feature = "client")]
27const CLIENT_ADDRESS: &'static str = "0.0.0.0:0";
28
29mod payload;
30
31/// Marker for scopes that display signals
32#[derive(Debug)]
33pub enum PlotScope {}
34/// Marker for scopes that display an image
35#[derive(Debug)]
36pub enum ImageScope {}
37/// Marker for scopes that display an image with a mask applied to it
38#[derive(Debug)]
39pub enum GmtScope {}
40
41/// Scopes marker trait
42pub trait ScopeKind {
43 fn window_size() -> (f32, f32);
44}
45impl ScopeKind for PlotScope {
46 fn window_size() -> (f32, f32) {
47 (800f32, 600f32)
48 }
49}
50impl ScopeKind for ImageScope {
51 fn window_size() -> (f32, f32) {
52 (800f32, 800f32)
53 }
54}
55impl ScopeKind for GmtScope {
56 fn window_size() -> (f32, f32) {
57 (800f32, 900f32)
58 }
59}
60/// Image scopes marker trait
61pub trait ImageScopeKind: ScopeKind {}
62impl ImageScopeKind for ImageScope {}
63impl ImageScopeKind for GmtScope {}
64
65#[cfg(any(feature = "client", doc))]
66pub mod client;
67
68#[cfg(any(feature = "server", doc))]
69pub mod server;