Skip to content

lib-schedule 库参考 ​

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

导读: 日程安排和日历

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


目录(导读) ​

  • lib
  • meta
  • docs
  • tags
  • apps
  • funcs
  • views
  • def
  • supertypes
  • usage
  • tags
  • Overview
  • Calendar
  • Schedule
  • Schedulable
  • scheduleHis(scheduleRec, dates, opts: {}, yield: null)
  • scheduleSync(timeout: null)
  • scheduleValAt(scheduleRec, ts)
    • src

概述(中译) ​

日程安排和日历


API 正文(英文) ​

docs ​

Overview • Calendar • Schedule • Schedulable


tags ​

calendarMarker tag for a calendar entity
calendarGridConfigures the items for a daily calendar
calendarRefUsed to chain a calendar to a schedule or another calendar
nextTimeNext time stamp when the schedule transition
nextValNext value the schedule will transition to
schedulableBinds a schedule to a writable point
scheduleMarker tag for a schedule entity
scheduleGridConfigures the items for a schedule
scheduleRefAssociates a schedulable with its schedule
scheduleValThe string name/encoding of a schedule value

apps ​

scheduleViews used to manage schedules

funcs ​

scheduleHisCompute a historical or future timeline of a schedule record
scheduleSyncBlock until any schedule changes are refreshed
scheduleValAtReturn the scheduled value at the given timestamp

views ​

scheduleFresco UI view


def ​

app:schedule ​

Views used to manage schedules


meta ​

defapp:schedule
disKeyui::schedule
iconcalendar
isapp
liblib:schedule

supertypes ​

featureFeature namespace of definitions formatted as feature:name
appUI application grouping of views


def ​

calendar ​

Marker tag for a calendar entity.


meta ​

defcalendar
ispoint
liblib:schedule

usage ​

calendar  point

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
pointData point such as a sensor or actuator

tags ​

calendarGridConfigures the items for a daily calendar
curSupports current value
disDisplay name for an entity
disMacroDisplay name using macro syntax
disabledIndicates the entity is in a disabled state
enumDefines an eumeration of string key names
equipRefReference to equip which contains this entity
ghgFactorHisIdentifies point record with interval emission factor data that the Greenhouse Gas Emission Engine uses to calculate emissions
hisSupports historization of data
idDefines the unique identifier of an entity in system using a ref value type
kindKind name used to identity a value data type
maxValInclusive maximum for a numeric value
minValInclusive minimum for a numeric value
navNameNavigation name commonly used with disMacro to create computed display strings
nextTimeNext time stamp when the schedule transition
nextValNext value the schedule will transition to
pointFunctionClassifies the point as a sensor, command, or setpoint
pointQuantityQuantity the point senses or controls
pointSubjectWhat the point senses or controls
siteRefReference to site which contains the entity
spaceRefReference to space which contains this entity
systemRefReference to system
tzTimezone identifier from standard timezone database
unitUnit identifier from standard unit database
writableSupports writing data


def ​

calendarGrid ​

Configures the items for a daily calendar. See schedule for further details.


meta ​

defcalendarGrid
isgrid
liblib:schedule
tagOncalendar

supertypes ​

valData value type
gridTwo dimension table of columns and rows


def ​

calendarRef ​

Used to chain a calendar to a schedule or another calendar.


meta ​

defcalendarRef
isref
liblib:schedule
ofcalendar

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity

lib schedule ​

Overview ​

The scheduleExt is provides a scheduling engine to:

  • schedule occupancy hours and building modes
  • schedule setpoints
  • schedule holidays and special events

The schedule engine is implemented using two concepts:

  • calendars: configure each day of the year into an enumerated string mode
  • schedules: configure each time of day to an output value such an occupancy mode or setpoint value

Calendars may be associated with schedules and other calendars to share a common configuration for classification of days.

Calendar ​

A calendar classifies each day of the year to a mode string. For example modes might be "Holiday" or a school system might classify dates as "In-Session" and "Out-Session".

The following tags are used to configure a calendar record:

  • dis: display name
  • calendar: marker tag for a calendar entity
  • calendarGrid: grid of calendar items
  • tz: timezone to use for computing daily transitions (if omitted host's default timezone is used)
  • calendarRef: used to chain calendars together

In addition calendars can be promoted to full points with the point tag.

The calendarGrid tag is used to configure zero or more calendar items. Items are saved as a grid. The following rules are used to encode items:

  • The val tag is used to encode each item's string mode value. Values must start with alpha char must not contain the special characters "\n \r ; , + $ \ / | " or quote chars
  • The dis tag provides comment on the specific item
  • Dates are encoded as strings as "YYYY-MM-DD" or "*-MM-DD" to wildcard the year

The following tags define how the item's dates are computed:

  • date: a single date with or without a wildcard year encoded as string where wildcard is encoded as "*"
  • dateSpan: a range of dates from an inclusive start and end date encoded as "start..end" string. The dates may both wildcard the year or use an explicit year, but cannot span years.
  • weekdays: a list of weekdays serialized as a comma separated string of sun, mon, tue, wed, thu, fri, sat - for example "mon,tue,wed"
  • calendar: if a calendarRef is configured, this item maps a series of values from the chain calendar separated by comma
  • dateRule: a wildcard rule encoded as a string used to handle special cases like "fourth Thursday of November", or "closest weekday to July 4th" (discussed in detail below)

The following illustrates each of the different calendar item types:

dis: "Calendar with Dates"
calendar
calendarGrid:Zinc:
  ver: "3.0"
  val,             date
  "Date",          "2012-07-04"
  "Date-Wildcard", "*-01-01"

dis: "Calendar with DateSpans"
calendar
calendarGrid:Zinc:
  ver: "3.0"
  val,                 dateSpan
  "DateSpan",          "2012-08-01..2012-08-03"
  "DateSpan-Wildcard", "*-08-04..*-08-06"

dis: "Calendar with Weekdays"
calendar
calendarGrid:Zinc:
  ver: "3.0"
  val,        weekdays
  "Weekends", "sun,sat"

dis: "Calendar Chaining"
calendar
calendarGrid:Zinc:
  ver: "3.0"
  val,        calendar
  "Calendar", "Summer-Session,Holiday"

The dateRule option is used to create special rules which don't map cleanly to dates or weekdays. The general format of a rule is:

<rule> := <basic-date-rule> | <closest-weekday-to-rule>
<basic-date-rule>      := <num> <weekday> "in" <month>
<closest-weekday-rule> := "closest-weekday-to" <wildcard-date>
<num>            := "1st" | "2nd" | "3rd" | "4th" | "last"
<weekday>        := "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat"
<month>          := "jan" | "feb" | "mar" | "apr" | "may" | "jun" |
                    "jul" | "aug" | "sep" | "oct" | "nov" | "dec"
<wildcard-date>  := <*-MM-DD>

Note that weekday and month are the standardized names in Weekday and Month system APIs.

dis: "Date Rules"
calendar
calendarGrid:Zinc:
  ver: "3.0"
  val,                      dateRule
  "Martin Luther King Day", "3rd mon in jan"
  "George Washington Day",  "3rd mon in feb"
  "Memorial Day",           "last mon in may"
  "Labor Day",              "1st mon in sep"
  "Thanksgiving",           "4th thu in nov"
  "Independence Day"        "closest-weekday-to *-07-04"

The closest-weekday-to rule is useful for situations where holidays need to be observed on the closest weekday if they fall on a weekend. In the example above, the closest-weekday-to rule will match under the given conditions:

  1. If July 4th falls on a weekday for a particular year, then it matches that date.
  2. If July 4th falls on a Saturday for a particular year, then July 3rd will match (Friday - i.e. the closest weekday) .
  3. If July 4th falls on a Sunday for a particular year, then July 5th will match (Monday - i.e. the closest weekday).

Items are declared from highest priority to lowest priority. When computing the value of a given date, the first matching item determines the output value.

The scheduling engine maintains the current value of a calendar using the following tags:

  • curVal: the current string mode for today or omitted if no mode is active for today
  • curStatus: status mode as "ok" or "fault" if calendar is not configured correctly
  • curErr: error message if calendar is in fault

Schedule ​

Schedules are used to output a configured value for each time of the day. They may be used to configure occupancy, equipment modes, or setpoints.

The following tags are used to configure a schedule record:

  • dis: display name
  • schedule: marker tag for a schedule entity
  • point: all schedules are points
  • scheduleGrid: grid of schedul items
  • tz: timezone to use for computing current value (if omitted host's default timezone is used)
  • calendarRef: used to configured calendar based items

The scheduleGrid tag is used to configure zero or more schedule items. Items are saved as a grid. The following rules are used to encode items:

  • val: tag is used to encode the items value
  • dis tag provides comment on the specific item
  • start: starting time of the item (00:00 is used for midnight at start of day)
  • end: ending time of the item (00:00 is used for midnight at end of the day)
  • Dates for the item follow the pattern as Calendar dates using the date, dateSpan, weekdays, or calendar tags

Items are declared from highest priority to lowest priority. When computing the value of a given timestamp, the first matching item which is active for that date and time determines the output value.

The scheduling engine maintains the current value of a schedule using the following tags:

  • curVal: the current value for right now or missing if auto/null
  • curStatus: status mode as "ok" or "fault" if schedule is not configured correctly
  • curErr: error message if schedule is in fault
  • nextVal: the next value for the schedule
  • nextTime: timestamp of next transition to a new span

The following illustrates a simple schedule which is on from 9am to 5pm on weekdays and a special event on Aug 11th to turn off early at 3pm.

dis: "Simple Schedule"
schedule
scheduleGrid:Zinc:
  ver: "3.0"
  val, weekdays, date,       start, end
  T,   "12345",  N,          9:00,  17:00
  F,   N,       "2012-08-11" 15:00, 17:00

Schedulable ​

Writable points with the writable tag may be made schedulable which binds a schedule to a level of the point's priority array. The schedule engine will automatically push any changes to the schedule's curVal to the point's priority array. Schedulable points are configured by defining the priority level with the schedulable tag and the schedule to bind to via the scheduleRef tag.



def ​

func:scheduleHis ​

scheduleHis(scheduleRec, dates, opts: {}, yield: null) ​

Compute a historical or future timeline of a schedule record. This function may be configured using hisFunc to turn in a schedule into a computed history. Or this function may be called with a schedule rec and a date range to returns a history grid of the schedule.

Time spans of the schedule which are auto/null are returned in the results with a null value. But these nulls may be processed incorrectly if performing a join with other histories or using history functions which treat null as an unaligned, sparse va


meta ​

deffunc:scheduleHis
hisFuncReady✓
isfunc
liblib:schedule
namescheduleHis

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:scheduleSync ​

scheduleSync(timeout: null) ​

Block until any schedule changes are refreshed.


meta ​

admin✓
deffunc:scheduleSync
isfunc
liblib:schedule
namescheduleSync

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:scheduleValAt ​

scheduleValAt(scheduleRec, ts) ​

Return the scheduled value at the given timestamp.


meta ​

deffunc:scheduleValAt
isfunc
liblib:schedule
namescheduleValAt

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

nextTime ​

Next time stamp when the schedule transition. Also see nextVal.


meta ​

defnextTime
isdateTime
liblib:schedule
tagOnschedule, calendar
transient✓

supertypes ​

valData value type
scalarScalar is an atomic value kind
dateTimeISO 8601 timestamp followed by timezone identifier


def ​

nextVal ​

Next value the schedule will transition to. Also see nextTime.


meta ​

defnextVal
isscalar
liblib:schedule
tagOnschedule, calendar
transient✓

supertypes ​

valData value type
scalarScalar is an atomic value kind


def ​

schedulable ​

Binds a schedule to a writable point. The value must be a number between 16 and 1 which indicates the priority level used to write the schedules current value. See schedule.


meta ​

defschedulable
isint
liblib:schedule
maxVal16
minVal1

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
intUnitless integer number


def ​

schedule ​

Marker tag for a schedule entity.


meta ​

defschedule
ispoint
liblib:schedule

usage ​

schedule  point

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
pointData point such as a sensor or actuator

tags ​

curSupports current value
disDisplay name for an entity
disMacroDisplay name using macro syntax
disabledIndicates the entity is in a disabled state
enumDefines an eumeration of string key names
equipRefReference to equip which contains this entity
ghgFactorHisIdentifies point record with interval emission factor data that the Greenhouse Gas Emission Engine uses to calculate emissions
hisSupports historization of data
idDefines the unique identifier of an entity in system using a ref value type
kindKind name used to identity a value data type
maxValInclusive maximum for a numeric value
minValInclusive minimum for a numeric value
navNameNavigation name commonly used with disMacro to create computed display strings
nextTimeNext time stamp when the schedule transition
nextValNext value the schedule will transition to
pointFunctionClassifies the point as a sensor, command, or setpoint
pointQuantityQuantity the point senses or controls
pointSubjectWhat the point senses or controls
scheduleGridConfigures the items for a schedule
siteRefReference to site which contains the entity
spaceRefReference to space which contains this entity
systemRefReference to system
tzTimezone identifier from standard timezone database
unitUnit identifier from standard unit database
writableSupports writing data


def ​

scheduleGrid ​

Configures the items for a schedule. See schedule for further details.


meta ​

defscheduleGrid
isgrid
liblib:schedule
tagOnschedule

supertypes ​

valData value type
gridTwo dimension table of columns and rows


def ​

scheduleRef ​

Associates a schedulable with its schedule.


meta ​

defscheduleRef
isref
liblib:schedule
ofschedule
tagOntariffCharge, writable-point

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity


def ​

scheduleVal ​

The string name/encoding of a schedule value


meta ​

defscheduleVal
isstr
liblib:schedule
tagOntariffCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

view:schedule ​

Fresco UI view. See Views


meta ​

appNameschedule
defview:schedule
disKeyui::schedule
iconview
isview
liblib:schedule

supertypes ​

featureFeature namespace of definitions formatted as feature:name
viewFresco UI view

src ​

view:      { uiType:"scheduleExt::ScheduleBuilder"}
spanCal:   { var kind:"Span" input defVal:Span("thisYear") spanModes:["year"] }
spanSched: { var kind:"Span" input defVal:Span("thisWeek") }
calNew:    { action:"recNew" defName:"calendar" refresh }
calEdit:   { action:"recEdit" defName:"calendar" refresh }
schedNew:  { action:"recNew" defName:"schedule" refresh }
schedEdit: { action:"recEdit" defName:"schedule" refresh }
dup:       { action:"recDup" refresh }
trash:     { action:"recTrash" refresh }
data:      { expr:"readAll(schedule or calendar)" }