外观
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)
- supertypes
- src
- 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
| ahuCoolAndEcon | Compute periods when AHU is in both cooling and economizing modes |
| ahuCoolAndHeat | Compute periods when AHU is in both cooling and heating modes |
| ahuCoolHeatCycling | Compute periods between cooling and heating which do not meeting a min time |
| ahuCoolPeriods | Compute periods when AHU is in cooling mode or matches given criteria |
| ahuEconPeriods | Compute periods when AHU is in economizing mode when the damper position is over 10% |
| ahuFanFailure | Params |
| ahuFanPeriods | Compute periods when AHU's supply fan is running or matches given criteria |
| ahuHeatAndEcon | Compute periods when AHU is in both cooling and economizing modes |
| ahuHeatPeriods | Compute periods when AHU is in heating mode or matches given criteria |
| ahuOnAndFanOff | Params |
| longCycling | Compute periods when an bool point's on period exceeds maxOnTime Params |
| sensorFailure | Compute periods when a point doesn't change by more than a tolerance |
| shortCycling | Compute periods when an bool point's on/off periods are not meeting min on/off times |
| toAhuCool | Given an ahu rec, get its cool cmd point rec |
| toAhuDischargeFan | Given an ahu rec, query its discharge fan cmd point rec |
| toAhuDischargePressure | Given an ahu rec, get its discharge pressure sensor point rec |
| toAhuDischargeTemp | Given an ahu rec, get its discharge temp sensor point rec |
| toAhuHeat | Given an ahu rec, get its heat cmd point rec |
| toAhuMixedTemp | Given an ahu rec, get its mixed temp sensor point rec |
| toAhuOutsideDamper | Given an ahu rec, get its outside damper cmd point |
| toAhuOutsideTemp | Given an ahu rec, get its outside temp sensor point rec |
| toAhuReturnTemp | Given an ahu rec, get its return temp sensor point rec |
| toAhuZoneTemp | Given 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
| def | func:ahuCoolAndEcon |
| dis | AHU Cool and Econ |
| help | Unit is simultaneously running mechanical cooling with t... |
| is | func |
| lib | lib:hvac |
| name | ahuCoolAndEcon |
| overridable | ✓ |
| ruleOn | ahu |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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)
enddef
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
| def | func:ahuCoolAndHeat |
| dis | AHU Cool and Heat |
| help | Unit is simultaneously running mechanical cooling and me... |
| is | func |
| lib | lib:hvac |
| name | ahuCoolAndHeat |
| overridable | ✓ |
| ruleOn | ahu |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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)
enddef
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
| def | func:ahuCoolHeatCycling |
| dis | AHU Cool/Heat Cycling |
| help | AHU is cycling between cooling and heating and not meeti... |
| is | func |
| lib | lib:hvac |
| name | ahuCoolHeatCycling |
| overridable | ✓ |
| ruleOn | ahu |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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 })
enddef
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:
ahuwithtoAhuCool()point - dates: any valid
hisRead()date range - match: critera to match via
matchPointVal()
Returns:
- history grid of duration values
meta
| def | func:ahuCoolPeriods |
| dis | Cool Periods |
| help | Periods of time when mechanical cooling is active. If m... |
| is | func |
| lib | lib:hvac |
| name | ahuCoolPeriods |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, dates, match:true) => do
ahu.toAhuCool.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
enddef
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:
ahuwithtoAhuOutsideDamper()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
| def | func:ahuEconPeriods |
| dis | Econ Periods |
| help | Periods of time when the outside damper is open beyond i... |
| is | func |
| lib | lib:hvac |
| name | ahuEconPeriods |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, dates, match:10..100) => do
ahu.toAhuOutsideDamper.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
enddef
func:ahuFanFailure
ahuFanFailure(ahu, dates, minTime: 0min)
Params:
- ahu: rec or grid of
ahu - dates: any valid
hisRead()date range
Returns:
- spark periods
meta
| def | func:ahuFanFailure |
| dis | AHU Fan Failure |
| help | Fan is on but dischargePressure is below threshold of 0.... |
| is | func |
| lib | lib:hvac |
| name | ahuFanFailure |
| overridable | ✓ |
| ruleOn | ahu |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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]})
enddef
func:ahuFanPeriods
ahuFanPeriods(ahu, dates, match: true)
Compute periods when AHU's supply fan is running or matches given criteria.
Params:
- ahu:
ahuwithtoAhuDischargeFan()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
| def | func:ahuFanPeriods |
| dis | Fan Periods |
| help | Periods of time when the supply fan is running. |
| is | func |
| lib | lib:hvac |
| name | ahuFanPeriods |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, dates, match:true) => do
ahu.toAhuDischargeFan.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
enddef
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
| def | func:ahuHeatAndEcon |
| dis | AHU Heat and Econ |
| help | Unit is simultaneously running mechanical heating with t... |
| is | func |
| lib | lib:hvac |
| name | ahuHeatAndEcon |
| overridable | ✓ |
| ruleOn | ahu |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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)
enddef
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:
ahuwithtoAhuHeat()point - dates: any valid
hisRead()date range - match: critera to match via
matchPointVal()
Returns:
- history grid of duration values
meta
| def | func:ahuHeatPeriods |
| dis | Heat Periods |
| help | Periods of time when mechanical heating is active. If m... |
| is | func |
| lib | lib:hvac |
| name | ahuHeatPeriods |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, dates, match:true) => do
ahu.toAhuHeat.hisRead(dates).hisFindPeriods(matchPointVal(_, match))
enddef
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
| def | func:ahuOnAndFanOff |
| dis | AHU On and Fan Off |
| help | The unit has some component in the "on" state such as co... |
| is | func |
| lib | lib:hvac |
| name | ahuOnAndFanOff |
| overridable | ✓ |
| ruleOn | ahu |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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)
enddef
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
| def | func:longCycling |
| dis | Long Cycling |
| help | Point has been continously longer than maxOnTime |
| is | func |
| lib | lib:hvac |
| name | longCycling |
| ruleOn | point and kind=="Bool" |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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)
enddef
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
| def | func:sensorFailure |
| dis | Sensor Failure |
| help | Sensor has failed to change over 24 hour period. Becaus... |
| is | func |
| lib | lib:hvac |
| name | sensorFailure |
| ruleOn | point and kind=="Number" and sensor |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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())
enddef
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
| def | func:shortCycling |
| dis | Short Cycling |
| help | Point is cycling on/off more often than its min on/off t... |
| is | func |
| lib | lib:hvac |
| name | shortCycling |
| ruleOn | point and kind=="Bool" |
| sparkRule | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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])
enddef
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
| def | func:toAhuCool |
| is | func |
| lib | lib:hvac |
| name | toAhuCool |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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
enddef
func:toAhuDischargeFan
toAhuDischargeFan(ahu, checked: true)
Given an ahu rec, query its discharge fan cmd point rec.
meta
| def | func:toAhuDischargeFan |
| is | func |
| lib | lib:hvac |
| name | toAhuDischargeFan |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, checked:true) => do
read(discharge and fan and cmd and equipRef == ahu->id, checked)
enddef
func:toAhuDischargePressure
toAhuDischargePressure(ahu, checked: true)
Given an ahu rec, get its discharge pressure sensor point rec.
meta
| def | func:toAhuDischargePressure |
| is | func |
| lib | lib:hvac |
| name | toAhuDischargePressure |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, checked:true) => do
read(discharge and pressure and sensor and equipRef == ahu->id, checked)
enddef
func:toAhuDischargeTemp
toAhuDischargeTemp(ahu, checked: true)
Given an ahu rec, get its discharge temp sensor point rec.
meta
| def | func:toAhuDischargeTemp |
| is | func |
| lib | lib:hvac |
| name | toAhuDischargeTemp |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, checked:true) => do
read(discharge and temp and sensor and equipRef == ahu->id, checked)
enddef
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
| def | func:toAhuHeat |
| is | func |
| lib | lib:hvac |
| name | toAhuHeat |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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
enddef
func:toAhuMixedTemp
toAhuMixedTemp(ahu, checked: true)
Given an ahu rec, get its mixed temp sensor point rec .
meta
| def | func:toAhuMixedTemp |
| is | func |
| lib | lib:hvac |
| name | toAhuMixedTemp |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, checked:true) => do
read(mixed and temp and sensor and equipRef == ahu->id, checked)
enddef
func:toAhuOutsideDamper
toAhuOutsideDamper(ahu, checked: true)
Given an ahu rec, get its outside damper cmd point.
meta
| def | func:toAhuOutsideDamper |
| is | func |
| lib | lib:hvac |
| name | toAhuOutsideDamper |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, checked:true) => do
read(outside and damper and cmd and equipRef == ahu->id, checked)
enddef
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
| def | func:toAhuOutsideTemp |
| is | func |
| lib | lib:hvac |
| name | toAhuOutsideTemp |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon 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)
enddef
func:toAhuReturnTemp
toAhuReturnTemp(ahu, checked: true)
Given an ahu rec, get its return temp sensor point rec.
meta
| def | func:toAhuReturnTemp |
| is | func |
| lib | lib:hvac |
| name | toAhuReturnTemp |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, checked:true) => do
read("return" and temp and sensor and equipRef==ahu->id, checked)
enddef
func:toAhuZoneTemp
toAhuZoneTemp(ahu, checked: true)
Given an ahu rec, get its zone temp sensor point rec or throw an exception.
meta
| def | func:toAhuZoneTemp |
| is | func |
| lib | lib:hvac |
| name | toAhuZoneTemp |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(ahu, checked:true) => do
read(zone and temp and sensor and equipRef == ahu->id, checked)
end