Tengil is a Program Manager and scripting environment that enables advanced interaction with data in EnergyView.
Built on the Tengo programming language, Tengil shares a similar syntax with Go and serves as an interface for basic calculations and data ingestion from external sources.
For security reasons, some built-in Tengo engine modules are disabled in Tengil. The disabled modules include:
os: A platform-independent interface for operating system functionalityTengil supports the following existing Tengo engine modules:
base64: Functions for encoding and decoding Base64enum: Enumeration functionsfmt: Formatting functionshex: Functions for encoding and decoding Hexjson: JSON functionsmath: Mathematical constants and functionsrand: Random functionstext: Regular expressions, string conversion, and manipulationtimes: Time-related functionsAdditionally, Tengil introduces the following new modules:
alert: Functions to create and send alertsconfig: Functions to get and set configuration datadbstore: Functions to get and set timeseries data in the databasehttp: Functions to get, post, put, and delete data via HTTPlog: Logging functionsmemstore: Functions for temporary data storage in memoryresources: Functions to access EnergyView resources associated with a ProgramA simple "Hello World" example of a Tengil program:
1 2 3 | log := import("log") log.Info("Hello World!") |
Or, a more "complex" example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | dbstore := import("dbstore") // Fetch the outdoortemp for Node with ID 1 data := dbstore.Get("1.outdoortemp") /* Format of data { node_id: 1, tag: "outdoortemp", timestamp: 2022-01-01 16:13:45.815817 +0100 CET, value: 3.14, unit: "c" } */ |
Or, an even more "complex" example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | dbstore := import("dbstore") // Fetch the supply and return temperature for Node with ID 1 supplytemp_sec := dbstore.Get("1.supplytemp_sec") returntemp_sec := dbstore.Get("1.returntemp_sec") // Find the latest timestamp ts := supplytemp_sec.timestamp if returntemp_sec.timestamp > ts { ts = returntemp_sec.timestamp } // Calculate delta temperature delta_temp := supplytemp_sec.value - returntemp_sec.value // Store the delta temperature dbstore.Set("1.delta_temp", delta_temp, ts) |