Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/connectors-advantech-atim #15

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions decoders/connector/advantech/wise-2410/connector.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "../../../../schema/connector.json",
"name": "Advantech WISE-2410",
"images": {
"logo": "./assets/logo.png"
},
"versions": {
"v1.0.0": {
"src": "./v1.0.0/payload.js",
"manifest": "./v1.0.0/payload-config.jsonc"
}
}
}
1 change: 1 addition & 0 deletions decoders/connector/advantech/wise-2410/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Industrial smart sensor with accelerometer and temperature sensors over LoRaWAN™
25 changes: 25 additions & 0 deletions decoders/connector/advantech/wise-2410/v1.0.0/payload-config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "../../../../../schema/connector_details.json",
"description": "../description.md",
"install_text": "WISE-2410 is a LoRaWAN wireless condition monitoring sensor integrated with an ARM Cortex-M4 processor, LoRa transceiver, 3-axis accelerometer and temperature sensor. It balances the wireless bandwidth between WISE-2410 and the gateway, so it also mitigates the data transmission fail rates between edge-devices and gateways.\n\nFeatures: \n* LoRaWAN wireless connectivity\n* Built-in 3-axis accelerometer and temperature sensor\n* On-board computing. Directly sends VRMS, ARMS, Peak, Displacement, Kurtosis, Crest factor, Skewness and Standard Deviation values to applications\n* Support battery power supply, no wiring installation needed\n* Easy settings with user friendly interfaces on WISE Studio utility\n* ISO 10816-1 compliant\n* Support wide temperature -20 ~ 80 °C (Battery-powered)\n* IP66 enclosure design\n\n \nProduct Website:\n* https://www.advantech.com/pt-br/products/b7e2306f-d561-4ca9-b0e3-33f7057e185f/wise-2410/mod_25018dc7-355c-40b4-bf9b-c93f6c73f1a0",
"install_end_text": "# Advantech WISE-2410 Dashboard Template\n\n\n\n![Template Image](https://api.tago.io/file/5bbcb03b667d7a002e56664b/advantech/smallwise2410dashimg.png)\n\n\n\nInstall the dashboard template by clicking [here](https://admin.tago.io/template/660beb6c2bbc8d00091dd697).",
"device_annotation": "Install the dashboard template by clicking [here](https://admin.tago.io/template/660beb6c2bbc8d00091dd697).",
"device_parameters": [],
"networks": [
"../../../../network/lorawan-actility/v1.0.0/payload.js",
"../../../../network/lorawan-brdot-/v1.0.0/payload.js",
"../../../../network/lorawan-chirpstack/v1.0.0/payload.js",
"../../../../network/lorawan-citykinect/v1.0.0/payload.js",
"../../../../network/lorawan-everynet/v1.0.0/payload.js",
"../../../../network/lorawan-helium/v1.0.0/payload.js",
"../../../../network/lorawan-kerlink/v1.0.0/payload.js",
"../../../../network/lorawan-loriot-/v1.0.0/payload.js",
"../../../../network/lorawan-machineq/v1.0.0/payload.js",
"../../../../network/lorawan-orbiwise/v1.0.0/payload.js",
"../../../../network/lorawan-senet/v1.0.0/payload.js",
"../../../../network/lorawan-senra/v1.0.0/payload.js",
"../../../../network/lorawan-swisscom/v1.0.0/payload.js",
"../../../../network/lorawan-tektelic/v1.0.0/payload.js",
"../../../../network/lorawan-ttittn-v3/v1.0.0/payload.js"
]
}
153 changes: 153 additions & 0 deletions decoders/connector/advantech/wise-2410/v1.0.0/payload.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { describe, test, expect } from "vitest";
import { decoderRun } from "../../../../../src/functions/decoder-run";

const file_path = "decoders/connector/advantech/wise-2410/v1.0.0/payload.ts" as const;

function preparePayload(payloadHex) {
let payload = [{ variable: "payload", value: payloadHex }];
payload = decoderRun(file_path, { payload });
//y axis
const accelerometer_y_axis_senevent = payload.find((item) => item.variable === "accelerometer_y_axis_senevent");
const accelerometer_y_axis_crestfactor = payload.find((item) => item.variable === "accelerometer_y_axis_crestfactor");
const accelerometer_y_axis_kurtosis = payload.find((item) => item.variable === "accelerometer_y_axis_kurtosis");
const accelerometer_y_axis_rms = payload.find((item) => item.variable === "accelerometer_y_axis_rms");
const accelerometer_y_axis_peak = payload.find((item) => item.variable === "accelerometer_y_axis_peak");
const accelerometer_y_axis_oavelocity = payload.find((item) => item.variable === "accelerometer_y_axis_oavelocity");
const accelerometer_y_axis_skewness = payload.find((item) => item.variable === "accelerometer_y_axis_skewness");
const accelerometer_y_axis_deviation = payload.find((item) => item.variable === "accelerometer_y_axis_deviation");
const accelerometer_y_axis_peak_to_peak_displacement = payload.find((item) => item.variable === "accelerometer_y_axis_peak_to_peak_displacement");
//x axis
const accelerometer_x_axis_senevent = payload.find((item) => item.variable === "accelerometer_x_axis_senevent");
const accelerometer_x_axis_crestfactor = payload.find((item) => item.variable === "accelerometer_x_axis_crestfactor");
const accelerometer_x_axis_kurtosis = payload.find((item) => item.variable === "accelerometer_x_axis_kurtosis");
const accelerometer_x_axis_rms = payload.find((item) => item.variable === "accelerometer_x_axis_rms");
const accelerometer_x_axis_peak = payload.find((item) => item.variable === "accelerometer_x_axis_peak");
const accelerometer_x_axis_oavelocity = payload.find((item) => item.variable === "accelerometer_x_axis_oavelocity");
const accelerometer_x_axis_skewness = payload.find((item) => item.variable === "accelerometer_x_axis_skewness");
const accelerometer_x_axis_deviation = payload.find((item) => item.variable === "accelerometer_x_axis_deviation");
const accelerometer_x_axis_peak_to_peak_displacement = payload.find((item) => item.variable === "accelerometer_x_axis_peak_to_peak_displacement");
//z axis
const accelerometer_z_axis_senevent = payload.find((item) => item.variable === "accelerometer_z_axis_senevent");
const accelerometer_z_axis_crestfactor = payload.find((item) => item.variable === "accelerometer_z_axis_crestfactor");
const accelerometer_z_axis_kurtosis = payload.find((item) => item.variable === "accelerometer_z_axis_kurtosis");
const accelerometer_z_axis_rms = payload.find((item) => item.variable === "accelerometer_z_axis_rms");
const accelerometer_z_axis_peak = payload.find((item) => item.variable === "accelerometer_z_axis_peak");
const accelerometer_z_axis_oavelocity = payload.find((item) => item.variable === "accelerometer_z_axis_oavelocity");
const accelerometer_z_axis_skewness = payload.find((item) => item.variable === "accelerometer_z_axis_skewness");
const accelerometer_z_axis_deviation = payload.find((item) => item.variable === "accelerometer_z_axis_deviation");
const accelerometer_z_axis_peak_to_peak_displacement = payload.find((item) => item.variable === "accelerometer_z_axis_peak_to_peak_displacement");

const temphumi_senval = payload.find((item) => item.variable === "temphumi_senval");
const temphumi_event = payload.find((item) => item.variable === "temphumi_event");
const temphumi_status = payload.find((item) => item.variable === "temphumi_status");
const temphumi_range = payload.find((item) => item.variable === "temphumi_range");

const accelerometer_time = payload.find((item) => item.variable === "accelerometer_time");
const accelerometer_logindex = payload.find((item) => item.variable === "accelerometer_logindex");
const device_batteryvolt = payload.find((item) => item.variable === "device_batteryvolt");
const device_powersrc = payload.find((item) => item.variable === "device_powersrc");
const device_events = payload.find((item) => item.variable === "device_events");

const parse_error = payload.find((item) => item.variable === "parse_error");
return {
payload,
accelerometer_y_axis_senevent,
accelerometer_y_axis_crestfactor,
accelerometer_y_axis_kurtosis,
accelerometer_y_axis_rms,
accelerometer_y_axis_peak,
accelerometer_y_axis_oavelocity,
accelerometer_y_axis_skewness,
accelerometer_y_axis_deviation,
accelerometer_y_axis_peak_to_peak_displacement,
accelerometer_x_axis_senevent,
accelerometer_x_axis_crestfactor,
accelerometer_x_axis_kurtosis,
accelerometer_x_axis_rms,
accelerometer_x_axis_peak,
accelerometer_x_axis_oavelocity,
accelerometer_x_axis_peak_to_peak_displacement,
accelerometer_x_axis_skewness,
accelerometer_x_axis_deviation,
accelerometer_z_axis_senevent,
accelerometer_z_axis_crestfactor,
accelerometer_z_axis_kurtosis,
accelerometer_z_axis_rms,
accelerometer_z_axis_peak,
accelerometer_z_axis_oavelocity,
accelerometer_z_axis_peak_to_peak_displacement,
accelerometer_z_axis_skewness,
accelerometer_z_axis_deviation,
temphumi_senval,
temphumi_event,
temphumi_status,
temphumi_range,
accelerometer_time,
accelerometer_logindex,
device_batteryvolt,
device_powersrc,
device_events,
parse_error,
};
}

describe("Axis", () => {
test("should decode the payload correctly", () => {
const payloadHex = "817a585008070000001e7800005441e2ff0000100015000f000c0007021b000200040000001f001a001300feff9d011d000200090000001a001a001300f4ff8b01fbff0200070003000000000f6c016660091b00010000106c016696";
const result = preparePayload(payloadHex);

expect(result.accelerometer_y_axis_senevent?.value).toBe(0);
expect(result.accelerometer_y_axis_crestfactor?.value).toBe(4.13);
expect(result.accelerometer_y_axis_kurtosis?.value).toBe(-0.02);
expect(result.accelerometer_y_axis_rms?.value).toBe(0.019);
expect(result.accelerometer_y_axis_peak?.value).toBe(0.026);
expect(result.accelerometer_y_axis_oavelocity?.value).toBe(0.31);
expect(result.accelerometer_y_axis_skewness?.value).toBe(0.29);
expect(result.accelerometer_y_axis_deviation?.value).toBe(0.02);
expect(result.accelerometer_y_axis_peak_to_peak_displacement?.value).toBe(9);

expect(result.accelerometer_x_axis_senevent?.value).toBe(0);
expect(result.accelerometer_x_axis_crestfactor?.value).toBe(5.19);
expect(result.accelerometer_x_axis_kurtosis?.value).toBe(0.12);
expect(result.accelerometer_x_axis_rms?.value).toBe(0.015);
expect(result.accelerometer_x_axis_peak?.value).toBe(0.021);
expect(result.accelerometer_x_axis_oavelocity?.value).toBe(0.16);
expect(result.accelerometer_x_axis_skewness?.value).toBe(0.27);
expect(result.accelerometer_x_axis_deviation?.value).toBe(0.02);
expect(result.accelerometer_x_axis_peak_to_peak_displacement?.value).toBe(4);

expect(result.accelerometer_z_axis_senevent?.value).toBe(0);
expect(result.accelerometer_z_axis_crestfactor?.value).toBe(3.95);
expect(result.accelerometer_z_axis_kurtosis?.value).toBe(-0.12);
expect(result.accelerometer_z_axis_rms?.value).toBe(0.019);
expect(result.accelerometer_z_axis_peak?.value).toBe(0.026);
expect(result.accelerometer_z_axis_oavelocity?.value).toBe(0.26);
expect(result.accelerometer_z_axis_skewness?.value).toBe(-0.05);
expect(result.accelerometer_z_axis_deviation?.value).toBe(0.02);
expect(result.accelerometer_z_axis_peak_to_peak_displacement?.value).toBe(7);

expect(result.temphumi_senval?.value).toBe(30.75);
expect(result.temphumi_event?.value).toBe(0);
expect(result.temphumi_status?.value).toBe(0);
expect(result.temphumi_range?.value).toBe(0);

expect(result.accelerometer_time?.value).toBe(1711369231);
expect(result.accelerometer_logindex?.value).toBe(0);
expect(result.device_batteryvolt?.value).toBe(0);
expect(result.device_powersrc?.value).toBe(1);
expect(result.device_events?.value).toBe(0);
});
});

describe("Shall not be parsed", () => {
let payload = [{ variable: "shallnotpass", value: "04096113950292" }];
payload = decoderRun(file_path, { payload });

test("Output Result", () => {
expect(Array.isArray(payload)).toBe(true);
});

test("Not parsed Result", () => {
expect(payload).toEqual([{ variable: "shallnotpass", value: "04096113950292" }]);
});
});
Loading