Source code

Download source archive ↓

src/StorageItemPM_LE.scala

1package cn.piflow.bundle.flux.dataCorrection
2
3
4import cn.piflow.bundle.flux.util.PM_LE
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_LE extends ConfigurableStop{
20
21  override val authorEmail: String = "rh@cnic.cn"
22  override val description: String = "LE : 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 LE:String = _
28  var everyPvaporFields: String = _
29  var everyTaFields: String = _
30  var time_interval: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_LE
39
40//    val time_nterval = 1800
41    val Lv: Double = 2440.0
42
43    val arrayH = equipmentHeightDifference.split(",").map(_.toString.toDouble).toList
44    val arrayLE = everyPvaporFields.split(",").map(_.toString).toList
45    val arrayHS = everyTaFields.split(",").map(_.toString).toList
46    val df = pm.calculateStoredItem(spark,fluxCBS,metroCBS,arrayH , LE, arrayLE, arrayHS, time_interval.toInt,Lv )
47
48    out.write(df)
49  }
50
51
52  override def setProperties(map: Map[String, Any]): Unit = {
53
54    equipmentHeightDifference = MapUtil.get(map, "equipmentHeightDifference").asInstanceOf[String]
55    LE = MapUtil.get(map, "LE").asInstanceOf[String]
56    everyPvaporFields = MapUtil.get(map, "everyPvaporFields").asInstanceOf[String]
57    everyTaFields = MapUtil.get(map, "everyTaFields").asInstanceOf[String]
58    time_interval = MapUtil.get(map, "time_interval").asInstanceOf[String]
59  }
60
61  override def getPropertyDescriptor(): List[PropertyDescriptor] = {
62    var descriptor: List[PropertyDescriptor] = List()
63
64    val equipmentHeightDifference = new PropertyDescriptor()
65      .name("equipmentHeightDifference")
66      .displayName("equipmentHeightDifference")
67      .description("通量设备安装高度差:Height of each layer of contour line")
68      .defaultValue("0.0, 1.0, 6.0, 4.0, 4.0, 8.0, 8.0")
69      .required(true)
70      .example("0.0, 1.0, 6.0, 4.0, 4.0, 8.0, 8.0")
71    descriptor = equipmentHeightDifference :: descriptor
72
73    val LE = new PropertyDescriptor()
74      .name("LE")
75      .displayName("LE")
76      .description("LE flux field name")
77      .defaultValue("LE")
78      .required(true)
79      .example("LE")
80    descriptor = LE :: descriptor
81
82    val everyPvaporFields = new PropertyDescriptor()
83      .name("everyPvaporFields")
84      .displayName("everyPvaporFields")
85      .description("各层水汽压:H2O concentration of each layer")
86      .defaultValue("Pvapor_1_AVG,Pvapor_2_AVG,Pvapor_3_AVG,Pvapor_4_AVG,Pvapor_5_AVG,Pvapor_6_AVG,Pvapor_7_AVG")
87      .required(true)
88      .example("")
89    descriptor = everyPvaporFields :: descriptor
90
91    val everyTaFields = new PropertyDescriptor()
92      .name("everyTaFields")
93      .displayName("everyTaFields")
94      .description("各层平均温度:temperature concentration of each layer")
95      .defaultValue("Ta_1_AVG,Ta_2_AVG,Ta_3_AVG,Ta_4_AVG,Ta_5_AVG,Ta_6_AVG,Ta_7_AVG")
96      .required(true)
97      .example("")
98    descriptor = everyTaFields :: descriptor
99
100    val time_interval = new PropertyDescriptor()
101      .name("time_interval")
102      .displayName("time_interval")
103      .description("time interval")
104      .defaultValue("1800")
105      .required(true)
106      .example("1800")
107    descriptor = time_interval :: descriptor
108
109    descriptor
110  }
111
112  override def getIcon(): Array[Byte] = {
113    ImageUtil.getImage("png/Flux/flux.png",this.getClass.getName)
114  }
115
116  override def getGroup(): List[String] = {
117    List("Flux_dataCorrection")
118  }
119
120  override def initialize(ctx: ProcessContext): Unit = {
121
122  }
123
124
125
126
127
128}