Skip to content

lib-hvac 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793619912/FIN+5.3.1+lib-hvac 中文整理基于 FIN 5.3.1

导读: 暖通空调公用和规则功能

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • funcs
  • def
  • ahuCoolAndEcon(ahu, dates, minTime: 0min)
  • ahuCoolAndHeat(ahu, dates, minTime: 0min)
  • ahuCoolHeatCycling(ahu, dates, minTime: 10min)
  • ahuCoolPeriods(ahu, dates, match: true)
  • ahuEconPeriods(ahu, dates, match: 10..100)
  • ahuFanFailure(ahu, dates, minTime: 0min)
  • ahuFanPeriods(ahu, dates, match: true)
  • ahuHeatAndEcon(ahu, dates, minTime: 0min)
  • ahuHeatPeriods(ahu, dates, match: true)
  • ahuOnAndFanOff(ahu, dates, minTime: 0min)
  • longCycling(point, dates, maxOnTime: 1hr)
  • sensorFailure(point, dates, tolerance: 0.1)
  • shortCycling(point, dates, minOffTime: 10min, minOnTime: 10min)
  • toAhuCool(ahu, checked: true)
  • toAhuDischargeFan(ahu, checked: true)
  • toAhuDischargePressure(ahu, checked: true)
  • toAhuDischargeTemp(ahu, checked: true)
  • toAhuHeat(ahu, checked: true)
  • toAhuMixedTemp(ahu, checked: true)
  • toAhuOutsideDamper(ahu, checked: true)
  • toAhuOutsideTemp(ahu, checked: true)
  • toAhuReturnTemp(ahu, checked: true)
  • toAhuZoneTemp(ahu, checked: true)

概述(中译) ​

暖通空调公用和规则功能


API 正文(英文) ​

funcs ​

ahuCoolAndEconCompute periods when AHU is in both cooling and economizing modes
ahuCoolAndHeatCompute periods when AHU is in both cooling and heating modes
ahuCoolHeatCyclingCompute periods between cooling and heating which do not meeting a min time
ahuCoolPeriodsCompute periods when AHU is in cooling mode or matches given criteria
ahuEconPeriodsCompute periods when AHU is in economizing mode when the damper position is over 10%
ahuFanFailureParams
ahuFanPeriodsCompute periods when AHU's supply fan is running or matches given criteria
ahuHeatAndEconCompute periods when AHU is in both cooling and economizing modes
ahuHeatPeriodsCompute periods when AHU is in heating mode or matches given criteria
ahuOnAndFanOffParams
longCyclingCompute periods when an bool point's on period exceeds maxOnTime Params
sensorFailureCompute periods when a point doesn't change by more than a tolerance
shortCyclingCompute periods when an bool point's on/off periods are not meeting min on/off times
toAhuCoolGiven an ahu rec, get its cool cmd point rec
toAhuDischargeFanGiven an ahu rec, query its discharge fan cmd point rec
toAhuDischargePressureGiven an ahu rec, get its discharge pressure sensor point rec
toAhuDischargeTempGiven an ahu rec, get its discharge temp sensor point rec
toAhuHeatGiven an ahu rec, get its heat cmd point rec
toAhuMixedTempGiven an ahu rec, get its mixed temp sensor point rec
toAhuOutsideDamperGiven an ahu rec, get its outside damper cmd point
toAhuOutsideTempGiven an ahu rec, get its outside temp sensor point rec
toAhuReturnTempGiven an ahu rec, get its return temp sensor point rec
toAhuZoneTempGiven an ahu rec, get its zone temp sensor point rec or throw an exception


def ​

func:ahuCoolAndEcon ​

ahuCoolAndEcon(ahu, dates, minTime: 0min) ​

Compute periods when AHU is in both cooling and economizing modes. See ahuCoolPeriods() and ahuEconPeriods().

Params:

  • ahu: rec or grid of ahu
  • dates: any valid hisRead() date range
  • minTime: minimum duration condition must persist before triggering

Returns:

  • spark periods

meta ​

deffunc:ahuCoolAndEcon
disAHU Cool and Econ
helpUnit is simultaneously running mechanical cooling with t...
isfunc
liblib:hvac
nameahuCoolAndEcon
overridable✓
ruleOnahu
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, minTime: 0min) => do
  // normalize minTime to hours
  minTime = minTime.to(1h)

  // get periods when cooling and heating
  cool: ahuCoolPeriods(ahu, dates)
  econ: ahuEconPeriods(ahu, dates)

  // compute intersection of those periods
  hisPeriodIntersection([cool, econ])
    .findAll(r => r->v0 >= minTime)
 end


def ​

func:ahuCoolAndHeat ​

ahuCoolAndHeat(ahu, dates, minTime: 0min) ​

Compute periods when AHU is in both cooling and heating modes. See ahuCoolPeriods() and ahuHeatPeriods().

Params:

  • ahu: rec or grid of ahu
  • dates: any valid hisRead() date range
  • minTime: minimum duration condition must persist before triggering

Returns:

  • spark periods

meta ​

deffunc:ahuCoolAndHeat
disAHU Cool and Heat
helpUnit is simultaneously running mechanical cooling and me...
isfunc
liblib:hvac
nameahuCoolAndHeat
overridable✓
ruleOnahu
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, minTime: 0min) => do
  // normalize minTime to hours
  minTime = minTime.to(1h)

  // get periods when cooling and heating
  cool: ahuCoolPeriods(ahu, dates)
  heat: ahuHeatPeriods(ahu, dates)

  // compute intersection of those periods
  hisPeriodIntersection([cool, heat])
    .findAll(r => r->v0 >= minTime)
 end


def ​

func:ahuCoolHeatCycling ​

ahuCoolHeatCycling(ahu, dates, minTime: 10min) ​

Compute periods between cooling and heating which do not meeting a min time.

Params:

  • ahu: rec or grid of ahu
  • dates: any valid hisRead() date range
  • minTime: duration for minimum time b/w heating and cooling

Returns:

  • history grid where value columns are durations equip is cycling

meta ​

deffunc:ahuCoolHeatCycling
disAHU Cool/Heat Cycling
helpAHU is cycling between cooling and heating and not meeti...
isfunc
liblib:hvac
nameahuCoolHeatCycling
overridable✓
ruleOnahu
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, minTime: 10min) => do

  // normalize min time to hours
  minTime = minTime.to(1h)

  // find matrix of cooling and heating periods
  cool: ahuCoolPeriods(ahu, dates)
  heat: ahuHeatPeriods(ahu, dates)
  matrix: hisPeriodMatrix([cool, heat])

  // create function to look for periods where both cool+heat
  // overlap or for transitions which don't meet minTime
  matchFunc: (cur, i) => do
    // if this is a period where both cool and heat are
    // running, then definitely consider it a match
    if (cur->numTrue == 2) return true

    // get previous row and next row
    if (i < 1 or i+1 >= matrix.size) return false
    prev: matrix[i - 1]
    next: matrix[i + 1]

    // look for these transitions:
    //   prev    cur    next
    //   ----    ---    ----
    //   cool -> off -> heat
    //   heat -> off -> cool
    // where off duration is less then our min time
    return prev->numTrue > 0 and     // prev: either cool or heat was on
           cur->numTrue == 0 and     // cur: both cool and heat off
           next->numTrue > 0 and     // next: either cool or heat was on
           prev->v0 != next->v0 and  // we made transition from cool<->heat
           cur->dur < minTime        // and off period doesn't meet min time
  end

   // find our matching periods, turn them back into normal ts/dur rows
   matrix.findAll(matchFunc).map(r => {ts: r->ts, v0: r->dur })
end


def ​

func:ahuCoolPeriods ​

ahuCoolPeriods(ahu, dates, match: true) ​

Compute periods when AHU is in cooling mode or matches given criteria. If there are multiple stages of cooling, only stage 1 is considered.

Params:

  • ahu: ahu with toAhuCool() point
  • dates: any valid hisRead() date range
  • match: critera to match via matchPointVal()

Returns:

  • history grid of duration values

meta ​

deffunc:ahuCoolPeriods
disCool Periods
helpPeriods of time when mechanical cooling is active. If m...
isfunc
liblib:hvac
nameahuCoolPeriods
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, match:true) => do
  ahu.toAhuCool.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
end


def ​

func:ahuEconPeriods ​

ahuEconPeriods(ahu, dates, match: 10..100) ​

Compute periods when AHU is in economizing mode when the damper position is over 10%.

Params:

  • ahu: ahu with toAhuOutsideDamper() point
  • dates: any valid hisRead() date range
  • match: critera to match damper via matchPointVal(), default 10% to 100%

Returns:

  • history grid of duration values

meta ​

deffunc:ahuEconPeriods
disEcon Periods
helpPeriods of time when the outside damper is open beyond i...
isfunc
liblib:hvac
nameahuEconPeriods
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, match:10..100) => do
  ahu.toAhuOutsideDamper.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
end


def ​

func:ahuFanFailure ​

ahuFanFailure(ahu, dates, minTime: 0min) ​

Params:

  • ahu: rec or grid of ahu
  • dates: any valid hisRead() date range

Returns:

  • spark periods

meta ​

deffunc:ahuFanFailure
disAHU Fan Failure
helpFan is on but dischargePressure is below threshold of 0....
isfunc
liblib:hvac
nameahuFanFailure
overridable✓
ruleOnahu
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, minTime: 0min) => do
  // normalize minTime to hours
  minTime = minTime.to(1h)

  // get discharge pression and figure out
  // threshold metric or US customary unit
  fan: toAhuDischargeFan(ahu)
  pressure: toAhuDischargePressure(ahu)
  threshold: if (pressure->unit == "kPa") 0.05kPa else 0.25inH₂O

  // points

  fanOn: ahuFanPeriods(ahu, dates)
  pressureOff: hisRead(pressure, dates).hisFindPeriods(p => p < threshold)

  // compute intersection of periods
  hisPeriodIntersection([fanOn, pressureOff])
     .findAll(r => r->v0 >= minTime)
     .addMeta({spark_points: [fan->id, pressure->id]})
 end


def ​

func:ahuFanPeriods ​

ahuFanPeriods(ahu, dates, match: true) ​

Compute periods when AHU's supply fan is running or matches given criteria.

Params:

  • ahu: ahu with toAhuDischargeFan() point
  • dates: any valid hisRead() date range
  • match: critera to match via matchPointVal()

Returns:

  • history grid of duration values

Examples:

// find periods where fan is on or over 0%
read(...).ahuFanPeriods(yesterday)

// find periods where fan is off or 0%
read(...).ahuFanPeriods(2010-08, false)

// find periods where variable speed fan is between 0% to 40%
read(...).ahuFanPeriods(pastWeek, 0..40)

meta ​

deffunc:ahuFanPeriods
disFan Periods
helpPeriods of time when the supply fan is running.
isfunc
liblib:hvac
nameahuFanPeriods
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, match:true) => do
  ahu.toAhuDischargeFan.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
end


def ​

func:ahuHeatAndEcon ​

ahuHeatAndEcon(ahu, dates, minTime: 0min) ​

Compute periods when AHU is in both cooling and economizing modes. See ahuHeatPeriods() and ahuEconPeriods().

Params:

  • ahu: rec or grid of ahu
  • dates: any valid hisRead() date range
  • minTime: minimum duration condition must persist before triggering

Returns:

  • spark periods

meta ​

deffunc:ahuHeatAndEcon
disAHU Heat and Econ
helpUnit is simultaneously running mechanical heating with t...
isfunc
liblib:hvac
nameahuHeatAndEcon
overridable✓
ruleOnahu
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, minTime: 0min) => do
  // normalize minTime to hours
  minTime = minTime.to(1h)

  // get periods when cooling and heating
  heat: ahuHeatPeriods(ahu, dates)
  econ: ahuEconPeriods(ahu, dates)

  // compute intersection of those periods
  hisPeriodIntersection([heat, econ])
    .findAll(r => r->v0 >= minTime)
 end


def ​

func:ahuHeatPeriods ​

ahuHeatPeriods(ahu, dates, match: true) ​

Compute periods when AHU is in heating mode or matches given criteria. If there are multiple stages of heating, only stage 1 is considered.

Params:

  • ahu: ahu with toAhuHeat() point
  • dates: any valid hisRead() date range
  • match: critera to match via matchPointVal()

Returns:

  • history grid of duration values

meta ​

deffunc:ahuHeatPeriods
disHeat Periods
helpPeriods of time when mechanical heating is active. If m...
isfunc
liblib:hvac
nameahuHeatPeriods
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, match:true) => do
  ahu.toAhuHeat.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
end


def ​

func:ahuOnAndFanOff ​

ahuOnAndFanOff(ahu, dates, minTime: 0min) ​

Params:

  • ahu: rec or grid of ahu
  • dates: any valid hisRead() date range
  • minTime: minimum duration condition must persist before triggering

Returns:

  • spark periods

meta ​

deffunc:ahuOnAndFanOff
disAHU On and Fan Off
helpThe unit has some component in the "on" state such as co...
isfunc
liblib:hvac
nameahuOnAndFanOff
overridable✓
ruleOnahu
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, dates, minTime: 0min) => do
  // normalize minTime to hours
  minTime = minTime.to(1h)

  // get our periods
  fanOff: ahuFanPeriods(ahu, dates, false)
  onPeriods: [ahuCoolPeriods(ahu, dates),
              ahuHeatPeriods(ahu, dates)]

  // compute intersection of periods
  hisPeriodIntersection([fanOff, hisPeriodUnion(onPeriods)])
     .findAll(r => r->v0 >= minTime)
end


def ​

func:longCycling ​

longCycling(point, dates, maxOnTime: 1hr) ​

Compute periods when an bool point's on period exceeds maxOnTime

Params:

  • point: rec or grid of Bool point
  • dates: any valid hisRead() date range
  • maxOnTime: duration for max time equip must be on

Returns:

  • history grid where value columns are durations equip is long cycling

meta ​

deffunc:longCycling
disLong Cycling
helpPoint has been continously longer than maxOnTime
isfunc
liblib:hvac
namelongCycling
ruleOnpoint and kind=="Bool"
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(point, dates, maxOnTime: 1hr) => do
  // normalize time to hours
  maxOnTime = maxOnTime.to(1h)

  // find periods when on and filter for those that exceed maxOnTime
  hisRead(point, dates)
    .hisFindPeriods(v => true == v)
    .findAll(row => row->v0 > maxOnTime)

end


def ​

func:sensorFailure ​

sensorFailure(point, dates, tolerance: 0.1) ​

Compute periods when a point doesn't change by more than a tolerance.

Params:

  • point: rec or grid of point
  • dates: any valid hisRead() date range (today always skipped)
  • tolerance: number or 0.1 by default

Returns:

  • history grid where value columns are durations

meta ​

deffunc:sensorFailure
disSensor Failure
helpSensor has failed to change over 24 hour period. Becaus...
isfunc
liblib:hvac
namesensorFailure
ruleOnpoint and kind=="Number" and sensor
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(point, dates, tolerance: 0.1) => do
  hisRead(point, dates)
    .hisRollup(spread, 1day)
    .hisFindPeriods((v, ts) => v != null and v != na() and v.abs < tolerance and ts.date != today())
end


def ​

func:shortCycling ​

shortCycling(point, dates, minOffTime: 10min, minOnTime: 10min) ​

Compute periods when an bool point's on/off periods are not meeting min on/off times.

Params:

  • point: rec or grid of Bool point
  • dates: any valid hisRead() date range
  • minOffTime: duration for minimum time equip must be off
  • minOnTime: duration for minimum time equip must be on

Returns:

  • history grid where value columns are durations equip is short cycling

meta ​

deffunc:shortCycling
disShort Cycling
helpPoint is cycling on/off more often than its min on/off t...
isfunc
liblib:hvac
nameshortCycling
ruleOnpoint and kind=="Bool"
sparkRule✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(point, dates, minOffTime: 10min, minOnTime: 10min) => do

  // normalize min on/off times to hours
  minOffTime = minOffTime.to(1h)
  minOnTime  = minOnTime.to(1h)

  // compute deadband min on/off timestamps
  tsOffDeadband: now() - minOffTime - 1min
  tsOnDeadband:  now() - minOnTime  - 1min

  // find periods not meeting min off time (skip times
  offProblems: hisRead(point, dates)
    .hisFindPeriods(v => (na() != v) and (not v))
    .findAll(row => row->v0 < minOffTime and row->ts < tsOffDeadband)

  // find periods not meeting min on time
  onProblems: hisRead(point, dates)
    .hisFindPeriods(v => true == v)
    .findAll(row => row->v0 < minOnTime and row->ts < tsOnDeadband)

  // return intersection as result
  hisPeriodUnion([offProblems, onProblems])
end


def ​

func:toAhuCool ​

toAhuCool(ahu, checked: true) ​

Given an ahu rec, get its cool cmd point rec. If the AHU has multiple stages of cooling, get first stage only.


meta ​

deffunc:toAhuCool
isfunc
liblib:hvac
nametoAhuCool
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  cools: readAll(cool and cmd and equipRef == ahu->id)

  if (cools.size > 1) cools = cools.findAll(p => p["stage"] == 1)
  if (cools.isEmpty) do
    if (checked) throw "No 'cool' points defined: " + dis(ahu)
    return null
  end
  cools.first
end


def ​

func:toAhuDischargeFan ​

toAhuDischargeFan(ahu, checked: true) ​

Given an ahu rec, query its discharge fan cmd point rec.


meta ​

deffunc:toAhuDischargeFan
isfunc
liblib:hvac
nametoAhuDischargeFan
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  read(discharge and fan and cmd and equipRef == ahu->id, checked)
end


def ​

func:toAhuDischargePressure ​

toAhuDischargePressure(ahu, checked: true) ​

Given an ahu rec, get its discharge pressure sensor point rec.


meta ​

deffunc:toAhuDischargePressure
isfunc
liblib:hvac
nametoAhuDischargePressure
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  read(discharge and pressure and sensor and equipRef == ahu->id, checked)
end


def ​

func:toAhuDischargeTemp ​

toAhuDischargeTemp(ahu, checked: true) ​

Given an ahu rec, get its discharge temp sensor point rec.


meta ​

deffunc:toAhuDischargeTemp
isfunc
liblib:hvac
nametoAhuDischargeTemp
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  read(discharge and temp and sensor and equipRef == ahu->id, checked)
end


def ​

func:toAhuHeat ​

toAhuHeat(ahu, checked: true) ​

Given an ahu rec, get its heat cmd point rec. If the AHU has multiple stages of heating, get first stage only.


meta ​

deffunc:toAhuHeat
isfunc
liblib:hvac
nametoAhuHeat
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  heats: readAll(heat and cmd and equipRef == ahu->id)

  if (heats.size > 1) heats = heats.findAll(p => p["stage"] == 1)
  if (heats.isEmpty) do
    if (checked) throw "No 'heat' points defined: " + dis(ahu)
    return null
  end
  heats.first
end


def ​

func:toAhuMixedTemp ​

toAhuMixedTemp(ahu, checked: true) ​

Given an ahu rec, get its mixed temp sensor point rec .


meta ​

deffunc:toAhuMixedTemp
isfunc
liblib:hvac
nametoAhuMixedTemp
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  read(mixed and temp and sensor and equipRef == ahu->id, checked)
end


def ​

func:toAhuOutsideDamper ​

toAhuOutsideDamper(ahu, checked: true) ​

Given an ahu rec, get its outside damper cmd point.


meta ​

deffunc:toAhuOutsideDamper
isfunc
liblib:hvac
nametoAhuOutsideDamper
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  read(outside and damper and cmd and equipRef == ahu->id, checked)
end


def ​

func:toAhuOutsideTemp ​

toAhuOutsideTemp(ahu, checked: true) ​

Given an ahu rec, get its outside temp sensor point rec. If the AHU doesn't have a direct outside temp point, then fallback to the site's weather temp.


meta ​

deffunc:toAhuOutsideTemp
isfunc
liblib:hvac
nametoAhuOutsideTemp
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  // first try direct
  direct: read(outside and temp and (sensor or in) and equipRef == ahu->id, false)
  if (direct != null) return direct

  // fallback to weather
  w: toWeather(ahu, checked)
  if (w == null) return null
  read(temp and weatherStationRef == w->id, checked)
end


def ​

func:toAhuReturnTemp ​

toAhuReturnTemp(ahu, checked: true) ​

Given an ahu rec, get its return temp sensor point rec.


meta ​

deffunc:toAhuReturnTemp
isfunc
liblib:hvac
nametoAhuReturnTemp
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  read("return" and temp and sensor and equipRef==ahu->id, checked)
end


def ​

func:toAhuZoneTemp ​

toAhuZoneTemp(ahu, checked: true) ​

Given an ahu rec, get its zone temp sensor point rec or throw an exception.


meta ​

deffunc:toAhuZoneTemp
isfunc
liblib:hvac
nametoAhuZoneTemp
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(ahu, checked:true) => do
  read(zone and temp and sensor and equipRef == ahu->id, checked)
end