meta-fii/meta-kudo:  Using Virtual sensor

1- Using Virtual sensor

Signed-off-by: mustafa <mustafa.shehabi@fii-na.com>
Change-Id: Id942cb0a1fb1032589476bc202148f47d1953c6e
Signed-off-by: Mohaimen Alsamarai <mohaimen.alsamarai@fii-na.com>
diff --git a/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/tla2024-enable.service b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/tla2024-enable.service
new file mode 100644
index 0000000..8d42594
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/tla2024-enable.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=TLA2024 change scale property
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/tla2024-enable.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/tla2024-enable.sh b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/tla2024-enable.sh
new file mode 100644
index 0000000..6c5b07a
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/tla2024-enable.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo 2.000000 > /sys/bus/iio/devices/iio:device1/scale
diff --git a/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config.json b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config.json
new file mode 100644
index 0000000..d7b2e44
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config.json
@@ -0,0 +1,64 @@
+[
+    {
+        "Desc":
+        {
+            "Name": "Mobo_NBM1_T",
+            "SensorType": "temperature",
+            "minValue": 0,
+            "maxValue": 160
+        },
+        "Threshold" :
+        {
+            "CriticalHigh": 110,
+            "CriticalLow": 0,
+            "WarningHigh": 108,
+            "WarningLow": 0
+        },
+        "Params":
+        {
+            "DbusParam":
+            [
+                {
+                    "ParamName": "V1",
+                    "Desc":
+                    {
+                        "Name": "Mobo_NBM1_RAW",
+                        "SensorType": "voltage"
+                    }
+                }
+            ]
+        },
+        "Expression": "(V1 - 2.73) * 100"
+    },
+    {
+        "Desc":
+        {
+            "Name": "Mobo_NBM2_T",
+            "SensorType": "temperature",
+            "minValue": 0,
+            "maxValue": 160
+        },
+        "Threshold" :
+        {
+            "CriticalHigh": 110,
+            "CriticalLow": 0,
+            "WarningHigh": 108,
+            "WarningLow": 0
+        },
+        "Params":
+        {
+            "DbusParam":
+            [
+                {
+                    "ParamName": "V2",
+                    "Desc":
+                    {
+                        "Name": "Mobo_NBM2_RAW",
+                        "SensorType": "voltage"
+                    }
+                }
+            ]
+        },
+        "Expression": "(V2 - 2.73) * 100"
+    }
+]
diff --git a/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend
new file mode 100644
index 0000000..43f5f56
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend
@@ -0,0 +1,21 @@
+FILESEXTRAPATHS_prepend_kudo := "${THISDIR}/${PN}:"
+
+inherit systemd
+RDEPENDS_${PN} += "bash"
+SYSTEMD_SERVICE_${PN}_append_kudo = " tla2024-enable.service"
+
+SRC_URI_append_kudo = " \
+    file://virtual_sensor_config.json \
+    file://tla2024-enable.service \
+    file://tla2024-enable.sh \
+    "
+FILES_${PN}_append_kudo = " ${bindir}/tla2024-enable.sh"
+
+do_install_append_kudo() {
+    install -d ${D}${datadir}/${PN}
+    install -m 0644 ${WORKDIR}/virtual_sensor_config.json ${D}${datadir}/${PN}/virtual_sensor_config.json
+    install -m 0755 ${WORKDIR}/tla2024-enable.sh ${D}${bindir}/tla2024-enable.sh
+
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/tla2024-enable.service ${D}${systemd_system_unitdir}/tla2024-enable.service
+}