外观
lib-tariff 库参考
原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793259390/FIN+5.3.1+lib-tariff 中文整理基于 FIN 5.3.1
导读: 公用事业费率引擎
以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。
目录(导读)
- lib
- meta
- docs
- tags
- funcs
- views
- Overview
- Tariffs
- Charges
- Usage-Based Charges
- Consumption Charges
- Demand Charges
- Fixed Charges
- Percentage Charges
- Axon Charges
- Configuring Bill Periods
- Historical Fees
- Utility Functions
- tariffBillPeriod(meter, date)
- tariffConsumptionCharge(tariff, dis, meterType, strategy, ranges, optTags: {})
- tariffCost(meter, dates, opts: {})
- tariffCostToHis(rec, dates, opts, yield)
- src
- tariffCreate(dis, currency)
- tariffCreateBillHis(rec: null, his: null, opts: {})
- tariffDemandCharge(tariff, dis, meterType, strategy, ranges, optTags: {})
- tariffFixedCharge(tariff, dis, fee, freq: "bill")
- tariffPercentageCharge(tariff, dis, percentage, charges)
概述(中译)
公用事业费率引擎
API 正文(英文)
docs
Overview • Tariffs • Charges • Configuring Bill Periods • Historical Fees • Utility Functions
tags
| tariff | A tariff rec |
| tariffAxonCharge | An Axon charge rec |
| tariffCharge | A tariff charge rec |
| tariffChargeFunc | The name of the function that tariff engine should call to compute the cost |
| tariffChargeRef | Reference to an entity |
| tariffChargeRefs | The charges that a percentage charge applies to |
| tariffConsumptionCharge | A consumption charge rec |
| tariffContractMin | The minimum contractual demand necessary for this charge to apply |
| tariffDemandCharge | A demand charge rec |
| tariffFee | A fixed numeric fee for the charge |
| tariffFeeFreq | The frequency that the charge applies per bill period |
| tariffFeeHisRef | The ref to the history point that contains the historical fee data |
| tariffFixedCharge | A fixed charge rec |
| tariffHis | Identifies the tariff history point for a meter |
| tariffHisRef | If multiple meters share the same tariff history, then you can use this tag to reference the "master" point containing the tariff history |
| tariffPercentageCharge | A percentage charge rec |
| tariffRangeStrategy | When a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges |
| tariffRanges | The fee ranges for a usage-based charge |
| tariffRatchetPercentage | The peak demand identified during the ratchet period will be multiplied by this percentage to obtain the minimum peak demand |
| tariffRatchetPeriod | A value representing how far back to go when calculating the minimum peak demand for a billing period |
| tariffRef | The tariff a charge belongs to |
| tariffUsageOn | An axon filter used by the tariff engine to identify the charge's historical usage data |
funcs
| tariffBillPeriod | For the given meter, get the date span of the bill period containing the given date |
| tariffConsumptionCharge | Create a consumption charge |
| tariffCost | Calculate the cost of energy for a meter |
| tariffCostToHis | Function to create a computed history for the tariff cost associated with that meter |
| tariffCreate | Create a new tariff |
| tariffCreateBillHis | Create the billing period history point |
| tariffDemandCharge | Create a demand charge |
| tariffFixedCharge | Create a fixed charge |
| tariffPercentageCharge | Create a percentage charge |
views
| tariffBillPeriods | Manage tariff billing periods |
| tariffCost | Analyze tariff costs against energy usage |
| tariffs | Tariff builder used to edit tariff and charge records |
lib tariff
Overview
The TariffExt provides a common model for describing energy tariffs in SkySpark.
To setup a tariff and apply it to a meter, the following high-level steps need to be completed. The rest of this guide describes these steps in more details
- Create a tariff record
- Create records for all the charges in your tariff
- Create the tariff history point that defines the bill periods for your meter
Tariffs
A tariff models a collection of charges that apply to an energy meter. The following tags are used on records to define a tariff.
tariff: Marker tag that identifies the record as a tariff.currency: Str for the currency unit of this tariff. All charges in the tariff must be expressed in terms of this unit.
dis: "Schedule 1B"
tariff
currency: "€"Charges
A charge is the term used to describe the different cost components of a tariff. Energy tariffs often define many cost components. For example: service charges, consumption and demand charges, and taxes. The tariff ext provides models for these different kinds of charges.
All charges share the following tags.
tariffCharge: Marker tag that identifies the record as a tariff charge.tariffRef: Ref of the tariff that this charge belongs to.scheduleRef: (optional) Ref for the schedule that defines when this charge applies.scheduleVal: Str. When a schedule is applied to this charge, the charge only applies when the schedule has this value. Schedules are most commonly used with "usage-based" charges. For example, if the tag's value isonPeak, then only data in the periods when the schedule's value isonPeakwill be used for calculating the charge. This tag is required if scheduleRef is specified.
The following sections describe the different charge types in more detail.
Usage-Based Charges
A usage-based charge is any charge this is calculated as a function of usage data. Usage data in the tariff ext falls into one of two categories: 1) consumption, and 2) demand. Consumption data measures the amount of energy/resource consumed, and demand data measures the rate at which the energy/resource is consumed.
A usage-based charge uses the tariffUsageOn tag to define an Axon filter to find the sensor point that contains the historical usage data for that charge. The filter is based on the meter type (elec, gas, water), and whether the charge is for consumption or demand. The tariff engine will ensure the filter is applied to the relevant meter. For example, this filter will would find the energy consumption data:
energy and sensorInternally, the engine will constrain this filter to the current meter as
energy and sensor and equipRef == meterRefThe history data from the matched point is then used for calculating the cost of the charge.
Ranges
It is common for usage-based charges to have different costs based on the amount of energy/resource used. For example, a consumption charge might be specified as:
- First 1,400 kWh @ 3.722¢ per kWh
- Over 1,400 kWh @ 4.995¢ per kWh
Ranges allow us to express these types of charge costs. Ranges are modeled as a grid on the usage charge and are stored in the tariffRanges tag. The rows specify ranges, and the columns are
min: (Number) the minimum value for this range (exclusive).max: (Number) the maximum value for this range (inclusive).tariffFee: (Number) the numeric fee for this range.tariffFeeHisRef: (Ref) the point with historical fee data for this range
You must specify a min, max, and one of tariffFee or tariffFeeHisRef.
So, for the example above, the ranges tag would be
tariffRanges:Zinc:
ver:"3.0"
min, max, tariffFee
0, 1400, 3.722
1400, INF, 4.995All usage charges must have at least one range. It is not necessary for the ranges to be contiguous. The tariff ext will fill all gaps with zero-cost ranges.
Single, all-inclusive range:
tariffRanges:Zinc:
ver:"3.0"
min, max, tariffFee
0, INF, 4.115Partial, non-contiguous range:
tariffRanges:Zinc:
ver:"3.0"
min, max, tariffFee
1400, INF, 4.995Range Strategy
The tariffRanges tag allows us to define the ranges for our usage-based charges. The tariffRangeStrategy tag tells the tariff engine how to calculate the cost for a usage-based charge based on those defined ranges. It can have one of three values:
cumulative: All ranges up-to-and-including the range containing the total/peak usage are used in calculating the cost.inRange: Only the range containing the total/peak usage is used in calculating the cost.perReading: Instead of looking at the total or peak usage, the cost for each individual data reading is calculated based on the range it falls in.
To illustrate the difference between the strategies, consider this demand charge specification
- 0-100 kW @ $1.00 per kW
- 100-150 kW @ $2.00 per kW
- Over 150 kW @ $3.00 per kW
Suppose the customer's peak demand is 125 kW. For the cumulative range strategy we look at each range and calculate the cost based on how much of that range contributed to the total/peak usage. In this case, all 100kW of the first range contributed to the peak demand of 125kW. For the second range, only 25kW contributed, and for the last range 0kW contributed. So the cost is:
(100kW * $1.00/kW) + (25kW * $2.00/kW) + (0kW * $3.00/kW) = $150For the inRange strategy, we find the one and only range that contains the total/peak usage and use that for calculating the cost. Since 125kW falls into the second range the cost is:
(125kW * $2.00/kW) = $250The cumulative and inRange strategies are essentially looking at rolled up values - total (sum) for consumption data, and peak (max) for demand data. The perReading strategy looks at each individual data reading and calculates the cost for that reading based on the range it falls into. This table shows how the cost would be calculated for the given demand data based on the different strategies.
ts demand perReading Cost cumulative Cost inRange Cost
----- ------ --------------- --------------- ------------
00:00 5 kW $5 $0 $0
00:15 50 kW $50 $0 $0
00:30 125 kW $250 $150 $250
00:45 10 kW $10 $0 $0Consumption Charges
A consumption charge is a usage-based charge that calculates cost based on the amount of energy/resource consumed. It applies only to consumption sensor data. A consumption charge is tagged with the tariffCharge and tariffConsumptionCharge tags. There are no additional tags required to configure a consumption charge.
Consider this example consumption charge specification
- Generation kWh Charge
- For the Billing Months of June - September
- First 1,400 kWh @ 3.722¢ per kWh
- Over 1,400 kWh @ 4.995¢ per kWh
- For the Billing Months of June - September
If the tariff's currency is in $, then this consumption charge could be modeled as
dis: "Generation kWh Charge - Summer"
tariffRef: @ExampleTariff
tariffUsageOn: "energy and sensor"
tariffCharge
tariffConsumptionCharge
scheduleRef: @SeasonSchedule
scheduleVal: "summer"
tariffRangeStrategy: "cumulative"
tariffRanges:Zinc:
ver:"3.0"
min, max, tariffFee
0, 1400, 0.03722
1400, INF, 0.04995Demand Charges
A demand charge is a usage-based charge that calculates cost based on the rate at which energy or a resource is consumed. It applies only to demand sensor data. A deman charge is tagged with the tariffCharge and tariffDemandCharge tags. Except in the case where the range strategy is perReading, a demand charge looks at historical usage and finds the peak (maximum) demand interval. It then uses this peak value as the basis for calculating the cost.
In addition to all the standard charge and usage-based charge tags, a demand charge may be configured with the following optional tags
tariffContractMin: (Number) - the minimum contracted demand for this charge. When specified, the peak demand used to calculate the cost is never less than this value. This is sometimes referred to as a simple "ratchet" demand charge.tariffRatchetPeriod: (Str) - A value representing how far back to go when calculating the minimum peak demand for a billing period. This is sometimes referred to as a "historical" ratchet.Currently, the tariff engine can only look back by bill periods. Its value must be of the form "{N}bills", where "N" is the number of bill periods to consider and includes the current bill period. For example,
12billsindicates we should look at this bill period's data as well as the previous 11 months to determine the minimum peak demand.NOTE: the
tariffContractMinis still in effect if both are specified.tariffRatchetPercentage: (Number) - This tag is only valid whentariffRatchetPeriodis also specified. When this tag is present, the peak demand identified during the ratchet period is multiplied by this percentage to obtain the minimum peak demand. If it is not specified, the default value is logically 100%.
The following is an example of modeling a basic peak demand charge.
- Generation Demand Charge
For the Billing Months of June - September
All kW of Demand @ $2.119 per kW
For the Billing Months of October - May
All kW of Demand @ $0.681 per kW
dis: "Generation Demand Charge - Summer"
tariffRef: @ExampleTariff
tariffUsageOn: "demand and sensor"
tariffCharge
tariffDemandCharge
scheduleRef: @SeasonSchedule
scheduleVal: "summer"
tariffRangeStrategy: "inRange"
tariffRanges:Zinc:
ver:"3.0"
min, max, tariffFee
0, INF, 2.119
dis: "Generation Demand Charge - Winter"
tariffRef: @ExampleTariff
tariffUsageOn: "demand and sensor"
tariffCharge
tariffDemandCharge
scheduleRef: @SeasonSchedule
scheduleVal: "winter"
tariffRangeStrategy: "inRange"
tariffRanges:Zinc:
ver:"3.0"
min, max, tariffFee
0, INF, 0.681This example demonstrates modeling a peak demand charge with a historical ratchet and contract minimum.
- The distribution demand shall be such as may be contracted for but not less than the highest of:
- The highest average kW measured at the location during any 30-minute interval of the current and previous 11 billing months.
- 30 kW.
- Transmission Demand Charge
- All on-peak ES kW of Demand @ $2.313 per kW
dis: "On-Peak Demand Charge Winter"
tariffRef: @ExampleTariff
tariffUsageOn: "demand and sensor"
scheduleRef: @TOUSched
scheduleVal: "onPeak"
tariffCharge
tariffDemandCharge
tariffRangeStrategy: "inRange"
tariffRanges:Zinc:
ver:"3.0"
min, max, tariffFee
0, INF, 2.313
tariffContractMin: 30
tariffRatchetPeriod: "12bills"
tariffRatchetPercentage: 100Fixed Charges
A fixed charge is for a charge that applies on a regular interval. A fixed charge is tagged with the tariffCharge and tariffFixedCharge tags. Typical examples of fixed charges are service charges, or rental fees. A fixed charge defines some additional configuration tags:
- tariffFee (Number): The numeric fee for the charge.
- tariffFeeHisRef (Ref): The Ref to a history point that contains the historical fee data
- tariffFeeFreq (optional) (Str): the frequency that the charge applies within a bill period. It supports two types of values:
- If set to
"bill"then the charge applies per bill period. This is the default value. - The Str encoding of a Duration. In this case it specifies how often within a bill period the charge applies. For example
"1day", or"1hr"
- If set to
dis: "Service Charge"
tariffRef: @ExampleTariff
tariffCharge
tariffFixedCharge
tariffFee: 102.50
tariffFeeFreq: "bill"
dis: "Rental Fee"
tariffRef: @ExampleTariff
tariffCharge
tariffFixedCharge
tariffFee: 2.50
tariffFeeFreq: "1day"Percentage Charges
A percentage charge is used for any cost component that represents a percentage of one or more other cost components. The typical use case is for taxes. A percentage charge is tagged with the tariffCharge and tariffPercentageCharge tags. A percentage charge defines some additional configuration tags:
- tariffChargeRefs (Ref[]) - The refs of the charges that this percentage charge applies to It is valid to reference other percentage charges, but it is an error to create a circular dependency.
- percentage (Number): The percentage to apply to the sum of the referenced charges. This should be a number between 0 and 100.
// a 3.5% state tax on the service charge and consumption charge
dis: "State Tax"
tariffRef: @ExampleTariff
tariffCharge
tariffPercentageCharge
percentage: 3.5
tariffChargeRefs: [@ServiceCharge,@ConsumptionCharge]Axon Charges
(This charge type is incubating and is subject to change)
An axon charge allows you to delegate the cost calculation to a custom Axon function that you have written. Is can be used if one of the other charge types does not adequately model your charge. Ax Axon charge is tagged with the tariffCharge and tariffAxonCharge tags. An axon charge defines some additional configuration tags:
- tariffChargeFunc (Str) - The name of the axon function that performs the cost calculation.
The func must have the following signature
myChargeFunc(meter, dates, charge)It is passed the meter to calculate cost against, the date span of the current billing period being calculated, and the axon charge record itself. You should put any custom configuration tags on the charge record. The function should return a grid with a single row, and the following columns
- "cost" (Grid) - This column is required. Its value is a history grid. The history grid should be the computed cost for the entire date span passed into the axon charge function.
- "data" (Grid) - You may optionally return a history grid containing the raw data values used to calculate the cost for the axon charge.
Note: the tariff engine completely delegates computation to the axon function. In particular, it does not do any schedule filtering.
dis: "Custom Charge"
tariffRef: @ExampleTariff
tariffCharge
tariffAxonCharge
tariffChargeFunc: "myChargeFunc"Here is a very simple axon charge function that calculates just a constant value
(meter, dates, charge) => do
{
cost: {ts: dates.start, v0: 100$}.toGrid
}.toGrid
endConfiguring Bill Periods
A meter is billed by an energy company on a semi-regular basis. The date span for each bill is called the bill period. In order to more accurately report the cost for arbitrary date ranges, the tariff engine needs to know when a bill period begins, and how long it lasts. Further, it needs to know which tariff to apply for a given bill period.
The tariff engine models a bill period as a historized point on an energy meter. The timestamp of each record indicates when a bill period begins. The value of the record is the id of the tariff to use for that bill period. A bill period implicitly ends when the next one begins.
To setup a meter's bill period history do the following:
- Create a standard history point with type
Str - Add the
tariffHismarker tag to the point - Add an
equipReftag that points to the meter
For example, if you have an elec meter called @ElecMeterMain, you would create a point with at least these tags:
his
point
hisSize: 0
kind: "Str"
tz: "New_York"
tariffHis
siteRef: @Campus
equipRef: @ElecMeterMainIf this meter is billed on the first of each month, then its bill period history might look like this.
ts v0
---------------- ----------------------
2015-01-01T00:00 Tariff-SmallCommercial
2015-02-01T00:00 Tariff-SmallCommercial
2015-03-01T00:00 Tariff-MediumCommmercialTOU
2015-04-01T00:00 Tariff-MediumCommmercialTOU
...If you have multiple meters that share the same tariff history, you don't have to create a tariffHis point for each of them. Instead, create the tariffHis point once as indicated above, then on subsequent meters you can use the tariffHisRef tag to reference that point.
Historical Fees
It is common for the fee within a charge to change on a regular basis (e.g. daily or monthly). Anywhere a fee tag is used, instead of using a Number you can give a Ref to a history point that tracks the fee for that charge.
Utility Functions
- The
tariffCreate()function can be used to create a tariff. - The
tariffConsumptionCharge()function can be used to create a consumption charge. - The
tariffDemandCharge()function can be used to create a demand charge. - The
tariffFixedCharge()function can be used to create a fixed charge. - The
tariffPercentageCharge()function can be used to create a fixed charge. - The
tariffCreateBillHis()function can be used to create an initial bill history.
def
func:tariffBillPeriod
tariffBillPeriod(meter, date)
For the given meter, get the date span of the bill period containing the given date.
meta
| def | func:tariffBillPeriod |
| is | func |
| lib | lib:tariff |
| name | tariffBillPeriod |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tariffConsumptionCharge
tariffConsumptionCharge(tariff, dis, meterType, strategy, ranges, optTags: {})
Create a consumption charge. The parameters are the same as tariffDemandCharge. Returns the new consumption charge record.
meta
| admin | ✓ |
| def | func:tariffConsumptionCharge |
| is | func |
| lib | lib:tariff |
| name | tariffConsumptionCharge |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tariffCost
tariffCost(meter, dates, opts: {})
Calculate the cost of energy for a meter. The parameters:
- meter: The energy meter to calculate the cost for. May be any target accepted by
toRec(). - dates: the date range to query.
The opts parameter is a Dict and supports the following options:
- interval: a Duration between
1minand1day. If specified, then the tariff engine will calculate the cost of each charge for every interval in thedatesrange. For example, if dates is yesterday, and interval is1hr, then the tariff engine will break down the cost into 24 hourly slices for yesterday. - tariffHisRef: a Ref that can be used to override the tariff history that would normally be used for the meter.
- tariffRef: a Ref that can be used to override the tariff that is used to calculate cost. Can be used in conjunction with the tariffHisRef option. If specified, this tariff will be used for all bill periods in the date span.
- data: The data option allows you to override the historical data that the tariff engine would normally run against. The value of this option is a map where where the keys are string encodings of a point's id. The values are history grids. See the discussion below for more details.
The function returns the cost as a history grid where each value column corresponds to a charge in the tariff.
The data option: Normally, the tariff engine will determine the history point to use for a charge by looking at the tariffUsageOn tag for a charge, and then resolve that filter to the appropriate point. However, if the data map has a key with the same id as the resolved usageOn point, then the history grid in the data map will be used instead. Care should be taken to ensure that the history grid you give the tariff engine has data for the entire billing period(s) you are calculating cost for. The tariffBillPeriod() function can help you in this regard.
Example:
// Get the cost for yesterday without any timestamp adjustment for intervals.
tariffCost(@Carytown.ElecMeter-Main, yesterday)
// Get the cost for yesterday at 1hr intervals
tariffCost(@Carytown.ElecMeter-Main, yesterday, {interval: 1hr})meta
| def | func:tariffCost |
| is | func |
| lib | lib:tariff |
| name | tariffCost |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tariffCostToHis
tariffCostToHis(rec, dates, opts, yield)
Function to create a computed history for the tariff cost associated with that meter. The function computes the history by calling tariffCost() for the meter associated with this point (it should be a siteMeter). All the charges for a ts are then folded into a single value using sum.
meta
| def | func:tariffCostToHis |
| hisFuncReady | ✓ |
| is | func |
| lib | lib:tariff |
| name | tariffCostToHis |
| overridable | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
src
(rec, dates, opts, yield) => do
meter: readById(rec->equipRef)
if (meter.missing("siteMeter")) return null
tariffCost(meter, dates)
.hisFoldCols(sum)
.each(row => yield(row["ts"], row["v0"]))
enddef
func:tariffCreate
tariffCreate(dis, currency)
Create a new tariff. Creates a new tariff with the given display name and currency, and returns the new tariff Dict record.
meta
| admin | ✓ |
| def | func:tariffCreate |
| is | func |
| lib | lib:tariff |
| name | tariffCreate |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tariffCreateBillHis
tariffCreateBillHis(rec: null, his: null, opts: {})
Create the billing period history point. The parameters:
- rec (optional): If specified, must be the site or meter to create the history point on. May be any target accepted by
toRec(). Ifnull, then the point will be created "project-wide". - his (optional): If specified, this grid will be written as the initial billing period history. The grid must have the following columns:
date(Date): the date marking the beginning of a bill period.tariff(Str or Ref): the id of the tariff for that bill period.
- opts (optional): A
Dictwith additional options to create the point. Supported options:tz: Str containing the name of the time zone to use for this point. This option is ignored if therecparameter is non-null.navName: The StrnavNameto use for this point. (default: "Tariff His")
If rec is null or is a site, then you can associate meters with the tariff billing history by using the tariffHisRef tag.
Returns the new billing period history point record.
meta
| admin | ✓ |
| def | func:tariffCreateBillHis |
| is | func |
| lib | lib:tariff |
| name | tariffCreateBillHis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tariffDemandCharge
tariffDemandCharge(tariff, dis, meterType, strategy, ranges, optTags: {})
Create a demand charge. The parameters:
- tariff: The tariff to assign the charge to. May be any target accepted by
toRec(). - dis: The display name for the charge.
- meterType: The meter type this charge applies to. Must be one of
elec,gas,waterorsteam. ThetariffUsageOntag will be configured based on the meter type. You can override thetariffUsageOnby setting it explicitly in theoptTagsparameter. - strategy: The range strategy to use. Must be one of
cumulative,inRange, orperReading - ranges: A list of range specifications where a range specifcation is a list with format
[min, max, fee]. - optTags: Any additional tags to apply to the charge. You can override any of the other settings by explicitly setting them in this Dict.
Returns the new demand charge record.
Example:
tariffDemandCharge(@Schedule1B, "Peak Demand Charge", "elec", "inRange",
[[0, 1000, 3.225], [1000, posInf(), 4.662]])meta
| admin | ✓ |
| def | func:tariffDemandCharge |
| is | func |
| lib | lib:tariff |
| name | tariffDemandCharge |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tariffFixedCharge
tariffFixedCharge(tariff, dis, fee, freq: "bill")
Create a fixed charge. The parameters:
- tariff: The tariff to assign the charge to. May be any target accepted by
toRec(). - dis: The display name for the charge.
- fee (Number or Ref): the fee for this charge.
- freq (Str or Duration):
bill(the default) if the charge applies to the entire bill period, or a Duration for the frequency of the charge.
Returns the new fixed charge record.
Example:
// A fixed charge that applies to the entire bill period
tariffFixedCharge(@Schedule1B, "Service Charge", 102.50, "bill")
// A fixed charge that applies every day
tariffFixedCharge(@Schedule1B, "Rental Fee", 7.25, 1day)meta
| admin | ✓ |
| def | func:tariffFixedCharge |
| is | func |
| lib | lib:tariff |
| name | tariffFixedCharge |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:tariffPercentageCharge
tariffPercentageCharge(tariff, dis, percentage, charges)
Create a percentage charge. The parameters:
- tariff: The tariff to assign the charge to. May be any target accepted by
toRec(). - dis: The display name for the charge.
- percentage: The percentage for this charge.
- charges: the charges this charge applies to. Maybe be any result target accepted by
toRecList().
Returns the new percentage charge record.
Example:
// A 3.5% tax on two other charges
tariffPercentageCharge(@Schedule1B, "State Tax", 3.5, "@ServiceCharge,@ConsumptionCharge")meta
| admin | ✓ |
| def | func:tariffPercentageCharge |
| is | func |
| lib | lib:tariff |
| name | tariffPercentageCharge |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
tariff
A tariff rec.
meta
| def | tariff |
| icon | bill |
| is | entity |
| lib | lib:tariff |
| mandatory | ✓ |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
tags
| currency | The currency unit related to the entity |
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
def
tariffAxonCharge
An Axon charge rec.
meta
| def | tariffAxonCharge |
| disKey | tariffExt::tariff.axonCharge |
| icon | dollar |
| is | tariffCharge |
| lib | lib:tariff |
usage
| tariffAxonCharge tariffCharge |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| tariffCharge | A tariff charge rec |
tags
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
| scheduleRef | Associates a schedulable with its schedule |
| scheduleVal | The string name/encoding of a schedule value |
| tariffChargeFunc | The name of the function that tariff engine should call to compute the cost |
| tariffRef | The tariff a charge belongs to |
| tariffUsageOn | An axon filter used by the tariff engine to identify the charge's historical usage data |
def
tariffCharge
A tariff charge rec.
meta
| def | tariffCharge |
| icon | dollar |
| is | entity |
| lib | lib:tariff |
| mandatory | ✓ |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
subtypes
| tariffAxonCharge | An Axon charge rec |
| tariffConsumptionCharge | A consumption charge rec |
| tariffDemandCharge | A demand charge rec |
| tariffFixedCharge | A fixed charge rec |
| tariffPercentageCharge | A percentage charge rec |
tags
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
| scheduleRef | Associates a schedulable with its schedule |
| scheduleVal | The string name/encoding of a schedule value |
| tariffRef | The tariff a charge belongs to |
def
tariffChargeFunc
The name of the function that tariff engine should call to compute the cost.
meta
| def | tariffChargeFunc |
| is | str |
| lib | lib:tariff |
| tagOn | tariffAxonCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
def
tariffChargeRef
Reference to an entity. Ref values are ASCII strings limited to the following chars: a-z, A-Z, 0-9, underbar, colon, dash, dot, or tilde. See Kinds chapter.
meta
| def | tariffChargeRef |
| is | ref |
| lib | lib:tariff |
| of | tariffCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| ref | Reference to an entity |
def
tariffChargeRefs
The charges that a percentage charge applies to.
meta
| def | tariffChargeRefs |
| is | list |
| lib | lib:tariff |
| of | tariffChargeRef |
| tagOn | tariffPercentageCharge |
| uiInput | ui::NavInput |
supertypes
| val | Data value type |
| list | Ordered list of zero or more values |
def
tariffConsumptionCharge
A consumption charge rec.
meta
| def | tariffConsumptionCharge |
| disKey | tariffExt::tariff.consumptionCharge |
| icon | dollar |
| is | tariffCharge |
| lib | lib:tariff |
usage
| tariffConsumptionCharge tariffCharge |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| tariffCharge | A tariff charge rec |
tags
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
| scheduleRef | Associates a schedulable with its schedule |
| scheduleVal | The string name/encoding of a schedule value |
| tariffRangeStrategy | When a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges |
| tariffRanges | The fee ranges for a usage-based charge |
| tariffRef | The tariff a charge belongs to |
| tariffUsageOn | An axon filter used by the tariff engine to identify the charge's historical usage data |
def
tariffContractMin
The minimum contractual demand necessary for this charge to apply.
meta
| def | tariffContractMin |
| is | number |
| lib | lib:tariff |
| tagOn | tariffDemandCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| number | Integer or floating point numbers annotated with an optional unit |
def
tariffDemandCharge
A demand charge rec.
meta
| def | tariffDemandCharge |
| disKey | tariffExt::tariff.demandCharge |
| icon | dollar |
| is | tariffCharge |
| lib | lib:tariff |
usage
| tariffDemandCharge tariffCharge |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| tariffCharge | A tariff charge rec |
tags
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
| scheduleRef | Associates a schedulable with its schedule |
| scheduleVal | The string name/encoding of a schedule value |
| tariffContractMin | The minimum contractual demand necessary for this charge to apply |
| tariffRangeStrategy | When a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges |
| tariffRanges | The fee ranges for a usage-based charge |
| tariffRatchetPercentage | The peak demand identified during the ratchet period will be multiplied by this percentage to obtain the minimum peak demand |
| tariffRatchetPeriod | A value representing how far back to go when calculating the minimum peak demand for a billing period |
| tariffRef | The tariff a charge belongs to |
| tariffUsageOn | An axon filter used by the tariff engine to identify the charge's historical usage data |
def
tariffFee
A fixed numeric fee for the charge. This value should be unitless since it inherits the currency of its tariff.
meta
| def | tariffFee |
| is | number |
| lib | lib:tariff |
| tagOn | tariffFixedCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| number | Integer or floating point numbers annotated with an optional unit |
def
tariffFeeFreq
The frequency that the charge applies per bill period. It supports two values:
- If set to
billthen the charge applies per bill period. This is the default value. - The string encoding of a duration. In this case it specifies how often within a bill period the charge applies. For example
1dayor1hr.
meta
| def | tariffFeeFreq |
| is | str |
| lib | lib:tariff |
| tagOn | tariffFixedCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
def
tariffFeeHisRef
The ref to the history point that contains the historical fee data.
meta
| def | tariffFeeHisRef |
| is | ref |
| lib | lib:tariff |
| of | point |
| tagOn | tariffFixedCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| ref | Reference to an entity |
def
tariffFixedCharge
A fixed charge rec.
meta
| def | tariffFixedCharge |
| disKey | tariffExt::tariff.fixedCharge |
| icon | dollar |
| is | tariffCharge |
| lib | lib:tariff |
usage
| tariffFixedCharge tariffCharge |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| tariffCharge | A tariff charge rec |
tags
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
| scheduleRef | Associates a schedulable with its schedule |
| scheduleVal | The string name/encoding of a schedule value |
| tariffFee | A fixed numeric fee for the charge |
| tariffFeeFreq | The frequency that the charge applies per bill period |
| tariffFeeHisRef | The ref to the history point that contains the historical fee data |
| tariffRef | The tariff a charge belongs to |
def
tariffHis
Identifies the tariff history point for a meter. See bill periods for details.
meta
| def | tariffHis |
| is | his-point |
| lib | lib:tariff |
usage
| tariffHis point |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| point | Data point such as a sensor or actuator |
| his-point | Historized point with a history log of timestamp/value pairs |
tags
| cur | Supports current value |
| dis | Display name for an entity |
| disMacro | Display name using macro syntax |
| disabled | Indicates the entity is in a disabled state |
| enum | Defines an eumeration of string key names |
| equipRef | Reference to equip which contains this entity |
| ghgFactorHis | Identifies point record with interval emission factor data that the Greenhouse Gas Emission Engine uses to calculate emissions |
| his | Supports historization of data |
| hisAppendNA | Specifies the amount of time after a history point's hisEnd that the hisRead() function should append an NA |
| hisCollectCov | Enables COV history collection of the curVal |
| hisCollectCovRateLimit | Rate limits the frequency for hisCollectCov |
| hisCollectInterval | Enables interval history collection of the curVal |
| hisCollectNA | Historize the NA value whenever the curVal is null or curStatus is not equal to "ok" |
| hisCollectWriteFreq | This tag configures how long to buffer collected history items in memory before flushing them to the historian |
| hisEnd | Timestamp of newest item in history |
| hisErr | Error description when hisStatus indicates error condition |
| hisInterpolateMode | Explicitly configures the interpolation mode to use for this point |
| hisMode | Indicates the way that history data is collected for a point |
| hisRollupAutoMinInterval | Forces hisRollupAuto() to do a rollup using this interval when none is specified and the range of the source history grid is less than 2 days |
| hisSize | Approximate number of timestamp/value pairs stored in history |
| hisStart | Timestamp of oldest item in history |
| hisStatus | Status of point's history collection or synchronization |
| hisTotalized | Indicates values which are a continuous stream of totalization |
| id | Defines the unique identifier of an entity in system using a ref value type |
| kind | Kind name used to identity a value data type |
| maxVal | Inclusive maximum for a numeric value |
| minVal | Inclusive minimum for a numeric value |
| navName | Navigation name commonly used with disMacro to create computed display strings |
| pointFunction | Classifies the point as a sensor, command, or setpoint |
| pointQuantity | Quantity the point senses or controls |
| pointSubject | What the point senses or controls |
| siteRef | Reference to site which contains the entity |
| spaceRef | Reference to space which contains this entity |
| systemRef | Reference to system |
| tz | Timezone identifier from standard timezone database |
| unit | Unit identifier from standard unit database |
| writable | Supports writing data |
def
tariffHisRef
If multiple meters share the same tariff history, then you can use this tag to reference the "master" point containing the tariff history. See bill periods for details.
meta
| def | tariffHisRef |
| is | ref |
| lib | lib:tariff |
| tagOn | meter |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| ref | Reference to an entity |
def
tariffPercentageCharge
A percentage charge rec.
meta
| def | tariffPercentageCharge |
| disKey | tariffExt::tariff.percentageCharge |
| icon | dollar |
| is | tariffCharge |
| lib | lib:tariff |
usage
| tariffPercentageCharge tariffCharge |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| tariffCharge | A tariff charge rec |
tags
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
| percentage | A percentage specified as as <percent> * 100 |
| scheduleRef | Associates a schedulable with its schedule |
| scheduleVal | The string name/encoding of a schedule value |
| tariffChargeRefs | The charges that a percentage charge applies to |
| tariffRef | The tariff a charge belongs to |
def
tariffRangeStrategy
When a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges. See ranges for details.
meta
| def | tariffRangeStrategy |
| enum | See below |
| is | str |
| lib | lib:tariff |
| tagOn | tariffConsumptionCharge, tariffDemandCharge |
enum
| cumulative | All ranges up-to-and-including the range containing the total/peak usage are used in calculating the cost. |
| inRange | Only the range containing the total/peak is used in calculating the cost. |
| perReading | Instead of looking at the total or peak usage, the cost for each individual data reading is calculated based on the range it falls in. |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
def
tariffRanges
The fee ranges for a usage-based charge. See ranges for details.
meta
| def | tariffRanges |
| is | grid |
| lib | lib:tariff |
| tagOn | tariffConsumptionCharge, tariffDemandCharge |
supertypes
| val | Data value type |
| grid | Two dimension table of columns and rows |
def
tariffRatchetPercentage
The peak demand identified during the ratchet period will be multiplied by this percentage to obtain the minimum peak demand. Must be specified as a number between 0 and 100.
meta
| def | tariffRatchetPercentage |
| is | number |
| lib | lib:tariff |
| tagOn | tariffDemandCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| number | Integer or floating point numbers annotated with an optional unit |
def
tariffRatchetPeriod
A value representing how far back to go when calculating the minimum peak demand for a billing period. Its value must be specified as {N}bills where N is the number of bill periods to consider and includes the current bill period.
meta
| def | tariffRatchetPeriod |
| is | str |
| lib | lib:tariff |
| tagOn | tariffDemandCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
def
tariffRef
The tariff a charge belongs to.
meta
| containedBy | tariff |
| def | tariffRef |
| is | ref |
| lib | lib:tariff |
| of | tariff |
| tagOn | tariffCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| ref | Reference to an entity |
def
tariffUsageOn
An axon filter used by the tariff engine to identify the charge's historical usage data. See usage-based charges.
meta
| def | tariffUsageOn |
| is | filterStr |
| lib | lib:tariff |
| tagOn | tariffConsumptionCharge, tariffDemandCharge, tariffAxonCharge |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
| filterStr | Haystack filter string |
def
view:tariffBillPeriods
Manage tariff billing periods
meta
| appName | energy |
| def | view:tariffBillPeriods |
| disKey | tariffExt::tariff.billPeriods |
| icon | view |
| is | view |
| lib | lib:tariff |
| order | 62 |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| view | Fresco UI view |
src
view: {inherit:"tile"}
layout: {var kind:"Str" defVal:"grid 6x6; 0 0 6 3; 0 3 6 3"}
meterTariffConfig: Trio:
view: {inherit:"table"}
selectedMeter: {var kind:"Ref" bindSelect:"id"}
editTariffHisRef: {disMacro:"$<ui::edit> $<tariffExt::tariff.tariffHisRef>" action:"tariffExt::TariffMeterActions.editAction" select}
createTariffHisPoint: { disMacro: "$<ui::new> $<tariffExt::tariff.childHisPoint>" action:"tariffCreateHisOnMeter" select}
data: {expr:"tariffShowMeterHisConfig()"}
tariffHis: Trio:
view: {inherit:"table"}
selectedMeter: {var input binding:"../meterTariffConfig/selectedMeter"}
span: {var input kind:"Span" defExpr: "pastYear().toSpan"}
enterBillPeriod: {disMacro:"$<ui::submit> $<tariffExt::tariff.billPeriod>" action:"tariffExt::TariffHisActions.newAction" }
removeBillPeriod: {disMacro:"$<ui::remove> $<tariffExt::tariff.billPeriod>" action:"tariffExt::TariffHisActions.removeAction" select confirm: { icon:"warn" disKey:"tariffExt::tariff.confirmBillPeriodRemove" detailsKey:"tariffExt::tariff.detailsBillPeriodRemove"} }
data: {expr:"tariffBillHis({{selectedMeter}}, {{span}})"}def
view:tariffCost
Analyze tariff costs against energy usage
meta
| appName | energy |
| def | view:tariffCost |
| disKey | tariffExt::tariffCostView |
| icon | view |
| is | view |
| lib | lib:tariff |
| order | 60 |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| view | Fresco UI view |
src
view: {inherit:"chart"}
sites: {input var disKey:"ui::sites" kind:"Ref<site>[]" navCluster navSelAny share}
span: {input var defVal:Span("today") share}
opts:Trio:
var
kind:"Dict"
disKey:"ui::options"
input
templateName:"tariffCostOpts"
defVal:Trio:
meter:"elec"
rollup: {fold:"sum", interval:"1day"}
data: {expr:"tariffCostView({{sites}}, {{span}}, {{opts}})"}def
view:tariffs
Tariff builder used to edit tariff and charge records
meta
| appName | energy |
| def | view:tariffs |
| disKey | ui::tariffs |
| icon | view |
| is | view |
| lib | lib:tariff |
| order | 61 |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| view | Fresco UI view |
src
view: {inherit:"tile"}
layout: {var kind:"Str" defVal:"grid 6x6; 0 0 6 3; 0 3 6 3"}
tariffs: Trio:
view: {inherit:"table" defName:"tariff"}
selectedTariff: {var kind:"Ref" bindSelect:"id"}
new: {disMacro:"$<ui::new> $<ui::tariff>" action:"recNew"}
edit: {disMacro:"$<ui::edit> $<ui::tariff>" action:"recEdit" select}
trash: {disMacro:"$<ui::trash> $<ui::tariff>" action:"recTrash" select}
newCharge: {action:"recNew" uiInput:"tariffExt::TariffChargeActions.newAction" select}
data: {expr:"readAll(tariff)"}
charges: Trio:
view: {inherit:"table" defName:"tariffCharge"}
selectedTariff: {var input binding:"../tariffs/selectedTariff"}
edit: {disMacro:"$<ui::edit> $<ui::charge>" action:"recEdit" select}
trash: {disMacro:"$<ui::trash> $<ui::charge>" action:"recTrash" select}
data: {expr:"readAll(tariffCharge and tariffRef == {{selectedTariff}})"}