├── .gitignore ├── LICENSE ├── readme.md └── src └── xeto ├── ashrae.g36 ├── lib.xeto └── vavs.xeto ├── doc.xeto.tools ├── Setup.md ├── index.md └── lib.xeto ├── doc.xeto.tutorials ├── DeepDive.md ├── Intro.md ├── index.md └── lib.xeto ├── doc.xeto ├── Choices.md ├── Constraints.md ├── Enums.md ├── Fidelity.md ├── Globals.md ├── Grammar.md ├── Inheritance.md ├── Instances.md ├── Libs.md ├── Meta.md ├── Namespaces.md ├── Specs.md ├── TypeSystem.md ├── Xetodoc.md ├── index.md └── lib.xeto ├── ph.attrs ├── base.xeto ├── elec.xeto ├── lib.xeto ├── tags.xeto ├── temp.xeto └── universal.xeto ├── ph.equips ├── ducts.xeto ├── hvac.xeto ├── lib.xeto └── meters.xeto ├── ph.examples ├── lib.xeto └── site.xeto ├── ph.points.elec ├── choices.xeto ├── lib.xeto ├── sensor-dc.xeto ├── sensor.xeto ├── sp-dc.xeto └── sp.xeto ├── ph.points ├── air-flow.xeto ├── air-humidity.xeto ├── air-pressure.xeto ├── air-temp.xeto ├── base.xeto ├── co2.xeto ├── damper.xeto ├── elec.xeto ├── fan.xeto ├── lib.xeto ├── misc.xeto ├── motor.xeto ├── naturalGas.xeto ├── occupied.xeto ├── valve.xeto ├── water-flow.xeto ├── water-volume.xeto └── weather.xeto ├── ph.protocols ├── bacnet.xeto ├── base.xeto ├── lib.xeto └── modbus.xeto ├── ph ├── choices.xeto ├── entities.xeto ├── enums.xeto ├── filetypes.xeto ├── kinds.xeto ├── lib.xeto ├── ops.xeto ├── phenomenon.xeto ├── quantity.xeto ├── tags-5.xeto └── tags.xeto ├── sys.api ├── api.xeto ├── lib.xeto ├── misc.xeto └── reads.xeto ├── sys.comp ├── lib.xeto └── types.xeto ├── sys.files ├── app.xeto ├── lib.xeto ├── media.xeto ├── meta.xeto └── text.xeto └── sys ├── lib.xeto ├── libmeta.xeto ├── meta.xeto ├── timezones.xeto ├── types.xeto └── units.xeto /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore files 2 | 3 | Thumbs.db 4 | .DS_Store 5 | fan.props 6 | 7 | /lib/ 8 | 9 | /src/xeto/acme/ 10 | 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Academic Free License ("AFL") v. 3.0 This Academic Free License (the "License") 2 | applies to any original work of authorship (the "Original Work") whose owner 3 | (the "Licensor") has placed the following licensing notice adjacent to the 4 | copyright notice for the Original Work: 5 | 6 | Licensed under the Academic Free License version 3.0 7 | 8 | 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, 9 | non-exclusive, sublicensable license, for the duration of the copyright, to do 10 | the following: 11 | 12 | a) to reproduce the Original Work in copies, either alone or as part of a 13 | collective work; 14 | 15 | b) to translate, adapt, alter, transform, modify, or arrange the Original Work, 16 | thereby creating derivative works ("Derivative Works") based upon the Original 17 | Work; 18 | 19 | c) to distribute or communicate copies of the Original Work and Derivative 20 | Works to the public, under any license of your choice that does not contradict 21 | the terms and conditions, including Licensor's reserved rights and remedies, in 22 | this Academic Free License; 23 | 24 | d) to perform the Original Work publicly; and 25 | 26 | e) to display the Original Work publicly. 27 | 28 | 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, 29 | non-exclusive, sublicensable license, under patent claims owned or controlled 30 | by the Licensor that are embodied in the Original Work as furnished by the 31 | Licensor, for the duration of the patents, to make, use, sell, offer for sale, 32 | have made, and import the Original Work and Derivative Works. 33 | 34 | 3) Grant of Source Code License. The term "Source Code" means the preferred 35 | form of the Original Work for making modifications to it and all available 36 | documentation describing how to modify the Original Work. Licensor agrees to 37 | provide a machine-readable copy of the Source Code of the Original Work along 38 | with each copy of the Original Work that Licensor distributes. Licensor 39 | reserves the right to satisfy this obligation by placing a machine-readable 40 | copy of the Source Code in an information repository reasonably calculated to 41 | permit inexpensive and convenient access by You for as long as Licensor 42 | continues to distribute the Original Work. 43 | 44 | 4) Exclusions From License Grant. Neither the names of Licensor, nor the names 45 | of any contributors to the Original Work, nor any of their trademarks or 46 | service marks, may be used to endorse or promote products derived from this 47 | Original Work without express prior permission of the Licensor. Except as 48 | expressly stated herein, nothing in this License grants any license to 49 | Licensor's trademarks, copyrights, patents, trade secrets or any other 50 | intellectual property. No patent license is granted to make, use, sell, offer 51 | for sale, have made, or import embodiments of any patent claims other than the 52 | licensed claims defined in Section 2. No license is granted to the trademarks 53 | of Licensor even if such marks are included in the Original Work. Nothing in 54 | this License shall be interpreted to prohibit Licensor from licensing under 55 | terms different from this License any Original Work that Licensor otherwise 56 | would have a right to license. 57 | 58 | 5) External Deployment. The term "External Deployment" means the use, 59 | distribution, or communication of the Original Work or Derivative Works in any 60 | way such that the Original Work or Derivative Works may be used by anyone other 61 | than You, whether those works are distributed or communicated to those persons 62 | or made available as an application intended for use over a network. As an 63 | express condition for the grants of license hereunder, You must treat any 64 | External Deployment by You of the Original Work or a Derivative Work as a 65 | distribution under section 1(c). 66 | 67 | 6) Attribution Rights. You must retain, in the Source Code of any Derivative 68 | Works that You create, all copyright, patent, or trademark notices from the 69 | Source Code of the Original Work, as well as any notices of licensing and any 70 | descriptive text identified therein as an "Attribution Notice." You must cause 71 | the Source Code for any Derivative Works that You create to carry a prominent 72 | Attribution Notice reasonably calculated to inform recipients that You have 73 | modified the Original Work. 74 | 75 | 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that 76 | the copyright in and to the Original Work and the patent rights granted herein 77 | by Licensor are owned by the Licensor or are sublicensed to You under the terms 78 | of this License with the permission of the contributor(s) of those copyrights 79 | and patent rights. Except as expressly stated in the immediately preceding 80 | sentence, the Original Work is provided under this License on an "AS IS" BASIS 81 | and WITHOUT WARRANTY, either express or implied, including, without limitation, 82 | the warranties of non-infringement, merchantability or fitness for a particular 83 | purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. 84 | This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No 85 | license to the Original Work is granted by this License except under this 86 | disclaimer. 87 | 88 | 8) Limitation of Liability. Under no circumstances and under no legal theory, 89 | whether in tort (including negligence), contract, or otherwise, shall the 90 | Licensor be liable to anyone for any indirect, special, incidental, or 91 | consequential damages of any character arising as a result of this License or 92 | the use of the Original Work including, without limitation, damages for loss of 93 | goodwill, work stoppage, computer failure or malfunction, or any and all other 94 | commercial damages or losses. This limitation of liability shall not apply to 95 | the extent applicable law prohibits such limitation. 96 | 97 | 9) Acceptance and Termination. If, at any time, You expressly assented to this 98 | License, that assent indicates your clear and irrevocable acceptance of this 99 | License and all of its terms and conditions. If You distribute or communicate 100 | copies of the Original Work or a Derivative Work, You must make a reasonable 101 | effort under the circumstances to obtain the express assent of recipients to 102 | the terms of this License. This License conditions your rights to undertake the 103 | activities listed in Section 1, including your right to create Derivative Works 104 | based upon the Original Work, and doing so without honoring these terms and 105 | conditions is prohibited by copyright law and international treaty. Nothing in 106 | this License is intended to affect copyright exceptions and limitations 107 | (including "fair use" or "fair dealing"). This License shall terminate 108 | immediately and You may no longer exercise any of the rights granted to You by 109 | this License upon your failure to honor the conditions in Section 1(c). 110 | 111 | 10) Termination for Patent Action. This License shall terminate automatically 112 | and You may no longer exercise any of the rights granted to You by this License 113 | as of the date You commence an action, including a cross-claim or counterclaim, 114 | against Licensor or any licensee alleging that the Original Work infringes a 115 | patent. This termination provision shall not apply for an action alleging 116 | patent infringement by combinations of the Original Work with other software or 117 | hardware. 118 | 119 | 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this 120 | License may be brought only in the courts of a jurisdiction wherein the 121 | Licensor resides or in which Licensor conducts its primary business, and under 122 | the laws of that jurisdiction excluding its conflict-of-law provisions. The 123 | application of the United Nations Convention on Contracts for the International 124 | Sale of Goods is expressly excluded. Any use of the Original Work outside the 125 | scope of this License or after its termination shall be subject to the 126 | requirements and penalties of copyright or patent law in the appropriate 127 | jurisdiction. This section shall survive the termination of this License. 128 | 129 | 12) Attorneys' Fees. In any action to enforce the terms of this License or 130 | seeking damages relating thereto, the prevailing party shall be entitled to 131 | recover its costs and expenses, including, without limitation, reasonable 132 | attorneys' fees and costs incurred in connection with such action, including 133 | any appeal of such action. This section shall survive the termination of this 134 | License. 135 | 136 | 13) Miscellaneous. If any provision of this License is held to be 137 | unenforceable, such provision shall be reformed only to the extent necessary to 138 | make it enforceable. 139 | 140 | 14) Definition of "You" in This License. "You" throughout this License, whether 141 | in upper or lower case, means an individual or a legal entity exercising rights 142 | under, and complying with all of the terms of, this License. For legal 143 | entities, "You" includes any entity that controls, is controlled by, or is 144 | under common control with you. For purposes of this definition, "control" means 145 | (i) the power, direct or indirect, to cause the direction or management of such 146 | entity, whether by contract or otherwise, or (ii) ownership of fifty percent 147 | (50%) or more of the outstanding shares, or (iii) beneficial ownership of such 148 | entity. 149 | 150 | 15) Right to Use. You may use the Original Work in all ways not otherwise 151 | restricted or conditioned by this License or by law, and Licensor promises not 152 | to interfere with or be responsible for such uses by You. 153 | 154 | 16) Modification of This License. This License is Copyright © 2005 Lawrence 155 | Rosen. Permission is granted to copy, distribute, or communicate this License 156 | without modification. Nothing in this License permits You to modify this 157 | License as applied to the Original Work or to Derivative Works. However, You 158 | may modify the text of this License and copy, distribute or communicate your 159 | modified version (the "Modified License") and apply it to other original works 160 | of authorship subject to the following conditions: (i) You may not indicate in 161 | any way that your Modified License is the "Academic Free License" or "AFL" and 162 | you may not use those names in the name of your Modified License; (ii) You must 163 | replace the notice specified in the first paragraph above with the notice 164 | "Licensed under " or with a notice of your own 165 | that is not confusingly similar to the notice in this License; and (iii) You 166 | may not claim that your original works are open source software unless your 167 | Modified License has been approved by Open Source Initiative (OSI) and You 168 | comply with its license review and certification process. 169 | 170 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Xeto is a data-only type system. The name is derived from the phrase "eXtensible 4 | Explicitly Typed Objects". Xeto defines a simple plain text format used to 5 | declare types and to exchange typed data. It is designed to build and validate 6 | [Project Haystack](https://project-haystack.org/) data models. But Xeto is general 7 | purpose enough to use with any structured data including CSV, JSON, or SQL data. 8 | 9 | This repository is used to manage the source code for the standard libraries. 10 | 11 | # Documentation 12 | 13 | You can browse the markdown documentation in GitHub repo: 14 | - [Language Docs](src/xeto/doc.xeto/index.md) 15 | - [Tool Docs](src/xeto/doc.xeto.tools/index.md) 16 | 17 | -------------------------------------------------------------------------------- /src/xeto/ashrae.g36/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "ASHRAE Guideline 36 examples" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | { lib: "ph", versions: "0.1.x" } 15 | { lib: "ph.points", versions: "0.1.x" } 16 | } 17 | categories: {"ph", "hvac"} 18 | license: "AFL-3.0" 19 | org: { 20 | dis: "Project Haystack" 21 | uri: "https://project-haystack.org/" 22 | } 23 | vcs: { 24 | type: "git" 25 | uri: "https://github.com/Project-Haystack/xeto.git" 26 | } 27 | > 28 | 29 | -------------------------------------------------------------------------------- /src/xeto/ashrae.g36/vavs.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // This file includes five VAV templates from ASHRAE Guideline 36 6 | // Author: Avijit Saha, Jaime Gagne, Maggie Sullivan 7 | // 8 | 9 | // Suggested Marker Tags in the tags.pog file 10 | // override: Marker 11 | // window: Marker 12 | 13 | // Guideline 36 base type for VAVs terminal units 14 | G36Vav : Vav { 15 | points: { 16 | ZoneAirTempSensor 17 | ZoneAirTempEffectiveSp 18 | ZoneOccupiedSensor 19 | ZoneCo2Sensor 20 | //{window, override, cmd, point} 21 | } 22 | } 23 | 24 | // Guideline 36 Fan Powered Terminal Unit 25 | G36FanPoweredTerminalUnit : G36Vav { 26 | fanPowered 27 | hotWaterHeating 28 | singleDuct 29 | points: { 30 | DischargeFanSpeedCmd 31 | DischargeFanRunSensor 32 | DischargeFanRunCmd 33 | DischargeDamperCmd 34 | HotWaterValveCmd 35 | DischargeAirFlowSensor 36 | DischargeAirTempSensor 37 | } 38 | } 39 | 40 | // Guideline 36 Dual-Duct Terminal Unit with Inlet Sensors 41 | G36DualDuctVavInlet : G36Vav { 42 | dualDuct 43 | coolingOnly 44 | points: { 45 | ColdDeckDischargeDamperCmd 46 | HotDeckDischargeDamperCmd 47 | ColdDeckDischargeAirFlowSensor 48 | HotDeckDischargeAirFlowSensor 49 | } 50 | } 51 | 52 | // Guideline 36 Dual-Duct Terminal Unit with Discharge Sensor 53 | G36DualDuctVavOutlet : G36Vav { 54 | dualDuct 55 | coolingOnly 56 | points: { 57 | ColdDeckDischargeDamperCmd 58 | HotDeckDischargeDamperCmd 59 | DischargeAirFlowSensor 60 | } 61 | } 62 | 63 | // Guideline 36 Variable Air Volume Box With Reheat 64 | G36ReheatVav : G36Vav { 65 | hotWaterHeating 66 | singleDuct 67 | points: { 68 | HotWaterValveCmd 69 | DischargeDamperCmd 70 | DischargeAirFlowSensor 71 | DischargeAirTempSensor 72 | } 73 | } 74 | 75 | // Guideline 36 Cooling Only VAV 76 | G36CoolingOnlyVav : G36Vav { 77 | singleDuct 78 | coolingOnly 79 | points: { 80 | DischargeDamperCmd 81 | DischargeAirFlowSensor 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto.tools/Setup.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | [Haxall](https://haxall.io) is an open source framework that includes 4 | the reference implementation of Xeto. It provides a suite of command 5 | line tools for working with Xeto. Haxall is written in the [Fantom](https://fantom.org) 6 | programming language which allows the Xeto tools to run with either 7 | NodeJS or Java. 8 | 9 | # Install for Java 10 | 11 | Follow the setup instructions from [Haxall docs](https://haxall.io/doc/docHaxall/Setup): 12 | 13 | 1. Install Java on your system 14 | 2. Download and unzip the last release from [GitHub](https://github.com/haxall/haxall/releases) 15 | 3. Run 'xeto version' to verify install 16 | 17 | ``` 18 | bin/xeto version 19 | ``` 20 | 21 | # Install for NodeJS 22 | 23 | Install [@haxall/haxall](https://www.npmjs.com/package/@haxall/haxall) using 24 | npm as follows: 25 | 26 | 1. Install '@haxall/haxall' using npm (if you get a permission error on Unix 27 | then run via sudo) 28 | 29 | ``` 30 | npm i -g @haxall/haxall 31 | ``` 32 | 33 | 2. Run 'xeto version' to verify install 34 | 35 | ``` 36 | xeto version 37 | ``` 38 | 39 | See NPM docs on package.json [bin scripts](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#bin) for additional details. 40 | 41 | # Env Path 42 | 43 | The Haxall tools all rely on a search path used to find Xeto libraries. The 44 | path is composed of a list of one or more directories on the local 45 | file system which is searched from beginning to end. The first directory 46 | is called the *workDir* and it is the default location to create and 47 | install new libs. The last directory in the path is called the *homeDir* 48 | and is always where you installed Haxall. 49 | 50 | The workDir and path are configured based on your current working 51 | directory by walking up the path looking for one of the following files 52 | to mark the root of your workDir: 53 | 54 | 1. 'xeto.props' - explicit configuration for Xeto 55 | 2. 'fan.props' - use standard [Fantom path](https://fantom.org/doc/docLang/Env#PathEnv) behavior 56 | 3. '.git' - assume you are developing new libs with Git version control 57 | 4. Fallback is to assume workDir is same as homeDir (where you installed Haxall) 58 | 59 | You can configure additional directories in your search path by adding the 'path' 60 | line to your "xeto.props" file. The value is a list of directories separated by 61 | a semicolon (note we do not use colon even on Unix). You can use "../" to 62 | specify a directory relative to the workDir. 63 | 64 | Example "xeto.props": 65 | 66 | ``` 67 | path=/work/project-libs;/work/global-libs 68 | ``` 69 | 70 | You can debug your environment setup using the 'xeto version' command: 71 | 72 | ``` 73 | /work/acme-lib> xeto version 74 | 75 | ... 76 | 77 | xeto.version: 3.1.12 78 | xeto.mode: xeto.props 79 | xeto.workDir: /work/acme-libs 80 | xeto.homeDir: /work/haxall-home 81 | xeto.installDir: /work/acme-libs 82 | xeto.path: 83 | /work/acme-libs 84 | /work/project-libs 85 | /work/global-libs 86 | /work/haxall-home 87 | ``` 88 | 89 | We always search the path looking for source and xetolib files according 90 | to the naming convention: 91 | 92 | ``` 93 | {dir}/src/xeto/{lib-name}/ 94 | {dir}/lib/xeto/{lib-name}/ 95 | ``` 96 | 97 | So in the above example we would search the following directories 98 | for a library named "acme.templates": 99 | 100 | ``` 101 | /work/acme-libs/src/xeto/acme.templates/ 102 | /work/acme-libs/lib/xeto/acme.templates/ 103 | /work/project-libs/src/xeto/acme.templates/ 104 | /work/project-libs/lib/xeto/acme.templates/ 105 | /work/global-libs/src/xeto/acme.templates/ 106 | /work/global-libs/lib/xeto/acme.templates/ 107 | /work/haxall-home/src/xeto/acme.templates/ 108 | /work/haxall-home/lib/xeto/acme.templates/ 109 | ``` 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto.tools/index.md: -------------------------------------------------------------------------------- 1 | # Xeto CLI Tool 2 | 3 | - [Setup](Setup.md): installation and setup instructions 4 | 5 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto.tools/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 21 Nov 2024 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "Xeto tools documentation" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | } 15 | categories: {"sys", "doc"} 16 | license: "AFL-3.0" 17 | org: { 18 | dis: "Project Haystack" 19 | uri: "https://project-haystack.org/" 20 | } 21 | vcs: { 22 | type: "git" 23 | uri: "https://github.com/Project-Haystack/xeto.git" 24 | } 25 | > 26 | 27 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto.tutorials/DeepDive.md: -------------------------------------------------------------------------------- 1 | # Video 2 | 3 | ![Youtube video](video://youtu.be/UvxWmU72wvs?si=ovuiq7xHuCu4J-v8) 4 | 5 | Deep dive into programming in Xeto recorded in May 2023. 6 | 7 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto.tutorials/Intro.md: -------------------------------------------------------------------------------- 1 | # Video 2 | 3 | ![Youtube video](video://youtu.be/fr-K-MVbAa8?si=dnJTcLsVdzfUfE7T) 4 | 5 | Introduction to Xeto recorded in 2023. 6 | 7 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto.tutorials/index.md: -------------------------------------------------------------------------------- 1 | # Xeto Tutorials 2 | 3 | - [Intro](Intro.md): introduction video 4 | - [Deep Dive](DeepDive.md): deep drive into programming with Xeto 5 | 6 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto.tutorials/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 29 Apr 2025 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "Xeto tutorials and training videos" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | } 15 | categories: {"sys", "doc"} 16 | license: "AFL-3.0" 17 | org: { 18 | dis: "Project Haystack" 19 | uri: "https://project-haystack.org/" 20 | } 21 | vcs: { 22 | type: "git" 23 | uri: "https://github.com/Project-Haystack/xeto.git" 24 | } 25 | > 26 | 27 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Choices.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Choices define exclusive relationship between a set of marker tags. 4 | They are used as "adjectives" in an ontology to add additional constrains 5 | that work in conjunction with the primary inheritance hierarchy. For 6 | example, a sensor measures the `ph::Quantity` of a specific `ph::Phenomenon`. 7 | Both quantity and phenomenon are mutually exclusive. A given sensor 8 | point cannot report both air temperature and air humidity - it has a 9 | single current value that is one or the other. 10 | 11 | # Syntax 12 | 13 | Choices leverage spec inheritance to build out a taxonomy of the 14 | choices. The root of the taxonomy extends `sys::Choice`. Choice 15 | specs can define only marker type slots. For example to build a 16 | exclusive set of markers to model color: 17 | 18 | ```xeto 19 | Color: Choice 20 | Red: Color { red } 21 | Green: Color { green } 22 | Blue: Color { blue } 23 | ``` 24 | 25 | When an entity defines the 'Color' choice it creates a validation rule 26 | that instances must have exactly one of the marker tags: 'red', 'blue', 27 | or 'blue'. Here is an example: 28 | 29 | ```xeto 30 | // color is required 31 | Car: { 32 | color: Color 33 | } 34 | 35 | // instances 36 | Car {red} // valid 37 | Car {} // invalid, color is required 38 | Car {red, blue} // invalid, red and blue are mutually exclusive 39 | ``` 40 | 41 | You can use a [maybe](TypeSystem.md#maybe) choice to define zero 42 | or one choice selection: 43 | 44 | ```xeto 45 | // color is required 46 | Car: { 47 | color: Color? 48 | } 49 | 50 | // instances 51 | Car {red} // valid 52 | Car {} // valid, color is maybe type 53 | Car {red, blue} // invalid, red and blue are mutually exclusive 54 | ``` 55 | 56 | # MultiChoice 57 | 58 | If the choice is not mutually exclusive then add the 'multiChoice' 59 | marker to call site. This allows instances to make multiple selections 60 | of the choice. Extending our car example from above: 61 | 62 | ```xeto 63 | // color is required multi choice 64 | Car: { 65 | color: Color 66 | } 67 | 68 | // instances 69 | Car {red} // valid 70 | Car {} // invalid, at least one color is required 71 | Car {red, blue} // valid 72 | ``` 73 | # Scope 74 | 75 | Choices are by design open ended. Any lib in the [namespace](Namespaces.md) can 76 | add additional choices via inheritance. This means that the range of choices 77 | might vary based on what libs are loaded into the namespace. If a choice 78 | should be a closed set, then add the 'sealed' metadata: 79 | 80 | ```xeto 81 | Color: Choice 82 | ``` 83 | 84 | The sealed marker indicates that only specs within the parent lib 85 | can extend the choice. 86 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Constraints.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Xeto includes a built-in set of constraint rules that are used 4 | for data validation. 5 | 6 | # Number Constraints 7 | 8 | Number specs can be annotated with the following meta to constrain 9 | their value space: 10 | 11 | - 'minVal': inclusive minimum value 12 | - 'maxVal': inclusive maximum value 13 | - 'unit': requires the number to have a specific unit 14 | - 'quantity': requires the number to have a unit of a specific quantity 15 | 16 | Examples: 17 | 18 | ``` xeto 19 | Foo: { 20 | percent: Number 21 | powerVal: Number 22 | } 23 | 24 | // Slot 'percent': Number 50°C must have unit of '%' 25 | @a: Foo { percent:50°C, powerVal:70kW } 26 | 27 | // Slot 'percent': Number 200% > maxVal 100 28 | @b: Foo { percent:200%, powerVal:70kW } 29 | 30 | // Slot 'power': Number must be 'power' unit; '°C' has quantity of 'temperature' 31 | @c: Foo { percent:50%, powerVal:70°C } 32 | ``` 33 | 34 | # Str Constraints 35 | 36 | Str specs can be annotated with the following meta to constrain 37 | their value space: 38 | 39 | - 'minVal': inclusive minimum length 40 | - 'maxVal': inclusive maximum length 41 | - 'nonEmpty': marker tag to require string to have non-whitespace characters 42 | - 'pattern': regex for required string pattern (example further below) 43 | 44 | ``` xeto 45 | Foo: { 46 | name: Str 47 | phone: Str 48 | } 49 | 50 | // Slot 'name': String must be non-empty 51 | @a: Foo { name:"", phone:"5551234" } 52 | 53 | // Slot 'phoneNum': String size 3 < minSize 7 54 | @b: Foo { name:"Bob", phone:"555" } 55 | 56 | // Slot 'phoneNum': String size 11 > maxSize 10 57 | @c: Foo { name:"Bob", phone:"21255512345" } 58 | ``` 59 | 60 | # List Constraints 61 | 62 | List specs can be annotated with the following meta to constrain 63 | their value space: 64 | 65 | - 'minVal': inclusive minimum length 66 | - 'maxVal': inclusive maximum length 67 | - 'nonEmpty': marker tag to require at least one item 68 | 69 | ``` xeto 70 | Foo: { 71 | listA: List 72 | listB: List 73 | } 74 | 75 | // Slot 'listA': List must be non-empty 76 | @a: Foo { listA:{}, listB:{"a", "b"}} 77 | 78 | // Slot 'listB': List size 1 < minSize 2 79 | @b: Foo { listA:{"x"}, listB:{"a"}} 80 | 81 | // Slot 'listB': List size 4 > maxSize 3 82 | @c: Foo { listA:{"x"}, listB:{"a", "b", "c", "d"}} 83 | ``` 84 | 85 | # Scalar Constraints 86 | 87 | All scalars must support a string encoding. The string encoding can 88 | be constrained at compile time using the 'pattern' tag with a regular 89 | expression: 90 | 91 | ```xeto 92 | SocialSecurityNumber: Scalar 93 | 94 | // ok 95 | @a: {ssn: SocialSecurityNumber "123-43-5678"} 96 | 97 | // String encoding does not match pattern for 'acme::SocialSecurityNumber' 98 | @b: {ssn: SocialSecurityNumber "123435678"} 99 | ``` 100 | 101 | # Fixed Values 102 | 103 | A spec can define a fixed value for a slot via the 'fixed' marker. 104 | A fixed value requires all instances to have that exact value. 105 | 106 | ``` xeto 107 | Foo: { 108 | // requires all instances to use the fixed value "%" 109 | unit: Unit "%" 110 | } 111 | 112 | // Slot 'unit': Must have fixed value '%' 113 | @a: Foo {unit:"meter"} 114 | ``` -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Enums.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Specs which inherit from `sys::Enum` define a closed enumerated range of 4 | string values. Enum specs are effectively sealed and cannot be extended. 5 | 6 | # Syntax 7 | 8 | Enums are declared just like a dict spec with the enumerated range defined 9 | as slots between curly braces: 10 | 11 | ```xeto 12 | Suit: Enum { 13 | clubs 14 | diamonds 15 | hearts 16 | spades 17 | } 18 | ``` 19 | 20 | The slot names define the range of valid string values for the enumerated type. 21 | The slots must not define a type - they are implied to be items for the parent 22 | enum type. The enum above specifies any value typed as Suit must be one of the 23 | following string values: "clubs", "diamonds", "hearts", or "spades". 24 | 25 | In the case when the range of string values are not valid slot names, then 26 | define the string value via 'key' in the slot metadata: 27 | 28 | ```xeto 29 | Suit: Enum { 30 | clubs 31 | diamonds 32 | hearts 33 | spades 34 | } 35 | ``` 36 | 37 | The enum spec above has a valid range of "Clubs", "Diamonds", "Hearts", 38 | or "Spades". Note in this case the slot names such as "clubs" is **not** 39 | a valid string value for the enum. 40 | 41 | You can also add arbitrary metadata to the enum and slots: 42 | 43 | ```xeto 44 | Suit: Enum { 45 | clubs 46 | diamonds 47 | hearts 48 | spades 49 | } 50 | ``` 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Fidelity.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Xeto provides an extensible, opened ended type system. Translating Xeto data 4 | to other data formats with less flexible type systems results in type erasure. 5 | We the use term *fidelity* to precisely describe how type erasure occurs. 6 | 7 | Three levels of fidelity are defined: 8 | 9 | - **Full Fidelity**: all types are completely modeled with no loss of fidelity 10 | - **Haystack Fidelity**: only the core Haystack types are used and 11 | all non-native scalars encode as simple strings 12 | - **JSON Fidelity**: most scalars are encoded as just strings 13 | 14 | # Full Fidelity 15 | 16 | Full fidelity requires that there is zero type erasure. All types 17 | (including scalars) must fully describe their type. Implementations 18 | must take special care how scalars are treated. Common low-level types 19 | such as 'Bool', 'Int', and 'Str' are sealed to more easily map to the 20 | native types of the implementation programming language. 21 | 22 | The only data serialization format that supports full fidelity is the 23 | Xeto format itself. 24 | 25 | The Haxall reference implementation uses the following strategy: 26 | 1. Map all system level specs to built-in Fantom classes 27 | 2. Allow users to customize mapping specs to Fantom classes via a factory framework 28 | 3. If there is no Fantom class mapping for a scalar we use a generic Scalar 29 | class that tracks the type qname and string encoding 30 | 31 | This design allows us to track all objects in memory back to their Xeto specs 32 | with no loss of fidelity. This strategy is non-normative, other implementations 33 | are free to tackle the problem however they they see fit. 34 | 35 | # Haystack Fidelity 36 | 37 | The Project Haystack type system provides a fixed set of types similar to 38 | that found in XML Schema. The Haystack kinds map one-to-one to Xeto 39 | specs as follows: 40 | 41 | ``` 42 | Xeto Haystack 43 | ----------- ----- 44 | sys::Marker Marker 45 | sys::NA NA 46 | sys::None Remove 47 | sys::Bool Bool 48 | sys::Number Number 49 | sys::Int Number (no unit) 50 | sys::Float Number (no unit) 51 | sys::Duration Number (time unit) 52 | sys::Str Str 53 | sys::Ref Ref 54 | sys::Uri Uri 55 | sys::Date Date 56 | sys::Time Time 57 | sys::DateTime DateTime 58 | sys::List List 59 | sys::Dict Dict 60 | sys::Grid Grid 61 | ph::Coord Coord 62 | ph::Symbol Symbol 63 | ``` 64 | 65 | Any scalar not mapped above is encoded in Haystack as a simple string. 66 | All dicts must declare a 'spec' tag to declare their Xeto spec. 67 | Lists are untyped in Haystack. We do not currently define a mapping 68 | for XStr - they should map to a specific scalar spec. 69 | 70 | Haystack fidelity is used when exchanging or validating data encoded 71 | using Haystack formats such as Zinc or Hayson. 72 | 73 | # JSON Fidelity 74 | 75 | JSON is widely used as a data interchange format. JSON supports a very 76 | limited type system, which requires significant type erasure. We opt for 77 | a clean, simple JSON mapping where most scalars are mapped to a string (versus 78 | mapping scalars to JSON objects). The following mapping is used: 79 | 80 | ``` 81 | Xeto JSON 82 | ---- ---- 83 | sys::Bool boolean 84 | sys::Int number 85 | sys::Float number 86 | sys::Number number (if no unit) 87 | sys::Number string (if there is a unit or NaN/-INF/INF) 88 | sys::Scalar string (all other scalars encode as string) 89 | sys::List array 90 | sys::Dict object 91 | ``` 92 | 93 | All dicts should include a 'spec' property with the type qname. 94 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Globals.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Globals are slot spec definitions that globally apply to all dict specs 4 | and instances. They provide a way to force the use of a consistent slot 5 | field type across all specs. They enforce a [covariant](TypeSystem.md#covariance) 6 | override in all specs of the parent lib and all libs that depend on 7 | the parent lib. Additionally all instance data is restricted by the global 8 | slots. 9 | 10 | # Names 11 | 12 | Globals follow same rules as [slot names](Specs.md#names): 13 | - Must contain only ASCII lower case letters, digits, or underbar 14 | - Must start with an ASCII lower case letter 15 | - Convention is to use camel case 16 | 17 | Additionally, it is invalid to declare a global spec that is already 18 | defined in one of the dependency libs. 19 | 20 | # Syntax 21 | 22 | Global specs follow the same syntax rules as [slot specs](Specs.md#slots): 23 | 24 | ```xeto 25 | globalTag: Type "default" 26 | ``` 27 | 28 | Here are concrete examples from the 'ph' lib: 29 | 30 | ```xeto 31 | // Area of a shape or floor space 32 | area: Number 33 | 34 | // Equipment used to store electric energy 35 | battery: Marker 36 | ``` 37 | 38 | # Examples 39 | 40 | Here is an example of a global spec: 41 | 42 | ```xeto 43 | height: Number 44 | ``` 45 | 46 | This forces all dict specs in the parent lib and all libs that depend 47 | on the parent lib to conform to this slot spec. Examples dicts: 48 | 49 | ```xeto 50 | // This spec is OK because it matches global type 51 | SomeDict: Dict { 52 | height: Number 53 | } 54 | 55 | // This spec is OK because it is a covariant override 56 | // compatible with the global since Int is a subtype of Number 57 | AnotherDict: Dict { 58 | height: Int 59 | } 60 | 61 | // This will not compile because the type is not compatible 62 | // with global; Str is not a subtype of Number 63 | InvalidDict: Dict { 64 | height: Str 65 | } 66 | ``` 67 | 68 | Globals also restrict instance data: 69 | 70 | ```xeto 71 | // OK because slot matches global slot restrictions 72 | @instance-1: { height: Number "12m" } 73 | 74 | // Error: Global slot type is 'sys::Number', value type is 'sys::Date' 75 | @instance-2: { height: Date "2024-12-03" } 76 | 77 | // Error: Number must be 'length' unit; '°C' has quantity of 'temperature' 78 | @instance-3: { height: Number 12°C } 79 | ``` 80 | 81 | # Inheritance 82 | 83 | When a dict spec declares a slot that matches a global spec, then it 84 | automatically inherits from that spec. In the reflection APIs and AST 85 | the slot will have a 'base' which references the global. The dict 86 | slot will inherit all the global's metadata. In the example above, both 87 | 'SomeDict.height' and 'AnotherDict.height' will inherit the 'quantity' 88 | and 'minVal' metadata tag from the global spec. 89 | 90 | # Project Haystack Tags 91 | 92 | Historically the Project Haystack ontology has required consistent use 93 | of all tags across all entity types. The `ph` library uses globals to 94 | enforce this design pattern. Every tag from 'ph' is defined as a global. 95 | This requires that every lib that depends on 'ph' to declare slots 96 | that are type compatible with the global tag definitions. 97 | 98 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Grammar.md: -------------------------------------------------------------------------------- 1 | # Grammar 2 | 3 | The formal BNF grammar for Xeto: 4 | 5 | 6 | ``` 7 | := [ | ]* 8 | := | * // single scalar/dict or list of named dicts 9 | := ":" 10 | := ":" 11 | 12 | := [ []] [] // must have at one 13 | := | 14 | := 15 | := "{" [ ]* "}" 16 | := [] ( | | ) [] 17 | := [] 18 | := ( [","] ) | "," 19 | := "<" ">" 20 | := ( )+ 21 | := "---" 22 | := "---" 23 | := // lines with same indentation as heredoc start 24 | 25 | := | | | 26 | := // may want to allow List 27 | := [] 28 | := [] "{" "}" 29 | := [ ]* 30 | := | | | 31 | | | 32 | := 33 | := ":" 34 | := 35 | := ":" 36 | := ":" 37 | := 38 | 39 | := | | | 40 | := "?" 41 | := ("&" )+ 42 | := ("|" )+ 43 | := 44 | 45 | := ()* 46 | := 47 | 48 | := [ "::"] 49 | := ("." )* 50 | := * 51 | := * 52 | := alpha | digit | '_' 53 | := "@" * [ ] 54 | := | | "_" | "~" | ":" | "-" 55 | := | | "_" | "~" // cannot end with ":" or "-" 56 | := alphaLower | alphaUpper 57 | := 'a' - 'z' 58 | := 'A' - 'Z' 59 | := '0' - '9' 60 | := ' ' 61 | 62 | := see below 63 | := single quoted string, see below 64 | ``` 65 | 66 | # Scalars 67 | 68 | Scalar values may take one of the following formats: 69 | - single double-quoted string such as "hi" 70 | - triple double-quoted strings such as """my name is "Brian", hi!""" 71 | - numbers with embedded units/symbols such as 123% or 2023-03-04 72 | - refs that start with "@" (see above) 73 | 74 | Quoted strings use the same backslash escape sequence as C languages: 75 | - '\n' for newline 76 | - '\\' for backslash itself 77 | - '\"' for double-quote itself (triple quoted string does not require escaping) 78 | - '\u2023" unicode hex value 79 | 80 | Triple quoted strings follow these indentation normalization rules: 81 | - If opening triple quote line is empty, then next line is the first line 82 | - Indentation is based on left-most line/closing quote 83 | - Any leading spaces are trimmed based on inferred indentation 84 | 85 | Number literals must start with an ASCII digit or "-" followed by an ASCII digit. 86 | Any of the following characters are matched to tokenize the number literal: 87 | - ASCII digit or letter 0-9, A-Z, a-z 88 | - "." dot (0x2E) 89 | - "-" dash (0x2D) 90 | - ":" colon (0x3A) 91 | - "/" forward slash (0x2F) 92 | - "$" dollar sign (0x24) 93 | - "%" percent sign (0x25) 94 | - any Unicode character > 0x7F 95 | 96 | # Legend 97 | Legend for BNF Grammar: 98 | 99 | ``` 100 | := is defined as 101 | non-terminal 102 | "x" literal 103 | 'x' char literal 104 | [x] optional 105 | (x) grouping 106 | s-e inclusive char range 107 | x* zero or more times 108 | x+ one or more times 109 | x|x or 110 | ``` -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Inheritance.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Xeto uses a form of object oriented inheritance as the main 4 | mechanism for composition. All type specs are declared to inherit 5 | from one or more other specs. The only exception to this rule 6 | is `sys::Obj` which is the root of the type hierarchy (it is the 7 | top of any type). 8 | 9 | Inheritance is used semantically to define a taxonomy of concepts. We 10 | use the terms *supertype* and *subtype* to define the two sides of an 11 | inheritance relationship. For example, `ph::Water` is a subtype `ph::Liquid`; 12 | conversely we say that `ph::Liquid` is the supertype `ph::Water`. From 13 | a semantic or type theory perspective this means that water is a specific 14 | type of liquid but that there are other types of liquid that are not water 15 | (such as `ph::Gasoline`). 16 | 17 | Inheritance is also used structurally to have subtypes inherit metadata 18 | and slots from supertypes. Inheritance rules ensure the Liskov Substitution 19 | Principle which guarantees a subtype is substitutable for its supertype. 20 | To enforce these rules, the Xeto compiler includes many compile time checks 21 | found in statically typed programming language. 22 | 23 | # Meta 24 | 25 | Specs inherit most metadata from their supertype(s). Meta is not 26 | inherited if it is defined with the `noInherit` tag (such as the `abstract` 27 | meta tag). Subtypes may add additional meta tags and may override 28 | meta from the supertype only if [covariant](TypeSystem.md#covariance). 29 | 30 | # Slots 31 | 32 | Dict subtypes inherit all the slots from their supertype(s). Subtypes 33 | can add new slots with new names. And subtypes can override slots 34 | from their supertype as long as they follow [covariance](TypeSystem.md#covariance) 35 | rules. 36 | 37 | In the example below the spec 'Bar' implicitly inherits the slots 'a' and 38 | 'b', plus adds its own slot 'c': 39 | 40 | ```xeto 41 | Foo: { 42 | a: Str 43 | b: Date 44 | } 45 | 46 | Bar: Foo { 47 | c: Number 48 | } 49 | ``` 50 | 51 | In this example, we show how a subtype can covariantly override a slot 52 | to narrow the type and/or add additional meta: 53 | 54 | ```xeto 55 | Foo: { 56 | num: Number 57 | } 58 | 59 | Bar: Foo { 60 | num: Int 61 | } 62 | ``` 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Instances.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Instances are the objects that represent the data modeled 4 | by specs. Instances are always dicts (dictionaries) or 5 | JSON objects. Instances may be defined within a [lib](Libs.md) 6 | or outside of a lib. 7 | 8 | # Id 9 | All instances must define an 'id' tag that is the unique identifier 10 | for the data entity. The 'id' tag must always be a Ref value. Instances 11 | which are defined within a lib will have a id formed from the qname: 12 | 13 | ```xeto 14 | // instance in lib acme.widgets; id is @acme.widgets::sku-123 15 | @sku-123: Part {...} 16 | ``` 17 | 18 | Instances outside of a lib will have an identifier that is 19 | project or system based. It is illegal for a non-lib id 20 | to contain "::" double colons; that format is reserved 21 | for lib instances. 22 | 23 | The scope of uniqueness for lib instances is global due to the 24 | fact that lib names are [globally unique](Libs.md#names). For 25 | non-lib instances the id must at least be unique within the 26 | containing dataset. 27 | 28 | # Spec 29 | 30 | Instances declare their type spec via the 'spec' tag. The value 31 | is a Ref with the spec qname. When the instance is declared via 32 | Xeto in a lib, the 'spec' tag is implied: 33 | 34 | ``` 35 | // Xeto instance - spec is ph::ElecMeter via name resolution 36 | @meter-1: ElecMeter {...} 37 | 38 | // Haystack instance 39 | id: @meter-1 40 | spec: @ph::ElecMeter 41 | 42 | // JSON object 43 | { 44 | "id": "meter-1", 45 | "spec": "ph::ElecMeter" 46 | } 47 | ``` 48 | 49 | # Syntax 50 | 51 | Lib instances follow the given syntax: 52 | 53 | ```xeto 54 | // separate slot tags with newline 55 | @id: TypeSpec { 56 | slotA: valA 57 | slotB: valB 58 | ... 59 | } 60 | 61 | // or separate slot tags with comma 62 | @id: TypeSpec { 63 | slotA: valA, slotB: valB, slot: valC 64 | ... 65 | } 66 | 67 | // the value can be omitted if it is a marker 68 | @id: TypeSpec { 69 | markerA, markerB 70 | } 71 | ``` 72 | 73 | Unlike specs, instances cannot define meta using '<>'. 74 | 75 | For example to create an instance of a floor and room: 76 | 77 | ```xeto 78 | @floor-2: Floor { 79 | dis: "Floor 2" 80 | } 81 | 82 | @room-204: Room { 83 | dis: "Room 204" 84 | spaceRef: @floor-2 85 | } 86 | ``` 87 | 88 | Note that we can cross reference other instances inside the lib 89 | using relative ids (absolute qnames are also permitted). All 90 | the non-maybe tags from the spec type are automatically added 91 | into the instance. The instances in the example above evaluate 92 | to the following Haystack dicts: 93 | 94 | ```trio 95 | id: @acme::floor-2 96 | spec: @ph::Floor 97 | dis: "Floor 2" 98 | space 99 | floor 100 | --- 101 | id: @acme::room-204 102 | spec: @ph::Room 103 | spaceRef: @acme::floor-2 104 | space 105 | room 106 | ``` 107 | 108 | Note that the `space` and `floor`/`room` markers are implied 109 | from the instance specs `ph::Floor` and `ph::Room`. 110 | 111 | The instances above map the following JSON representation: 112 | 113 | ```json 114 | { 115 | "id": "acme::floor-2" 116 | "spec": "ph::Floor", 117 | "dis": "Floor 2", 118 | "space": "✓", 119 | "floor": "✓" 120 | } 121 | 122 | { 123 | "id": "acme::room-204" 124 | "spec": "ph::Room", 125 | "dis": "Room 204", 126 | "spaceRef": "acme::floor-2", 127 | "space": "✓", 128 | "room": "✓" 129 | } 130 | ``` 131 | 132 | # Nesting Instances 133 | 134 | Xeto allows instances to be nested into a tree of dicts. 135 | Nested instances can have a slot name, a top-level id, or both. 136 | 137 | Here is an example where the nested dicts have only a slot name: 138 | 139 | ```xeto 140 | Toolbar: Dict 141 | Button: Dict 142 | 143 | @toolbar: Toolbar { 144 | save: Button { text:"Save" } 145 | exit: Button { text:"Exit" } 146 | } 147 | ``` 148 | 149 | This maps to the following Haystack and JSON representations 150 | where 'save' and 'exit' are just named slots that contain a 151 | nested dict: 152 | 153 | ```trio 154 | // Trio 155 | id: @acme::toolbar 156 | spec: @acme::Toolbar 157 | exit: {spec:@acme::Button, text:"Exit" } 158 | save: {spec:@acme::Button, text:"Save"} 159 | ``` 160 | 161 | ```json 162 | // JSON 163 | "toolbar": { 164 | "id": "acme::toolbar" 165 | "spec": "acme::Toolbar", 166 | "save": { 167 | "spec": "acme::Button" 168 | "text": "Save", 169 | }, 170 | "exit": { 171 | "spec": "acme::Button" 172 | "text": "Exit", 173 | }, 174 | } 175 | ``` 176 | 177 | But we can also make those nested dicts first class instances with 178 | an id using this syntax by adding an id after the slot name and 179 | before the colon: 180 | 181 | ```xeto 182 | // Xeto 183 | @toolbar: Toolbar { 184 | save @save-button: Button { text:"Save" } 185 | exit @exit-button: Button { text:"Exit" } 186 | } 187 | ``` 188 | 189 | ```trio 190 | // Haystack 191 | id: @acme::toolbar 192 | exit: {id:@acme::exit-button spec:@acme::Button text:"Exit"} 193 | save: {id:@acme::save-button spec:@acme::Button text:"Save"} 194 | spec: @acme::Toolbar 195 | ``` 196 | 197 | ```json 198 | // JSON 199 | "toolbar": { 200 | "id": "acme::toolbar" 201 | "spec": "acme::Toolbar", 202 | "save": { 203 | "id": "acme::save-button", 204 | "spec": "acme::Button" 205 | "text": "Save", 206 | }, 207 | "exit": { 208 | "id": "acme::exit-button", 209 | "spec": "acme::Button" 210 | "text": "Exit", 211 | }, 212 | } 213 | ``` 214 | 215 | In many use cases if we don't care about the slot name, only 216 | the nested id, in which case we can omit the slot name and 217 | one is auto-generated for us: 218 | 219 | ```xeto 220 | // Xeto 221 | @toolbar: Toolbar { 222 | @save-button: Button { text:"Save" } 223 | @exit-button: Button { text:"Exit" } 224 | } 225 | ``` 226 | 227 | ```trio 228 | // Haystack 229 | id: @acme::toolbar 230 | _0: {id:@acme::save-button spec:@acme::Button text:"Save"} 231 | _1: {id:@acme::exit-button spec:@acme::Button text:"Exit"} 232 | spec: @acme::Toolbar 233 | ```` 234 | 235 | ```json 236 | // JSON 237 | "toolbar": { 238 | "id": "acme::toolbar" 239 | "spec": "acme::Toolbar", 240 | "_0": { 241 | "id": "acme::save-button", 242 | "spec": "acme::Button" 243 | "text": "Save", 244 | }, 245 | "_1": { 246 | "id": "acme::exit-button", 247 | "spec": "acme::Button" 248 | "text": "Exit", 249 | }, 250 | } 251 | ``` 252 | 253 | Note that in the reflection APIs the nested instances can be looked 254 | up directly. However, when exporting libs that contain nested instances 255 | only top-level instances are included (with their nested instances). 256 | 257 | 258 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Libs.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Libs or libraries are used to package Xeto into versioned modules. Libs 4 | are deployed as zip files with the "xetolib" extension and contain the 5 | source for the library's specs, globals, instances, and additional resource 6 | files. Libs define explicit dependencies for the specs and instances they 7 | import into their namespace. 8 | 9 | # Names 10 | 11 | Libs have a globally unique dotted name. Lib names must obey the following 12 | restrictions: 13 | - Must contain only ASCII lower case letters, digits, or underbar 14 | - Use dot as separator character 15 | - Each dotted section must start with a lowercase ASCII letter 16 | - Dots and underbars may only be used between letters and digits 17 | 18 | Example of valid vs invalid lib names: 19 | 20 | ``` 21 | foo // ok 22 | foo.bar // ok 23 | foo.bar_13 // ok 24 | foo!bar // error - invalid char "!" 25 | foo.7bar // error - dotted sections must start with lowercase 26 | foo_.bar // error - underbar may not be adjacent to dot 27 | foo__bar // error - underbar may not be adjacent to another underbar 28 | foo.barBaz // error - only lower case ASCII letters permitted 29 | ``` 30 | 31 | The lib name is determined by the directory name of the Xeto source 32 | code. For example to create library called "acme.assets", then your 33 | source tree would be organized: 34 | 35 | ``` 36 | src/xeto/ 37 | acme.assets/ // directory name determines lib name 38 | lib.xeto // must have a pragma file with this name 39 | specs.xeto // additional definitions 40 | ``` 41 | 42 | # Lib Name Prefixes 43 | 44 | In order to guarantee globally unique names, the following conventions are 45 | used for lib name prefixes: 46 | 47 | - Reverse DNS names are reserved for the top level domains: com, org, net, 48 | gov, edu, and io 49 | - The prefix "cc." is reserved for community contributions 50 | - Top level prefixes are granted when appropriate to avoid name squatting 51 | 52 | The Project Haystack non-profit organization manages prefix registration 53 | on the https://xeto.dev website. Both "cc." and top level prefixes should 54 | be registered on the website for your organization. 55 | 56 | For example, if you own the DNS domain "acme.com", then you automatically 57 | own the "com.acme" lib name (as well as names that start with "com.acme."). 58 | This same convention is also followed by the Java community for package naming. 59 | Note: there is a plethora of TLDs now, we currently only standardize a 60 | limited set (the most common ones). 61 | 62 | If you are vendor or have a project with a name such as FooBar, then 63 | you can request a top level prefix for "foobar" at https://xeto.dev. Or if 64 | developing a community contribution for a vendor named "Baz", you 65 | can request "cc.baz". Top-level prefixes that would conflict with 66 | DNS top level domains such as country codes will not be granted. 67 | 68 | # Pragma 69 | 70 | All libs must define their metadata file in a file named "lib.xeto". 71 | Lib meta includes: 72 | - version 73 | - dependencies 74 | - summary documentation 75 | - organization metadata 76 | 77 | Lib metadata is declared in lib.xeto via the *pragma*. Here is an 78 | example template: 79 | 80 | ```xeto 81 | pragma: Lib < 82 | doc: "Summary of the lib goes here" 83 | version: "2.0.6" 84 | depends: { 85 | { lib: "sys", versions: "1.0.x" } 86 | { lib: "foo.bar", versions "2.x.x" } 87 | } 88 | org: { 89 | dis: "Acme, Inc" 90 | uri: "https://acme.com/" 91 | } 92 | > 93 | ``` 94 | 95 | Specific lib metadata is discussed in detail below. 96 | 97 | ## Doc 98 | 99 | The pragma 'doc' tag declares a short summary of the library. This tag should 100 | be used for summary information only, not the complete documentation. The 101 | first sentence will be used for the lib in documentation indexes. 102 | 103 | ## Version 104 | 105 | The pragma 'version' tag declares the library version. This must be 106 | string formatted as three decimal digits separated by a dot. 107 | 108 | ## Depends 109 | 110 | The pragma 'depends' tag specifies a list of lib dependencies that are 111 | formatted as lib name and version constraints. Depends are used 112 | to define the dependency graph of a lib which imports all spec and 113 | instance names from the dependencies in to the library's namespace. 114 | 115 | Version constraints are formatted a string with the following BNF grammar 116 | 117 | ``` 118 | := "-" 119 | := "." "." 120 | := | 121 | := "x" 122 | := + 123 | := "0" - "9" 124 | ``` 125 | 126 | Examples for version constraints: 127 | 128 | ``` 129 | 1.2.3 // version 1.2.3 exact 130 | 1.2.x // any version that starts with "1.2." 131 | 3.x.x // any version that starts with "3." 132 | x.x.x // any version - wildcard match 133 | 1.0.0-2.0.0 // range from 1.0.0 to 2.0.0 inclusive 134 | 1.2.0-1.3.x // range from 1.2.0 to 1.3.* inclusive 135 | ``` 136 | 137 | If a dependency's 'versions' tag is omitted, then it is assumed 138 | to be "x.x.x" (any version). 139 | 140 | ## Org 141 | 142 | The pragma 'org' tag specifies summary information for the organization 143 | publishing the library. Org is a dict with the following tags: 144 | - 'dis': display name for the organization 145 | - 'uri': URL to the organization's web site 146 | 147 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Meta.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Libs and specs can define arbitrary *meta* or metadata. Many of xeto's 4 | built-in features leverage meta to annotate specs. For example, the `sealed` 5 | meta is used by the compiler to indicate that a spec cannot be subtyped. 6 | Both lib and spec meta is a normal dict, but uses special rules for 7 | static typing. Meta tags are formally defined using a specialized 8 | [global spec](Globals.md). These *meta spec*s define a single tag that may be 9 | used in meta dicts. It is required that all meta tags are defined by a 10 | meta spec in the library's [namespace](Namespaces.md#lib-namespaces). 11 | 12 | # Names 13 | 14 | Meta specs follow same rules at [globals](Globals.md) and 15 | [slot names](Specs.md#names): 16 | - Must contain only ASCII lower case letters, digits, or underbar 17 | - Must start with an ASCII lower case letter 18 | - Convention is to use camel case 19 | 20 | There are additional restrictions on meta names that are reserved 21 | for the [AST representation](Specs.md#representation). The following 22 | meta names are reserved: 23 | 24 | ``` 25 | base, class, data, def, id, is, lib, loaded, loc, instances, name, 26 | parent, qname, slot, slots, spec, specs, super, supers, type, types, 27 | and any name starting with "xeto" 28 | ``` 29 | 30 | Additionally, it is invalid to declare a meta spec that is already 31 | define by 'sys' or in any other dependent lib. 32 | 33 | # Syntax 34 | 35 | Meta specs follow the same syntax rules as [global specs](Globals.md#syntax) 36 | except they include the `meta` metadata tag: 37 | 38 | ```xeto 39 | metaTag: Type 40 | ``` 41 | 42 | Here are concrete examples from the 'sys' lib: 43 | 44 | ```xeto 45 | // Abstract types cannot be implemented directly by instance data 46 | abstract: Marker 47 | 48 | // Applied to strings and lists to specify inclusive maximum length 49 | maxSize: Int 50 | ``` 51 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Namespaces.md: -------------------------------------------------------------------------------- 1 | # Namespaces 2 | 3 | A namespace is a set of [libs](Libs.md) used to build the scope of specs and 4 | instances. A namespace is defined by a list of lib names and a specific 5 | version of each lib. Namespaces are used to: 6 | 7 | - reflect specs, globals, and lib instances in scope 8 | - [resolve](#name-resolution) qnames and simple names 9 | - compute [xmeta](#xmeta) 10 | - compute taxonomy of [choices](Choices.md) 11 | 12 | # Named Definitions 13 | 14 | There are three types of named definitions in a lib: 15 | - **Type Specs**: named via a string starting with an upper case letter 16 | - **Global Specs**: named via a string starting with a lower case letter 17 | - **Instances**: named with an Ref identifier 18 | 19 | It is a compile time error to declare a spec and instance with the 20 | same name (even though one is a string and one is a Ref). For example 21 | this code will not compile: 22 | 23 | ```xeto 24 | // invalid code - duplicate top-level names 25 | device: Marker 26 | @device: {} 27 | ``` 28 | 29 | It is valid (and common) to have a type spec and global spec with 30 | the same name that differs only by case: 31 | 32 | ```xeto 33 | // this is ok 34 | device: Marker 35 | Device: Dict { device } 36 | ``` 37 | 38 | # Lib Namespaces 39 | 40 | Libs import external names into their local namespace via their dependencies. 41 | All libs must depend on `lib:sys` (with the exception of sys itself). The 42 | range of all named definitions in the lib itself and its direct dependencies 43 | is called the *lib namespace*. 44 | 45 | Only names found in the lib's namespace may be used for spec and instance 46 | definitions. It is a compile time error to use a name not defined in the 47 | lib namespace. 48 | 49 | Code within a lib may use fully qualified names or simple names. The rules 50 | for resolving names is discussed below in [name resolution](#name-resolution). 51 | 52 | # Project Namespaces 53 | 54 | Individual projects may pick and choose which libs are used to define their 55 | application specific data. We call this namespace the *project namespace*. 56 | Project namespaces will often be a mix of standardized libs, vendor specific 57 | libs, and project specific libs. It is outside the scope of this specification 58 | to define how libs are included or enabled for project namespaces. 59 | 60 | It is recommended that project applications always use fully qualified names 61 | for referencing specs and instances. But it if an application choses to allow 62 | simple names, then it should follow the standard [name resolution](#name-resolution) 63 | rules discussed below. 64 | 65 | # Name Resolution 66 | 67 | Names are used to reference a spec or instance. Names come in four flavors: 68 | - Fully qualified spec names (qnames) 69 | - Simple spec name 70 | - Fully qualified instance identifiers 71 | - Simple instance identifiers 72 | 73 | Examples for the four flavors: 74 | 75 | ```xeto 76 | ph.points::AirTempSensor // spec qname 77 | AirTempSensor // spec simple name 78 | @ph::filetype:json // qname instance id 79 | @filetype:json // simple instance id 80 | ``` 81 | 82 | The rules for resolving spec names and instances identifiers are identical; 83 | the only difference is what kind of definition is resolved. 84 | 85 | If the name contains a "::" double colon then it is assumed to be a qname 86 | (fully qualified with the global lib name). Any name missing the 87 | double colon is assumed to be a simple name. 88 | 89 | To resolve a qname: 90 | - resolve the qname lib part to a lib from the namespace dependencies 91 | - resolve the qname simple name part to a spec/instance within that lib 92 | 93 | To resolve a simple name: 94 | - check all libs in the namespace for an appropriate definition 95 | - if exactly one definition is found then use it 96 | - if zero definitions are found it is an unresolved name error 97 | - if multiple definitions are found it is ambiguous name error 98 | 99 | In the case of an ambiguous name error, the code can be fixed by 100 | replacing the simple name with a qname to the correct library. 101 | 102 | When [compiling](#lib-namespaces) a lib, its namespace is defined 103 | by the direct dependencies. 104 | 105 | # XMeta 106 | 107 | Extended meta or *xmeta* is a feature used to add additional 108 | metadata to specs via late binding. This feature is commonly used 109 | to overlay UI annotations over built-in types. 110 | 111 | Adding xmeta to a spec is done by creating [instances](Instances.md) 112 | with a specific naming convention: 113 | 114 | ``` 115 | xmeta-{lib name}-{spec name} 116 | ``` 117 | 118 | For example, to add a color and icon tag to `ph::Room`: 119 | 120 | ```xeto 121 | @xmeta-ph-Room: {icon:"door", color:"purple"} 122 | ``` 123 | 124 | When resolving the xmeta for `ph::Room` the runtime checks all libs 125 | in the namespace for instances that match the given naming convention 126 | and merges it with the spec's definition metadata. The runtime will 127 | also check the spec's full inheritance hierarchy for xmeta definitions. 128 | 129 | We support a special syntax for using xmeta with an [enum](Enums.md) 130 | to annotate the range items with a single dict using the following 131 | instance naming pattern: 132 | 133 | ``` 134 | xmeta-{lib name}-{spec name}-enum 135 | ``` 136 | 137 | The instance is a nested dict where the keys are the enum range 138 | items and the values are the extended metadata. Consider an example 139 | to add icons and color to the `ph::CurStatus` type: 140 | 141 | ```xeto 142 | @xmeta-ph-CurStatus-enum: { 143 | ok: {icon::"check, color:"green"} 144 | stale: {icon:"check, color:"amber"} 145 | fault: {icon:"err", color:"red"} 146 | down: {icon:"warn", color:"orange"} 147 | disabled: {icon:"ban", color:"gray"} 148 | unknown: {icon:"question"", color:"gray"} 149 | } 150 | ``` 151 | 152 | It is a compile time error to use the xmeta naming pattern for 153 | a spec not found in the lib namespace. 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Specs.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Specs or specifications are type definitions. Specs define the shape 4 | of data using principles of an object oriented type system. Specs 5 | use inheritance for composition and may define arbitrary metadata. 6 | There are two fundamental types of specs: *scalars* and *dicts*. 7 | - [**Scalars**](#scalars) define an atomic type encoded as a string. 8 | Common scalars include Str, Number, Date, Time, and DateTime. 9 | - [**Dicts**](#dicts) define a compound type composed of zero or 10 | more *slots* that are the data fields. 11 | 12 | # Names 13 | 14 | Specs are always defined within a [lib](Libs.md). User defined spec 15 | names must obey the following restrictions: 16 | - Must contain only ASCII lower case letters, digits, or underbar 17 | - Must start with an ASCII upper case letter 18 | - Convention is to use camel case 19 | 20 | The compiler may generate synthetic spec names which follow these restrictions 21 | - Start with underbar 22 | - Contain only ASCII digits 23 | - For example "_34" is a synthetic or auto name 24 | 25 | We call the spec name within the library the *simple name*. We combine 26 | the simple name with the lib name using "::" to create the *qualified name* 27 | or *qname*. Because lib names are globally unique, spec qnames are also 28 | globally unique. Examples: 29 | 30 | ``` 31 | Str // simple name 32 | sys::Str // qualified name 33 | NaturalGasMeter // simple name 34 | ph.equips::NaturalGasMeter // qualified name 35 | ``` 36 | 37 | Dict slots are also specs that follow same naming restrictions but must start 38 | with a lower case letter. Slot specs have a qname formed from the parent 39 | spec qname and a dot: 40 | 41 | ``` 42 | LibDepend: Dict { 43 | lib: Str // qname is sys::LibDepend.lib 44 | versions: LibDependVersions // qname is sys::LibDepend.versions 45 | } 46 | ``` 47 | 48 | # Syntax 49 | 50 | Spec definitions follow the given syntax: 51 | 52 | ```xeto 53 | SpecName: BaseType { 54 | slotA: Type 55 | } 56 | ``` 57 | 58 | Scalar and list subtypes cannot define slots. Here are some examples: 59 | 60 | ```xeto 61 | // simple scalar 62 | MyScalar: Scalar 63 | 64 | // scalar with metadata 65 | SocialSecurityNumber: Scalar 66 | 67 | // simple dict type 68 | Point: Dict { 69 | x: Int 70 | y: Int 71 | } 72 | 73 | // dict with metadata 74 | Person: Dict { 75 | name: Str 76 | height: Number 77 | } 78 | ``` 79 | 80 | # Scalars 81 | 82 | Scalar specs define an atomic type encoded as a string. All scalars 83 | inherit from `sys::Scalar`. Scalars must define a canonical string 84 | encoding used by instance data or in JSON. 85 | 86 | Scalars may define a default value using the 'val' meta: 87 | 88 | ```xeto 89 | // meta data 90 | MyScalar: Scalar 91 | 92 | // syntax sugar for same 93 | MyScalar: Scalar "default" 94 | ``` 95 | Scalars may define a regular expression for their encoding 96 | using the 'pattern' meta: 97 | 98 | ```xeto 99 | Date: Scalar "2000-01-01" 100 | ``` 101 | 102 | # Dicts 103 | 104 | Dicts or dictionaries are specs that define a compound type. Dicts 105 | are equivalent to JSON object types. Dicts are composed of *slots*. 106 | Slots are named fields with an explicit value type. 107 | 108 | Lets consider the example from above: 109 | 110 | ```xeto 111 | Point: Dict { 112 | x: Int 113 | y: Int 114 | } 115 | ``` 116 | 117 | This defines a spec named "Point" with two slots named "x" and "y". 118 | The value space for the "x" and "y" fields is restricted to integers 119 | via the `sys::Int` spec. 120 | 121 | We can give slots a default value using the 'val' meta: 122 | 123 | ```xeto 124 | Point: Dict { 125 | x: Int 126 | y: Int 127 | } 128 | 129 | // syntax sugar for same 130 | Point: Dict { 131 | x: Int "-99" 132 | y: Int "-99" 133 | } 134 | ``` 135 | 136 | # Slots 137 | 138 | Slot specs are specs nested inside a dict spec to define a field 139 | value in instance data. They follow all the same rules as other specs, 140 | but must start with a lower case ASCII letter. 141 | 142 | We call the containing spec of a slot the *parent*. Slots have 143 | a qname formatted as: 144 | 145 | ``` 146 | {parent qname}.{slot name} 147 | ``` 148 | 149 | # Lists 150 | 151 | The `sys::List` type is used to define an ordered list of values. 152 | The list item type may be parameterized by the 'of' meta: 153 | 154 | ```xeto 155 | Foo: { 156 | numbers: List // List that contains only Numbers 157 | } 158 | ``` 159 | 160 | In Xeto instance data that contains a list uses curly braces (we do 161 | not use '[]' like JSON): 162 | 163 | ```xeto 164 | // explicitly typed list with individual items typed 165 | @foo-1: Foo { 166 | numbers: List { Number 2, Number 3, Number 4} 167 | } 168 | 169 | // items are implicitly typed as Number from the 'of' 170 | @foo-2: Foo { 171 | numbers: List { 2, 3, 4} 172 | } 173 | 174 | // typed list is inferred from Foo.numbers slot definition 175 | @foo-3: Foo { 176 | numbers: { 2, 3, 4} 177 | } 178 | ``` 179 | 180 | The `sys::List` type is sealed, you cannot derive new types 181 | from it via inheritance: 182 | 183 | ```xeto 184 | // This will not compile 185 | MyNumbersList: List 186 | ``` 187 | 188 | # Representation 189 | 190 | Specs are modeled as dict data just like [instance data](Instances.md). 191 | The following tags are defined by Xeto itself and may not be used 192 | as metadata tags: 193 | 194 | - 'id': a Ref which is the spec qname 195 | - 'base': a qname Ref to the type inherited from; null for `sys::Obj`; 196 | - 'type': a qname Ref to slot type 197 | - 'parent': a qname Ref to the parent dict if spec is a slot 198 | - 'doc': documentation from comments 199 | - 'spec': always a Ref to `sys::Spec` (the spec is an instance of Spec) 200 | - 'slots': the slot specs of a dict spec 201 | 202 | Type specs use 'base' and slot specs use 'type'. 203 | 204 | Note: the compiler currently reserves several other metadata tags for 205 | future proofing. 206 | 207 | When representing a spec as a dict or JSON object, the tags above are 208 | merged with the spec meta. Example: 209 | 210 | ```xeto 211 | // Xeto spec example 212 | Person: Dict { 213 | name: Str // Full name 214 | } 215 | ``` 216 | 217 | Haystack representation of the example spec: 218 | 219 | ``` 220 | id: @acme::Person 221 | spec: @sys::Spec 222 | base: @sys::Dict 223 | doc: "Xeto spec example" 224 | sealed 225 | icon: "user" 226 | slots: { 227 | name: { 228 | id: @acme::Person.name 229 | spec: @sys::Spec, 230 | type: @sys::Str, 231 | doc: "Full name" 232 | } 233 | } 234 | ``` 235 | 236 | JSON representation of the example spec: 237 | 238 | ```json 239 | "Person": { 240 | "id": "acme::Person", 241 | "spec": "sys::Spec", 242 | "base": "sys::Dict", 243 | "sealed": "✓", 244 | "icon": "user", 245 | "slots": { 246 | "name": { 247 | "id": "acme::Person.name", 248 | "spec": "sys::Spec", 249 | "type": "sys::Str", 250 | "doc": "Full name" 251 | } 252 | } 253 | } 254 | ``` 255 | 256 | Note that when mapping specs to Haystack or JSON there is a level 257 | of type erasure as discussed in [Fidelity](Fidelity.md). 258 | 259 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/TypeSystem.md: -------------------------------------------------------------------------------- 1 | # Maybe 2 | 3 | Slot specs may be annotated with the 'maybe' marker to make 4 | them a *maybe type* or *option type*. Maybe types mean that the 5 | value may be omitted in instance data. Maybe types are used 6 | extensively, so we give them a special syntax - you can use 7 | a question mark after the type name: 8 | 9 | ```xeto 10 | // standard syntax for optional age field 11 | age: Number 12 | 13 | // syntax sugar for above 14 | age: Number? 15 | ``` 16 | 17 | When validating instance data, maybe slots can be omitted. However, if 18 | defined they must meet the slot spec's type and constraint requirements. 19 | 20 | Xeto's covariance rules allow a maybe slot to be overridden as a non-maybe 21 | type, but not vice versa. For example the following is legal because 22 | we are narrowing the value space in the subtype: 23 | 24 | ```xeto 25 | OptionalAge: { age: Number? } 26 | 27 | RequiredAge: OptionalAge { age: Number } 28 | ``` 29 | 30 | # Of 31 | The `of` meta is used to parameterize container and reference types. 32 | It is used with the following types: 33 | - `sys::List`: parameterize the item types 34 | - `sys::Ref`: parameterize the referent type 35 | - `sys::MultiRef`: parameterize the referent type 36 | - `sys::Query`: parameterize what the query returns 37 | 38 | When validating covariance the 'of' type may be narrowed, but it may not 39 | be widened. For example the following is legal because we are narrowing 40 | the list's 'of' type to be more constrained and honoring the supertype's 41 | contract: 42 | 43 | ```xeto 44 | Foo: { 45 | list: List 46 | } 47 | 48 | Bar: Foo { 49 | list: List 50 | } 51 | ``` 52 | 53 | However, in this example we will get a compile time error because we 54 | are widening the supertype's contract for list: 55 | 56 | ```xeto 57 | Foo: { 58 | list: List 59 | } 60 | 61 | Bar: Foo { 62 | list: List 63 | } 64 | ``` 65 | 66 | We also use the 'of' type to perform [type inference](Specs.md#lists) for lists. 67 | 68 | # Covariance 69 | 70 | Covariance is the set rules for narrowing a spec definition. Covariance 71 | rules are checked when subtyping via inheritance or overriding a slot 72 | from a supertype. The primary idea of covariance is that we are 73 | narrowing the possible set of values, but never widening it. This ensures 74 | the subtypes adhere to the type contract of their supertype. 75 | 76 | Covariance requires the following sets of conditions: 77 | - Slot type must be a subtype of the overridden slot 78 | - `maybe` can be removed, but not added from base spec 79 | - `of` meta must be a subtype of the base 'of' type 80 | - `minVal` meta must be equal to or greater than base value 81 | - `maxVal` meta must be equal to or less than base value 82 | - `quantity` meta cannot be modified from base if defined 83 | - `unit` meta cannot be modified from base if defined 84 | 85 | Consider the spec below where slot 'a' has value space of the integers 2-7. 86 | In the example, the subtype is covariant because it narrows the value space 87 | to 3-5 (which adheres to the supertype's constraints): 88 | 89 | ```xeto 90 | Foo: { 91 | a: Int 92 | } 93 | 94 | Bar: Foo { 95 | a: Int 96 | } 97 | ``` 98 | 99 | However, this example is not covariant because the subtype is widening the 100 | value space of the 'a' slot resulting in compile time error: 101 | 102 | ```xeto 103 | Foo: { 104 | a: Int 105 | } 106 | 107 | Bar: Foo { 108 | a: Int 109 | } 110 | ``` 111 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/Xetodoc.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | All xeto documentation uses a flavor of markdown we call *xetodoc*. 4 | Xetodoc is formally based [Commonmark](https://commonmark.org/), with 5 | the following extensions: 6 | - [Doc Links](#doc-links): the backtick is used for doc hyperlinks 7 | - [Inline Code](#inline-code): the single quote is used for inline code 8 | - [Tables](#tables): Github table extensions 9 | - [Videos](#videos): embedded video support for YouTube, Vimeo, and Loom 10 | - [HTML](#html): nested HTML is explicitly disallowed 11 | 12 | # Doc Links 13 | 14 | Standard markdown uses the backtick to denote inline code text. 15 | In xetodoc these are treated as hyperlinks to the reference 16 | documentation. The following syntax is supported: 17 | 18 | ``` 19 | `ph.points` Link to library index 20 | `ph.points::FanPoint` Link to spec, global, or instance via qname 21 | ``` 22 | 23 | # Inline Code 24 | 25 | Since we use the backtick for code links, we also support creating inline 26 | code using the single quote: 27 | 28 | ``` 29 | This is a `link`, but this is 'inline text' 30 | ``` 31 | 32 | # Tables 33 | 34 | Xetodoc allows tables using the Github flavored [table extension](https://github.github.com/gfm/#tables-extension-) format. 35 | 36 | Example: 37 | 38 | ``` 39 | | foo | bar | 40 | | --- | --- | 41 | | baz | bim | 42 | ``` 43 | 44 | # Videos 45 | 46 | Xetodoc allows embedded videos using the standard image format with 47 | special handling for the "video:" URI scheme. The following sources 48 | are supported: 49 | 50 | 1. **YouTube** The format for the YouTube URL is 'video://youtu.be/?si=' or 51 | 'video://youtube/?si='. The 'id' and 'si' can be found by going 52 | to the YouTube video, clicking the 'Share' button, and inspecting the link text. 53 | 54 | 2. **Loom** The format for a Loom URL is 'video://loom/?sid='. The 'id 55 | and 'sid' can be found by going to the Loom video, clicking the "link" icon and 56 | inspecting the link text. 57 | 58 | Youtube example: 59 | 60 | ``` 61 | ![iframe title](video://youtu.be/fr-K-MVbAa8?si=dnJTcLsVdzfUfE7T) 62 | ``` 63 | 64 | # HTML 65 | 66 | Nested HTML is explicitly disallowed in xetodoc and will be ignored 67 | when displaying documentation. 68 | 69 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/index.md: -------------------------------------------------------------------------------- 1 | # Concepts 2 | 3 | - [Libs](Libs.md): library modules 4 | - [Specs](Specs.md): specification type definitions 5 | - [Globals](Globals.md): global slot definitions 6 | - [Meta](Meta.md): lib and spec meta definitions 7 | - [Instances](Instances.md): instance data 8 | - [Enums](Enums.md): enumeration specs 9 | - [Choices](Choices.md): mutually exclusive marker choices 10 | - [Type System](TypeSystem.md): type system features 11 | - [Inheritance](Inheritance.md): composition through inheritance 12 | - [Namespaces](Namespaces.md): closed set of libs that define name space 13 | - [Constraints](Constraints.md): constraint rules used for validation 14 | - [Fidelity](Fidelity.md): type erasure rules when mapping to other data formats 15 | - [Xetodoc](Xetodoc.md): markdown flavor 16 | 17 | # Appendix 18 | 19 | - [Grammar](Grammar.md): formal BNF grammar for Xeto 20 | 21 | -------------------------------------------------------------------------------- /src/xeto/doc.xeto/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 28 Oct 2024 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "Xeto language documentation" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | } 15 | categories: {"sys", "doc"} 16 | license: "AFL-3.0" 17 | org: { 18 | dis: "Project Haystack" 19 | uri: "https://project-haystack.org/" 20 | } 21 | vcs: { 22 | type: "git" 23 | uri: "https://github.com/Project-Haystack/xeto.git" 24 | } 25 | > 26 | 27 | -------------------------------------------------------------------------------- /src/xeto/ph.attrs/base.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 27 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | // Attribute is a single datum of static information on an entity. 10 | // Attributes often represent nameplate data or design/rated data. 11 | Attr: Entity { 12 | attr // Required marker tag for all attributes 13 | val: Obj // Value of the attribute 14 | } 15 | 16 | // Attribute with a string value type 17 | StrAttr: Attr { 18 | val: Str // String value of the attribute 19 | } 20 | 21 | // Attribute with a date value type 22 | DateAttr: Attr { 23 | val: Date // Date value of the attribute 24 | } 25 | 26 | // Attribute with a number value type 27 | NumberAttr: Attr { 28 | val: Number // Number value of the attribute 29 | } 30 | 31 | // Attribute with a number value with length unit 32 | LengthAttr: NumberAttr { 33 | val: Number 34 | } 35 | 36 | // Attribute with a number value with mass (weight) unit 37 | MassAttr: NumberAttr { 38 | val: Number 39 | } 40 | 41 | // Attribute with a number value with temperature unit 42 | TempAttr : NumberAttr { 43 | temp 44 | val: Number 45 | } 46 | -------------------------------------------------------------------------------- /src/xeto/ph.attrs/elec.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 16 Apr 2025 Rick Jennings Creation 7 | // 8 | 9 | // Current attribute for the asset 10 | ElecCurrentAttr : NumberAttr { elec, current } 11 | 12 | // AC current attribute for the asset 13 | ElecAcCurrentAttr : ElecCurrentAttr { ac } 14 | 15 | // AC current rating of the asset 16 | ElecAcRatedCurrentAttr : ElecAcCurrentAttr { rated } 17 | 18 | // Continuous AC current capacity rating of the asset (80% or 100% - for circuit breakers) 19 | ElecAcRatedContinuousCapacityCurrentAttr : ElecAcRatedCurrentAttr { currentContinuousCapacity } 20 | 21 | // Continuous AC current rating of the asset (for circuit breakers) 22 | ElecAcRatedContinuousCurrentAttr : ElecAcRatedCurrentAttr { currentContinuous } 23 | 24 | // Max continuous AC current rating of the asset (for circuit breakers) 25 | ElecAcRatedMaxContinuousCurrentAttr : ElecAcRatedContinuousCurrentAttr { max } 26 | 27 | // AC current input rating of the asset 28 | ElecAcRatedInputCurrentAttr : ElecAcRatedCurrentAttr { input } 29 | 30 | // Maximum AC current input rating of the asset 31 | ElecAcRatedInputMaxCurrentAttr : ElecAcRatedInputCurrentAttr { max } 32 | 33 | // Voltage attribute for the asset 34 | ElecVoltAttr : NumberAttr { elec, volt } 35 | 36 | // AC voltage attribute for the asset 37 | ElecAcVoltAttr : ElecVoltAttr { ac } 38 | 39 | // AC voltage rating of the asset 40 | ElecAcRatedVoltAttr : ElecAcVoltAttr { rated } 41 | 42 | // AC voltage input rating of the asset 43 | ElecAcRatedInputVoltAttr : ElecAcRatedVoltAttr { input } 44 | 45 | // Nominal AC voltage input rating of the asset 46 | ElecAcRatedInputNominalVoltAttr : ElecAcRatedInputVoltAttr { nominal } 47 | 48 | // Nominal line-to-line AC voltage input rating of the asset 49 | ElecAcRatedInputLineToLineNominalVoltAttr : ElecAcRatedInputNominalVoltAttr { voltLineToLine } 50 | 51 | // Nominal line-to-neutral AC voltage input rating of the asset 52 | ElecAcRatedInputLineToNeutralNominalVoltAttr : ElecAcRatedInputNominalVoltAttr { voltLineToNeutral } 53 | 54 | // Minimum AC voltage input rating of the asset 55 | ElecAcRatedInputMinVoltAttr : ElecAcRatedInputVoltAttr { min } 56 | 57 | // Minimum line-to-line AC voltage input rating of the asset 58 | ElecAcRatedInputLineToLineMinVoltAttr : ElecAcRatedInputMinVoltAttr { voltLineToLine } 59 | 60 | // Maximum AC voltage input rating of the asset 61 | ElecAcRatedInputMaxVoltAttr : ElecAcRatedInputVoltAttr { max } 62 | 63 | // Maximum line-to-line AC voltage input rating of the asset 64 | ElecAcRatedInputLineToLineMaxVoltAttr : ElecAcRatedInputMaxVoltAttr { voltLineToLine } 65 | -------------------------------------------------------------------------------- /src/xeto/ph.attrs/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 27 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "Project haystack experimental attributes library" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | { lib: "ph", versions: "0.1.x" } 15 | } 16 | categories: {"ph"} 17 | license: "AFL-3.0" 18 | org: { 19 | dis: "Project Haystack" 20 | uri: "https://project-haystack.org/" 21 | } 22 | vcs: { 23 | type: "git" 24 | uri: "https://github.com/Project-Haystack/xeto.git" 25 | } 26 | > 27 | 28 | -------------------------------------------------------------------------------- /src/xeto/ph.attrs/tags.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 27 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | // 10 | // TODO: these are experimental tags not standardized yet 11 | // 12 | 13 | // Attribute is a single datum of static information on an entity. 14 | // Attributes often represent nameplate data or design/rated data. 15 | attr: Marker 16 | 17 | // Company name that produced the asset. 18 | manufacturer: Marker 19 | 20 | // Manufacturer assigned identifier for a general product line. 21 | // For example, modelSeries is "iPhone 12", but modelNumber is "MGF43LL/A". 22 | // The modelSeries tends to be a marketing name and not an exact identifier. 23 | // Always use modelNumber for the actual model identifier. 24 | modelSeries: Marker 25 | 26 | // Manufacturer assigned alphanumeric identifier for a specific product configuration. 27 | // For example, modelSeries is "iPhone 12", but modelNumber is "MGF43LL/A". 28 | modelNumber: Marker 29 | 30 | // Manufacturer assigned unique, alphanumeric identifier for a specific asset. 31 | serialNumber: Marker 32 | 33 | // Date the asset was produced by the manufacturer. 34 | manufactureDate: Marker 35 | 36 | // Dimensional length of the asset 37 | length: Marker 38 | 39 | // Dimensional width of the asset 40 | width: Marker 41 | 42 | // Dimensional height of the asset 43 | height: Marker 44 | 45 | // Weight of the asset 46 | weight: Marker 47 | 48 | -------------------------------------------------------------------------------- /src/xeto/ph.attrs/temp.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 12 May 2025 Rick Jennings Creation 7 | // 8 | 9 | // Rated operating temperature of the asset 10 | RatedOperatingTempAttr : TempAttr { rated, operating } 11 | 12 | // Minimum rated operating temperature of the asset 13 | MinRatedOperatingTempAttr : RatedOperatingTempAttr { min } 14 | 15 | // Maximum rated operating temperature of the asset 16 | MaxRatedOperatingTempAttr : RatedOperatingTempAttr { max } 17 | -------------------------------------------------------------------------------- /src/xeto/ph.attrs/universal.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 27 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | // Company name that produced the asset 10 | ManufacturerAttr : StrAttr { manufacturer } 11 | 12 | // Manufacturer assigned identifier for a general product line. 13 | // For example, modelSeries is "iPhone 12", but modelNumber is "MGF43LL/A". 14 | // The modelSeries tends to be a marketing name and not an exact identifier. 15 | // Always use modelNumber for the actual model identifier. 16 | ModelSeriesAttr : StrAttr { modelSeries } 17 | 18 | // Manufacturer assigned alphanumeric identifier for a specific product configuration. 19 | // For example, modelSeries is "iPhone 12", but modelNumber is "MGF43LL/A". 20 | ModelNumberAttr : StrAttr { modelNumber } 21 | 22 | // Manufacturer assigned unique, alphanumeric identifier for an equip. 23 | SerialNumberAttr : StrAttr { serialNum } 24 | 25 | // Date that the asset was produced by the manufacturer. 26 | ManufactureDateAttr : DateAttr { manufactureDate } 27 | 28 | // Dimensional length of the asset 29 | DimensionLengthAttr : LengthAttr { length } 30 | 31 | // Dimensional width of the asset 32 | DimensionWidthAttr : LengthAttr { width } 33 | 34 | // Dimensional height of the asset 35 | DimensionHeightAttr : LengthAttr { height } 36 | 37 | // Weight of the asset 38 | WeightAttr : MassAttr { weight } 39 | -------------------------------------------------------------------------------- /src/xeto/ph.equips/ducts.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 26 Feb 2025 Brian Frank Creation 7 | // 8 | 9 | // Duct to access fresh outside air only for economizing, not ventilation 10 | EconomizerDuct: Duct { economizer } 11 | 12 | // Duct for exhausting combustion 13 | FlueDuct: Duct { flue } 14 | 15 | // Duct with air entering an equipment 16 | InletDuct: Duct { inlet } 17 | 18 | // Duct to access fresh outside air only for ventilation, not economizing 19 | VentilationDuct: Duct { ventilation } 20 | 21 | // Duct to access fresh outside air for both ventilation and economizer. 22 | OutsideDuct: Duct { outside } 23 | 24 | // Duct for air leaving an equipment 25 | DischargeDuct: Duct { discharge } 26 | 27 | // Duct used to expel air back outside 28 | ExhaustDuct: Duct { exhaust } 29 | 30 | // Duct returning air back to equipment 31 | ReturnDuct: Duct { return } 32 | 33 | // Duct where fresh outside air and return air is mixed together 34 | MixedDuct: DuctSection { mixed } 35 | 36 | // Discharge duct for cooling 37 | ColdDeckDischargeDuct: DischargeDuct { coldDeck } 38 | 39 | // Discharge duct for heating 40 | HotDeckDischargeDuct: DischargeDuct { hotDeck } 41 | 42 | // Discharge duct which by-passes both heating and cooling coils 43 | NeutralDeckDischargeDuct: DischargeDuct { neutralDeck } 44 | 45 | -------------------------------------------------------------------------------- /src/xeto/ph.equips/hvac.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 22 Mar 2023 Brian Frank Creation 7 | // 8 | 9 | // Air handler which feeds VAVs 10 | VavZoneAhu : Ahu { 11 | vavZone 12 | vavs: Query 13 | } 14 | 15 | // VAV which is fed by an AHU 16 | AhuVav : Vav { 17 | myAhu: Query 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/xeto/ph.equips/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 22 Mar 2023 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "Project haystack experimental equips library" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | { lib: "ph", versions: "0.1.x" } 15 | } 16 | categories: {"ph"} 17 | license: "AFL-3.0" 18 | org: { 19 | dis: "Project Haystack" 20 | uri: "https://project-haystack.org/" 21 | } 22 | vcs: { 23 | type: "git" 24 | uri: "https://github.com/Project-Haystack/xeto.git" 25 | } 26 | > 27 | 28 | -------------------------------------------------------------------------------- /src/xeto/ph.equips/meters.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 21 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | // Water flow meter 10 | WaterMeter : FlowMeter { water } 11 | 12 | // Domestic water flow meter 13 | DomesticWaterMeter : WaterMeter { domestic } 14 | 15 | // VAV which is fed by an AHU 16 | NaturalGasMeter : FlowMeter { naturalGas } 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/xeto/ph.examples/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 6 Feb 2025 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "Project haystack example data" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | { lib: "ph", versions: "0.1.x" } 15 | { lib: "ph.points", versions: "0.1.x" } 16 | } 17 | categories: {"ph"} 18 | license: "AFL-3.0" 19 | org: { 20 | dis: "Project Haystack" 21 | uri: "https://project-haystack.org/" 22 | } 23 | vcs: { 24 | type: "git" 25 | uri: "https://github.com/Project-Haystack/xeto.git" 26 | } 27 | > 28 | 29 | -------------------------------------------------------------------------------- /src/xeto/ph.examples/site.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 6 Feb 2025 Brian Frank Creation 7 | // 8 | 9 | @a: Site { 10 | dis: "ExSite" 11 | geoAddr: "100 W Main St, Richmond VA 23220" 12 | geoStreet: "100 W Main St" 13 | geoCity: "Richmond" 14 | geoState: "VA" 15 | geoPostalCode: "23220" 16 | geoCountry: "US" 17 | } 18 | 19 | @a-ahu-1: Ahu { 20 | dis: "AHU-1" 21 | siteRef: @a 22 | hotWaterHeating 23 | chilledWaterCooling 24 | } 25 | 26 | @a-ahu-dat: DischargeAirTempSensor { 27 | dis: "AHU-1 Discharge Temp Sensor" 28 | siteRef: @a 29 | equipRef: @a-ahu-1 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/xeto/ph.points.elec/choices.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 21 Mar 2025 Rick Jennings Creation 7 | // 8 | 9 | ElecDemandCalc: Choice 10 | ElecFixedWindowDemandCalc: ElecDemandCalc { fixedWindow } 11 | ElecSlidingWindowDemandCalc : ElecDemandCalc { slidingWindow } 12 | 13 | ElecAcSpectralContent: Choice 14 | ElecAcWaveform: ElecAcSpectralContent { waveform } 15 | ElecAcFundamentalComponent: ElecAcSpectralContent { fundamental } 16 | ElecAcHarmonicComponent: ElecAcSpectralContent { harmonic } 17 | 18 | ElecAcWaveformMagnitude: Choice 19 | ElecAcAvgWaveformMagnitude: ElecAcWaveformMagnitude { avg } 20 | ElecAcRmsWaveformMagnitude: ElecAcWaveformMagnitude { rootMeanSquare } 21 | ElecAcPeakWaveformMagnitude: ElecAcWaveformMagnitude { peak } 22 | ElecAcPeakToPeakWaveformMagnitude: ElecAcWaveformMagnitude { peakToPeak } 23 | 24 | ElecAcWaveformMetric: Choice 25 | ElecAcThffWaveformMetric: ElecAcWaveformMetric { telephoneHarmonicFormFactor } 26 | ElecAcIhdWaveformMetric: ElecAcWaveformMetric { individualHarmonicDistortion } 27 | ElecAcThdWaveformMetric: ElecAcWaveformMetric { totalHarmonicDistortion } 28 | ElecAcOddThdWaveformMetric: ElecAcWaveformMetric { oddTotalHarmonicDistortion } 29 | ElecAcEvenThdWaveformMetric: ElecAcWaveformMetric { evenTotalHarmonicDistortion } 30 | ElecAcKFactorWaveformMetric: ElecAcWaveformMetric { kFactor } 31 | ElecAcCrestFactorWaveformMetric: ElecAcWaveformMetric { crestFactor } 32 | ElecAcImbalanceWaveformMetric: ElecAcWaveformMetric { imbalance } 33 | -------------------------------------------------------------------------------- /src/xeto/ph.points.elec/lib.xeto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, Project-Haystack 2 | // Licensed under the Academic Free License version 3.0 3 | // 4 | // History: 5 | // 3 Nov 2024 Rick Jennings Creation 6 | 7 | pragma: Lib < 8 | doc: "Project haystack advanced electrical points" 9 | version: "0.1.1" 10 | depends: { 11 | { lib: "sys", versions: "0.1.x" } 12 | { lib: "ph", versions: "0.1.x" } 13 | { lib: "ph.points", versions: "0.1.x" } 14 | } 15 | categories: {"ph", "elec"} 16 | license: "AFL-3.0" 17 | org: { 18 | dis: "Project Haystack" 19 | uri: "https://project-haystack.org/" 20 | } 21 | vcs: { 22 | type: "git" 23 | uri: "https://github.com/Project-Haystack/xeto.git" 24 | } 25 | > 26 | 27 | -------------------------------------------------------------------------------- /src/xeto/ph.points.elec/sensor-dc.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 8 Apr 2025 Rick Jennings Creation 7 | // 8 | 9 | // Sensor for DC electric voltage 10 | ElecDcVoltSensor : ElecVoltSensor { dc } 11 | 12 | // Sensor for DC electric current 13 | ElecDcCurrentSensor : ElecCurrentSensor { 14 | dc 15 | unit: Unit "A" 16 | } 17 | 18 | // Sensor for DC electric power 19 | ElecDcPowerSensor : ElecPowerSensor { 20 | dc 21 | unit: Unit "kW" 22 | } 23 | 24 | // Sensor for DC electric energy 25 | ElecDcEnergySensor : ElecEnergySensor { 26 | dc 27 | unit: Unit "kWh" 28 | } 29 | 30 | // Sensor for DC electric state of charge 31 | ElecDcStateOfChargeSensor : ElecSensor { 32 | dc 33 | stateOfCharge 34 | unit: Unit "%" 35 | } 36 | 37 | // Sensor for import of DC electric power 38 | ElecDcImportPowerSensor : ElecDcPowerSensor { import } 39 | 40 | // Sensor for export of DC electric power 41 | ElecDcExportPowerSensor : ElecDcPowerSensor { export } 42 | 43 | // Sensor for net of DC electric power 44 | ElecDcNetPowerSensor : ElecDcPowerSensor { net } 45 | 46 | // Sensor for import of DC electric current 47 | ElecDcImportCurrentSensor : ElecDcCurrentSensor { import } 48 | 49 | // Sensor for export of DC electric current 50 | ElecDcExportCurrentSensor : ElecDcCurrentSensor { export } 51 | 52 | // Sensor for net of DC electric current 53 | ElecDcNetCurrentSensor : ElecDcCurrentSensor { net } 54 | 55 | // Sensor for import of DC electric energy 56 | ElecDcImportEnergySensor : ElecDcEnergySensor { import } 57 | 58 | // Sensor for export of DC electric energy 59 | ElecDcExportEnergySensor : ElecDcEnergySensor { export } 60 | 61 | // Sensor for net of DC electric energy 62 | ElecDcNetEnergySensor : ElecDcEnergySensor { net } 63 | -------------------------------------------------------------------------------- /src/xeto/ph.points.elec/sp-dc.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 8 Apr 2025 Rick Jennings Creation 7 | // 8 | 9 | // Max setpoint for DC electric current 10 | ElecDcCurrentMaxSp : ElecCurrentMaxSp { dc } 11 | 12 | // Max setpoint for DC electric power 13 | ElecDcPowerMaxSp : ElecPowerMaxSp { dc } 14 | 15 | // Max setpoint for import of DC electric power 16 | ElecDcImportPowerMaxSp : ElecDcPowerMaxSp { import } 17 | 18 | // Max setpoint for import of DC electric current 19 | ElecDcImportCurrentMaxSp : ElecDcCurrentMaxSp { import } 20 | -------------------------------------------------------------------------------- /src/xeto/ph.points.elec/sp.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Sep 2024 Rick Jennings Creation 7 | // 8 | 9 | // Setpoint for electricity 10 | ElecSp : NumberPoint & SpPoint { elec } 11 | 12 | // Max setpoint for electricity 13 | ElecMaxSp : ElecSp { max } 14 | 15 | // Max setpoint for electric current 16 | ElecCurrentMaxSp : ElecMaxSp { 17 | current 18 | unit: Unit "A" 19 | } 20 | 21 | // Max setpoint for electric power 22 | ElecPowerMaxSp : ElecMaxSp { 23 | power 24 | unit: Unit "kW" 25 | } 26 | 27 | // Max setpoint for electric demand 28 | ElecDemandMaxSp : ElecMaxSp { 29 | demand 30 | unit: Unit "kW" 31 | } 32 | 33 | // Max setpoint for RMS of AC electric current 34 | ElecAcCurrentMaxSp : ElecCurrentMaxSp { 35 | ac 36 | magnitude 37 | rootMeanSquare 38 | } 39 | 40 | // Max setpoint for AC electric power 41 | ElecAcPowerMaxSp : ElecPowerMaxSp { ac } 42 | 43 | // Max setpoint for magnitude of AC electric power 44 | ElecAcMagnitudePowerMaxSp : ElecAcPowerMaxSp { 45 | magnitude 46 | elecAcWaveformMagnitude: ElecAcWaveformMagnitude 47 | } 48 | 49 | // Max setpoint for average magnitude of AC electric active power 50 | ElecAcActivePowerMaxSp : ElecAcMagnitudePowerMaxSp { 51 | avg 52 | active 53 | } 54 | 55 | // Max setpoint for AC electric active power demand 56 | ElecAcActiveDemandMaxSp : ElecDemandMaxSp { 57 | ac 58 | active 59 | power 60 | } 61 | 62 | // Max setpoint for import of RMS of AC electric current 63 | ElecAcImportCurrentMaxSp : ElecAcCurrentMaxSp { import } 64 | 65 | // Max setpoint for import of average magnitude of AC electric active power 66 | ElecAcImportActivePowerMaxSp : ElecAcActivePowerMaxSp { import } 67 | 68 | // Max setpoint for import of AC electric active power demand 69 | ElecAcImportActiveDemandMaxSp : ElecAcActiveDemandMaxSp { import } 70 | 71 | // Max setpoint for line import of RMS of AC electric current 72 | ElecAcLineImportCurrentMaxSp : ElecAcImportCurrentMaxSp { lineCurrent: LineCurrent } 73 | 74 | // Max setpoint for phase import of RMS of AC electric current 75 | ElecAcPhaseImportCurrentMaxSp : ElecAcImportCurrentMaxSp { phaseCurrent: PhaseCurrent } 76 | 77 | // Max setpoint for total import of average magnitude of AC electric active power 78 | ElecAcTotalImportActivePowerMaxSp : ElecAcImportActivePowerMaxSp { total } 79 | 80 | // Max setpoint for total import of AC electric active power demand 81 | ElecAcTotalImportActiveDemandMaxSp : ElecAcImportActiveDemandMaxSp { total } 82 | -------------------------------------------------------------------------------- /src/xeto/ph.points/air-flow.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with volumetric flow of air 10 | AirFlowPoint : NumberPoint { 11 | air 12 | flow 13 | unit: Unit "cfm" 14 | } 15 | 16 | // Sensor for volumetric air flow 17 | AirFlowSensor : AirFlowPoint & SensorPoint 18 | 19 | // Setpoint for volumetric air flow 20 | AirFlowSp : AirFlowPoint & SpPoint 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Discharge 24 | ////////////////////////////////////////////////////////////////////////// 25 | 26 | // Sensor for volumetric air flow in discharge duct 27 | DischargeAirFlowSensor : AirFlowSensor { discharge } 28 | 29 | // Setpoint for volumetric air flow in discharge duct 30 | DischargeAirFlowSp : AirFlowSp { discharge } 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | // ColdDeck Discharge 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Sensor for volumetric air flow in cold deck discharge duct 37 | ColdDeckDischargeAirFlowSensor : DischargeAirFlowSensor { coldDeck } 38 | 39 | // Setpoint for volumetric air flow in cold deck discharge duct 40 | ColdDeckDischargeAirFlowSp : DischargeAirFlowSp { coldDeck } 41 | 42 | ////////////////////////////////////////////////////////////////////////// 43 | // HotDeck Discharge 44 | ////////////////////////////////////////////////////////////////////////// 45 | 46 | // Sensor for volumetric air flow in hot deck discharge duct 47 | HotDeckDischargeAirFlowSensor : DischargeAirFlowSensor { hotDeck } 48 | 49 | // Setpoint for volumetric air flow in hot deck discharge duct 50 | HotDeckDischargeAirFlowSp : DischargeAirFlowSp { hotDeck } 51 | 52 | ////////////////////////////////////////////////////////////////////////// 53 | // Economizing 54 | ////////////////////////////////////////////////////////////////////////// 55 | 56 | // Sensor for volumetric air flow in economizing duct. 57 | // Used when there are separate ducts for minimum fresh air vs economizing. 58 | EconomizingAirFlowSensor : AirFlowSensor { economizing } 59 | 60 | // Setpoint for volumetric air flow in economizing duct. 61 | EconomizingAirFlowSp : AirFlowSp { economizing } 62 | 63 | ////////////////////////////////////////////////////////////////////////// 64 | // Exhaust 65 | ////////////////////////////////////////////////////////////////////////// 66 | 67 | // Sensor for volumetric air flow in exhaust duct 68 | ExhaustAirFlowSensor : AirFlowSensor { exhaust } 69 | 70 | // Setpoint for volumetric air flow in exhaust duct 71 | ExhaustAirFlowSp : AirFlowSp { exhaust } 72 | 73 | ////////////////////////////////////////////////////////////////////////// 74 | // Inlet 75 | ////////////////////////////////////////////////////////////////////////// 76 | 77 | // Sensor for volumetric air flow in inlet duct 78 | InletAirFlowSensor : AirFlowSensor { inlet } 79 | 80 | // Setpoint for volumetric air flow in inlet duct 81 | InletAirFlowSp : AirFlowSp { inlet } 82 | 83 | ////////////////////////////////////////////////////////////////////////// 84 | // Outside 85 | ////////////////////////////////////////////////////////////////////////// 86 | 87 | // Sensor for volumetric air flow in outside duct. 88 | // Used when there one duct for both minimum fresh air and economizing. 89 | OutsideAirFlowSensor : AirFlowSensor { outside } 90 | 91 | // Setpoint for volumetric air flow in outside duct. 92 | // Used when there one duct for both minimum fresh air and economizing. 93 | OutsideAirFlowSp : AirFlowSp { outside } 94 | 95 | ////////////////////////////////////////////////////////////////////////// 96 | // Return 97 | ////////////////////////////////////////////////////////////////////////// 98 | 99 | // Sensor for volumetric air flow in return duct 100 | ReturnAirFlowSensor : AirFlowSensor { return } 101 | 102 | // Setpoint for volumetric air flow in return duct 103 | ReturnAirFlowSp : AirFlowSp { return } 104 | 105 | ////////////////////////////////////////////////////////////////////////// 106 | // Ventilation 107 | ////////////////////////////////////////////////////////////////////////// 108 | 109 | // Sensor for volumetric air flow in ventilation or minimum fresh air duct. 110 | // Used when there are separate ducts for minimum fresh air vs economizing. 111 | VentilationAirFlowSensor : AirFlowSensor { ventilation } 112 | 113 | // Setpoint for volumetric air flow in ventilation or minimum fresh air duct. 114 | // Used when there are separate ducts for minimum fresh air vs economizing. 115 | VentilationAirFlowSp : AirFlowSp { ventilation } 116 | 117 | -------------------------------------------------------------------------------- /src/xeto/ph.points/air-humidity.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 5 Apr 2023 Brian Frank Creation 7 | // 8 | 9 | // Point associated with relative humidity; measure of moisture in the air 10 | AirHumidityPoint : NumberPoint { 11 | air 12 | humidity 13 | unit: Unit "%RH" 14 | } 15 | 16 | // Sensor for relative humidity 17 | AirHumiditySensor : AirHumidityPoint & SensorPoint 18 | 19 | // Setpoint for relative humidity 20 | AirHumiditySp : AirHumidityPoint & SpPoint 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Discharge 24 | ////////////////////////////////////////////////////////////////////////// 25 | 26 | // Sensor for relative humidity in discharge duct 27 | DischargeAirHumiditySensor : AirHumiditySensor { discharge } 28 | 29 | // Setpoint for relative humidity in discharge duct 30 | DischargeAirHumiditySp : AirHumiditySp { discharge } 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | // Outdoor 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Sensor for relative humidity in outdoor duct 37 | OutdoorAirHumiditySensor : AirHumiditySensor { outdoor } 38 | 39 | // Setpoint for relative humidity in outdoor duct 40 | OutdoorAirHumiditySp : AirHumiditySp { outdoor } 41 | 42 | ////////////////////////////////////////////////////////////////////////// 43 | // Zone 44 | ////////////////////////////////////////////////////////////////////////// 45 | 46 | // Sensor for relative humidity in the zone 47 | ZoneAirHumiditySensor : AirHumiditySensor { zone } 48 | 49 | // Setpoint for relative humidity in the zone 50 | ZoneAirHumiditySp : AirHumiditySp { zone } 51 | 52 | -------------------------------------------------------------------------------- /src/xeto/ph.points/air-pressure.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with static air pressure 10 | AirPressurePoint : NumberPoint { 11 | air 12 | pressure 13 | unit: Unit "inH₂O" 14 | } 15 | 16 | // Sensor for static air pressure 17 | AirPressureSensor : AirPressurePoint & SensorPoint 18 | 19 | // Setpoint for static air pressure 20 | AirPressureSp : AirPressurePoint & SpPoint 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Discharge 24 | ////////////////////////////////////////////////////////////////////////// 25 | 26 | // Sensor for static air pressure in discharge duct 27 | DischargeAirPressureSensor : AirPressureSensor { discharge } 28 | 29 | // Setpoint for static air pressure in discharge duct 30 | DischargeAirPressureSp : AirPressureSp { discharge } 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | // Return 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Sensor for static air pressure in return duct 37 | ReturnAirPressureSensor : AirPressureSensor { return } 38 | 39 | // Setpoint for static air pressure in return duct 40 | ReturnAirPressureSp : AirPressureSp { return } 41 | 42 | -------------------------------------------------------------------------------- /src/xeto/ph.points/air-temp.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with drybulb air temperature 10 | AirTempPoint : NumberPoint { 11 | air 12 | temp 13 | unit: Unit "°F" 14 | } 15 | 16 | // Sensor for drybulb air temperature 17 | AirTempSensor : AirTempPoint & SensorPoint 18 | 19 | // Setpoint for drybulb air temperature 20 | AirTempSp : AirTempPoint & SpPoint 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Discharge 24 | ////////////////////////////////////////////////////////////////////////// 25 | 26 | // Sensor for drybulb air temperature of discharge duct 27 | DischargeAirTempSensor : AirTempSensor { discharge } 28 | 29 | // Setpoint for drybulb air temperature of discharge duct 30 | DischargeAirTempSp : AirTempSp { discharge } 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | // Economizing 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Sensor for drybulb air temperature of economizing duct. 37 | // Used when there are separate ducts for minimum fresh air vs economizing. 38 | EconomizingAirTempSensor : AirTempSensor { economizing } 39 | 40 | ////////////////////////////////////////////////////////////////////////// 41 | // Inlet 42 | ////////////////////////////////////////////////////////////////////////// 43 | 44 | // Sensor for drybulb air temperature of inlet duct 45 | InletAirTempSensor : AirTempSensor { inlet } 46 | 47 | // Setpoint for drybulb air temperature of inlet duct 48 | InletAirTempSp : AirTempSp { inlet } 49 | 50 | ////////////////////////////////////////////////////////////////////////// 51 | // Mixed 52 | ////////////////////////////////////////////////////////////////////////// 53 | 54 | // Sensor for drybulb air temperature of mixed duct 55 | MixedAirTempSensor : AirTempSensor { mixed } 56 | 57 | // Setpoint for drybulb air temperature of mixed duct 58 | MixedAirTempSp : AirTempSp { mixed } 59 | 60 | ////////////////////////////////////////////////////////////////////////// 61 | // Outside 62 | ////////////////////////////////////////////////////////////////////////// 63 | 64 | // Sensor for drybulb air temperature of outside duct. 65 | // Used when there one duct for both minimum fresh air and economizing. 66 | OutsideAirTempSensor : AirTempSensor { outside } 67 | 68 | ////////////////////////////////////////////////////////////////////////// 69 | // Return 70 | ////////////////////////////////////////////////////////////////////////// 71 | 72 | // Sensor for drybulb air temperature of return duct 73 | ReturnAirTempSensor : AirTempSensor { return } 74 | 75 | // Setpoint for drybulb air temperature of return duct 76 | ReturnAirTempSp : AirTempSp { return } 77 | 78 | ////////////////////////////////////////////////////////////////////////// 79 | // Ventilation 80 | ////////////////////////////////////////////////////////////////////////// 81 | 82 | // Sensor for drybulb air temperature of ventilation or minimum fresh duct. 83 | // Used when there are separate ducts for minimum fresh air vs economizing. 84 | VentilationAirTempSensor : AirTempSensor { ventilation } 85 | 86 | ////////////////////////////////////////////////////////////////////////// 87 | // Zone 88 | ////////////////////////////////////////////////////////////////////////// 89 | 90 | // Drybulb air temperature sensor for zone 91 | ZoneAirTempSensor : AirTempSensor { zone } 92 | 93 | // Setpoint for drybulb air temperature zone 94 | ZoneAirTempSp : AirTempSp { zone } 95 | 96 | // Effective setpoint for drybulb air temperature a zone 97 | ZoneAirTempEffectiveSp : ZoneAirTempSp { effective } 98 | 99 | // Cooling mode temperature setpoint for zone 100 | ZoneAirTempCoolingSp : ZoneAirTempSp { cooling } 101 | 102 | // Cooling mode temperature setpoint for zone when occupied 103 | ZoneAirTempOccCoolingSp : ZoneAirTempCoolingSp { occ } 104 | 105 | // Cooling mode temperature setpoint for zone when unoccupied 106 | ZoneAirTempUnoccCoolingSp : ZoneAirTempCoolingSp { unocc } 107 | 108 | // Cooling mode temperature setpoint for zone when in standby mode 109 | ZoneAirTempStandbyCoolingSp : ZoneAirTempCoolingSp { standby } 110 | 111 | // Heating mode temperature setpoint for zone 112 | ZoneAirTempHeatingSp : ZoneAirTempSp { heating } 113 | 114 | // Heating mode temperature setpoint for zone when occupied 115 | ZoneAirTempOccHeatingSp : ZoneAirTempHeatingSp { occ } 116 | 117 | // Heating mode temperature setpoint for zone when unoccupied 118 | ZoneAirTempUnoccHeatingSp : ZoneAirTempHeatingSp { unocc } 119 | 120 | // Heating mode temperature setpoint for zone when in standby mode 121 | ZoneAirTempStandbyHeatingSp : ZoneAirTempHeatingSp { standby } 122 | 123 | -------------------------------------------------------------------------------- /src/xeto/ph.points/base.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | ////////////////////////////////////////////////////////////////////////// 10 | // Point Kinds 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | // Boolean or digital point with an true/false state 14 | BoolPoint : Point { 15 | kind: "Bool" 16 | } 17 | 18 | // Numeric or analog point with floating point value 19 | NumberPoint : Point { 20 | kind: "Number" 21 | unit: Unit 22 | } 23 | 24 | // Enumerated or multi-state point with string value 25 | EnumPoint : Point { 26 | kind: "Str" 27 | enum: Obj 28 | } 29 | 30 | ////////////////////////////////////////////////////////////////////////// 31 | // Point Functions 32 | ////////////////////////////////////////////////////////////////////////// 33 | 34 | // Point is a command, actuator, AO/BO. 35 | CmdPoint: Point { cmd } 36 | 37 | // Point is a sensor, input, AI/BI. 38 | SensorPoint: Point { sensor } 39 | 40 | // Point is a setpoint, soft point, internal control variable, schedule. 41 | SpPoint: Point { sp } 42 | 43 | // Synthetic point with computed operational data 44 | SyntheticPoint: Point { synthetic } 45 | 46 | // Computed poin 47 | ComputedSyntheticPoint: SyntheticPoint { computed } 48 | 49 | // Machine learning point 50 | MlSyntheticPoint: SyntheticPoint { ml } 51 | 52 | // Simulation point 53 | SimSyntheticPoint: SyntheticPoint { sim } 54 | 55 | -------------------------------------------------------------------------------- /src/xeto/ph.points/co2.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with the concentration of carbon dioxide (CO₂) 10 | Co2Point : NumberPoint { 11 | air 12 | co2 13 | concentration 14 | unit: Unit "ppm" 15 | } 16 | 17 | // Sensor for concentration of carbon dioxide (CO₂) 18 | Co2Sensor : Co2Point & SensorPoint 19 | 20 | // Setpoint for concentration of carbon dioxide (CO₂) 21 | Co2Sp : Co2Point & SpPoint 22 | 23 | ////////////////////////////////////////////////////////////////////////// 24 | // Zone 25 | ////////////////////////////////////////////////////////////////////////// 26 | 27 | // Sensor for concentration of carbon dioxide (CO₂) in zone space. 28 | ZoneCo2Sensor : Co2Sensor { zone } 29 | 30 | // Setpoint for concentration of carbon dioxide (CO₂) in zone space. 31 | ZoneCo2Sp : Co2Sp { zone } 32 | 33 | -------------------------------------------------------------------------------- /src/xeto/ph.points/damper.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with damper position; 0% is fully closed, 100% is fully open 10 | DamperPoint : NumberPoint { 11 | air 12 | damper 13 | unit: Unit "%" 14 | } 15 | 16 | // Damper position sensor; 0% is fully closed, 100% is fully open 17 | DamperSensor : DamperPoint & SensorPoint 18 | 19 | // Damper position command; 0% is fully closed, 100% is fully open 20 | DamperCmd : DamperPoint & CmdPoint 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Discharge 24 | ////////////////////////////////////////////////////////////////////////// 25 | 26 | // Damper position sensor in dischage duct 27 | DischargeDamperSensor : DamperSensor { discharge } 28 | 29 | // Damper position command in dischage duct 30 | DischargeDamperCmd : DamperCmd { discharge } 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | // ColdDeck Discharge 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Damper position sensor in cold deck dischage duct 37 | ColdDeckDischargeDamperSensor : DischargeDamperSensor { coldDeck } 38 | 39 | // Damper position command in cold deck dischage duct 40 | ColdDeckDischargeDamperCmd : DischargeDamperCmd { coldDeck } 41 | 42 | ////////////////////////////////////////////////////////////////////////// 43 | // HotDeck Discharge 44 | ////////////////////////////////////////////////////////////////////////// 45 | 46 | // Damper position sensor in hot deck dischage duct 47 | HotDeckDischargeDamperSensor : DischargeDamperSensor { hotDeck } 48 | 49 | // Damper position command in hot deck dischage duct 50 | HotDeckDischargeDamperCmd : DischargeDamperCmd { hotDeck } 51 | 52 | ////////////////////////////////////////////////////////////////////////// 53 | // Economizing 54 | ////////////////////////////////////////////////////////////////////////// 55 | 56 | // Damper position sensor in economizing duct. 57 | // Used when there are separate ducts for minimum fresh air vs economizing. 58 | EconomizingDamperSensor : DamperSensor { economizing } 59 | 60 | // Damper position command in economizing duct. 61 | // Used when there are separate ducts for minimum fresh air vs economizing. 62 | EconomizingDamperCmd : DamperCmd { economizing } 63 | 64 | ////////////////////////////////////////////////////////////////////////// 65 | // Exhaust 66 | ////////////////////////////////////////////////////////////////////////// 67 | 68 | // Damper position sensor in exhaust duct 69 | ExhaustDamperSensor : DamperSensor { exhaust } 70 | 71 | // Damper position command in exhaust duct 72 | ExhaustDamperCmd : DamperCmd { exhaust } 73 | 74 | ////////////////////////////////////////////////////////////////////////// 75 | // Mixed 76 | ////////////////////////////////////////////////////////////////////////// 77 | 78 | // Damper position sensor in mixed air duct 79 | MixedDamperSensor : DamperSensor { mixed } 80 | 81 | // Damper position command in mixed duct 82 | MixedDamperCmd : DamperCmd { mixed } 83 | 84 | ////////////////////////////////////////////////////////////////////////// 85 | // Outside 86 | ////////////////////////////////////////////////////////////////////////// 87 | 88 | // Damper position sensor in outside duct. 89 | // Used when there one duct for both minimum fresh air and economizing. 90 | OutsideDamperSensor : DamperSensor { outside } 91 | 92 | // Damper position command in outside duct. 93 | // Used when there one duct for both minimum fresh air and economizing. 94 | OutsideDamperCmd : DamperCmd { outside } 95 | 96 | ////////////////////////////////////////////////////////////////////////// 97 | // Return 98 | ////////////////////////////////////////////////////////////////////////// 99 | 100 | // Damper position sensor in return duct 101 | ReturnDamperSensor : DamperSensor { return } 102 | 103 | // Damper position command in return duct 104 | ReturnDamperCmd : DamperCmd { return } 105 | 106 | ////////////////////////////////////////////////////////////////////////// 107 | // Ventilation 108 | ////////////////////////////////////////////////////////////////////////// 109 | 110 | // Damper position sensor in ventilation or minimum fresh air duct. 111 | // Used when there are separate ducts for minimum fresh air vs economizing. 112 | VentilationDamperSensor : DamperSensor { ventilation } 113 | 114 | // Damper position command in ventilation or minimum fresh air duct. 115 | // Used when there are separate ducts for minimum fresh air vs economizing. 116 | VentilationDamperCmd : DamperCmd { ventilation } 117 | 118 | -------------------------------------------------------------------------------- /src/xeto/ph.points/elec.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 9 Apr 2025 Rick Jennings Creation 7 | // 8 | 9 | ElecDirection: Choice 10 | ElecImportDirection: ElecDirection { import } 11 | ElecExportDirection: ElecDirection { export } 12 | ElecNetDirection: ElecDirection { net } 13 | ElecAbsoluteDirection: ElecDirection { absolute } 14 | 15 | ElecAcPowerSubtype: Choice 16 | ElecAcActivePower: ElecAcPowerSubtype { active } 17 | ElecAcReactivePower: ElecAcPowerSubtype { reactive } 18 | ElecAcApparentPower: ElecAcPowerSubtype { apparent } 19 | 20 | // Sensor for electricity 21 | ElecSensor : NumberPoint & SensorPoint { elec } 22 | 23 | // Sensor for electric demand 24 | ElecDemandSensor : ElecSensor { 25 | demand 26 | elecDirection: ElecDirection 27 | } 28 | 29 | // Sensor for electric energy 30 | ElecEnergySensor : ElecSensor { 31 | energy 32 | elecDirection: ElecDirection 33 | } 34 | 35 | // Sensor for AC electric power factor 36 | ElecAcPfSensor : ElecSensor { 37 | pf 38 | unit: Unit "pf" 39 | ac 40 | pfScope: PfScope? 41 | pfStandard: PfStandard? 42 | } 43 | 44 | // Sensor for AC electric energy 45 | ElecAcEnergySensor : ElecEnergySensor { 46 | ac 47 | elecAcPowerSubtype: ElecAcPowerSubtype 48 | } 49 | 50 | // Sensor for AC electric active energy 51 | ElecAcActiveEnergySensor : ElecAcEnergySensor { 52 | active 53 | unit: Unit "kWh" 54 | } 55 | 56 | // Sensor for AC electric reactive energy 57 | ElecAcReactiveEnergySensor : ElecAcEnergySensor { 58 | reactive 59 | unit: Unit "kVARh" 60 | } 61 | 62 | // Sensor for AC electric apparent energy 63 | ElecAcApparentEnergySensor : ElecAcEnergySensor { 64 | apparent 65 | unit: Unit "kVAh" 66 | } 67 | 68 | // Sensor for AC electric power demand 69 | ElecAcDemandSensor : ElecDemandSensor { 70 | ac 71 | power 72 | elecAcPowerSubtype: ElecAcPowerSubtype 73 | } 74 | 75 | // Sensor for AC electric active power demand 76 | ElecAcActiveDemandSensor : ElecAcDemandSensor { 77 | active 78 | unit: Unit "kW" 79 | } 80 | 81 | // Sensor for AC electric reactive power demand 82 | ElecAcReactiveDemandSensor : ElecAcDemandSensor { 83 | reactive 84 | unit: Unit "kVAR" 85 | } 86 | 87 | // Sensor for AC electric apparent power demand 88 | ElecAcApparentDemandSensor : ElecAcDemandSensor { 89 | apparent 90 | unit: Unit "kVA" 91 | } 92 | 93 | // Sensor for import of AC electric active energy 94 | ElecAcImportActiveEnergySensor : ElecAcActiveEnergySensor { import } 95 | 96 | // Sensor for export of AC electric active energy 97 | ElecAcExportActiveEnergySensor : ElecAcActiveEnergySensor { export } 98 | 99 | // Sensor for net of AC electric active energy 100 | ElecAcNetActiveEnergySensor : ElecAcActiveEnergySensor { net } 101 | 102 | // Sensor for import of AC electric reactive energy 103 | ElecAcImportReactiveEnergySensor : ElecAcReactiveEnergySensor { import } 104 | 105 | // Sensor for export of AC electric reactive energy 106 | ElecAcExportReactiveEnergySensor : ElecAcReactiveEnergySensor { export } 107 | 108 | // Sensor for net of AC electric reactive energy 109 | ElecAcNetReactiveEnergySensor : ElecAcReactiveEnergySensor { net } 110 | 111 | // Sensor for import of AC electric apparent energy 112 | ElecAcImportApparentEnergySensor : ElecAcApparentEnergySensor { import } 113 | 114 | // Sensor for export of AC electric apparent energy 115 | ElecAcExportApparentEnergySensor : ElecAcApparentEnergySensor { export } 116 | 117 | // Sensor for net of AC electric apparent energy 118 | ElecAcNetApparentEnergySensor : ElecAcApparentEnergySensor { net } 119 | 120 | // Sensor for import of AC electric active power demand 121 | ElecAcImportActiveDemandSensor : ElecAcActiveDemandSensor { import } 122 | 123 | // Sensor for export of AC electric active power demand 124 | ElecAcExportActiveDemandSensor : ElecAcActiveDemandSensor { export } 125 | 126 | // Sensor for net of AC electric active power demand 127 | ElecAcNetActiveDemandSensor : ElecAcActiveDemandSensor { net } 128 | 129 | // Sensor for import of AC electric reactive power demand 130 | ElecAcImportReactiveDemandSensor : ElecAcReactiveDemandSensor { import } 131 | 132 | // Sensor for export of AC electric reactive power demand 133 | ElecAcExportReactiveDemandSensor : ElecAcReactiveDemandSensor { export } 134 | 135 | // Sensor for net of AC electric reactive power demand 136 | ElecAcNetReactiveDemandSensor : ElecAcReactiveDemandSensor { net } 137 | 138 | // Sensor for import of AC electric apparent power demand 139 | ElecAcImportApparentDemandSensor : ElecAcApparentDemandSensor { import } 140 | 141 | // Sensor for export of AC electric apparent power demand 142 | ElecAcExportApparentDemandSensor : ElecAcApparentDemandSensor { export } 143 | 144 | // Sensor for net of AC electric apparent power demand 145 | ElecAcNetApparentDemandSensor : ElecAcApparentDemandSensor { net } 146 | 147 | // Sensor for total import of AC electric active energy 148 | ElecAcTotalImportActiveEnergySensor : ElecAcImportActiveEnergySensor { total } 149 | 150 | // Sensor for total export of AC electric active energy 151 | ElecAcTotalExportActiveEnergySensor : ElecAcExportActiveEnergySensor { total } 152 | 153 | // Sensor for total net of AC electric active energy 154 | ElecAcTotalNetActiveEnergySensor : ElecAcNetActiveEnergySensor { total } 155 | 156 | // Sensor for total import of AC electric reactive energy 157 | ElecAcTotalImportReactiveEnergySensor : ElecAcImportReactiveEnergySensor { total } 158 | 159 | // Sensor for total export of AC electric reactive energy 160 | ElecAcTotalExportReactiveEnergySensor : ElecAcExportReactiveEnergySensor { total } 161 | 162 | // Sensor for total net of AC electric reactive energy 163 | ElecAcTotalNetReactiveEnergySensor : ElecAcNetReactiveEnergySensor { total } 164 | 165 | // Sensor for total import of AC electric apparent energy 166 | ElecAcTotalImportApparentEnergySensor : ElecAcImportApparentEnergySensor { total } 167 | 168 | // Sensor for total export of AC electric apparent energy 169 | ElecAcTotalExportApparentEnergySensor : ElecAcExportApparentEnergySensor { total } 170 | 171 | // Sensor for total net of AC electric apparent energy 172 | ElecAcTotalNetApparentEnergySensor : ElecAcNetApparentEnergySensor { total } 173 | 174 | // Sensor for total AC electric power factor 175 | ElecAcTotalPfSensor : ElecAcPfSensor { total } 176 | 177 | // Sensor for total import of AC electric active power demand 178 | ElecAcTotalImportActiveDemandSensor : ElecAcImportActiveDemandSensor { total } 179 | 180 | // Sensor for total export of AC electric active power demand 181 | ElecAcTotalExportActiveDemandSensor : ElecAcExportActiveDemandSensor { total } 182 | 183 | // Sensor for total net of AC electric active power demand 184 | ElecAcTotalNetActiveDemandSensor : ElecAcNetActiveDemandSensor { total } 185 | 186 | // Sensor for total import of AC electric reactive power demand 187 | ElecAcTotalImportReactiveDemandSensor : ElecAcImportReactiveDemandSensor { total } 188 | 189 | // Sensor for total export of AC electric reactive power demand 190 | ElecAcTotalExportReactiveDemandSensor : ElecAcExportReactiveDemandSensor { total } 191 | 192 | // Sensor for total net of AC electric reactive power demand 193 | ElecAcTotalNetReactiveDemandSensor : ElecAcNetReactiveDemandSensor { total } 194 | 195 | // Sensor for total import of AC electric apparent power demand 196 | ElecAcTotalImportApparentDemandSensor : ElecAcImportApparentDemandSensor { total } 197 | 198 | // Sensor for total export of AC electric apparent power demand 199 | ElecAcTotalExportApparentDemandSensor : ElecAcExportApparentDemandSensor { total } 200 | 201 | // Sensor for total net of AC electric apparent power demand 202 | ElecAcTotalNetApparentDemandSensor : ElecAcNetApparentDemandSensor { total } 203 | 204 | -------------------------------------------------------------------------------- /src/xeto/ph.points/fan.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with a fan 10 | FanPoint : Point { 11 | air 12 | fan 13 | } 14 | 15 | // Sensor for primary on/off state of fan 16 | FanRunSensor : FanPoint & RunSensor 17 | 18 | // Command for primary on/off state of fan 19 | FanRunCmd : FanPoint & RunCmd 20 | 21 | // Sensor for secondary on/off state of fan 22 | FanEnableSensor : FanPoint & EnableSensor 23 | 24 | // Command for secondary on/off state of fan 25 | FanEnableCmd : FanPoint & EnableCmd 26 | 27 | // Sensor for speed of a fan as percentage 0% off and 100% full speed 28 | FanSpeedSensor : FanPoint & VfdSpeedSensor 29 | 30 | // Command for speed of a fan as percentage 0% off and 100% full speed 31 | FanSpeedCmd : FanPoint & VfdSpeedCmd 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | // Discharge 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | // Sensor for primary on/off state of fan in discharge duct 38 | DischargeFanRunSensor : FanRunSensor { discharge } 39 | 40 | // Command for primary on/off state of fan in discharge duct 41 | DischargeFanRunCmd : FanRunCmd { discharge } 42 | 43 | // Sensor for secondary on/off state of fan in discharge duct 44 | DischargeFanEnableSensor : FanEnableSensor { discharge } 45 | 46 | // Command for secondary on/off state of fan in discharge duct 47 | DischargeFanEnableCmd : FanEnableCmd { discharge } 48 | 49 | // Sensor for fan speed as percentage in discharge duct. 50 | // Percentage is 0% for off and 100% for full speed. 51 | DischargeFanSpeedSensor : FanSpeedSensor { discharge } 52 | 53 | // Command for fan speed as percentage in discharge duct. 54 | // Percentage is 0% for off and 100% for full speed. 55 | DischargeFanSpeedCmd : FanSpeedCmd { discharge } 56 | 57 | ////////////////////////////////////////////////////////////////////////// 58 | // Return 59 | ////////////////////////////////////////////////////////////////////////// 60 | 61 | // Sensor for primary on/off state of fan in return duct 62 | ReturnFanRunSensor : FanRunSensor { return } 63 | 64 | // Command for primary on/off state of fan in return duct 65 | ReturnFanRunCmd : FanRunCmd { return } 66 | 67 | // Sensor for secondary on/off state of fan in return duct 68 | ReturnFanEnableSensor : FanEnableSensor { return } 69 | 70 | // Command for secondary on/off state of fan in return duct 71 | ReturnFanEnableCmd : FanEnableCmd { return } 72 | 73 | // Sensor for fan speed as percentage in return duct. 74 | // Percentage is 0% for off and 100% for full speed. 75 | ReturnFanSpeedSensor : FanSpeedSensor { return } 76 | 77 | // Command for fan speed as percentage in return duct. 78 | // Percentage is 0% for off and 100% for full speed. 79 | ReturnFanSpeedCmd : FanSpeedCmd { return } 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/xeto/ph.points/lib.xeto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, Project-Haystack 2 | // Licensed under the Academic Free License version 3.0 3 | // 4 | // History: 5 | // 6 Nov 2022 Brian Frank Creation 6 | 7 | pragma: Lib < 8 | doc: "Project haystack experimental points library" 9 | version: "0.1.1" 10 | depends: { 11 | { lib: "sys", versions: "0.1.x" } 12 | { lib: "ph", versions: "0.1.x" } 13 | } 14 | categories: {"ph"} 15 | license: "AFL-3.0" 16 | org: { 17 | dis: "Project Haystack" 18 | uri: "https://project-haystack.org/" 19 | } 20 | vcs: { 21 | type: "git" 22 | uri: "https://github.com/Project-Haystack/xeto.git" 23 | } 24 | > 25 | 26 | -------------------------------------------------------------------------------- /src/xeto/ph.points/misc.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 5 Apr 2023 Brian Frank Creation 7 | // 8 | 9 | // Cooling enable command 10 | CoolCmd : BoolPoint { cool } 11 | 12 | // Heating enable command 13 | HeatCmd : BoolPoint { heat } 14 | 15 | // Dessicant dehumidifier enable command 16 | DessicantDehumidifierCmd : BoolPoint { dessicantDehumidifier } 17 | 18 | // Temperature conditioning mode for a zone in an HVAC system 19 | ZoneAirHvacModeSp : EnumPoint & SpPoint { zone, air, hvacMode } 20 | 21 | -------------------------------------------------------------------------------- /src/xeto/ph.points/motor.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with the primary on/off state for equipment 10 | RunPoint : BoolPoint { 11 | run 12 | enum: Obj 13 | } 14 | 15 | // On and off enumeration 16 | RunEnum: Enum { off, on } 17 | 18 | // Sensor for the primary on/off command for equipment 19 | RunSensor : RunPoint & SensorPoint 20 | 21 | // Primary on/off command to run a equipment such as a motor 22 | RunCmd : RunPoint & CmdPoint 23 | 24 | // Point associated with secondary on/off state for equipment 25 | EnablePoint : BoolPoint { 26 | enable 27 | enum: Obj 28 | } 29 | 30 | // Sensor for the secondary on/off command for equipment 31 | EnableSensor : EnablePoint & SensorPoint 32 | 33 | // Secondary on/off command to run equipment 34 | EnableCmd : EnablePoint & CmdPoint 35 | 36 | // Boolean alarm condition 37 | AlarmSensor : BoolPoint & SensorPoint { alarm } 38 | 39 | // Point associated with VFD frequency measured in Hertz 40 | VfdFreqPoint : NumberPoint { 41 | vfd 42 | freq 43 | unit: "Hz" 44 | } 45 | 46 | // Sensor for VFD frequency in Hertz 47 | VfdFreqSensor : VfdFreqPoint & SensorPoint 48 | 49 | // Command for VFD frequency in Hertz 50 | VfdFreqCmd : VfdFreqPoint & CmdPoint 51 | 52 | // Point associated with VFD speed. Speed is measured as 53 | // percentage where 0% is off and 100% if full speed 54 | VfdSpeedPoint : NumberPoint { 55 | vfd 56 | speed 57 | unit: "%" 58 | } 59 | 60 | // VFD speed sensor as percentage where 0% is off, 100% if full speed 61 | VfdSpeedSensor : VfdSpeedPoint & SensorPoint 62 | 63 | // VFD speed command as percentage where 0% is off, 100% if full speed 64 | VfdSpeedCmd : VfdSpeedPoint & CmdPoint 65 | 66 | -------------------------------------------------------------------------------- /src/xeto/ph.points/naturalGas.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 21 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | ////////////////////////////////////////////////////////////////////////// 10 | // Flow 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | // Point associated with rate of volumetric flow of natural gas 14 | NaturalGasFlowPoint : NumberPoint { 15 | naturalGas 16 | flow 17 | unit: Unit "cfm" 18 | } 19 | 20 | // Sensor for volumetric flow of natural gas 21 | NaturalGasFlowSensor : NaturalGasFlowPoint & SensorPoint 22 | 23 | // Setpoint for volumetric flow of natural gas 24 | NaturalGasFlowSp : NaturalGasFlowPoint & SpPoint 25 | 26 | ////////////////////////////////////////////////////////////////////////// 27 | // Volume 28 | ////////////////////////////////////////////////////////////////////////// 29 | 30 | // Point associated with volumetric consumption of natural gas 31 | NaturalGasVolumePoint : NumberPoint { 32 | naturalGas 33 | volume 34 | unit: Unit "Ccf" 35 | } 36 | 37 | // Sensor for volumetric consumption of natural gas 38 | NaturalGasVolumeSensor : NaturalGasVolumePoint & SensorPoint 39 | 40 | // Setpoint for volumetric consumption of natural gas 41 | NaturalGasVolumeSp : NaturalGasVolumePoint & SpPoint 42 | 43 | ////////////////////////////////////////////////////////////////////////// 44 | // Volume 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | // Point associated with energy consumption of natural gas 48 | NaturalGasEnergyPoint : NumberPoint { 49 | naturalGas 50 | energy 51 | unit: Unit "Ccf_natural_gas" 52 | } 53 | 54 | // Sensor for energy consumption of natural gas 55 | NaturalGasEnergySensor : NaturalGasEnergyPoint & SensorPoint 56 | 57 | // Setpoint for energy consumption of natural gas 58 | NaturalGasEnergySp : NaturalGasEnergyPoint & SpPoint 59 | 60 | -------------------------------------------------------------------------------- /src/xeto/ph.points/occupied.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with the occupied state. This is a boolean 10 | // state where false means unoccupied and true means occupied. 11 | OccupiedPoint : BoolPoint { 12 | occupied 13 | enum: Obj 14 | } 15 | 16 | // Unoccupied/occupied enumeration 17 | OccupiedEnum : Enum { unoccupied, occupied } 18 | 19 | // Occupancy sensor 20 | OccupiedSensor : OccupiedPoint & SensorPoint 21 | 22 | // Occupancy setpoint 23 | OccupiedSp : OccupiedPoint & SpPoint 24 | 25 | ////////////////////////////////////////////////////////////////////////// 26 | // Zone 27 | ////////////////////////////////////////////////////////////////////////// 28 | 29 | // Occupancy sensor for zone space 30 | ZoneOccupiedSensor : OccupiedSensor { zone } 31 | 32 | // Occupancy setpoint for zone space 33 | ZoneOccupiedSp : OccupiedSp { zone } 34 | 35 | -------------------------------------------------------------------------------- /src/xeto/ph.points/valve.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 3 Nov 2022 Brian Frank Creation 7 | // 8 | 9 | // Point associated with a valve; 0% is fully closed and 100% is fully open. 10 | ValvePoint : NumberPoint { 11 | valve 12 | unit: Unit "%" 13 | } 14 | 15 | // Valve position sensor; 0% is fully closed and 100% is fully open. 16 | ValveSensor : ValvePoint & SensorPoint 17 | 18 | // Valve position command; 0% is fully closed and 100% is fully open. 19 | ValveCmd : ValvePoint & CmdPoint 20 | 21 | ////////////////////////////////////////////////////////////////////////// 22 | // Chilled Water 23 | ////////////////////////////////////////////////////////////////////////// 24 | 25 | // Valve sensor for chilled water 26 | ChilledWaterValveSensor : ValveSensor { chilled, water } 27 | 28 | // Valve commad for hot water 29 | ChilledWaterValveCmd : ValveCmd { chilled, water } 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | // Hot Water 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | // Valve sensor for hot water 36 | HotWaterValveSensor : ValveSensor { hot, water } 37 | 38 | // Valve commad for hot water 39 | HotWaterValveCmd : ValveCmd { hot, water } 40 | 41 | -------------------------------------------------------------------------------- /src/xeto/ph.points/water-flow.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 21 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | // Point associated with rate of volumetric flow of water 10 | WaterFlowPoint : NumberPoint { 11 | water 12 | flow 13 | unit: Unit "gal/min" 14 | } 15 | 16 | // Sensor for volumetric flow of water 17 | WaterFlowSensor : WaterFlowPoint & SensorPoint 18 | 19 | // Setpoint for volumetric flow of water 20 | WaterFlowSp : WaterFlowPoint & SpPoint 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Domestic 24 | ////////////////////////////////////////////////////////////////////////// 25 | 26 | // Sensor for volumetric flow of domestic water 27 | DomesticWaterFlowSensor : WaterFlowSensor { domestic } 28 | 29 | // Setpoint for volumetric flow of domestic water 30 | DomesticWaterFlowSp : WaterFlowSp { domestic } 31 | 32 | -------------------------------------------------------------------------------- /src/xeto/ph.points/water-volume.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 21 Mar 2024 Brian Frank Creation 7 | // 8 | 9 | // Point associated with volumetric consumption of water 10 | WaterVolumePoint : NumberPoint { 11 | water 12 | volume 13 | unit: Unit "gal" 14 | } 15 | 16 | // Sensor for volumetric consumption of water 17 | WaterVolumeSensor : WaterVolumePoint & SensorPoint 18 | 19 | // Setpoint for volumetric consumption of water 20 | WaterVolumeSp : WaterVolumePoint & SpPoint 21 | 22 | ////////////////////////////////////////////////////////////////////////// 23 | // Domestic 24 | ////////////////////////////////////////////////////////////////////////// 25 | 26 | // Sensor for volumetric consumption of domestic water 27 | DomesticWaterVolumeSensor : WaterVolumeSensor { domestic } 28 | 29 | // Setpoint for volumetric consumption of domestic water 30 | DomesticWaterVolumeSp : WaterVolumeSp { domestic } 31 | 32 | -------------------------------------------------------------------------------- /src/xeto/ph.points/weather.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 16 Jan 2024 Brian Frank Creation 7 | // 8 | 9 | // Weather observation point 10 | WeatherPoint : Point & SensorPoint { 11 | weather 12 | weatherStationRef: Ref 13 | } 14 | 15 | // Weather enumeration for condition such as clear, cloudy, rain, etc 16 | WeatherCondPoint : WeatherPoint & EnumPoint { 17 | weatherCond 18 | enum: Obj 19 | } 20 | 21 | // Weather boolean point that is true between sunrise and sunset 22 | WeatherDaytimePoint : WeatherPoint & BoolPoint { 23 | daytime 24 | enum: Obj 25 | } 26 | 27 | // Numeric weather observation point 28 | WeatherNumberPoint : WeatherPoint & NumberPoint { 29 | } 30 | 31 | // Dry bulb weather temperature 32 | WeatherTempPoint : WeatherNumberPoint { 33 | temp 34 | unit: Unit "°F" 35 | } 36 | 37 | // Wet bulb weather temperature 38 | WeatherWetbulbPoint : WeatherNumberPoint { 39 | webBulb 40 | unit: Unit "°F" 41 | } 42 | 43 | // Apparent weather temperature considering humidity, wind 44 | // chill, and heat index 45 | WeatherFeelsLikePoint : WeatherNumberPoint { 46 | feelsLike 47 | unit: Unit "°F" 48 | } 49 | 50 | // Weather dew point temperature at whicih water vapor will form dew 51 | WeatherDewPointPoint : WeatherNumberPoint { 52 | dewPoint 53 | unit: Unit "°F" 54 | } 55 | 56 | // Weather percent relative humidity 57 | WeatherHumidityPoint : WeatherNumberPoint { 58 | humidity 59 | unit: Unit "%RH" 60 | } 61 | 62 | // Weather enthalpy is sum of heat energy in the dry air and water vapor 63 | WeatherEnthalpyPoint : WeatherNumberPoint { 64 | enthalpy 65 | unit: Unit "BTU/lb" 66 | } 67 | 68 | // Weather barometric pressure in millibar or inHg 69 | WeatherAtmosphericPressurePoint : WeatherNumberPoint { 70 | atmospheric 71 | pressure 72 | unit: Unit "inHg" 73 | } 74 | 75 | // Weather cloudiness as percentage 76 | WeatherCloudagePoint : WeatherNumberPoint { 77 | cloudage 78 | unit: Unit "%" 79 | } 80 | 81 | // Weather fallen atmospheric water vapor in mm or in 82 | WeatherPrecipitationPoint : WeatherNumberPoint { 83 | precipitation 84 | unit: Unit "in" 85 | } 86 | 87 | // Weather energy received from the sun in W/m² 88 | WeatherSolarIrradiancePoint : WeatherNumberPoint { 89 | solar 90 | irradiance 91 | unit: Unit "W/m²" 92 | } 93 | 94 | // Weather wind speed in km/h or mph 95 | WeatherWindSpeedPoint : WeatherNumberPoint { 96 | wind 97 | speed 98 | unit: Unit "mph" 99 | } 100 | 101 | // Weather direction that wind originates in degrees 102 | WeatherWindDirectionPoint : WeatherNumberPoint { 103 | wind 104 | direction 105 | unit: Unit "deg" 106 | } 107 | 108 | // Weather visibility at which light can be discerned in km or mile 109 | WeatherVisibilityPoint : WeatherNumberPoint { 110 | visibility 111 | unit: Unit "mile" 112 | } 113 | 114 | -------------------------------------------------------------------------------- /src/xeto/ph.protocols/bacnet.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 5 Feb 2025 James Gessel Creation 7 | // 8 | 9 | // BacnetAddr contains all addressing info to communicate with a BACnet 10 | // point. The 'addr' field is used to specify the primary object to 11 | // read present value and issue writes. Optionally the 'trend' field 12 | // can be used to specify the trend log object for historical data. 13 | // 14 | // Address fields are formatted as XXXNNN where XXX is an objec type 15 | // code in the table below and NNN is the object identifer number 16 | // in the device. 17 | // 18 | // | Object Name | Code | Object Type 19 | // |------------------------|------|------------ 20 | // | ACCUMULATOR | ACC | 23 21 | // | ANALOG_INPUT | AI | 0 22 | // | ANALOG_OUTPUT | AO | 1 23 | // | ANALOG_VALUE | AV | 2 24 | // | BINARY_INPUT | BI | 3 25 | // | BINARY_OUTPUT | BO | 4 26 | // | BINARY_VALUE | BV | 5 27 | // | CHARACTERSTRING_VALUE | STR | 40 28 | // | LARGE_ANALOG_VALUE | LAV | 46 29 | // | LOAD_CONTROL | LC | 28 30 | // | MULTI_STATE_INPUT | MSI | 13 31 | // | MULTI_STATE_OUTPUT | MSO | 14 32 | // | MULTI_STATE_VALUE | MSV | 19 33 | // | POSITIVE_INTEGER_VALUE | PIV | 48 34 | // | PROGRAM_OBJECT | PRG | 16 35 | // | PULSE_CONVERTER | PC | 24 36 | // | SCHEDULE | SCH | 17 37 | // | TREND_LOG | TL | 20 38 | // 39 | BacnetAddr: ProtocolAddr { 40 | addr: Str //cur/write address (such as AO4, AI3, BO2, BI1) 41 | trend: Str? //optional trend log address (such as TL1) 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/xeto/ph.protocols/base.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 5 Feb 2025 James Gessel Creation 7 | // 8 | 9 | // ProtocolAddr is a dict that contains all information necessary for a point 10 | // to communicate via a given protocol. It must always contain a 11 | // primary address, which is assumed to be where a point accesses its 12 | // current value. Subtypes may add additional addresses for trend, etc. 13 | ProtocolAddr: Dict { 14 | addr: Str 15 | } -------------------------------------------------------------------------------- /src/xeto/ph.protocols/lib.xeto: -------------------------------------------------------------------------------- 1 | pragma: Lib < 2 | doc: "Project haystack experimental protocol library" 3 | version: "0.1.1" 4 | depends: { 5 | { lib: "sys", versions: "0.1.x" } 6 | } 7 | categories: {"ph"} 8 | license: "AFL-3.0" 9 | org: { 10 | dis: "Project Haystack" 11 | uri: "https://project-haystack.org/" 12 | } 13 | vcs: { 14 | type: "git" 15 | uri: "https://github.com/Project-Haystack/xeto.git" 16 | } 17 | > 18 | 19 | -------------------------------------------------------------------------------- /src/xeto/ph.protocols/modbus.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 5 Feb 2025 James Gessel Creation 7 | // 8 | 9 | // ModbusAddr contains all info required to connect to a modbus point 10 | // Only supports decimal format (no hex or modicon) 11 | // Fields: 12 | // - **addr**: Modbus address (0=Coil, 1=Input, 3=Holding Reg, 4=Input Reg). Must follow '0xxxx'-'4xxxx' pattern. 13 | // - **encoding**: Data format for interpretation. 14 | // - **bitIndex**: (0-15) Optional bit position within a register. 15 | // - **access**: '"r"' (default) or '"rw"' (Read/Write). 16 | // - **scale**: Multiplier for raw values (default 1). 17 | // - **offset**: Optional offset value applied after scaling. 18 | // - **byteOrder**: Optional, defines endianness for multi-register values. 19 | // 20 | // Example: '{ "addr": "40001", "encoding": "u2", "scale": 10, "access": "rw" }' 21 | ModbusAddr: ProtocolAddr { 22 | addr: Str // Must follow standard Modbus addressing rules (0xxxx-4xxxx) 23 | encoding: ModbusEncoding // Specifies data representation format 24 | bitIndex: Int? // Optional bit index within a register 25 | access: ModbusAccess "r" // Read/write access 26 | scale: Number "1" // Scaling factor for raw values 27 | offset: Number? // Optional offset applied after scaling 28 | byteOrder: ModbusByteOrder? // Defines byte ordering for multi-register values 29 | } 30 | 31 | // ModbusAccess specifies read/write access for a modbus point 32 | ModbusAccess: Enum { 33 | r // Read Only 34 | rw // Read/Write 35 | w // Write Only 36 | } 37 | 38 | // ModbusEncoding specifies the data type and encoding for a modbus point 39 | ModbusEncoding: Enum { 40 | bit // Bool 41 | u1 // Unsigned 8-bit Int 42 | u2 // Unsigned 16-bit Int 43 | u4 // Unsigned 32-bit Int 44 | s1 // Signed 8-bit Int 45 | s2 // Signed 16-bit Int 46 | s4 // Signed 32-bit Int 47 | s8 // Signed 64-bit Int 48 | f4 // 32-bit Float 49 | f8 // 64-bit Float 50 | } 51 | 52 | // Specifies byte and word order for a modbus point 53 | ModbusByteOrder: Enum { 54 | be // Big endian or network byte order 55 | le // Little endian both byte and word order 56 | leb // Little endian byte order 57 | lew // Little endian word order 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/xeto/ph/choices.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // Auto-generated 26-Feb-2025 5 | // 6 | 7 | ////////////////////////////////////////////////////////////////////////// 8 | // AhuZoneDelivery 9 | ////////////////////////////////////////////////////////////////////////// 10 | 11 | // AHU delivery method of conditioned air to the zone 12 | AhuZoneDelivery: Choice 13 | 14 | // AHU supplies air to chilled beam terminal units 15 | ChilledBeamAhuZoneDelivery: AhuZoneDelivery { chilledBeamZone } 16 | 17 | // AHU supplies air directly to the zone 18 | DirectAhuZoneDelivery: AhuZoneDelivery { directZone } 19 | 20 | // AHU discharge air is split into a duct per zone 21 | MultiAhuZoneDelivery: AhuZoneDelivery { multiZone } 22 | 23 | // AHU supplies air to VAV terminal units 24 | VavAhuZoneDelivery: AhuZoneDelivery { vavZone } 25 | 26 | ////////////////////////////////////////////////////////////////////////// 27 | // AirVolumeAdjustability 28 | ////////////////////////////////////////////////////////////////////////// 29 | 30 | // Ability of air handling equip to adjust volume of air flow 31 | AirVolumeAdjustability: Choice 32 | 33 | // Delivers a constant volume of air flow. Typically this means 34 | // equipment with a single speed fan. 35 | ConstantAirVolumeAdjustability: AirVolumeAdjustability { constantAirVolume } 36 | 37 | // Delivers a variable volume of air flow. Most variable volume systems 38 | // are powered by a VFD fan. However other techniques such as inlet vanes 39 | // may be used in older systems. 40 | VariableAirVolumeAdjustability: AirVolumeAdjustability { variableAirVolume } 41 | 42 | ////////////////////////////////////////////////////////////////////////// 43 | // AtesDesign 44 | ////////////////////////////////////////////////////////////////////////// 45 | 46 | // Design type of the ATES underground system. 47 | AtesDesign: Choice 48 | 49 | // The ATES uses closed piping to transport a water/glycol mixture 50 | // through the ground. The system works like a heat exchanger; there 51 | // is no ground water transported. 52 | ClosedLoopAtesDesign: AtesDesign { atesClosedLoop } 53 | 54 | // The ATES has one or more pairs of a separate warm and cool well. 55 | DoubletAtesDesign: AtesDesign { atesDoublet } 56 | 57 | // The ATES is as a doublet, but with specific warm and cool wells linked together. 58 | // These linked wells do not exchange water with other wells. 59 | DoubletPairedAtesDesign: AtesDesign { atesDoubletPaired } 60 | 61 | // The ATES has only one physical well. This well is deep enough 62 | // to penetrate two layers of groundwater. 63 | MonoAtesDesign: AtesDesign { atesMono } 64 | 65 | // Similar to a doublet, but water always flows in the same direction from 66 | // the extraction to the infiltration well. 67 | UnidirectionalAtesDesign: AtesDesign { atesUnidirectional } 68 | 69 | ////////////////////////////////////////////////////////////////////////// 70 | // ChillerMechanism 71 | ////////////////////////////////////////////////////////////////////////// 72 | 73 | // Primary mechanism of chiller 74 | ChillerMechanism: Choice 75 | 76 | // Cooling process using energy from heat source such as hot water 77 | AbsorptionChillerMechanism: ChillerMechanism { absorption } 78 | 79 | // Compression via a continuous flow of fluid through an impeller 80 | CentrifugalChillerMechanism: ChillerMechanism { centrifugal } 81 | 82 | // Piston compressor driven by a crankshaft 83 | ReciprocalChillerMechanism: ChillerMechanism { reciprocal } 84 | 85 | // Rotary screw compression 86 | RotaryScrewChillerMechanism: ChillerMechanism { rotaryScrew } 87 | 88 | ////////////////////////////////////////////////////////////////////////// 89 | // CondenserLoop 90 | ////////////////////////////////////////////////////////////////////////// 91 | 92 | // Open or closed loop for condenser working fluid 93 | CondenserLoop: Choice 94 | 95 | // Working fluid is kept separate from fluid used for heat transfer into the atmosphere 96 | ClosedCondenserLoop: CondenserLoop { condenserClosedLoop } 97 | 98 | // Uses working fluid itself for evaporation into the atmosphere 99 | OpenCondenserLoop: CondenserLoop { condenserOpenLoop } 100 | 101 | ////////////////////////////////////////////////////////////////////////// 102 | // CoolingProcess 103 | ////////////////////////////////////////////////////////////////////////// 104 | 105 | // Processed used to cool a substance 106 | CoolingProcess: Choice 107 | 108 | // Cooling by dissipating heat into the surrounding air 109 | AirCoolingProcess: CoolingProcess { airCooling } 110 | 111 | // Cooling using transfer of heat to chilled water 112 | ChilledWaterCoolingProcess: CoolingProcess { chilledWaterCooling } 113 | 114 | // Removal of heat through the process of water condensation 115 | CondenserCoolingProcess: CoolingProcess { condenserCooling } 116 | 117 | // Cooling using direct expansion of a refrigerant vapor. 118 | // Also see `dxHeating` and `heatPump`. 119 | DxCoolingProcess: CoolingProcess { dxCooling } 120 | 121 | // Cooling using transfer of heat to water which is not explicitly chilled 122 | WaterCoolingProcess: CoolingProcess { waterCooling } 123 | 124 | ////////////////////////////////////////////////////////////////////////// 125 | // DuctConfig 126 | ////////////////////////////////////////////////////////////////////////// 127 | 128 | // Ductwork configuration 129 | DuctConfig: Choice 130 | 131 | // Two ducts: combination of hotDeck, coldDeck, or neutralDeck 132 | DualDuctConfig: DuctConfig { dualDuct } 133 | 134 | // One single duct 135 | SingleDuctConfig: DuctConfig { singleDuct } 136 | 137 | // Three ducts: hotDeck, coldDeck, or neutralDeck 138 | TripleDuctConfig: DuctConfig { tripleDuct } 139 | 140 | ////////////////////////////////////////////////////////////////////////// 141 | // DuctDeck 142 | ////////////////////////////////////////////////////////////////////////// 143 | 144 | // Cold, hot, or neutral deck. Can be applied to 'ahu' equip if the AHU 145 | // is part of a 'dualDuct' or 'tripleDuct' system but only serves a single 146 | // deck type. 147 | DuctDeck: Choice 148 | 149 | // Duct carries air for cooling 150 | ColdDuctDeck: DuctDeck { coldDeck } 151 | 152 | // Duct carries air for heating 153 | HotDuctDeck: DuctDeck { hotDeck } 154 | 155 | // Duct carries air which by-passes both heating and cooling coils 156 | NeutralDuctDeck: DuctDeck { neutralDeck } 157 | 158 | ////////////////////////////////////////////////////////////////////////// 159 | // DuctSection 160 | ////////////////////////////////////////////////////////////////////////// 161 | 162 | // Equipment section of ductwork 163 | DuctSection: Choice 164 | 165 | // Duct for air leaving an equipment 166 | DischargeDuctSection: DuctSection { discharge } 167 | 168 | // Duct to access fresh outside air only for economizing, not ventilation 169 | EconomizerDuctSection: DuctSection { economizer } 170 | 171 | // Duct used to expel air back outside 172 | ExhaustDuctSection: DuctSection { exhaust } 173 | 174 | // Duct for exhausting combustion 175 | FlueDuctSection: DuctSection { flue } 176 | 177 | // Duct with air entering an equipment 178 | InletDuctSection: DuctSection { inlet } 179 | 180 | // Duct where fresh outside air and return air is mixed together 181 | MixedDuctSection: DuctSection { mixed } 182 | 183 | // Duct to access fresh outside air for both ventilation and economizer. 184 | OutsideDuctSection: DuctSection { outside } 185 | 186 | // Duct returning air back to equipment 187 | ReturnDuctSection: DuctSection { return } 188 | 189 | // Duct to access fresh outside air only for ventilation, not economizing 190 | VentilationDuctSection: DuctSection { ventilation } 191 | 192 | ////////////////////////////////////////////////////////////////////////// 193 | // HeatingProcess 194 | ////////////////////////////////////////////////////////////////////////// 195 | 196 | // Processed used to heat a substance 197 | HeatingProcess: Choice 198 | 199 | // Heating by the combustion of biomass 200 | BiomassHeatingProcess: HeatingProcess { biomassHeating } 201 | 202 | // Heating by the combustion of coal 203 | CoalHeatingProcess: HeatingProcess { coalHeating } 204 | 205 | // Heating using direct expansion of a refrigerant vapor. 206 | // Also see `dxCooling` and `heatPump`. 207 | DxHeatingProcess: HeatingProcess { dxHeating } 208 | 209 | // Heating by the conversion of electrical energy 210 | ElecHeatingProcess: HeatingProcess { elecHeating } 211 | 212 | // Heating by the combustion of fuel oil 213 | FuelOilHeatingProcess: HeatingProcess { fuelOilHeating } 214 | 215 | // Heating using energy of hot water 216 | HotWaterHeatingProcess: HeatingProcess { hotWaterHeating } 217 | 218 | // Heating by the combustion of natural gas 219 | NaturalGasHeatingProcess: HeatingProcess { naturalGasHeating } 220 | 221 | // Heating by the combustion of propane 222 | PropaneHeatingProcess: HeatingProcess { propaneHeating } 223 | 224 | // Heating using energy of steam 225 | SteamHeatingProcess: HeatingProcess { steamHeating } 226 | 227 | ////////////////////////////////////////////////////////////////////////// 228 | // MeterScope 229 | ////////////////////////////////////////////////////////////////////////// 230 | 231 | // Classifies a meter as a main site meter or submeter 232 | MeterScope: Choice 233 | 234 | // Main meter for the associated site 235 | SiteMeterScope: MeterScope { siteMeter } 236 | 237 | // Submeters measure usage of a sub-system or equipment within a site 238 | SubmeterMeterScope: MeterScope { submeter } 239 | 240 | ////////////////////////////////////////////////////////////////////////// 241 | // PfScope 242 | ////////////////////////////////////////////////////////////////////////// 243 | 244 | // Power factor scope 245 | PfScope: Choice 246 | 247 | // Displacement power factor, which accounts for the phase angle between 248 | // voltage and current but excludes effects of nonlinear waveforms ( 249 | // harmonic distortion). 250 | DisplacementPfScope: PfScope { pfDisplacement } 251 | 252 | // Distortion power factor, which measures the component of power factor 253 | // attributable to harmonic distortion in voltage and current waveforms. 254 | DistortionPfScope: PfScope { pfDistortion } 255 | 256 | // True power factor, which includes effects of harmonic distortion. 257 | // Power factor is assumed to be true power factor when `pfScope` is not 258 | // defined. However, it is recommended to specify a scope for power 259 | // factor to help avoid misinterpretation of data. 260 | TruePfScope: PfScope { pfTrue } 261 | 262 | ////////////////////////////////////////////////////////////////////////// 263 | // PfStandard 264 | ////////////////////////////////////////////////////////////////////////// 265 | 266 | // Standard for interpreting power factor's positive or negative sign 267 | PfStandard: Choice 268 | 269 | // Power factor according to the IEC convention defines a positive or 270 | // negative sign based on the direction of active power flow. Power factor 271 | // is positive when active power flows into a load. Power factor is negative 272 | // when active power flows out of a load. 273 | IecPfStandard: PfStandard { pfIec } 274 | 275 | // Power factor according to the IEEE convention defines a positive or 276 | // negative sign based on whether the load is capacitive or inductive. Power 277 | // factor is positive when the load is capacitive, or when voltage lags behind 278 | // current. Power factor is negative when the load is inductive, or when 279 | // current lags behind voltage. 280 | IeeePfStandard: PfStandard { pfIeee } 281 | 282 | ////////////////////////////////////////////////////////////////////////// 283 | // PhaseCount 284 | ////////////////////////////////////////////////////////////////////////// 285 | 286 | // Number of phases for an AC electrical power system or 287 | // connected equipment: single-phase, split-phase, two-phase, or 288 | // three-phase. 289 | PhaseCount: Choice 290 | 291 | // Single-phase AC electricity. Power is provided by a 292 | // single AC voltage source with a 2-wire connection. 293 | SinglePhaseCount: PhaseCount { singlePhase } 294 | 295 | // Split-phase AC electricity. Power is provided by a 296 | // single AC voltage source with a 3-wire connection, consisting of two hot 297 | // wires (phases), separated from each other by a 180-degree phase angle, 298 | // and one neutral wire. Despite having two labeled phases, split-phase AC 299 | // electricity is not a true two-phase system. 300 | SplitPhaseCount: PhaseCount { splitPhase } 301 | 302 | // Three-phase AC electricity. Power is provided by three AC voltage 303 | // sources, each separated from the others by a 120-degree phase angle. 304 | // May have a 4-wire connection with a neutral (Wye) or a 3-wire connection 305 | // without a neutral (Delta). 306 | ThreePhaseCount: PhaseCount { threePhase } 307 | 308 | // Two-phase AC electricity. Power is provided by two AC voltage sources, 309 | // separated from each other by a 90-degree phase angle. Two-phase systems 310 | // are extremely rare in modern buildings; they have been replaced by 311 | // modern `threePhase` systems. 312 | TwoPhaseCount: PhaseCount { twoPhase } 313 | 314 | ////////////////////////////////////////////////////////////////////////// 315 | // PipeSection 316 | ////////////////////////////////////////////////////////////////////////// 317 | 318 | // Equipment section of piping 319 | PipeSection: Choice 320 | 321 | // Pipe used to bypass an equipment 322 | BypassPipeSection: PipeSection { bypass } 323 | 324 | // Pipe used to circulate fluid through an equipment or system 325 | CircPipeSection: PipeSection { circ } 326 | 327 | // Pipe conveys fluid into an equipment 328 | EnteringPipeSection: PipeSection { entering } 329 | 330 | // Pipe used as central connection or manifold for other piping runs. 331 | HeaderPipeSection: PipeSection { header } 332 | 333 | // Pipe conveys fluid out of an equipment 334 | LeavingPipeSection: PipeSection { leaving } 335 | 336 | ////////////////////////////////////////////////////////////////////////// 337 | // PlantLoop 338 | ////////////////////////////////////////////////////////////////////////// 339 | 340 | // Plant piping loop: primary, secondary, or tertiary 341 | PlantLoop: Choice 342 | 343 | // Pipework which circulates closest to the energy source. In a central 344 | // plant, the primary loop indicates the pipes and equipment within the 345 | // central plant. In context of heat exchangers between the primary 346 | // and secondary loops, this tag indicates the side closest to the plant. 347 | PrimaryPlantLoop: PlantLoop { primaryLoop } 348 | 349 | // Pipework which circulates closest to the building or end use. In a 350 | // central plant, the secondary loop indicates the pipes and equipment between 351 | // the central plant and the building. In context of heat exchangers between 352 | // the primary and secondary loops, this tag indicates the side closest to 353 | // the building. 354 | SecondaryPlantLoop: PlantLoop { secondaryLoop } 355 | 356 | // Pipework which circulates within the building. 357 | TertiaryPlantLoop: PlantLoop { tertiaryLoop } 358 | 359 | ////////////////////////////////////////////////////////////////////////// 360 | // PointFunction 361 | ////////////////////////////////////////////////////////////////////////// 362 | 363 | // Classifies the point as a sensor, command, or setpoint. 364 | // See `docHaystack::Points#function` chapter. 365 | PointFunction: Choice 366 | 367 | // Point is a command, actuator, AO/BO. 368 | // See `docHaystack::Points#function` chapter. 369 | CmdPointFunction: PointFunction { cmd } 370 | 371 | // Point is a sensor, input, AI/BI. 372 | // See `docHaystack::Points#function` chapter. 373 | SensorPointFunction: PointFunction { sensor } 374 | 375 | // Point is a setpoint, soft point, internal control variable, schedule. 376 | // See `docHaystack::Points#function` chapter. 377 | SpPointFunction: PointFunction { sp } 378 | 379 | // Synthetic point with computed operational data. The computed data 380 | // if classified as: 381 | // - `ml` for machine learning 382 | // - `sim` for simulation 383 | // - `computed` as catch all for other computations 384 | // 385 | // See `docHaystack::Synthetics` chapter. 386 | SyntheticPointFunction: PointFunction { synthetic } 387 | 388 | // Computed point. See `docHaystack::Synthetics` chapter. 389 | ComputedSyntheticPointFunction: SyntheticPointFunction { computed } 390 | 391 | // Machine learning point. See `docHaystack::Synthetics` chapter. 392 | MlSyntheticPointFunction: SyntheticPointFunction { ml } 393 | 394 | // Simulation point. See `docHaystack::Synthetics` chapter. 395 | SimSyntheticPointFunction: SyntheticPointFunction { sim } 396 | 397 | ////////////////////////////////////////////////////////////////////////// 398 | // SimScenario 399 | ////////////////////////////////////////////////////////////////////////// 400 | 401 | // See `docHaystack::Synthetics#sims` chapter. 402 | SimScenario: Choice 403 | 404 | // See `docHaystack::Synthetics#sims` chapter. 405 | BaselineSimScenario: SimScenario { simBaseline } 406 | 407 | // See `docHaystack::Synthetics#sims` chapter. 408 | OperationSimScenario: SimScenario { simOperation } 409 | 410 | // See `docHaystack::Synthetics#sims` chapter. 411 | OptimumSimScenario: SimScenario { simOptimum } 412 | 413 | ////////////////////////////////////////////////////////////////////////// 414 | // VavAirCircuit 415 | ////////////////////////////////////////////////////////////////////////// 416 | 417 | // How does the VAV pull in air 418 | VavAirCircuit: Choice 419 | 420 | // VAV pulls air from outside the primary air flow 421 | ParallelVavAirCircuit: VavAirCircuit { parallel } 422 | 423 | // VAV pulls air from the primary air flow 424 | SeriesVavAirCircuit: VavAirCircuit { series } 425 | 426 | ////////////////////////////////////////////////////////////////////////// 427 | // VavModulation 428 | ////////////////////////////////////////////////////////////////////////// 429 | 430 | // How does VAV modulate the temp based on duct pressure 431 | VavModulation: Choice 432 | 433 | // VAV damper modulates to control space temp; dependent on duct pressure 434 | // being maintained 435 | PressureDependentVavModulation: VavModulation { pressureDependent } 436 | 437 | // VAV damper or a control valve that modulates to maintain desired flow 438 | // setpoint; independent of the duct pressure 439 | PressureIndependentVavModulation: VavModulation { pressureIndependent } 440 | 441 | -------------------------------------------------------------------------------- /src/xeto/ph/filetypes.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // Auto-generated 29-Nov-2024 5 | // 6 | 7 | // File format type definition 8 | Filetype: Feature { 9 | filetype // Filetype marker 10 | fileExt: Str? // Filename extension such as "csv" 11 | mime: Str? // Mime type formatted as "type/subtype" 12 | wikipedia: Uri? // Wikipedia link 13 | } 14 | 15 | // Comma Separated Values - see `docHaystack::Csv` 16 | @filetype:csv : Filetype { 17 | dis: "CSV" 18 | fileExt: "csv" 19 | mime: "text/csv" 20 | wikipedia: "https://wikipedia.org/wiki/Comma-separated_values" 21 | } 22 | 23 | // Haystack JavaScript Object Notation format - see `docHaystack::Json` 24 | @filetype:json : Filetype { 25 | dis: "JSON" 26 | fileExt: "json" 27 | mime: "application/json" 28 | wikipedia: "https://wikipedia.org/wiki/JSON" 29 | } 30 | 31 | // JavaScript Object Notation for Linked Data - see `docHaystack::Rdf` 32 | @filetype:jsonld : Filetype { 33 | dis: "JSON-LD" 34 | fileExt: "jsonld" 35 | mime: "application/ld+json" 36 | wikipedia: "https://wikipedia.org/wiki/JSON-LD" 37 | } 38 | 39 | // Haystack Tag Record Input Output - see `docHaystack::Trio` 40 | @filetype:trio : Filetype { 41 | dis: "Trio" 42 | fileExt: "trio" 43 | mime: "text/trio" 44 | } 45 | 46 | // RDF Turtle - see `docHaystack::Rdf` 47 | @filetype:turtle : Filetype { 48 | dis: "Turtle" 49 | fileExt: "ttl" 50 | mime: "text/turtle" 51 | wikipedia: "https://wikipedia.org/wiki/Turtle_(syntax)" 52 | } 53 | 54 | // Haystack typed CSV format - see `docHaystack::Zinc` 55 | @filetype:zinc : Filetype { 56 | dis: "Zinc" 57 | fileExt: "zinc" 58 | mime: "text/zinc" 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/xeto/ph/kinds.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 20 Jul 2022 Brian Frank Creation 7 | // 8 | 9 | // Symbol to a def. Symbol values are ASCII strings limited to the 10 | // following chars: a-z, A-Z, 0-9, underbar, colon, dash, dot. 11 | Symbol: Scalar "x" 12 | 13 | // Geographic coordinate in latitude/longitude in decimal degrees. 14 | Coord: Scalar "C(0,0)" 15 | 16 | // Extended string - type name and string value encoding. 17 | XStr: Scalar 18 | 19 | // Feature namespace of definitions identified as 'lib::feature:name' 20 | Feature: Dict 21 | 22 | -------------------------------------------------------------------------------- /src/xeto/ph/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // Auto-generated 11-Dec-2023 5 | // 6 | 7 | pragma: Lib < 8 | doc: "Project haystack core library" 9 | version: "0.1.1" 10 | depends: { 11 | { lib: "sys", versions: "0.1.x" } 12 | } 13 | categories: {"ph"} 14 | license: "AFL-3.0" 15 | org: { 16 | dis: "Project Haystack" 17 | uri: "https://project-haystack.org/" 18 | } 19 | vcs: { 20 | type: "git" 21 | uri: "https://github.com/Project-Haystack/xeto.git" 22 | } 23 | > 24 | 25 | -------------------------------------------------------------------------------- /src/xeto/ph/ops.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // Auto-generated 11-Dec-2023 5 | // 6 | 7 | // Operation for HTTP API. See `docHaystack::Ops` chapter. 8 | Op: Feature { 9 | // Op marker 10 | op 11 | 12 | // Marks a function or operation as having no side effects. The function 13 | // may or may not be *pure* in that calling it multiple times with the 14 | // same arguments always evaluates to the same result. 15 | noSideEffects: Marker? 16 | } 17 | 18 | // Query basic information about the server. 19 | // See `docHaystack::Ops#about` chapter. 20 | @op:about : Op { 21 | noSideEffects 22 | } 23 | 24 | // Close the current session and cancel the auth bearer token. 25 | // See `docHaystack::Ops#close` chapter. 26 | @op:close : Op { 27 | } 28 | 29 | // Query the definitions in the current namespace. 30 | // See `docHaystack::Ops#defs` chapter. 31 | @op:defs : Op { 32 | noSideEffects 33 | } 34 | 35 | // Query the filetype defs in the current namespace. 36 | // See `docHaystack::Ops#filetypes` chapter. 37 | @op:filetypes : Op { 38 | noSideEffects 39 | } 40 | 41 | // Read historized time series data from a `his-point`. 42 | // See `docHaystack::Ops#hisRead` chapter. 43 | @op:hisRead : Op { 44 | noSideEffects 45 | } 46 | 47 | // Write historized time series data from a `his-point`. 48 | // See `docHaystack::Ops#hisWrite` chapter. 49 | @op:hisWrite : Op { 50 | } 51 | 52 | // Invoke a user action on a target entity. 53 | // See `docHaystack::Ops#invokeAction` chapter. 54 | @op:invokeAction : Op { 55 | } 56 | 57 | // Query the lib defs in the current namespace. 58 | // See `docHaystack::Ops#libs` chapter. 59 | @op:libs : Op { 60 | noSideEffects 61 | } 62 | 63 | // Query the navigation tree for discovery. 64 | // See `docHaystack::Ops#nav` chapter. 65 | @op:nav : Op { 66 | noSideEffects 67 | } 68 | 69 | // Query the op defs in the current namespace. 70 | // See `docHaystack::Ops#ops` chapter. 71 | @op:ops : Op { 72 | noSideEffects 73 | } 74 | 75 | // Read or command a `writable-point`. 76 | // See `docHaystack::Ops#pointWrite` chapter. 77 | @op:pointWrite : Op { 78 | } 79 | 80 | // Query the a set of entity records by id or by filter. 81 | // See `docHaystack::Ops#read` chapter. 82 | @op:read : Op { 83 | noSideEffects 84 | } 85 | 86 | // Poll a watch subscription. 87 | // See `docHaystack::Ops#watchPoll` chapter. 88 | @op:watchPoll : Op { 89 | } 90 | 91 | // Subscribe to entity data. 92 | // See `docHaystack::Ops#watchSub` chapter. 93 | @op:watchSub : Op { 94 | } 95 | 96 | // Unsubscribe to entity data. 97 | // See `docHaystack::Ops#watchUnsub` chapter. 98 | @op:watchUnsub : Op { 99 | } 100 | 101 | -------------------------------------------------------------------------------- /src/xeto/ph/phenomenon.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // Auto-generated 27-Jun-2024 5 | // 6 | 7 | // Aspect of scientific interest with measurable quantities 8 | Phenomenon: Choice 9 | 10 | // Associated with electricity or with electrical force, power, or energy. 11 | // This is often opposed to `mech` mechanical energy. 12 | Elec: Phenomenon { elec } 13 | 14 | // Alternating current electricity 15 | AcElec: Elec { ac } 16 | 17 | // Direct current electricity 18 | DcElec: Elec { dc } 19 | 20 | // Electromagnetic radiation in the visible spectrum 21 | Light: Phenomenon { light } 22 | 23 | // Relating to energy from the sun 24 | Solar: Phenomenon { solar } 25 | 26 | // Matter in one the three states solid, liquid, or gas 27 | Substance: Phenomenon 28 | 29 | // Plant or animal material used as fuel to produce electricity or heat 30 | Biomass: Substance { biomass } 31 | 32 | // Liquid or gas 33 | Fluid: Substance 34 | 35 | // Substance with neither definite volume nor shape 36 | Gas: Fluid 37 | 38 | // The mixture of gases which surrounds the earth 39 | Air: Gas { air } 40 | 41 | // Formaldehyde (CH₂O) 42 | Ch2o: Gas { ch2o } 43 | 44 | // Methane (CH₄) 45 | Ch4: Gas { ch4 } 46 | 47 | // Carbon monoxide (CO) 48 | Co: Gas { co } 49 | 50 | // Carbon dioxide (CO₂) 51 | Co2: Gas { co2 } 52 | 53 | // Hydrofluorocarbons 54 | Hfc: Gas { hfc } 55 | 56 | // Nitrous oxide (N₂O) 57 | N2o: Gas { n2o } 58 | 59 | // Fossil fuel energy source consisting largely of methane and other hydrocarbons. 60 | // 61 | // The energy content of natural gas varies by region within a range determined 62 | // on impurities in the gas. You can find a table of these conversions 63 | // [here]`https://en.wikipedia.org/wiki/Heat_of_combustion#Higher_heating_values_of_natural_gases_from_various_sources` 64 | NaturalGas: Gas { naturalGas } 65 | 66 | // Nitrogen trifluoride (NF₃) 67 | Nf3: Gas { nf3 } 68 | 69 | // Ammonia (NH₃) 70 | Nh3: Gas { nh3 } 71 | 72 | // Nitrogen dioxide (NO₂) 73 | No2: Gas { no2 } 74 | 75 | // Oxygen (O₂) - the common dioxygen allotrope in the air 76 | O2: Gas { o2 } 77 | 78 | // Ozone (O₃) 79 | O3: Gas { o3 } 80 | 81 | // Perfluorocarbons 82 | Pfc: Gas { pfc } 83 | 84 | // By-product of natural gas processing and petroleum refining (C₃H₈) 85 | Propane: Gas { propane } 86 | 87 | // Sulphur hexafluoride (SF₆) 88 | Sf6: Gas { sf6 } 89 | 90 | // Water in its gas form 91 | Steam: Gas { steam } 92 | 93 | // Total volatile organic compound (TVOC). 94 | Tvoc: Gas { tvoc } 95 | 96 | // Substance with definite volume but takes the shape of its container 97 | Liquid: Fluid 98 | 99 | // Liquid phase produced by the condensation of steam or other gas 100 | Condensate: Liquid { condensate } 101 | 102 | // Liquid fuel specifically designed for use in diesel engines 103 | Diesel: Liquid { diesel } 104 | 105 | // Petroleum based oil burned for energy 106 | FuelOil: Liquid { fuelOil } 107 | 108 | // Petroleum derived liquid used as a fuel source 109 | Gasoline: Liquid { gasoline } 110 | 111 | // Water in its liquid form 112 | Water: Liquid { water } 113 | 114 | // Water expelled from a system to remove mineral build up 115 | BlowdownWater: Water { blowdown } 116 | 117 | // Water cooled for use in HVAC and industrial processes 118 | ChilledWater: Water { chilled } 119 | 120 | // Water supplied to cold taps 121 | ColdWater: Water { cold } 122 | 123 | // Water used used to remove heat through condensation 124 | CondenserWater: Water { condenser } 125 | 126 | // Relatively cool water without active chilling 127 | CoolWater: Water { cool } 128 | 129 | // Tap water for drinking, washing, cooking, and flushing of toilets 130 | DomesticWater: Water { domestic } 131 | 132 | // Water present under the ground or from a well 133 | GroundWater: Water { ground } 134 | 135 | // Hot water used for HVAC heating or supplied to hot taps 136 | HotWater: Water { hot } 137 | 138 | // Water used used to makeup water loss through leaks, evaporation, or blowdown 139 | MakeupWater: Water { makeup } 140 | 141 | // Water expelled from a system to remove contaminants. 142 | PurgeWater: Water { purge } 143 | 144 | // Relatively warm water without active heating 145 | WarmWater: Water { warm } 146 | 147 | // Fluid used in refrigeration and heat exchange. Refrigerants typically 148 | // alternate between liquid and gas state. 149 | Refrig: Fluid { refrig } 150 | 151 | // Substance with definite shape and volume 152 | Solid: Substance { solid } 153 | 154 | // Combustible sedimentary rock 155 | Coal: Solid { coal } 156 | 157 | // Water in its solid form 158 | Ice: Solid { ice } 159 | 160 | // Particulate matter 0.1; atmospheric pollutant of fine particles with an aerodynamic diameter of 0.1 micrometers or less 161 | Pm01: Solid { pm01 } 162 | 163 | // Particulate matter 10; atmospheric pollutant of fine particles with an aerodynamic diameter of 10 micrometers or less 164 | Pm10: Solid { pm10 } 165 | 166 | // Particulate matter 2.5; atmospheric pollutant of fine particles with an aerodynamic diameter of 2.5 micrometers or less 167 | Pm25: Solid { pm25 } 168 | 169 | // Associated with atmospheric air or phenomenon. 170 | // See `docHaystack::Weather` chapter. 171 | Weather: Phenomenon { weather } 172 | 173 | // Flow of air on surface of the Earth 174 | Wind: Phenomenon { wind } 175 | 176 | -------------------------------------------------------------------------------- /src/xeto/ph/quantity.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // Auto-generated 24-Jan-2025 5 | // 6 | 7 | // Measurable property of a substance or phenomenon 8 | Quantity: Choice 9 | 10 | // Rate of air movement as distance over time 11 | AirVelocity: Quantity { air, velocity } 12 | 13 | // Apparent energy in an AC eletrical power system. Integral of 14 | // `apparent-power` over time. 15 | ApparentEnergy: Quantity { apparent, energy } 16 | 17 | // Apparent power; the perceived magnitude of electric power transfer in an 18 | // AC electric system due to the combination of active and reactive power. 19 | ApparentPower: Quantity { apparent, power } 20 | 21 | // Percentage of sky obscured by clouds. This is also known as cloudiness, or cloud amount. 22 | Cloudage: Quantity { cloudage } 23 | 24 | // Abundance of substance in the total volume of a mixture. 25 | Concentration: Quantity { concentration } 26 | 27 | // Concentration of contaminants in the air 28 | AirQuality: Concentration 29 | 30 | // Concentration of formaldehyde (CH₂O) in the air. 31 | Ch2oConcentration: AirQuality { ch2o } 32 | 33 | // Concentration of carbon monoxide (CO) in the air. 34 | CoConcentration: AirQuality { co } 35 | 36 | // Concentration of carbon dioxide (CO₂) in the air. 37 | Co2Concentration: AirQuality { co2 } 38 | 39 | // Concentration of ammonia (NH₃) in the air 40 | Nh3Concentration: AirQuality { nh3 } 41 | 42 | // Concentration of nitrogen dioxide (NO₂) in the air 43 | No2Concentration: AirQuality { no2 } 44 | 45 | // Concentration of ozone (O₃) in the air 46 | O3Concentration: AirQuality { o3 } 47 | 48 | // Concentration of particulate matter 0.1 in the air. 49 | Pm01Concentration: AirQuality { pm01 } 50 | 51 | // Concentration of particulate matter 10 in the air 52 | Pm10Concentration: AirQuality { pm10 } 53 | 54 | // Concentration of particulate matter 2.5 in the air. 55 | Pm25Concentration: AirQuality { pm25 } 56 | 57 | // Concentration of total volatile organic compounds (TVOC) in the air 58 | TvocConcentration: AirQuality { tvoc } 59 | 60 | // AC current phase angle 61 | CurrentAngle: Quantity { current, angle } 62 | 63 | // AC current phase imbalance. Also referred to as current unbalance. 64 | CurrentImbalance: Quantity { current, imbalance } 65 | 66 | // Total harmonic distortion (THD) of AC current 67 | CurrentThd: Quantity { current, thd } 68 | 69 | // Time between sunrise and sunset 70 | Daytime: Quantity { daytime } 71 | 72 | // Dew point temperature at which water vapor will form dew 73 | DewPoint: Quantity { dewPoint } 74 | 75 | // Compass direction measured in degrees: North: 0° = 360°, East: 90°, South: 180°, West: 270° 76 | Direction: Quantity { direction } 77 | 78 | // Compass direction from which wind originates 79 | WindDirection: Direction { wind } 80 | 81 | // Electrical current 82 | ElecCurrent: Quantity { elec, current } 83 | 84 | // Root-mean-square (RMS) magnitude of AC electrical current 85 | CurrentMagnitude: ElecCurrent { current, magnitude } 86 | 87 | // Electrical voltage, potential difference 88 | ElecVolt: Quantity { elec, volt } 89 | 90 | // Root-mean-square (RMS) magnitude of AC electrical voltage 91 | VoltMagnitude: ElecVolt { volt, magnitude } 92 | 93 | // Amount of a substance discharged into the air 94 | Emission: Quantity { emission } 95 | 96 | // Greenhouse gas emission of methane (CH₄) into the air. 97 | Ch4Emission: Emission { ch4 } 98 | 99 | // Greenhouse gas emission of carbon dioxide (CO₂) into the air. 100 | Co2Emission: Emission { co2 } 101 | 102 | // Greenhouse gas emission of hydrofluorocarbons into the air. 103 | HfcEmission: Emission { hfc } 104 | 105 | // Greenhouse gas emission of nitrous oxide (N₂O) into the air. 106 | N2oEmission: Emission { n2o } 107 | 108 | // Greenhouse gas emission of nitrogen trifluoride (NF₃) into the air. 109 | Nf3Emission: Emission { nf3 } 110 | 111 | // Greenhouse gas emission of perfluorocarbons into the air. 112 | PfcEmission: Emission { pfc } 113 | 114 | // Greenhouse gas emission of sulphur hexafluoride (SF₆) into the air. 115 | Sf6Emission: Emission { sf6 } 116 | 117 | // Measure of ability to do work 118 | Energy: Quantity { energy } 119 | 120 | // Electrical energy; integral of electric power 121 | ElecEnergy: Energy { elec } 122 | 123 | // Active energy in an AC eletrical power system. Integral of 124 | // `active-power` over time. 125 | ActiveEnergy: ElecEnergy { active } 126 | 127 | // Total heat content of a system. It is defined as internal energy of the system plus the product of pressure and volume. 128 | Enthalpy: Quantity { enthalpy } 129 | 130 | // Apparent temperature perceived when considering humidity, wind chill, and heat index 131 | FeelsLike: Quantity { feelsLike } 132 | 133 | // Measure of volumetric flow of fluid 134 | Flow: Quantity { flow } 135 | 136 | // Occurrences per unit time 137 | Freq: Quantity { freq } 138 | 139 | // Frequency of an alternating current waveform 140 | AcFreq: Freq { ac } 141 | 142 | // Percent relative humidity; measure of moisture in the air 143 | Humidity: Quantity { humidity } 144 | 145 | // Luminous flux hitting the inside of the sphere at a specific point. 146 | // 147 | // Also see [ies.org]`https://www.ies.org/definitions/illuminance/` 148 | Illuminance: Quantity { illuminance } 149 | 150 | // Energy received at a surface by area 151 | Irradiance: Quantity { irradiance } 152 | 153 | // Energy received on surface of the earth from the sun 154 | SolarIrradiance: Irradiance { solar } 155 | 156 | // Range from 0% to 100%. When paired with a fluid this implies a fill 157 | // level where 0% is empty and 100% is full. 158 | Level: Quantity { level } 159 | 160 | // Sensed or controlled dimming level of electrical lighting. 161 | // Level is measured as a percentage where 0% is off and 100% 162 | // is full brightness. 163 | LightLevel: Level { light } 164 | 165 | // Energy of light in a given direction. 166 | // 167 | // Also see [ies.org]`https://www.ies.org/definitions/luminance/` 168 | Luminance: Quantity { luminance } 169 | 170 | // Total perceived light in all directions. 171 | // 172 | // Also see [ies.org]`https://www.ies.org/definitions/luminous-flux/` 173 | LuminousFlux: Quantity { luminous, flux } 174 | 175 | // Perceived light in a particular direction per unit solid angle. 176 | // 177 | // Also see [ies.org]`https://www.ies.org/definitions/luminous-intensity/` 178 | LuminousIntensity: Quantity { luminous, intensity } 179 | 180 | // Electric power factor; which is the ratio of active power to apparent 181 | // power in an AC electric power system. Measured with values in the range 182 | // of -1.0 to 1.0 or 0.0 to 1.0 without a unit. When the range of -1.0 to 183 | // 1.0 is applied, a negative value for power factor indicates the 184 | // electrical current leads the electrical voltage and a positive value 185 | // indicates the electrical current lags the electrical voltage. 186 | Pf: Quantity { pf } 187 | 188 | // Energy consumed per unit time 189 | Power: Quantity { power } 190 | 191 | // Rate of electrical energy transfer; energy transfer per unit time 192 | ElecPower: Power { elec } 193 | 194 | // Active power or real power; represents energy transfer that contributes 195 | // useful work. 196 | ActivePower: ElecPower { active } 197 | 198 | // Active power averaged over a regular interval. For utility meters 199 | // the demand interval is based on the billing period. 200 | ElecDemand: ActivePower { elec, demand } 201 | 202 | // Amount of atmospheric water vapor fallen including rain, sleet, snow, and hail 203 | Precipitation: Quantity { precipitation } 204 | 205 | // Measure of force applied 206 | Pressure: Quantity { pressure } 207 | 208 | // Barometric pressure exerted by the weight of the atmosphere 209 | AtmosphericPressure: Pressure { atmospheric } 210 | 211 | // Reactive energy in an AC eletrical power system. Integral of 212 | // `reactive-power` over time. 213 | ReactiveEnergy: Quantity { reactive, energy } 214 | 215 | // Reactive power or imaginary power; represents energy that recirculates 216 | // within an AC power system but does not contribute useful work. 217 | ReactivePower: Quantity { reactive, power } 218 | 219 | // Distance per unit time 220 | Speed: Quantity { speed } 221 | 222 | // Wind flow speed 223 | WindSpeed: Speed { wind } 224 | 225 | // State of charge (SoC) of an electric `battery`. Uses a percentage in 226 | // the range of 0% to 100%, where no charge is indicated as 0% and full 227 | // charge is indicated as 100%. 228 | StateOfCharge: Quantity { stateOfCharge } 229 | 230 | // Temperature - measure of hot and cold 231 | Temp: Quantity { temp } 232 | 233 | // Dry bulb temperature 234 | AirTemp: Temp { air } 235 | 236 | // VFD frequency measured in "Hz". 237 | VfdFreq: Quantity { vfd, freq } 238 | 239 | // VFD speed measured in "%"; 0% is off and 100% is the fastest speed. 240 | VfdSpeed: Quantity { vfd, speed } 241 | 242 | // Distance at which light can be clearly discerned 243 | Visibility: Quantity { visibility } 244 | 245 | // AC voltage phase angle 246 | VoltAngle: Quantity { volt, angle } 247 | 248 | // AC voltage phase imbalance. Also referred to as voltage unbalance. 249 | VoltImbalance: Quantity { volt, imbalance } 250 | 251 | // Total harmonic distortion (THD) of AC voltage 252 | VoltThd: Quantity { volt, thd } 253 | 254 | // Three dimensional space occupied by a substance 255 | Volume: Quantity { volume } 256 | 257 | // Enumeration of weather conditions 258 | WeatherCond: Quantity { weatherCond } 259 | 260 | // Wet bulb air temperature. Temperature which the air would have if cooled to saturation by the evaporation of water into it. 261 | WetBulb: Quantity { wetBulb } 262 | 263 | -------------------------------------------------------------------------------- /src/xeto/ph/tags-5.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 6 Mar 2025 Brian Frank Creation 7 | // 8 | 9 | // Number of historical timestamped samples historized by point 10 | hisSize: Number 11 | 12 | // First historized timestamped sample 13 | hisStart: DateTime 14 | 15 | // Last historized timestamped sample 16 | hisEnd: DateTime 17 | 18 | -------------------------------------------------------------------------------- /src/xeto/sys.api/api.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 14 Feb 2025 Brian Frank Creation 7 | // 8 | 9 | // Network API endpoint 10 | Api: Func 11 | 12 | // Envelope to package API response of data, meta, and error 13 | ApiEnvelope: Dict { 14 | status: ApiStatus // Result status - ok or error 15 | meta: Dict? // Result meta data if status ok 16 | data: Obj? // Result data if status ok 17 | warn: ApiWarn? // Warning infomation if status is ok 18 | error: ApiError? // Error information if status is error 19 | } 20 | 21 | // API request status 22 | ApiStatus: Enum { 23 | ok // Success - result in 'data' field 24 | error // Failure - details in 'error' field 25 | } 26 | 27 | // Additional information when API returns ok, but with a warning message 28 | ApiWarn: Dict { 29 | message: Str // Reason message to display to user 30 | limit: Int? // Integer if incomplete due to threshold limit 31 | timeout: Duration? // Duration if incomplete due to timeout 32 | } 33 | 34 | // Additional information when an API request returns error status 35 | ApiError: Dict { 36 | message: Str // Reason message to display to user 37 | trace: Str? // Stack trace for debugging if available 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/xeto/sys.api/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 14 Feb 2025 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "System library for network APIs" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | } 15 | categories: {"sys"} 16 | license: "AFL-3.0" 17 | org: { 18 | dis: "Project Haystack" 19 | uri: "https://project-haystack.org/" 20 | } 21 | vcs: { 22 | type: "git" 23 | uri: "https://github.com/Project-Haystack/xeto.git" 24 | } 25 | > 26 | 27 | -------------------------------------------------------------------------------- /src/xeto/sys.api/misc.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 14 Feb 2025 Brian Frank Creation 7 | // 8 | 9 | ////////////////////////////////////////////////////////////////////////// 10 | // Ping 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | // Health check for a server 14 | ping: Api { 15 | returns: PingRes // Ping response 16 | } 17 | 18 | // Ping response 19 | PingRes: Dict { 20 | time: DateTime // Current timestamp of the server's clock 21 | } 22 | 23 | ////////////////////////////////////////////////////////////////////////// 24 | // About 25 | ////////////////////////////////////////////////////////////////////////// 26 | 27 | // Return summary information about the server 28 | about: Api { 29 | returns: AboutRes // About response 30 | } 31 | 32 | // About response 33 | AboutRes: Dict { 34 | // API information 35 | api: Dict { 36 | version: Version // System API version supported 37 | } 38 | // Server information 39 | server: Dict { 40 | name: Str // Name of the server or project database 41 | time: DateTime // Current timestamp of the server's clock 42 | tz: TimeZone // Default timezone of the server 43 | boot: DateTime? // Timestamp the server was booted 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/xeto/sys.api/reads.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 14 Feb 2025 Brian Frank Creation 7 | // 8 | 9 | // Return an database record by its id 10 | readById: Api { 11 | id: Ref // Database id to read 12 | returns: Entity? // Database record or null if not found 13 | } 14 | 15 | // Return a list of database records by their id 16 | readByIds: Api { 17 | ids: List // List of database ids to read 18 | returns: List // Database records in order of ids 19 | } 20 | 21 | // Return a list of database records that match a filter query. 22 | // If limit is reached, include limit warning in envelope. 23 | readByFilter: Api { 24 | filter: Filter // Filter query to read 25 | limit: Int? // Max number of entities to read 26 | returns: List // Database records matched 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/xeto/sys.comp/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 18 Jul 2024 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "System library for component oriented programming" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | } 15 | categories: {"sys"} 16 | license: "AFL-3.0" 17 | org: { 18 | dis: "Project Haystack" 19 | uri: "https://project-haystack.org/" 20 | } 21 | vcs: { 22 | type: "git" 23 | uri: "https://github.com/Project-Haystack/xeto.git" 24 | } 25 | > 26 | 27 | -------------------------------------------------------------------------------- /src/xeto/sys.comp/types.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 24 Apr 2024 Brian Frank Creation 7 | // 8 | 9 | // Component or function block 10 | Comp: Dict { 11 | parentRef: Ref? // Component tree parent 12 | compName: Str? // Component name in parent 13 | compLayout: CompLayout? // Layout in a visual coordinate system 14 | links: Links? // List of links to this component 15 | } 16 | 17 | // Component layout stored as "x, y, w" in a logical coordinate system. 18 | CompLayout: Scalar 19 | 20 | // Component link is a dataflow between two slots 21 | Link: Dict { 22 | fromRef: Ref // Reference to source component 23 | fromSlot: Str // Slot name of source component 24 | } 25 | 26 | // Incoming links on a component as dict keyed by toSlot name. 27 | // The values for each slot name may be a Link or a list of Link. 28 | Links: Dict > 29 | 30 | // Variable component to inject input and output variables 31 | Var: Comp { 32 | val: Obj? // Current value of the variable 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/xeto/sys.files/app.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 4 Apr 2025 Brian Frank Creation 7 | // 8 | 9 | // Application specific file format 10 | AppFile : File 11 | 12 | // Microsoft Word file in docx format 13 | MicorosftWordFile : AppFile 14 | 15 | // Microsoft Excel file in xlsx format 16 | MicorosftExcelFile : AppFile 17 | 18 | // Microsoft PowerPoint file in pptx format 19 | MicorosftPowerPointFile : AppFile 20 | 21 | // Portable Document Format file 22 | PdfFile : AppFile 23 | 24 | // TAR archive file 25 | TarFile : AppFile 26 | 27 | // Xeto library zip file 28 | XetoLibFile : AppFile 29 | 30 | // Zip archive file 31 | ZipFile : AppFile 32 | 33 | -------------------------------------------------------------------------------- /src/xeto/sys.files/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 12 May 2023 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "System library for MIME typed file specs" 11 | version: "0.1.1" 12 | depends: { 13 | { lib: "sys", versions: "0.1.x" } 14 | } 15 | categories: {"sys"} 16 | license: "AFL-3.0" 17 | org: { 18 | dis: "Project Haystack" 19 | uri: "https://project-haystack.org/" 20 | } 21 | vcs: { 22 | type: "git" 23 | uri: "https://github.com/Project-Haystack/xeto.git" 24 | } 25 | > 26 | 27 | -------------------------------------------------------------------------------- /src/xeto/sys.files/media.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2023, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 12 May 2023 Brian Frank Creation 7 | // 8 | 9 | ////////////////////////////////////////////////////////////////////////// 10 | // Images 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | // Image file 14 | ImageFile : File 15 | 16 | // Image file in GIF format 17 | GifImage : ImageFile 18 | 19 | // Image file in JPEG format 20 | JpegImage : ImageFile 21 | 22 | // Image file in PNG format 23 | PngFile : ImageFile 24 | 25 | // Scalable vector graphics image file 26 | SvgFile : ImageFile 27 | 28 | // Image file in TIFF format 29 | TiffFile : ImageFile 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | // Audio 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | // Audio media file 36 | AudioFile : File 37 | 38 | // AAC audio file 39 | AacFile : AudioFile 40 | 41 | // MP3 audio file 42 | Mp3File : AudioFile 43 | 44 | // Waveform audio file 45 | WavFile : AudioFile 46 | 47 | ////////////////////////////////////////////////////////////////////////// 48 | // Video 49 | ////////////////////////////////////////////////////////////////////////// 50 | 51 | // Video media file 52 | VideoFile : File 53 | 54 | // MP4 video file 55 | Mp4File : VideoFile 56 | 57 | // MP3 video file 58 | MpegFile : VideoFile 59 | 60 | // Ogg video file 61 | OggFile : VideoFile 62 | 63 | -------------------------------------------------------------------------------- /src/xeto/sys.files/meta.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 4 Apr 2025 Brian Frank Creation 7 | // 8 | 9 | // MIME type for a file spec 10 | mimeType: Str 11 | 12 | // Default file name extension to use for a file spec 13 | fileExt: Str 14 | 15 | -------------------------------------------------------------------------------- /src/xeto/sys.files/text.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2025, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 4 Apr 2025 Brian Frank Creation 7 | // 8 | 9 | // Text file 10 | TextFile : File 11 | 12 | // Comma separated values text field 13 | CsvFile : TextFile 14 | 15 | // HTML text file 16 | HtmlFile : TextFile 17 | 18 | // JSON text file 19 | JsonFile : TextFile 20 | 21 | // JSON-LD text file 22 | JsonLdFile : TextFile 23 | 24 | // Markdown text file 25 | MarkdownFile : TextFile 26 | 27 | // Plain text file 28 | PlainTextFile : TextFile 29 | 30 | // Project Haystack Trio text file 31 | TrioFile : TextFile 32 | 33 | // RDF turtle file 34 | TurtleFile : TextFile 35 | 36 | // Project Haystack Zinc text file 37 | ZincFile : TextFile 38 | 39 | // Extensible markup language text file 40 | XmlFile : TextFile 41 | 42 | // YAML Ain't Markup Language text file 43 | YamlFile : TextFile 44 | 45 | -------------------------------------------------------------------------------- /src/xeto/sys/lib.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 18 Jul 2022 Brian Frank Creation 7 | // 8 | 9 | pragma: Lib < 10 | doc: "System library of built-in types" 11 | version: "0.1.1" 12 | categories: {"sys"} 13 | license: "AFL-3.0" 14 | org: { 15 | dis: "Project Haystack" 16 | uri: "https://project-haystack.org/" 17 | } 18 | vcs: { 19 | type: "git" 20 | uri: "https://github.com/Project-Haystack/xeto.git" 21 | } 22 | > 23 | 24 | -------------------------------------------------------------------------------- /src/xeto/sys/libmeta.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 18 Jul 2022 Brian Frank Creation 7 | // 8 | 9 | // Library module meta data 10 | Lib: Dict 11 | 12 | // Library dependency 13 | LibDepend: Dict { 14 | lib: Str // Library qualified dotted name 15 | versions: LibDependVersions // Version constraints for dependency 16 | } 17 | 18 | // Version constraints for a library dependency. 19 | // 20 | // The format is: 21 | // := | 22 | // := "." "." 23 | // := "-" 24 | // := | "x" 25 | // 26 | // Examples: 27 | // 1.5.20 // match only 1.5.20 28 | // 1.5.x // match any patch version within 1.5 29 | // 3.x.x // match any version with 3 as major version 30 | // 1.5.20 - 1.x.x // greater than 1.5.20 and has 1 in major ver 31 | LibDependVersions: Scalar 32 | 33 | // Organization library metadata 34 | LibOrg: Dict { 35 | dis: Str // Display name for the organization 36 | uri: Uri // URI for organization website 37 | } 38 | 39 | // Version control library metadata 40 | LibVcs: Dict { 41 | type: Str // Type of VCS such as "git" or "mercurial" 42 | uri: Uri // URI for repository to be used directly by a VCS program (not the HTML page) 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/xeto/sys/meta.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 18 Jul 2022 Brian Frank Creation 7 | // 8 | 9 | // Abstract types cannot be implemented directly by instance data 10 | abstract: Marker 11 | 12 | // Indicates an asynchronous operation or function call 13 | async: Marker 14 | 15 | // Indicates an immutable value 16 | const: Marker 17 | 18 | // Library dependencies 19 | depends: List 20 | 21 | // Documentation description 22 | doc: Str 23 | 24 | // Annotates a slot as a fixed value that must be equal to 'val' 25 | fixed: Marker 26 | 27 | // Inverse query to run against parent 28 | inverse: Str 29 | 30 | // String key; used in enums to define normalized string identifier 31 | key: Str 32 | 33 | // License [SPDX name](https://spdx.org/licenses/) or "commerical" 34 | license: Str 35 | 36 | // Applied to strings and lists to specify inclusive maximum length 37 | maxSize: Int 38 | 39 | // Inclusive maximum value for numbers 40 | maxVal: Self 41 | 42 | // Indicates an optional type 43 | maybe: Marker 44 | 45 | // Marks a global slot as a meta data tag 46 | meta: Marker 47 | 48 | // Applied to strings and lists to specify inclusive minimum length 49 | minSize: Int 50 | 51 | // Inclusive minimum value for numbers 52 | minVal: Self 53 | 54 | // Applied to Choices to allow multiple selections 55 | multiChoice: Marker 56 | 57 | // Indicates a constructor function 58 | new: Marker 59 | 60 | // Marks spec as undocumented and not officially supported 61 | nodoc: Marker 62 | 63 | // Indicates a meta tag that is not inherited into subtypes 64 | noInherit: Marker 65 | 66 | // Applied to strings to require value is non-empty when trimmed of whitespace 67 | nonEmpty: Marker 68 | 69 | // Item type for parameterized Seq/Query; target type for Ref/MultiRef 70 | of: Ref 71 | 72 | // Types used in compound types like And and Or 73 | ofs: List > 74 | 75 | // Library organization information 76 | org: LibOrg 77 | 78 | // Regex pattern for scalar string encoding 79 | pattern: Str 80 | 81 | // Restrict number or unit enum to specific quantity 82 | quantity: UnitQuantity 83 | 84 | // Indicates a readonly value that may not be written (but may mutate) 85 | readonly: Marker 86 | 87 | // Sealed types cannot be extended outside of their own lib. If used 88 | // on a interface slot, the slot cannot be overridden in a subtype. 89 | sealed: Marker 90 | 91 | // Indicates a spec level slot versus an instance level slot 92 | static: Marker 93 | 94 | // Mark data as summary level for display in summarized tables and other views 95 | summary: Marker 96 | 97 | // Free form category tags 98 | categories: List 99 | 100 | // Indicates data which should be persisted 101 | transient: Unit 102 | 103 | // Restrict number or unit enum to specific unit 104 | unit: Unit 105 | 106 | // Restrict a number to have no unit 107 | unitless: Marker 108 | 109 | // Default value for this slot 110 | val: Obj 111 | 112 | // Library version control system metadata 113 | vcs: LibVcs 114 | 115 | // Version number 116 | version: Version 117 | 118 | // Named path to traverse to execute query 119 | via: Str 120 | 121 | // Used on a interface non-static slot to indicate it can be overridden subtypes 122 | virtual: Marker 123 | 124 | -------------------------------------------------------------------------------- /src/xeto/sys/timezones.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2024, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // Auto-generated 07-Aug-2024 5 | // 6 | 7 | // TimeZone names for standardized database 8 | TimeZone: Enum { 9 | utc 10 | abidjan 11 | accra 12 | adak 13 | adelaide 14 | algiers 15 | almaty 16 | amman 17 | amsterdam 18 | anadyr 19 | anchorage 20 | andorra 21 | apia 22 | aqtau 23 | aqtobe 24 | araguaina 25 | ashgabat 26 | astrakhan 27 | asuncion 28 | athens 29 | atikokan 30 | atyrau 31 | auckland 32 | azores 33 | baghdad 34 | bahia 35 | bahia_Banderas 36 | baku 37 | bangkok 38 | barbados 39 | barnaul 40 | beirut 41 | belem 42 | belgrade 43 | belize 44 | berlin 45 | bermuda 46 | beulah 47 | bishkek 48 | bissau 49 | blancSablon 50 | boa_Vista 51 | bogota 52 | boise 53 | bougainville 54 | brisbane 55 | broken_Hill 56 | brunei 57 | brussels 58 | bucharest 59 | budapest 60 | buenos_Aires 61 | cet 62 | cst6CDT 63 | cairo 64 | cambridge_Bay 65 | campo_Grande 66 | canary 67 | cancun 68 | cape_Verde 69 | caracas 70 | casablanca 71 | casey 72 | catamarca 73 | cayenne 74 | center 75 | ceuta 76 | chagos 77 | chatham 78 | chicago 79 | chihuahua 80 | chisinau 81 | chita 82 | choibalsan 83 | christmas 84 | chuuk 85 | cocos 86 | colombo 87 | copenhagen 88 | cordoba 89 | costa_Rica 90 | creston 91 | cuiaba 92 | curacao 93 | currie 94 | damascus 95 | danmarkshavn 96 | darwin 97 | davis 98 | dawson 99 | dawson_Creek 100 | denver 101 | detroit 102 | dhaka 103 | dili 104 | dubai 105 | dublin 106 | dumontDUrville 107 | dushanbe 108 | eet 109 | est 110 | est5EDT 111 | easter 112 | edmonton 113 | efate 114 | eirunepe 115 | el_Aaiun 116 | el_Salvador 117 | enderbury 118 | eucla 119 | fakaofo 120 | famagusta 121 | faroe 122 | fiji 123 | fort_Nelson 124 | fortaleza 125 | funafuti 126 | gmt 127 | gmtPlus1 128 | gmtPlus10 129 | gmtPlus11 130 | gmtPlus12 131 | gmtPlus2 132 | gmtPlus3 133 | gmtPlus4 134 | gmtPlus5 135 | gmtPlus6 136 | gmtPlus7 137 | gmtPlus8 138 | gmtPlus9 139 | gmtMinus1 140 | gmtMinus10 141 | gmtMinus11 142 | gmtMinus12 143 | gmtMinus13 144 | gmtMinus14 145 | gmtMinus2 146 | gmtMinus3 147 | gmtMinus4 148 | gmtMinus5 149 | gmtMinus6 150 | gmtMinus7 151 | gmtMinus8 152 | gmtMinus9 153 | galapagos 154 | gambier 155 | gaza 156 | gibraltar 157 | glace_Bay 158 | godthab 159 | goose_Bay 160 | grand_Turk 161 | guadalcanal 162 | guam 163 | guatemala 164 | guayaquil 165 | guyana 166 | hst 167 | halifax 168 | havana 169 | hebron 170 | helsinki 171 | hermosillo 172 | ho_Chi_Minh 173 | hobart 174 | hong_Kong 175 | honolulu 176 | hovd 177 | indianapolis 178 | inuvik 179 | iqaluit 180 | irkutsk 181 | istanbul 182 | jakarta 183 | jamaica 184 | jayapura 185 | jerusalem 186 | johannesburg 187 | juba 188 | jujuy 189 | juneau 190 | kabul 191 | kaliningrad 192 | kamchatka 193 | karachi 194 | kathmandu 195 | kerguelen 196 | khandyga 197 | khartoum 198 | kiev 199 | kiritimati 200 | kirov 201 | knox 202 | kolkata 203 | kosrae 204 | krasnoyarsk 205 | kuala_Lumpur 206 | kuching 207 | kwajalein 208 | la_Paz 209 | la_Rioja 210 | lagos 211 | lima 212 | lindeman 213 | lisbon 214 | london 215 | lord_Howe 216 | los_Angeles 217 | louisville 218 | luxembourg 219 | met 220 | mst 221 | mst7MDT 222 | macau 223 | maceio 224 | macquarie 225 | madeira 226 | madrid 227 | magadan 228 | mahe 229 | majuro 230 | makassar 231 | maldives 232 | malta 233 | managua 234 | manaus 235 | manila 236 | maputo 237 | marengo 238 | marquesas 239 | martinique 240 | matamoros 241 | mauritius 242 | mawson 243 | mazatlan 244 | melbourne 245 | mendoza 246 | menominee 247 | merida 248 | metlakatla 249 | mexico_City 250 | minsk 251 | miquelon 252 | monaco 253 | moncton 254 | monrovia 255 | monterrey 256 | montevideo 257 | monticello 258 | moscow 259 | nairobi 260 | nassau 261 | nauru 262 | ndjamena 263 | new_Salem 264 | new_York 265 | nicosia 266 | nipigon 267 | niue 268 | nome 269 | norfolk 270 | noronha 271 | noumea 272 | novokuznetsk 273 | novosibirsk 274 | ojinaga 275 | omsk 276 | oral 277 | oslo 278 | pst8PDT 279 | pago_Pago 280 | palau 281 | palmer 282 | panama 283 | pangnirtung 284 | paramaribo 285 | paris 286 | perth 287 | petersburg 288 | phoenix 289 | pitcairn 290 | pohnpei 291 | pontianak 292 | portAuPrince 293 | port_Moresby 294 | port_of_Spain 295 | porto_Velho 296 | prague 297 | puerto_Rico 298 | punta_Arenas 299 | pyongyang 300 | qatar 301 | qostanay 302 | qyzylorda 303 | rainy_River 304 | rankin_Inlet 305 | rarotonga 306 | recife 307 | regina 308 | rel 309 | resolute 310 | reunion 311 | reykjavik 312 | riga 313 | rio_Branco 314 | rio_Gallegos 315 | riyadh 316 | rome 317 | rothera 318 | sakhalin 319 | salta 320 | samara 321 | samarkand 322 | san_Juan 323 | san_Luis 324 | santarem 325 | santiago 326 | santo_Domingo 327 | sao_Paulo 328 | sao_Tome 329 | saratov 330 | scoresbysund 331 | seoul 332 | shanghai 333 | simferopol 334 | singapore 335 | sitka 336 | sofia 337 | south_Georgia 338 | srednekolymsk 339 | st_Johns 340 | stanley 341 | stockholm 342 | swift_Current 343 | sydney 344 | syowa 345 | tahiti 346 | taipei 347 | tallinn 348 | tarawa 349 | tashkent 350 | tbilisi 351 | tegucigalpa 352 | tehran 353 | tell_City 354 | thimphu 355 | thule 356 | thunder_Bay 357 | tijuana 358 | tirane 359 | tokyo 360 | tomsk 361 | tongatapu 362 | toronto 363 | tripoli 364 | troll 365 | tucuman 366 | tunis 367 | ulaanbaatar 368 | ulyanovsk 369 | urumqi 370 | ushuaia 371 | ustNera 372 | uzhgorod 373 | vancouver 374 | vevay 375 | vienna 376 | vilnius 377 | vincennes 378 | vladivostok 379 | volgograd 380 | vostok 381 | wet 382 | wake 383 | wallis 384 | warsaw 385 | whitehorse 386 | winamac 387 | windhoek 388 | winnipeg 389 | yakutat 390 | yakutsk 391 | yangon 392 | yekaterinburg 393 | yellowknife 394 | yerevan 395 | zaporozhye 396 | zurich 397 | } 398 | -------------------------------------------------------------------------------- /src/xeto/sys/types.xeto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2022, Project-Haystack 3 | // Licensed under the Academic Free License version 3.0 4 | // 5 | // History: 6 | // 2 May 2022 Brian Frank Creation 7 | // 8 | 9 | // Root type for all objects 10 | Obj: 11 | 12 | // Self is a placeholder that always represents the parent type 13 | Self: Obj 14 | 15 | // Scalar is an atomic value kind 16 | Scalar: Obj 17 | 18 | // None is the bottom type used to represent absense of value 19 | None: Scalar "none" 20 | 21 | // Marker labels a dict with typing information 22 | Marker: Scalar "marker" 23 | 24 | // Not available indicates invalid or missing data 25 | NA: Scalar "na" 26 | 27 | // Unicode string of characters 28 | Str: Scalar "" 29 | 30 | // Boolean value either true or false 31 | Bool: Scalar "false" 32 | 33 | // Integer or floating point numbers annotated with an optional unit 34 | Number: Scalar "0" 35 | 36 | // Unitless integer number 37 | Int: Number "0" 38 | 39 | // Unitless floating point number 40 | Float: Number "0" 41 | 42 | // Number with a unit of time 43 | Duration: Number "0sec" 44 | 45 | // Universal resource identifier 46 | Uri: Scalar "" 47 | 48 | // Reference to another dict. The 'of' meta defines target type 49 | Ref: Scalar "x" 50 | 51 | // Reference or list of references. The 'of' meta defines target type. 52 | // The value may be either a single ref or a list of refs. 53 | MultiRef: Obj 54 | 55 | // Version string formatted as decimal digits separated by a dot 56 | Version: Scalar "0" 57 | 58 | // ISO 8601 date as year, month, day: '2011-06-07' 59 | Date: Scalar "2000-01-01" 60 | 61 | // ISO 8601 time as hour, minute, seconds: '09:51:27.354' 62 | Time: Scalar "00:00:00" 63 | 64 | // ISO 8601 timestamp followed by timezone identifier 65 | DateTime: Scalar "2000-01-01T00:00:00Z UTC" 66 | 67 | // Span models a time range between two DateTimes. 68 | // It supports the following string encoding: 69 | // - relative 'SpanMode' name such as "yesterday" 70 | // - absolute single date: 'YYYY-MM-DD' 71 | // - absolute date span: 'YYYY-MM-DD,YYYY-MM-DD' 72 | // - absolute date time span: 'YYYY-MM-DDThh:mm:ss.FFF zzzz,YYYY-MM-DDThh:mm:ss.FFF zzzz' 73 | // In the case of two DateTime, the timezones must match. In the other 74 | // cases the timezone to use is context sensitive based on the application. 75 | Span: Scalar 76 | 77 | // Relative span to current date 78 | SpanMode: Enum { 79 | today // Current date 80 | yesterday // Day before current date 81 | thisWeek // Localized week which includes today 82 | lastWeek // Localized week before thisWeek 83 | pastWeek // Past 7 dates including today 84 | thisMonth // Calendar month which includes today 85 | lastMonth // Calendar month before thisMonth 86 | pastMonth // Past 28 days including today 87 | thisQuarter // Three month quarter which includes today 88 | lastQuarter // Three month quarter before thisQuarter 89 | pastQuarter // Past 90 days including today 90 | thisYear // Calendar year which includes today 91 | lastYear // Calendar year before thisYear 92 | pastYear // Past 365 days including today 93 | } 94 | 95 | // Closed enumerated set of string values 96 | Enum: Scalar 97 | 98 | // Open enumerated taxonomy of marker tags 99 | Choice: Dict 100 | 101 | // Sequence is base type for all collections 102 | Seq: Obj 103 | 104 | // Associative array of name/value pairs 105 | Dict: Seq 106 | 107 | // Ordered list of zero or more values 108 | List: Seq 109 | 110 | // Two dimension table of columns and rows. 111 | Grid: Seq 112 | 113 | // Or type is a choice between one of multiple types. 114 | // It is a union of the set of types. 115 | Or: Obj 116 | 117 | // And type is a combination of multiple types. 118 | // It is an intersection of the set of types. 119 | And: Obj 120 | 121 | // Blob of raw binary data in base64url encoding as specified by 122 | // RFC 4648. This encoding does not use padding and uses minus "-" 123 | // and underbar "_" as the 62nd and 63 char respectively. 124 | Buf: Scalar 125 | 126 | // Filter query string 127 | Filter: Scalar 128 | 129 | // Query defines a named data set 130 | Query: Dict 131 | 132 | // Function represents the signature of a computation with 133 | // zero or more parameter types and one return type. The 'returns' 134 | // slot specifies the return type, and all other slots specify 135 | // the parameters. 136 | Func: Dict { 137 | returns: Obj? // Return type of the function 138 | } 139 | 140 | // Top-level dicts with a unique identifier. 141 | Entity: Dict { 142 | id: Ref // Unique identifier for entity in its project 143 | spec: Ref? // Type of this entity 144 | } 145 | 146 | // Entity that represents a file containing textual or binary data. 147 | // Common MIME types are mapped to specs by the 'lib.files' library. 148 | File: Entity 149 | 150 | // Spec models a value specification 151 | Spec: Dict 152 | 153 | // Inferface is an object oriented API defined as set of named 154 | // field and method slots. 155 | Interface: Dict 156 | 157 | --------------------------------------------------------------------------------