From ef9692dd7a43e0620632e48ef295da738da50f90 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 27 十月 2021 16:10:15 +0800
Subject: [PATCH] 1. 监测数据根据设备类型不同分别存储不同数据表 2. 车载数据部分监测因子进行量级调整 3. 无人机监测数据部分监测因子由于偏差较大采用车载数据填充 4. 监测数据存储之前先进行平滑预处理,矫正异常值

---
 src/main/kotlin/com/flightfeather/uav/model/BaseWeight.kt |   40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/model/BaseWeight.kt b/src/main/kotlin/com/flightfeather/uav/model/BaseWeight.kt
index 247845c..82e258b 100644
--- a/src/main/kotlin/com/flightfeather/uav/model/BaseWeight.kt
+++ b/src/main/kotlin/com/flightfeather/uav/model/BaseWeight.kt
@@ -1,21 +1,53 @@
 package com.flightfeather.uav.model
 
+import com.flightfeather.uav.lightshare.bean.DataVo
+
 /**
  * 鏉冮噸
  * 鏌愮褰卞搷鍥犵礌鍦ㄤ笉鍚屾儏鍐典笅瀵规煇绉嶇洃娴嬫暟鎹骇鐢熺殑鏉冮噸褰卞搷
  */
-abstract class BaseWeight {
+abstract class BaseWeight <M: BaseMData, S : BaseSOP> {
 
-//    鍖洪棿闃堝��
+    abstract val tag:String
+
+    // 鍖洪棿闃堝��
     abstract val sectionValues: List<Double>
-//    鍖洪棿瀵瑰簲鏉冮噸
+
+    // 鍖洪棿瀵瑰簲鏉冮噸
     abstract val weights: List<Double>
+
+    // 涓婃璁$畻鐨勬潈閲嶅��
+    private var lastWeight = -1.0
+
+    // 鏉冮噸鏄惁鍙樺寲
+    var isChange = true
+
+    fun getWeight(mData: M, sop: S): Double? {
+        if (!isChange) {
+            if (lastWeight < 0) {
+                val v = onWeightFactor(mData, sop) ?: return null
+                lastWeight = weightCal(v)
+            }
+//            println("$tag: $lastWeight")
+            return lastWeight
+        } else {
+            val v = onWeightFactor(mData, sop) ?: return null
+            lastWeight = weightCal(v)
+//            println("$tag: $lastWeight")
+            return lastWeight
+        }
+    }
+
+    /**
+     * 鑾峰彇鏉冮噸鍥犲瓙鍊�
+     */
+    abstract fun onWeightFactor(mData: M, sop: S): Double?
 
     /**
      * 鏉冮噸璁$畻
      * @param value 褰卞搷鍥犵礌鐨勫��
      */
-    fun weightCal(value: Double): Double {
+    private fun weightCal(value: Double): Double {
         for (i in sectionValues.indices) {
             if (value < sectionValues[i]) {
                 return weights[i]

--
Gitblit v1.9.3