diff options
author | Lukasz Woznicki <75632179+makr11st@users.noreply.github.com> | 2021-11-24 20:54:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 20:54:56 +0000 |
commit | a4ffeccf60090e4456755bc53a6e3b8c8038e855 (patch) | |
tree | 9583f187114913a92866571920dd3bb205bd50a3 /crates/core/c8y_translator/examples | |
parent | 8217e80670e76dbf9168780f5e0545355a39f8f3 (diff) |
Restructure directories of the workspace (#559)
* Restructure directories of the workspace
* Rename c8y_translator_lib to c8y_translator
* Update comment on how to get dummy plugin path
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Diffstat (limited to 'crates/core/c8y_translator/examples')
3 files changed, 79 insertions, 0 deletions
diff --git a/crates/core/c8y_translator/examples/multi_value_translation.rs b/crates/core/c8y_translator/examples/multi_value_translation.rs new file mode 100644 index 00000000..22fe5721 --- /dev/null +++ b/crates/core/c8y_translator/examples/multi_value_translation.rs @@ -0,0 +1,28 @@ +use c8y_translator::json::from_thin_edge_json; + +fn multi_value_translation() { + let multi_value_thin_edge_json = r#" { + "temperature": 0 , + "location": { + "latitude": 32.54, + "longitude": -117.67, + "altitude": 98.6 + }, + "pressure": 98 + }"#; + + println!("\nThin_Edge_Json: {:#}", multi_value_thin_edge_json); + let output = from_thin_edge_json(multi_value_thin_edge_json); + match output { + Ok(vec) => { + println!("{:?}", vec); + } + Err(e) => { + eprintln!("Error: {}", e); + } + } +} + +pub fn main() { + multi_value_translation(); +} diff --git a/crates/core/c8y_translator/examples/single_value_translation.rs b/crates/core/c8y_translator/examples/single_value_translation.rs new file mode 100644 index 00000000..ffadd1b0 --- /dev/null +++ b/crates/core/c8y_translator/examples/single_value_translation.rs @@ -0,0 +1,24 @@ +use c8y_translator::json::from_thin_edge_json; + +fn single_value_translation() { + let single_value_thin_edge_json = r#" { + "temperature": 23, + "pressure": 220 + }"#; + + println!("Thin_Edge_Json: \n{:#}", single_value_thin_edge_json); + + let output = from_thin_edge_json(single_value_thin_edge_json); + match output { + Ok(vec) => { + println!("{:?}", vec); + } + Err(e) => { + eprintln!("Error: {}", e); + } + } +} + +pub fn main() { + single_value_translation(); +} diff --git a/crates/core/c8y_translator/examples/translate_to_c8yjson.rs b/crates/core/c8y_translator/examples/translate_to_c8yjson.rs new file mode 100644 index 00000000..4bc568ce --- /dev/null +++ b/crates/core/c8y_translator/examples/translate_to_c8yjson.rs @@ -0,0 +1,27 @@ +use c8y_translator::json::from_thin_edge_json; + +fn thin_edge_translation_with_type_and_timestamp() { + let single_value_thin_edge_json_with_type_and_time = r#" { + "time" : "2013-06-22T17:03:14.100+02:00", + "temperature": 23, + "pressure": 220 + }"#; + + println!( + "\nThin_Edge_Json: \n{:#}", + single_value_thin_edge_json_with_type_and_time + ); + let output = from_thin_edge_json(single_value_thin_edge_json_with_type_and_time); + match output { + Ok(vec) => { + println!("{:?}", vec); + } + Err(e) => { + eprintln!("Error: {}", e); + } + } +} + +pub fn main() { + thin_edge_translation_with_type_and_timestamp(); +} |