src/StorageItemPM_Hs.scala
1package cn.piflow.bundle.flux.dataCorrection
2
3
4import cn.piflow.bundle.flux.util.PM_HS
5import cn.piflow.conf.bean.PropertyDescriptor
6import cn.piflow.conf.util.{ImageUtil, MapUtil}
7import cn.piflow.conf.{ConfigurableStop, Port}
8import cn.piflow.{JobContext, JobInputStream, JobOutputStream, ProcessContext}
9import org.apache.spark.sql.SparkSession
10
11/**
12 * 存储项校正计算,廓线法(PMCheck)利用配 套的廓线系统获取的分层 CO2、H2O 浓度、温度数据计算存储项
13 *
14 * @Author renhao
15 * @Description:
16 * @Data 2023/2/27 16:08
17 * @Modified By:
18 */
19class StorageItemPM_Hs extends ConfigurableStop{
20
21 override val authorEmail: String = "rh@cnic.cn"
22 override val description: String = "Hs : Stored item correction by PMCheck"
23 val inportList: List[String] = List("fluxCbsPort","metroCbsPort")
24 override val outportList: List[String] = List(Port.DefaultPort)
25
26 var equipmentHeightDifference:String = _
27 var Hs:String = _
28 var everyTaFields: String = _
29 var time_interval:String = _
30 var rho_a_Avg :String = _
31
32 override def perform(in: JobInputStream, out: JobOutputStream, pec: JobContext): Unit = {
33 val spark = pec.get[SparkSession]()
34
35 val fluxCBS = in.read("fluxCbsPort")
36 val metroCBS = in.read("metroCbsPort")
37
38 val pm = new PM_HS
39
40// val time_nterval = 1800
41 val CP: Double = 1004.67
42
43 val arrayH = equipmentHeightDifference.split(",").map(_.toString.toDouble).toList
44 val arrayHS = everyTaFields.split(",").map(_.toString).toList
45 val df = pm.calculateStoredItem(spark,fluxCBS,metroCBS,arrayH , Hs, arrayHS, time_interval.toInt,CP,rho_a_Avg )
46
47 out.write(df)
48 }
49
50
51 override def setProperties(map: Map[String, Any]): Unit = {
52
53 equipmentHeightDifference = MapUtil.get(map, "equipmentHeightDifference").asInstanceOf[String]
54 Hs = MapUtil.get(map, "Hs").asInstanceOf[String]
55 everyTaFields = MapUtil.get(map, "everyTaFields").asInstanceOf[String]
56 time_interval = MapUtil.get(map, "time_interval").asInstanceOf[String]
57 rho_a_Avg = MapUtil.get(map, "rho_a_Avg").asInstanceOf[String]
58 }
59
60 override def getPropertyDescriptor(): List[PropertyDescriptor] = {
61 var descriptor: List[PropertyDescriptor] = List()
62
63 val equipmentHeightDifference = new PropertyDescriptor()
64 .name("equipmentHeightDifference")
65 .displayName("equipmentHeightDifference")
66 .description("通量设备安装高度差,自第一层开始:Height of each layer of contour line")
67 .defaultValue("0.0, 1.0, 6.0, 4.0, 4.0, 8.0, 8.0")
68 .required(true)
69 .example("0.0, 1.0, 6.0, 4.0, 4.0, 8.0, 8.0")
70 descriptor = equipmentHeightDifference :: descriptor
71
72 val Hs = new PropertyDescriptor()
73 .name("Hs")
74 .displayName("Hs")
75 .description("Hs flux field name")
76 .defaultValue("Hs")
77 .required(true)
78 .example("Hs")
79 descriptor = Hs :: descriptor
80
81 val rho_a_Avg = new PropertyDescriptor()
82 .name("rho_a_Avg")
83 .displayName("rho_a_Avg")
84 .description("平均空气密度:rho_a_Avg")
85 .defaultValue("rho_a_Avg")
86 .required(true)
87 .example("")
88 descriptor = rho_a_Avg :: descriptor
89
90 val everyTaFields = new PropertyDescriptor()
91 .name("everyTaFields")
92 .displayName("everyTaFields")
93 .description("各层平均温度:temperature concentration of each layer")
94 .defaultValue("Ta_1_AVG,Ta_2_AVG,Ta_3_AVG,Ta_4_AVG,Ta_5_AVG,Ta_6_AVG,Ta_7_AVG")
95 .required(true)
96 .example("")
97 descriptor = everyTaFields :: descriptor
98
99 val time_interval = new PropertyDescriptor()
100 .name("time_interval")
101 .displayName("time_interval")
102 .description("time interval")
103 .defaultValue("1800")
104 .required(true)
105 .example("1800")
106 descriptor = time_interval :: descriptor
107
108 descriptor
109 }
110
111 override def getIcon(): Array[Byte] = {
112 ImageUtil.getImage("png/Flux/flux.png",this.getClass.getName)
113 }
114
115 override def getGroup(): List[String] = {
116 List("Flux_dataCorrection")
117 }
118
119 override def initialize(ctx: ProcessContext): Unit = {
120
121 }
122
123
124
125
126
127}