Skip to content

Commit

Permalink
Merge pull request #384 from cailloumajor/tag-container-reference-typ…
Browse files Browse the repository at this point in the history
…e-organizes

Tag container reference type organizes
  • Loading branch information
cailloumajor authored Sep 13, 2023
2 parents ed03e39 + 9aed8ea commit ea62eef
Show file tree
Hide file tree
Showing 14 changed files with 841 additions and 784 deletions.
5 changes: 5 additions & 0 deletions integration/config-api/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"namespaceUri": "http://opcfoundation.org/UA/",
"nodeIdentifier": 2256
},
{
"type": "container",
"namespaceUri": "http://microsoft.com/Opc/OpcPlc/",
"nodeIdentifier": "Basic"
},
{
"type": "tag",
"name": "slowNumberOfUpdates",
Expand Down
16 changes: 11 additions & 5 deletions integration/tests.mongodb
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ result = db.data.findOne(
{
state: "$val.State",
slowNumberOfUpdates: "$val.slowNumberOfUpdates",
alternatingBoolean: "$val.AlternatingBoolean",
randomUnsignedInt32: "$val.RandomUnsignedInt32",
timeDiff: {
$abs: {
$subtract: [
{ $dateFromString: { dateString: "$val.CurrentTime" } },
{ $dateFromString: { dateString: "$val.StartTime" } }
]
}
{ $dateFromString: { dateString: "$val.StartTime" } },
],
},
},
timestampDiff: {
$dateDiff: {
startDate: "$ts.State",
endDate: "$$NOW",
unit: "millisecond"
}
unit: "millisecond",
},
},
}
);
Expand All @@ -33,6 +35,10 @@ assert.equal(result.state, 0);

assert.equal(result.slowNumberOfUpdates, -1);

assert.equal(typeof result.alternatingBoolean, "boolean");

assert.ok(result.randomUnsignedInt32 > 0);

assert.ok(result.timeDiff > 0);

assert.ok(result.timestampDiff > 0);
9 changes: 8 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
use anyhow::{anyhow, Context as _};
use serde::Deserialize;
use tracing::{debug, info, instrument};
use url::Url;

use crate::model::ConfigFromApi;
use crate::opcua::TagsConfigGroup;

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ConfigFromApi {
pub(crate) tags: Vec<TagsConfigGroup>,
}

#[instrument(skip_all)]
pub(crate) async fn fetch_config(api_url: &Url, partner_id: &str) -> anyhow::Result<ConfigFromApi> {
Expand Down
2 changes: 1 addition & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tracing::{debug, error, info, info_span, instrument, Instrument};

use opcua_proxy::{DATABASE, OPCUA_DATA_COLL, OPCUA_HEALTH_COLL};

use crate::model::TagChange;
use crate::opcua::TagChange;

const VALUES_KEY: &str = "val";
const TIMESTAMPS_KEY: &str = "ts";
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use url::Url;
mod config;
mod db;
mod level_filter;
mod model;
mod opcua;
mod variant;

use config::fetch_config;
use db::MongoDBDatabase;
Expand Down
39 changes: 0 additions & 39 deletions src/model.rs

This file was deleted.

Loading

0 comments on commit ea62eef

Please sign in to comment.